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

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

?? demo7_3.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
字號:
// DEMO7_3.CPP basic full-screen 32-bit color pixel plotting DirectDraw demo

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

#define WIN32_LEAN_AND_MEAN  // just say no to MFC

#define INITGUID

#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      32    // bits per pixel

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

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

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

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

// this builds a 16 bit color value in 5.5.5 format (1-bit alpha mode)
#define _RGB16BIT555(r,g,b) ((b & 31) + ((g & 31) << 5) + ((r & 31) << 10))

// this builds a 16 bit color value in 5.6.5 format (green dominate mode)
#define _RGB16BIT565(r,g,b) ((b & 31) + ((g & 63) << 5) + ((r & 31) << 11))

// this builds a 32 bit color value in A.8.8.8 format (8-bit alpha mode)
#define _RGB32BIT(a,r,g,b) ((b) + ((g) << 8) + ((r) << 16) + ((a) << 24))

// initializes a direct draw struct
#define DDRAW_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

LPDIRECTDRAW7         lpdd         = NULL;   // dd object
LPDIRECTDRAWSURFACE7  lpddsprimary = NULL;   // dd primary surface
LPDIRECTDRAWSURFACE7  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

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

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

inline void Plot_Pixel_32(int x, int y, 
                          int alpha,int red, int green, int blue, 
                          UINT *video_buffer, int lpitch32)
{
// this function plots a pixel in 32-bit color mode
// assuming that the caller already locked the surface
// and is sending a pointer and DWORD aligned pitch to it

// first build up color WORD
UINT pixel = _RGB32BIT(alpha,red,green,blue);

// write the data
video_buffer[x + y*lpitch32] = pixel;

} // end Plot_Pixel_32

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

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
DDRAW_INIT_STRUCT(ddsd); 

// lock the primary surface
if (FAILED(lpddsprimary->Lock(NULL, &ddsd,
                   DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,
                   NULL)))
   return(0);

// 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 lpitch32 = (int)(ddsd.lPitch >> 2);
UINT *video_buffer = (UINT *)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 640x480x16
    int red   = rand()%256;
    int green = rand()%256;
    int blue  = rand()%256;
    int x = rand()%640;
    int y = rand()%480;

    // plot the pixel
    Plot_Pixel_32(x,y,0,red,green,blue,video_buffer,lpitch32);       

    } // end for index

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

// 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 640x480x16
if (FAILED(lpdd->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP,0,0)))
   return(0);

// 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(lpdd->CreateSurface(&ddsd, &lpddsprimary, NULL)))
   return(0);

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

