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

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

?? demo7_13.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁 / 共 3 頁
字號:

    } // end for index


// flip pages
while (FAILED(lpddsprimary->Flip(NULL, DDFLIP_WAIT)));

// wait a sec
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

// create IDirectDraw interface 7.0 object and test for error
if (FAILED(DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL)))
   return(0);
// set cooperation to full screen
if (FAILED(lpdd->SetCooperativeLevel(main_window_handle, 
                                      DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX | 
                                      DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT)))
   return(0);

// set display mode to 640x480x8
if (FAILED(lpdd->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP,0,0)))
   return(0);

// we need a complex surface system with a primary and backbuffer

// clear ddsd and set size
DDRAW_INIT_STRUCT(ddsd); 

// enable valid fields
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;

// set the backbuffer count field to 1, use 2 for triple buffering
ddsd.dwBackBufferCount = 1;

// request a complex, flippable
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;

// create the primary surface
if (FAILED(lpdd->CreateSurface(&ddsd, &lpddsprimary, NULL)))
   return(0);

// now query for attached surface from the primary surface

// this line is needed by the call
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;

// get the attached back buffer surface
if (FAILED(lpddsprimary->GetAttachedSurface(&ddsd.ddsCaps, &lpddsback)))
  return(0);

// 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(lpdd->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256 | 
                                DDPCAPS_INITIALIZE, 
                                palette,&lpddpal, NULL)))
return(0);

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

// set clipper up on back buffer since that's where well clip
RECT screen_rect= {0,0,SCREEN_WIDTH-1,SCREEN_HEIGHT-1};
lpddclipper = DDraw_Attach_Clipper(lpddsback,1,&screen_rect);

// load the 8-bit image
if (!Load_Bitmap_File(&bitmap,"alley8.bmp"))
   return(0);

// load it's palette into directdraw
if (FAILED(lpddpal->SetEntries(0,0,MAX_COLORS_PALETTE,bitmap.palette)))
   return(0);

// clean the surfaces
DDraw_Fill_Surface(lpddsprimary,0);
DDraw_Fill_Surface(lpddsback,0);

// create the buffer to hold the background
lpddsbackground = DDraw_Create_Surface(640,480,0,-1);

// copy the background bitmap image to the background surface 

// lock the surface
lpddsbackground->Lock(NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL);

// get video pointer to primary surfce
UCHAR *image_buffer = (UCHAR *)ddsd.lpSurface;       

// test if memory is linear
if (ddsd.lPitch == SCREEN_WIDTH)
   {
   // copy memory from double buffer to primary buffer
   memcpy((void *)image_buffer, (void *)bitmap.buffer, SCREEN_WIDTH*SCREEN_HEIGHT);
   } // end if
else
   { // non-linear

   // make copy of source and destination addresses
   UCHAR *dest_ptr = image_buffer;
   UCHAR *src_ptr  = bitmap.buffer;

   // memory is non-linear, copy line by line
   for (int y=0; y < SCREEN_HEIGHT; y++)
       {
       // copy line
       memcpy((void *)dest_ptr, (void *)src_ptr, SCREEN_WIDTH);

       // advance pointers to next line
       dest_ptr+=ddsd.lPitch;
       src_ptr +=SCREEN_WIDTH;
       } // end for

   } // end else

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

// unload the bitmap file, we no longer need it
Unload_Bitmap_File(&bitmap);

// seed random number generator
srand(GetTickCount());

// initialize all the aliens

// alien on level 1 of complex

aliens[0].x              = rand()%SCREEN_WIDTH;
aliens[0].y              = 116 - 72;                  
aliens[0].velocity       = 2+rand()%4;
aliens[0].current_frame  = 0;             
aliens[0].counter        = 0;       

// alien on level 2 of complex

aliens[1].x              = rand()%SCREEN_WIDTH;
aliens[1].y              = 246 - 72;                  
aliens[1].velocity       = 2+rand()%4;
aliens[1].current_frame  = 0;             
aliens[1].counter        = 0;  

// alien on level 3 of complex

