亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? demo6_3.cpp

?? 《Windows游戲編程大師技巧》代碼
?? CPP
字號:
// DEMO6_3.CPP basic full-screen pixel plotting DirectDraw demo

// INCLUDES ///////////////////////////////////////////////

#define WIN32_LEAN_AND_MEAN  // just say no to MFC

#include <windows.h>   // include important windows stuff
#include <windowsx.h> 
#include <mmsystem.h>
#include <iostream.h> // include important C/C++ stuff
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h> 
#include <math.h>
#include <io.h>
#include <fcntl.h>

#include <ddraw.h> // include directdraw

// DEFINES ////////////////////////////////////////////////

// defines for windows 
#define WINDOW_CLASS_NAME "WINCLASS1"

// default screen size
#define SCREEN_WIDTH    640  // size of screen
#define SCREEN_HEIGHT   480
#define SCREEN_BPP      8    // bits per pixel
#define MAX_COLORS      256  // maximum colors

// TYPES //////////////////////////////////////////////////////

// basic unsigned types
typedef unsigned short USHORT;
typedef unsigned short WORD;
typedef unsigned char  UCHAR;
typedef unsigned char  BYTE;

// MACROS /////////////////////////////////////////////////

#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEYUP(vk_code)   ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)

// initializes a direct draw struct
#define DD_INIT_STRUCT(ddstruct) { memset(&ddstruct,0,sizeof(ddstruct)); ddstruct.dwSize=sizeof(ddstruct); }

// GLOBALS ////////////////////////////////////////////////
HWND      main_window_handle = NULL; // globally track main window
HINSTANCE hinstance_app      = NULL; // globally track hinstance

// directdraw stuff

LPDIRECTDRAW          lpdd         = NULL;   // dd object
LPDIRECTDRAW4         lpdd4        = NULL;   // dd4 object
LPDIRECTDRAWSURFACE4  lpddsprimary = NULL;   // dd primary surface
LPDIRECTDRAWSURFACE4  lpddsback    = NULL;   // dd back surface
LPDIRECTDRAWPALETTE   lpddpal      = NULL;   // a pointer to the created dd palette
LPDIRECTDRAWCLIPPER   lpddclipper  = NULL;   // dd clipper
PALETTEENTRY          palette[256];          // color palette
PALETTEENTRY          save_palette[256];     // used to save palettes
DDSURFACEDESC2        ddsd;                  // a direct draw surface description struct
DDBLTFX               ddbltfx;               // used to fill
DDSCAPS2              ddscaps;               // a direct draw surface capabilities struct
HRESULT               ddrval;                // result back from dd calls
DWORD                 start_clock_count = 0; // used for timing

// these defined the general clipping rectangle
int min_clip_x = 0,                          // clipping rectangle 
    max_clip_x = SCREEN_WIDTH-1,
    min_clip_y = 0,
    max_clip_y = SCREEN_HEIGHT-1;

// these are overwritten globally by DD_Init()
int screen_width  = SCREEN_WIDTH,            // width of screen
    screen_height = SCREEN_HEIGHT,           // height of screen
    screen_bpp    = SCREEN_BPP;              // bits per pixel


char buffer[80];                     // general printing buffer

// FUNCTIONS //////////////////////////////////////////////
LRESULT CALLBACK WindowProc(HWND hwnd, 
						    UINT msg, 
                            WPARAM wparam, 
                            LPARAM lparam)
{
// this is the main message handler of the system
PAINTSTRUCT		ps;		// used in WM_PAINT
HDC				hdc;	// handle to a device context
char buffer[80];        // used to print strings

// what is the message 
switch(msg)
	{	
	case WM_CREATE: 
        {
		// do initialization stuff here
        // return success
		return(0);
		} break;
   
	case WM_PAINT: 
		{
		// simply validate the window 
   	    hdc = BeginPaint(hwnd,&ps);	 
        
        // end painting
        EndPaint(hwnd,&ps);

        // return success
		return(0);
   		} break;

	case WM_DESTROY: 
		{

		// kill the application, this sends a WM_QUIT message 
		PostQuitMessage(0);

        // return success
		return(0);
		} break;

	default:break;

    } // end switch

// process any messages that we didn't take care of 
return (DefWindowProc(hwnd, msg, wparam, lparam));

} // end WinProc

///////////////////////////////////////////////////////////