// 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 16-Bit 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一区二区三区免费野_久草精品视频
日韩欧美国产三级电影视频| 欧洲生活片亚洲生活在线观看| 日韩小视频在线观看专区| 日日嗨av一区二区三区四区| 91麻豆精品国产无毒不卡在线观看 | 久久精品一区二区| 麻豆成人综合网| 国产拍揄自揄精品视频麻豆| av爱爱亚洲一区| 亚洲国产一区在线观看| 日韩欧美一区中文| 国产成人免费在线视频| 亚洲男同性视频| 欧美日韩国产一级二级| 久久国产免费看| 亚洲色欲色欲www在线观看| 欧美日韩国产一级| 国产一区二区不卡老阿姨| 最新不卡av在线| 884aa四虎影成人精品一区| 国产一区二区在线影院| 中文字幕五月欧美| 欧美高清www午色夜在线视频| 国产一区二区精品久久99| 亚洲少妇最新在线视频| 欧美一区在线视频| 538prom精品视频线放| 国产精品18久久久久久久久久久久 | 国产清纯美女被跳蛋高潮一区二区久久w | 色素色在线综合| 麻豆精品蜜桃视频网站| 国产精品嫩草影院com| 欧美一区二区免费观在线| 成人99免费视频| 久久福利视频一区二区| 夜夜精品浪潮av一区二区三区| www成人在线观看| 欧美日韩高清在线| 99riav久久精品riav| 韩国一区二区视频| 亚洲国产成人91porn| 欧美激情在线一区二区| 日韩欧美的一区二区| 色综合久久久久久久久久久| 国产激情一区二区三区| 蜜臀av在线播放一区二区三区| 亚洲欧洲av一区二区三区久久| 精品对白一区国产伦| 69堂亚洲精品首页| 成人激情电影免费在线观看| 精品一区二区三区免费视频| 日韩在线卡一卡二| 亚洲色欲色欲www在线观看| 国产欧美日韩在线视频| 91麻豆精品国产91久久久久久久久 | 国产欧美一区二区三区鸳鸯浴| 欧美日韩国产经典色站一区二区三区| 99热精品国产| 国产成人精品aa毛片| 国产在线视视频有精品| 琪琪久久久久日韩精品| 日韩激情视频网站| 亚洲成a天堂v人片| 亚洲国产综合在线| 亚洲另类色综合网站| 亚洲少妇最新在线视频| 中文字幕欧美一| 国产精品成人一区二区三区夜夜夜| 久久日一线二线三线suv| 欧美一区二区三区在线看 | 911精品国产一区二区在线| 欧美在线观看一二区| 色呦呦一区二区三区| 99国产精品久久久久久久久久久| 成人小视频在线观看| 国产成人午夜精品5599| 国产成人99久久亚洲综合精品| 国产一区二区视频在线播放| 久久99久久99精品免视看婷婷| 玖玖九九国产精品| 精品在线观看免费| 国产一区中文字幕| 国产精品白丝av| 成人福利视频网站| 日本精品一区二区三区高清 | 国内偷窥港台综合视频在线播放| 国产最新精品免费| 国产不卡在线一区| 91在线高清观看| 欧美亚洲一区二区在线| 欧美日本韩国一区二区三区视频 | 99免费精品视频| 色天天综合色天天久久| 欧美日韩亚洲国产综合| 4438成人网| 国产日韩一级二级三级| 最新久久zyz资源站| 亚洲一区在线观看视频| 美女看a上一区| 成人精品免费看| 欧美亚洲自拍偷拍| 日韩精品中文字幕在线一区| 久久网这里都是精品| 亚洲欧洲美洲综合色网| 亚洲一区二区三区在线看| 久久国内精品视频| 成人免费毛片片v| 欧美亚洲另类激情小说| 欧美精品一区二区三区四区| 最新国产成人在线观看| 日韩激情一二三区| 成人免费视频一区二区| 欧美精品久久一区| 中文字幕免费观看一区| 亚洲风情在线资源站| 国产精品中文字幕欧美| 91久久人澡人人添人人爽欧美| 日韩视频在线一区二区| 自拍偷拍亚洲综合| 蜜桃视频在线一区| 一本大道久久a久久综合婷婷| 日韩三级在线免费观看| 国产精品白丝在线| 麻豆国产精品一区二区三区| 色94色欧美sute亚洲13| 久久九九久精品国产免费直播| 亚洲综合精品自拍| 国产精品小仙女| 91精品国产手机| 亚洲视频狠狠干| 国产福利一区在线观看| 欧美一级淫片007| 一区二区久久久久| 成人免费精品视频| 欧美不卡视频一区| 亚洲成人免费视| 99精品在线观看视频| 久久久久久免费毛片精品| 亚洲一区二区三区四区在线观看 | 欧美久久久久久久久中文字幕| 中文字幕av一区二区三区免费看| 日韩精品电影在线观看| 一本色道久久综合亚洲91| 26uuu久久综合| 日韩二区三区四区| 色88888久久久久久影院野外| 国产精品美女久久久久久久久| 久久99国产精品免费| 91精品蜜臀在线一区尤物| 亚洲精品乱码久久久久| 91伊人久久大香线蕉| 欧美韩日一区二区三区四区| 国产自产视频一区二区三区| 日韩区在线观看| 日韩高清在线观看| 欧美日韩三级视频| 亚洲一区欧美一区| 色久优优欧美色久优优| 1区2区3区欧美| 成人高清免费在线播放| 亚洲国产精品v| 国产69精品久久久久777| www精品美女久久久tv| 久久97超碰色| 精品日韩欧美在线| 韩国精品免费视频| 国产欧美一区二区精品久导航| 国产电影一区在线| 国产日韩欧美精品综合| 高清av一区二区| 中文字幕一区二区三| 成人av在线影院| 亚洲免费观看在线观看| 91福利视频久久久久| 亚洲一区二区三区四区的| 欧美日韩免费高清一区色橹橹 | 欧美精品v日韩精品v韩国精品v| 亚洲午夜羞羞片| 4438成人网| 国内精品写真在线观看| 久久精品人人做人人爽97| 成人va在线观看| 亚洲一区二区3| 欧美一级生活片| 国产盗摄一区二区三区| 亚洲视频一区二区在线| 欧美性猛片xxxx免费看久爱| 免费成人在线网站| 国产三级精品三级在线专区| 91视视频在线观看入口直接观看www| 亚洲人精品一区| 欧美日韩激情在线| 捆绑紧缚一区二区三区视频| 亚洲国产高清在线观看视频| 91社区在线播放| 日本亚洲最大的色成网站www| 久久蜜桃av一区二区天堂| 色婷婷久久久综合中文字幕| 日本中文字幕一区| 日本一二三不卡|