aliens[2].x              = rand()%SCREEN_WIDTH;
aliens[2].y              = 382 - 72;                  
aliens[2].velocity       = 2+rand()%4;
aliens[2].current_frame  = 0;             
aliens[2].counter        = 0;  

// now load the bitmap containing the alien imagery
// then scan the images out into the surfaces of alien[0]
// and copy then into the other two, be careful of reference counts!

// load the 8-bit image
if (!Load_Bitmap_File(&bitmap,"dedsp0.bmp"))
   return(0);

// create each surface and load bits
for (int index = 0; index < 3; index++)
    {
    // create surface to hold image
    aliens[0].frames[index] = DDraw_Create_Surface(72,80,0);

    // now load bits...
    Scan_Image_Bitmap(&bitmap,                 // bitmap file to scan image data from
                      aliens[0].frames[index], // surface to hold data
                      index, 0);               // cell to scan image from    

    } // end for index

// unload the bitmap file, we no longer need it
Unload_Bitmap_File(&bitmap);

// now for the tricky part. There is no need to create more surfaces with the same
// data, so I'm going to copy the surface pointers member for member to each alien
// however, be careful, since the reference counts do NOT go up, you still only need
// to release() each surface once!

for (index = 0; index < 3; index++)
    aliens[1].frames[index] = aliens[2].frames[index] = aliens[0].frames[index];

// 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

// kill all the surfaces