int Game_Main(void *parms = NULL, int num_parms = 0)
{
// this is the main loop of the game, do all your processing
// here

// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
   SendMessage(main_window_handle,WM_CLOSE,0,0);


// plot 1000 random pixels to the primary surface and return
// clear ddsd and set size, never assume it's clean
memset(&ddsd,0,sizeof(ddsd)); 
ddsd.dwSize = sizeof(ddsd);

if (FAILED(lpddsprimary->Lock(NULL, &ddsd,
                   DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,
                   NULL)))
   {
   // error
   return(0);
   } // end if

// now ddsd.lPitch is valid and so is ddsd.lpSurface

// make a couple aliases to make code cleaner, so we don't
// have to cast
int mempitch        = (int)ddsd.lPitch;
UCHAR *video_buffer = (UCHAR *)ddsd.lpSurface;

// plot 1000 random pixels with random colors on the
// primary surface, they will be instantly visible
for (int index=0; index < 1000; index++)
    {
    // select random position and color for 640x480x8
    UCHAR color = rand()%256;
    int x = rand()%640;
    int y = rand()%480;

    // plot the pixel
    video_buffer[x+y*mempitch] = color;        

    } // end for index

// now unlock the primary surface
if (FAILED(lpddsprimary->Unlock(NULL)))
   return(0);

// sleep a bit
Sleep(30);

// return success or failure or your own return code here
return(1);

} // end Game_Main

////////////////////////////////////////////////////////////

int Game_Init(void *parms = NULL, int num_parms = 0)
{
// this is called once after the initial window is created and
// before the main event loop is entered, do all your initialization
// here

// first create base IDirectDraw interface
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
   {
   // error
   return(0);
   } // end if

// now query for IDirectDraw4
if (FAILED(lpdd->QueryInterface(IID_IDirectDraw4,
                               (LPVOID *)&lpdd4)))
   {
   // error
   return(0);
   } // end if

// set cooperation to full screen
if (FAILED(lpdd4->SetCooperativeLevel(main_window_handle, 
                                      DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX | 
                                      DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT)))
   {
   // error
   return(0);
   } // end if

// set display mode to 640x480x8
if (FAILED(lpdd4->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP,0,0)))
   {
   // error
   return(0);
   } // end if


// clear ddsd and set size
memset(&ddsd,0,sizeof(ddsd)); 
ddsd.dwSize = sizeof(ddsd);

// enable valid fields
ddsd.dwFlags = DDSD_CAPS;

// request primary surface
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

// create the primary surface
if (FAILED(lpdd4->CreateSurface(&ddsd, &lpddsprimary, NULL)))
   {
   // error
   return(0);
   } // end if

// build up the palette data array
for (int color=1; color < 255; color++)
    {
    // fill with random RGB values
    palette[color].peRed   = rand()%256;
    palette[color].peGreen = rand()%256;
    palette[color].peBlue  = rand()%256;

    // set flags field to PC_NOCOLLAPSE
    palette[color].peFlags = PC_NOCOLLAPSE;
    } // end for color

// now fill in entry 0 and 255 with black and white
palette[0].peRed   = 0;
palette[0].peGreen = 0;
palette[0].peBlue  = 0;
palette[0].peFlags = PC_NOCOLLAPSE;

palette[255].peRed   = 255;
palette[255].peGreen = 255;
palette[255].peBlue  = 255;
palette[255].peFlags = PC_NOCOLLAPSE;

// create the palette object
if (FAILED(lpdd4->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256 | 
                                DDPCAPS_INITIALIZE, 
                                palette,&lpddpal, NULL)))
{
// error
return(0);
} // end if

// finally attach the palette to the primary surface
if (FAILED(lpddsprimary->SetPalette(lpddpal)))
    {
    // error
    return(0);
    } // end if

// return success or failure or your own return code here
return(1);

} // end Game_Init

/////////////////////////////////////////////////////////////

int Game_Shutdown(void *parms = NULL, int num_parms = 0)
{
// this is called after the game is exited and the main event
// loop while is exited, do all you cleanup and shutdown here

// first the palette
if (lpddpal)
   {
   lpddpal->Release();
   lpddpal = NULL;
   } // end if

// now the primary surface
if (lpddsprimary)
   {
   lpddsprimary->Release();
   lpddsprimary = NULL;
   } // end if

// now blow away the IDirectDraw4 interface
if (lpdd4)
   {
   lpdd4->Release();
   lpdd4 = NULL;
   } // end if

// return success or failure or your own return code here
return(1);

} // end Game_Shutdown

