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

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

?? demo8_7.cpp

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

    float yr = (float)poly->vlist[curr_vert].x*sin_look[theta] + 
                    (float)poly->vlist[curr_vert].y*cos_look[theta];

    // store result back
    poly->vlist[curr_vert].x = xr;
    poly->vlist[curr_vert].y = yr;

    } // end for curr_vert

// return success
return(1);

} // end Rotate_Polygon2D

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

int Scale_Polygon2D(POLYGON2D_PTR poly, float sx, float sy)
{
// this function scalesthe local coordinates of the polygon

// test for valid pointer
if (!poly)
   return(0);

// loop and scale each point
for (int curr_vert = 0; curr_vert < poly->num_verts; curr_vert++)
    {
    // scale and store result back
    poly->vlist[curr_vert].x *= sx;
    poly->vlist[curr_vert].y *= sy;

    } // end for curr_vert

// return success
return(1);

} // end Scale_Polygon2D

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

inline int Draw_Pixel(int x, int y,int color,
                      UCHAR *video_buffer, int lpitch)
{
// this function plots a single pixel at x,y with color
video_buffer[x + y*lpitch] = color;

// return success
return(1);

} // end Draw_Pixel

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

int DDraw_Fill_Surface(LPDIRECTDRAWSURFACE7 lpdds,int color)
{
DDBLTFX ddbltfx; // this contains the DDBLTFX structure

// clear out the structure and set the size field 
DDRAW_INIT_STRUCT(ddbltfx);

// set the dwfillcolor field to the desired color
ddbltfx.dwFillColor = color; 

// ready to blt to surface
lpdds->Blt(NULL,       // ptr to dest rectangle
           NULL,       // ptr to source surface, NA            
           NULL,       // ptr to source rectangle, NA
           DDBLT_COLORFILL | DDBLT_WAIT,   // fill and wait                   
           &ddbltfx);  // ptr to DDBLTFX structure

// return success
return(1);
} // end DDraw_Fill_Surface

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

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

// make sure this isn't executed again
if (window_closed)
   return(0);

// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
   {
   PostMessage(main_window_handle,WM_CLOSE,0,0);
   window_closed = 1;
   } // end if

// clear out the back buffer
DDraw_Fill_Surface(lpddsback, 0);

// lock primary buffer
DDRAW_INIT_STRUCT(ddsd);

if (FAILED(lpddsback->Lock(NULL,&ddsd,
                           DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
                           NULL)))
return(0);

// draw the triangle
Draw_Triangle_2D(rand()%SCREEN_WIDTH, rand()%SCREEN_HEIGHT,
                 rand()%SCREEN_WIDTH, rand()%SCREEN_HEIGHT,
                 rand()%SCREEN_WIDTH, rand()%SCREEN_HEIGHT,
                 rand()%256,(UCHAR *)ddsd.lpSurface, ddsd.lPitch);

// unlock primary buffer
if (FAILED(lpddsback->Unlock(NULL)))
   return(0);

// draw the text
Draw_Text_GDI("Press <ESC> to exit.", 8,8,255, lpddsback);

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

// wait a sec
Sleep(33);

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

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

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


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

// make this color glow green
palette[1].peRed     = 0;
palette[1].peGreen   = 16;
palette[1].peBlue    = 0;
palette[1].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);

// clear the surfaces out
DDraw_Fill_Surface(lpddsprimary, 0 );
DDraw_Fill_Surface(lpddsback, 0 );

// define points of object (must be convex)
VERTEX2DF object_vertices[4] = {-100,-100, 100,-100, 100,100, -100, 100};

// initialize polygon object
object.state       = 1;   // turn it on
object.num_verts   = 4;  
object.x0          = SCREEN_WIDTH/2; // position it
object.y0          = SCREEN_HEIGHT/2;
object.xv          = 0;
object.yv          = 0;
object.color       = 1; // animated green
object.vlist       = new VERTEX2DF [object.num_verts];
 
for (int index = 0; index < object.num_verts; index++)
    object.vlist[index] = object_vertices[index];

   
// create sin/cos lookup table

// generate the tables
for (int ang = 0; ang < 360; ang++)
    {
    // convert ang to radians
    float theta = (float)ang*PI/(float)180;

    // insert next entry into table
    cos_look[ang] = cos(theta);
    sin_look[ang] = sin(theta);

    } // end for ang