// 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 (lpdd)
   {
   lpdd->Release();
   lpdd = 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 8-Bit Blitting 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一区二区三区免费野_久草精品视频
国产综合久久久久久鬼色 | 成人福利视频网站| 91麻豆产精品久久久久久| 91精品国产综合久久香蕉麻豆| 国产人妖乱国产精品人妖| 日韩精品三区四区| 欧美伊人精品成人久久综合97| 国产午夜精品理论片a级大结局| 亚洲成av人片| 97国产一区二区| 国产女人18毛片水真多成人如厕 | 中文字幕在线观看一区| 久久精品久久精品| 欧美日韩精品系列| 亚洲一区二区三区免费视频| av高清久久久| 国产精品女人毛片| 国产成人av电影| 欧美va亚洲va香蕉在线| 免费观看在线综合色| 欧美日韩国产高清一区二区| 一区二区成人在线| 色猫猫国产区一区二在线视频| 久久久久久99久久久精品网站| 九色综合国产一区二区三区| 欧美一区午夜视频在线观看 | 欧美久久久久久久久中文字幕| 亚洲欧美日韩一区二区三区在线观看| 国产乱码精品一区二区三区五月婷| 91精品国产91久久综合桃花| 日韩avvvv在线播放| 717成人午夜免费福利电影| 亚洲国产精品久久久久秋霞影院| 欧美性猛交xxxx黑人交| 亚洲国产欧美另类丝袜| 欧美日韩国产综合视频在线观看 | 日韩美女啊v在线免费观看| 国产宾馆实践打屁股91| 国产亚洲精品aa| 成人黄色在线看| 亚洲另类在线制服丝袜| 欧美日韩精品一区视频| 日本欧美韩国一区三区| 精品国产91亚洲一区二区三区婷婷 | 欧美韩国日本综合| 99久久99精品久久久久久| 中文字幕中文字幕在线一区| 成人午夜短视频| 亚洲综合在线电影| 制服丝袜在线91| 国产一区二区免费在线| 亚洲日本在线观看| 欧美精品电影在线播放| 国产一区二区三区久久久 | 日韩视频123| 国产麻豆精品theporn| 国产精品欧美一区喷水| 一本一本久久a久久精品综合麻豆| 亚洲综合激情网| www一区二区| 99热在这里有精品免费| 午夜精品成人在线视频| 久久久欧美精品sm网站| 色婷婷狠狠综合| 久久不见久久见免费视频1| 国产精品久久久99| 欧美顶级少妇做爰| 成人av中文字幕| 轻轻草成人在线| 亚洲视频香蕉人妖| 欧美一级理论性理论a| 成人av网址在线观看| 天堂一区二区在线免费观看| 久久久久88色偷偷免费| 欧美日韩精品欧美日韩精品 | 欧美无砖专区一中文字| 国产精品69毛片高清亚洲| 一区二区国产视频| 亚洲国产成人午夜在线一区| 欧美日韩国产系列| av一区二区不卡| 久久99九九99精品| 亚洲国产成人tv| 国产精品美女久久久久av爽李琼| 欧美美女激情18p| 一本高清dvd不卡在线观看| 韩国一区二区在线观看| 亚洲a一区二区| 一级精品视频在线观看宜春院 | 亚洲精品视频在线观看免费| 精品国偷自产国产一区| 69堂国产成人免费视频| 欧美性猛交一区二区三区精品| caoporn国产精品| 国产高清久久久| 精品一区二区成人精品| 五月婷婷综合激情| 一个色在线综合| 亚洲欧美电影一区二区| 国产精品美女久久久久久久网站| 精品剧情v国产在线观看在线| 欧美久久久久久久久中文字幕| 色婷婷久久综合| 91官网在线免费观看| 一本色道久久加勒比精品 | 日韩精品一区在线| 欧美老年两性高潮| 欧美性videosxxxxx| 色综合久久中文综合久久97| 91免费观看在线| 一本色道久久综合狠狠躁的推荐| 99久久免费视频.com| 91麻豆国产福利在线观看| 91网站最新网址| 欧美亚洲高清一区| 欧美调教femdomvk| 欧美日韩色一区| 欧美日韩在线精品一区二区三区激情| 色丁香久综合在线久综合在线观看| 成人美女在线观看| 色天天综合久久久久综合片| 欧美性色综合网| 日韩欧美激情一区| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 欧美成人精品福利| 久久久蜜桃精品| 国产精品久久久久影院色老大| 中文字幕一区二区在线播放| 亚洲人成精品久久久久久| 一区二区三区资源| 日本成人在线不卡视频| 国内精品伊人久久久久av影院 | 久久99精品久久久久久国产越南 | 欧美影院精品一区| 91精品国产免费久久综合| 欧美sm极限捆绑bd| 国产精品久久久久影院色老大| 亚洲欧美另类综合偷拍| 丝袜诱惑亚洲看片| 国产精品亚洲一区二区三区妖精 | 日韩精品欧美精品| 国产精品1区2区| 欧美色视频一区| 久久久久久久综合日本| 亚洲精品乱码久久久久久久久 | 91免费版pro下载短视频| 欧美三级资源在线| 国产亚洲一区二区三区四区| 最新不卡av在线| 久久99国产精品成人| 99riav一区二区三区| 欧美电影在线免费观看| 中日韩免费视频中文字幕| 婷婷久久综合九色国产成人| 成人污视频在线观看| 91精品国产综合久久久久久漫画| 日本一区二区三区在线观看| 亚洲h在线观看| 成年人午夜久久久| 欧美一区二区三区在线电影 | 一本色道a无线码一区v| 精品国产乱码久久久久久久久 | 欧美一级在线免费| 综合婷婷亚洲小说| 国产一区二区中文字幕| 欧美色窝79yyyycom| 国产精品久久久久久久久免费桃花 | 亚洲成人第一页| 成人高清伦理免费影院在线观看| 欧美一区二区精品久久911| 樱桃视频在线观看一区| 成人毛片老司机大片| 精品剧情在线观看| 日本欧美久久久久免费播放网| 91网站黄www| 国产精品国产精品国产专区不蜜| 国产一区在线观看视频| 欧美人狂配大交3d怪物一区| 中文字幕一区二区视频| 国产999精品久久久久久| 精品久久五月天| 免费一级片91| 日韩一区二区三区免费看| 亚洲线精品一区二区三区八戒| 91在线视频网址| 最新中文字幕一区二区三区| 成人免费视频播放| 国产欧美在线观看一区| 国产精品1024久久| 久久久国际精品| 国产成人午夜电影网| 国产亚洲成年网址在线观看| 国产乱人伦精品一区二区在线观看| 欧美大胆一级视频| 久久精品国产成人一区二区三区| 日韩欧美一区在线| 国产综合久久久久久久久久久久| 久久久亚洲综合| 成人小视频免费在线观看| 国产精品国产三级国产aⅴ中文|