// WINMAIN ////////////////////////////////////////////////

int WINAPI WinMain(	HINSTANCE hinstance,
					HINSTANCE hprevinstance,
					LPSTR lpcmdline,
					int ncmdshow)
{

WNDCLASSEX winclass; // this will hold the class we create
HWND	   hwnd;	 // generic window handle
MSG		   msg;		 // generic message
HDC        hdc;      // graphics device context

// first fill in the window class stucture
winclass.cbSize         = sizeof(WNDCLASSEX);
winclass.style			= CS_DBLCLKS | CS_OWNDC | 
                          CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc	= WindowProc;
winclass.cbClsExtra		= 0;
winclass.cbWndExtra		= 0;
winclass.hInstance		= hinstance;
winclass.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor		= LoadCursor(NULL, IDC_ARROW); 
winclass.hbrBackground	= (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName	= NULL;
winclass.lpszClassName	= WINDOW_CLASS_NAME;
winclass.hIconSm        = LoadIcon(NULL, IDI_APPLICATION);

// save hinstance in global
hinstance_app = hinstance;

// register the window class
if (!RegisterClassEx(&winclass))
	return(0);

// create the window
if (!(hwnd = CreateWindowEx(NULL,                  // extended style
                            WINDOW_CLASS_NAME,     // class
						    "DirectDraw Full-Screen Demo", // title
						    WS_POPUP | WS_VISIBLE,
					 	    0,0,	  // initial x,y
						    SCREEN_WIDTH,SCREEN_HEIGHT,  // initial width, height
						    NULL,	  // handle to parent 
						    NULL,	  // handle to menu
						    hinstance,// instance of this application
						    NULL)))	// extra creation parms
return(0);

// save main window handle
main_window_handle = hwnd;

// initialize game here
Game_Init();

// enter main event loop
while(TRUE)
	{
    // test if there is a message in queue, if so get it
	if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
	   { 
	   // test if this is a quit
       if (msg.message == WM_QUIT)
           break;
	
	   // translate any accelerator keys
	   TranslateMessage(&msg);

	   // send the message to the window proc
	   DispatchMessage(&msg);
	   } // end if
    
       // main game processing goes here
       Game_Main();
       
	} // end while

// closedown game here
Game_Shutdown();

// return to Windows like this
return(msg.wParam);

} // end WinMain

///////////////////////////////////////////////////////////

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品99一区二区三区| 亚洲欧美电影院| 国产精品美女久久福利网站| 亚洲综合免费观看高清完整版在线 | 91麻豆精品国产91久久久久| 国产亚洲人成网站| 免费人成精品欧美精品| 国产在线观看免费一区| 欧美高清hd18日本| 亚洲毛片av在线| 成人综合在线观看| 久久亚洲综合色一区二区三区| 6080亚洲精品一区二区| 亚洲男人的天堂一区二区| 国产福利91精品一区| 欧美大胆一级视频| 亚洲成av人片一区二区| 97se亚洲国产综合自在线观| 国产精品无圣光一区二区| 国产综合色在线| 日韩你懂的在线播放| 日韩黄色一级片| 欧美人狂配大交3d怪物一区| 亚洲国产美女搞黄色| 91久久精品一区二区| 一区二区三区在线视频观看| 99天天综合性| 亚洲精品视频免费看| 99精品欧美一区| 亚洲人成精品久久久久| 色欧美片视频在线观看| 亚洲精品成人少妇| 欧美性猛交xxxx乱大交退制版 | 91精品免费在线| 亚洲国产精品精华液网站| 欧美亚洲丝袜传媒另类| 亚洲第四色夜色| 欧美一区二区三区思思人| 免费在线观看成人| 精品免费99久久| 国产盗摄一区二区三区| 国产精品久久久久久久久图文区| 亚洲精品老司机| 日本韩国精品在线| 亚洲国产精品嫩草影院| 67194成人在线观看| 激情综合色综合久久| 国产午夜久久久久| 91麻豆精品秘密| 午夜成人免费电影| 久久免费电影网| 91丨九色porny丨蝌蚪| 午夜电影久久久| 久久久蜜桃精品| 91国产成人在线| 免费成人在线观看视频| 国产日韩欧美在线一区| 91久久精品国产91性色tv| 日本成人在线网站| 久久精品人人爽人人爽| 欧美主播一区二区三区美女| 人人超碰91尤物精品国产| 国产精品久久久久三级| 欧美精品在线一区二区三区| 国产酒店精品激情| 亚洲麻豆国产自偷在线| 精品久久久网站| 一本色道a无线码一区v| 久久99久久99| 亚洲激情男女视频| 久久久国产综合精品女国产盗摄| 日本一区中文字幕| 久久久久99精品国产片| 欧美日韩一区二区三区在线| 国产在线精品免费| 洋洋成人永久网站入口| 久久久精品国产99久久精品芒果| 激情综合亚洲精品| 亚洲国产欧美另类丝袜| 久久精品一区二区| 91精品国产综合久久久久久| 懂色av一区二区三区蜜臀| 日本不卡视频在线| 洋洋av久久久久久久一区| 国产日韩欧美在线一区| 日韩一级黄色片| 在线国产电影不卡| 99国产麻豆精品| 国产剧情一区在线| 日本亚洲免费观看| 亚洲一区二区三区小说| 国产精品久久精品日日| 久久精品在线免费观看| 日韩精品一区国产麻豆| 欧美精品久久天天躁| 91福利视频网站| 91在线云播放| 97久久精品人人爽人人爽蜜臀 | 精品国产成人系列| 欧美日韩成人激情| 91在线免费播放| 成人丝袜18视频在线观看| 久久精品国产精品亚洲红杏| 亚洲va欧美va国产va天堂影院| 91精品国产一区二区三区香蕉| 免费日本视频一区| 五月婷婷综合网| 亚洲v日本v欧美v久久精品| 亚洲免费成人av| 综合激情成人伊人| 最新高清无码专区| 一区精品在线播放| 亚洲三级久久久| 一区二区三区高清| 亚洲一区二区三区四区在线免费观看 | 国产精品日韩成人| 久久免费电影网| 国产人伦精品一区二区| 欧美高清在线一区| 国产免费久久精品| 国产精品二三区| 一区二区三区不卡视频在线观看| 欧美成人三级在线| 久久嫩草精品久久久精品 | 国产一区91精品张津瑜| 青青草成人在线观看| 麻豆精品新av中文字幕| 激情综合网av| 成人精品在线视频观看| 91视视频在线直接观看在线看网页在线看 | 偷拍一区二区三区| 奇米888四色在线精品| 免费成人在线网站| 风间由美一区二区av101| a美女胸又www黄视频久久| 色悠久久久久综合欧美99| 欧美日韩一区二区三区高清| 91精品国产高清一区二区三区蜜臀| av日韩在线网站| 欧美色网站导航| 精品久久一区二区三区| 国产精品伦一区| 午夜激情一区二区三区| 韩国成人精品a∨在线观看| 成人精品国产免费网站| 欧美性大战久久| 精品日本一线二线三线不卡| 中文久久乱码一区二区| 亚洲国产日韩在线一区模特| 国产乱码精品一区二区三区五月婷 | 中文字幕一区视频| 视频在线观看一区二区三区| 国产成人免费在线观看| 欧美日韩国产在线观看| www国产精品av| 亚洲韩国一区二区三区| 国产精品夜夜嗨| 欧美精品在欧美一区二区少妇| 在线观看日韩电影| 亚洲精品在线网站| 亚洲精品免费一二三区| 国产一区福利在线| 欧美日韩欧美一区二区| 国产精品日日摸夜夜摸av| 人人爽香蕉精品| 欧美无乱码久久久免费午夜一区| 91精品1区2区| 国产喷白浆一区二区三区| 五月婷婷另类国产| 91色porny| 精品动漫一区二区三区在线观看| 日韩久久久精品| 亚洲制服丝袜在线| 99久久婷婷国产精品综合| 欧美sm极限捆绑bd| 日韩极品在线观看| 色视频一区二区| 中文字幕的久久| 狠狠色丁香婷婷综合| 6080午夜不卡| 午夜a成v人精品| 欧美探花视频资源| 亚洲人午夜精品天堂一二香蕉| 亚洲影视在线播放| 91最新地址在线播放| 中文字幕欧美日本乱码一线二线 | 亚洲青青青在线视频| 国产成人精品免费在线| 欧美高清精品3d| 日韩精品欧美精品| 欧美日韩一卡二卡三卡| 一区二区三区在线视频免费 | 一区二区三区不卡视频在线观看| 亚洲国产成人av网| 在线观看一区二区视频| 伊人一区二区三区| 一本到三区不卡视频| 中文字幕一区不卡| 91蝌蚪国产九色| 亚洲欧美国产三级|