// 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 back buffer surface
if (lpddsback)
   {
   lpddsback->Release();
   lpddsback = 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 Triangle Drawing 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一区二区三区免费野_久草精品视频
国产成人丝袜美腿| 国产精品综合av一区二区国产馆| 欧洲精品一区二区| 蜜臀99久久精品久久久久久软件| 中文字幕国产精品一区二区| 欧美日韩另类一区| 91一区二区在线| 激情综合一区二区三区| 一区二区三区**美女毛片| 久久综合丝袜日本网| 在线不卡中文字幕| 成人污视频在线观看| 久久99蜜桃精品| 日韩激情一区二区| 精品久久久久香蕉网| 丁香婷婷综合色啪| 国产成人日日夜夜| 精品一区二区三区日韩| 午夜亚洲国产au精品一区二区| 国产精品无圣光一区二区| 精品国产一区二区三区久久久蜜月| 欧美在线高清视频| 欧美网站一区二区| 欧美综合色免费| 91国产精品成人| 99re热这里只有精品视频| av亚洲产国偷v产偷v自拍| 国产成人亚洲综合a∨婷婷 | 欧美成人午夜电影| 欧美成人aa大片| 国产日韩欧美不卡在线| 国产三区在线成人av| 国产精品久久久久久久久搜平片 | 一区二区三区四区国产精品| 久久久国际精品| 欧美激情中文字幕| 亚洲欧美另类久久久精品2019| 欧美国产一区二区| 亚洲精品国产无套在线观| 有坂深雪av一区二区精品| 亚洲妇熟xx妇色黄| 麻豆国产91在线播放| 激情六月婷婷久久| 国产精品一区专区| 99国产精品久久久久| 在线电影国产精品| 国产三级欧美三级日产三级99| 欧美成人精品二区三区99精品| 日韩丝袜情趣美女图片| 亚洲视频一二区| 国产精品三级电影| 精品久久免费看| 国产精品欧美久久久久一区二区 | 91精品国产综合久久香蕉的特点| 欧美日韩国产成人在线免费| 欧美激情一区二区三区蜜桃视频 | 国产欧美一区二区精品婷婷| 午夜一区二区三区视频| 欧美午夜片在线观看| 色欧美乱欧美15图片| 欧美精品黑人性xxxx| 国产人成一区二区三区影院| 亚洲成人福利片| av在线这里只有精品| 精品乱码亚洲一区二区不卡| 亚洲午夜精品久久久久久久久| 国产一区二区三区免费| 99在线热播精品免费| 国产蜜臀av在线一区二区三区| 蜜臀av一区二区在线免费观看 | 99精品国产热久久91蜜凸| 日韩精品在线一区| 蜜臀精品久久久久久蜜臀| 欧美熟乱第一页| 日日夜夜免费精品视频| 欧美日韩亚洲高清一区二区| 亚洲激情图片一区| 在线国产亚洲欧美| 亚洲一二三四在线| 欧美日韩一区不卡| 国产精品美女www爽爽爽| 国产一区二区毛片| 久久午夜电影网| 九色|91porny| 久久精品欧美一区二区三区不卡 | 亚洲卡通动漫在线| 日本久久一区二区| 丝袜美腿成人在线| 欧美精品久久久久久久多人混战| 男女性色大片免费观看一区二区| 日韩欧美的一区二区| 不卡一二三区首页| 视频一区二区三区在线| 6080日韩午夜伦伦午夜伦| 一区二区三区 在线观看视频| 欧美日韩一区小说| 国产老肥熟一区二区三区| 亚洲国产精品黑人久久久| 91在线观看免费视频| 丝袜诱惑制服诱惑色一区在线观看 | 亚洲成人av一区二区三区| 精品日韩成人av| 99久久婷婷国产综合精品| 日韩精品成人一区二区三区| 日韩免费在线观看| 欧美日韩一区久久| 国v精品久久久网| 亚洲男人的天堂av| 337p日本欧洲亚洲大胆色噜噜| 成人黄色电影在线| 看电影不卡的网站| 亚洲午夜三级在线| 中文字幕一区二区日韩精品绯色| 在线视频欧美精品| 91在线观看成人| 成人免费视频播放| 国产精品正在播放| 老司机精品视频导航| 午夜精品免费在线观看| 亚洲免费av在线| 亚洲天堂av老司机| xfplay精品久久| 精品福利一区二区三区| 91精品国产综合久久福利| 日本高清不卡视频| 91丝袜美女网| 一本色道综合亚洲| 成人国产精品免费观看动漫| 久久99久久99精品免视看婷婷| 亚洲综合免费观看高清完整版在线 | 亚洲成人一区在线| 亚洲精品欧美激情| 一区二区三区四区不卡视频| 欧美精品 日韩| 国产精一品亚洲二区在线视频| 热久久久久久久| 精品一区二区精品| 国产精品亚洲午夜一区二区三区 | 国产激情视频一区二区三区欧美 | 国产精品伦理一区二区| 国产精品久久久久久久久久久免费看 | 九色|91porny| 丁香啪啪综合成人亚洲小说| 国产成人精品一区二区三区四区 | 日本伊人精品一区二区三区观看方式| 亚洲国产日韩一区二区| 美女精品一区二区| 国产精品一二二区| 色综合天天在线| 欧美一级在线视频| 国产精品每日更新在线播放网址| 亚洲一级片在线观看| 日本成人中文字幕| 99久久99久久综合| 欧美高清hd18日本| 国产精品久久久久久久岛一牛影视 | 高清beeg欧美| 欧美一区二区三区免费在线看| 亚洲欧洲精品一区二区三区 | 337p粉嫩大胆噜噜噜噜噜91av| 欧美高清一级片在线| 国产欧美一区二区在线观看| 五月天久久比比资源色| 成人av高清在线| 欧美xingq一区二区| 亚洲午夜视频在线| bt欧美亚洲午夜电影天堂| 日韩三级免费观看| 亚洲已满18点击进入久久| 成人午夜短视频| 精品1区2区在线观看| 日韩经典一区二区| 91久久精品日日躁夜夜躁欧美| 欧美国产成人在线| 国产成人综合在线| 精品久久久久av影院| 久久疯狂做爰流白浆xx| 欧美日韩在线直播| 色综合激情久久| 国产三级久久久| 久久99久久99| 日韩一区二区三区视频在线观看| 亚洲综合视频在线观看| 不卡视频在线看| 中文字幕五月欧美| 国产一区二区不卡| 国产精品久久久久久久久搜平片| 国产成人亚洲综合a∨猫咪| 久久久久久久久久久99999| 国产一区二区三区久久悠悠色av| 欧美一区二区三级| 国产一区二区免费在线| 国产亚洲女人久久久久毛片| 成人av在线一区二区三区| 亚洲天堂a在线| 欧美一区二区私人影院日本| 国产做a爰片久久毛片| 国产精品丝袜久久久久久app| 成人a级免费电影| 亚洲国产欧美日韩另类综合|