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

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

?? demo7_2.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
字號:
// DEMO7_2.CPP basic full-screen 24-bit color pixel plotting DirectDraw demo
// you must have 24-bit graphics available otherwise this demo
// will simply exit

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

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

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

// 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_24(int x, int y, 
                          int red, int green, int blue, 
                          UCHAR *video_buffer, int lpitch)
{
// this function plots a pixel in 24-bit color mode
// assuming that the caller already locked the surface
// and is sending a pointer and byte pitch to it

// in byte or 8-bit math the proper address is: 3*x + y*lpitch
// this is the address of the low order byte which is the Blue channel
// since the data is in RGB order
DWORD pixel_addr = (x+x+x) + y*lpitch;

// write the data, first blue
video_buffer[pixel_addr]   = blue;

// now red
video_buffer[pixel_addr+1] = green;

// finally green
video_buffer[pixel_addr+2] = red;

} // end Plot_Pixel_24

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

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 lpitch = (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 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_24(x,y,red,green,blue,video_buffer,lpitch);       

    } // 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看片淫黄大片一级在线观看| 亚洲一区二区精品视频| 日韩毛片在线免费观看| 亚洲欧美韩国综合色| 国产精品成人免费| 亚洲精品乱码久久久久久黑人| 国产精品美日韩| 国产精品国产a| 一区二区三区四区av| 亚洲自拍偷拍网站| 日本欧美在线看| 国产成人在线看| 色综合视频在线观看| 欧美日韩在线观看一区二区| 欧美一区二区人人喊爽| 久久亚洲二区三区| 国产欧美一区二区精品秋霞影院| 国产欧美精品日韩区二区麻豆天美| 国产欧美日韩中文久久| 国产精品成人一区二区三区夜夜夜| 亚洲男人的天堂av| 亚洲一区日韩精品中文字幕| 免费成人小视频| 成人动漫在线一区| 欧美色图激情小说| 久久久综合视频| 一区二区三区不卡在线观看 | 日av在线不卡| 老鸭窝一区二区久久精品| 国内精品视频666| 色综合中文字幕国产| 欧美午夜不卡在线观看免费| 欧美不卡一区二区| 亚洲欧美色一区| 国内欧美视频一区二区| 欧美主播一区二区三区| 亚洲国产精品av| 首页国产欧美日韩丝袜| 成人avav影音| 日韩欧美你懂的| 一区二区三区在线观看动漫| 久久66热re国产| 欧美午夜宅男影院| 国产三级精品在线| 日日夜夜精品视频免费| 成年人网站91| 久久夜色精品一区| 日韩精品亚洲一区二区三区免费| 国产成人夜色高潮福利影视| 欧美人与z0zoxxxx视频| 中文字幕欧美一区| 国产一区二区三区久久悠悠色av| 一本久久精品一区二区| 久久精品人人爽人人爽| 轻轻草成人在线| 在线看国产一区二区| 国产精品久久久久久一区二区三区 | 日韩码欧中文字| 久久精品国产一区二区| 欧美精品一卡两卡| 亚洲免费视频成人| 91一区在线观看| 中文字幕制服丝袜一区二区三区 | 91精品婷婷国产综合久久| 亚洲欧美综合色| 99久久精品国产毛片| 国产精品丝袜黑色高跟| 国产福利一区二区三区视频在线| 日韩三级.com| 日本aⅴ亚洲精品中文乱码| 欧美喷潮久久久xxxxx| 亚洲午夜影视影院在线观看| 91国偷自产一区二区三区成为亚洲经典| 国产精品女人毛片| 国产白丝网站精品污在线入口| 久久久久99精品一区| 国产一二精品视频| 国产视频一区二区在线| 成人在线综合网| 国产精品不卡一区| 色视频成人在线观看免| 亚洲一区二区欧美激情| 欧美精品日韩一区| 美女一区二区视频| 久久嫩草精品久久久精品| 国产成人亚洲综合a∨婷婷图片| 欧美精品一区男女天堂| 国产老妇另类xxxxx| 中文字幕精品一区二区精品绿巨人 | 香蕉久久夜色精品国产使用方法| 在线观看日韩电影| 日韩国产精品91| 久久九九久久九九| 色狠狠综合天天综合综合| 亚洲综合免费观看高清在线观看| 欧美久久婷婷综合色| 国内精品久久久久影院薰衣草| 久久久久久黄色| 色婷婷国产精品| 捆绑变态av一区二区三区| 欧美国产精品一区二区三区| 91成人国产精品| 免播放器亚洲一区| 中文一区二区完整视频在线观看| 色综合天天综合网天天狠天天| 日韩国产欧美在线观看| 国产日韩v精品一区二区| 在线日韩一区二区| 国内外成人在线| 尤物视频一区二区| 精品少妇一区二区三区在线播放| av一区二区不卡| 蜜桃精品视频在线| 亚洲精品美腿丝袜| 国产免费观看久久| 欧美日本乱大交xxxxx| 丁香婷婷深情五月亚洲| 日韩高清在线不卡| 日韩一区在线播放| 久久影院视频免费| 欧美性视频一区二区三区| 国产成人在线观看| 全国精品久久少妇| 一区二区三区四区av| 久久精品亚洲乱码伦伦中文| 欧美疯狂做受xxxx富婆| 成人手机电影网| 国产一区三区三区| 午夜精品一区二区三区免费视频| 欧美国产精品v| 久久免费精品国产久精品久久久久| 欧美性生活久久| 色婷婷综合在线| 91视频www| av电影在线不卡| 成人午夜av在线| 粉嫩在线一区二区三区视频| 美女视频一区二区三区| 婷婷综合另类小说色区| 亚洲在线中文字幕| 一区二区三区国产精品| 日韩伦理免费电影| 国产精品美女一区二区| 国产欧美日韩综合精品一区二区| 日韩欧美国产综合| 日韩精品一区二区三区在线播放| 在线不卡免费av| 欧美日韩卡一卡二| 538prom精品视频线放| 欧美无人高清视频在线观看| 色美美综合视频| 色综合色综合色综合| 色综合激情久久| 欧美午夜精品久久久| 欧美日韩国产一级| 91精品国产综合久久福利| 日韩亚洲国产中文字幕欧美| 日韩午夜激情视频| 精品国产91亚洲一区二区三区婷婷| 日韩欧美国产小视频| 久久久精品影视| 中文字幕一区三区| 亚洲精品乱码久久久久久日本蜜臀| 一区二区三区欧美日韩| 亚洲3atv精品一区二区三区| 91国内精品野花午夜精品| 欧美精品少妇一区二区三区| 4438成人网| 亚洲欧美日韩国产手机在线| 4438x成人网最大色成网站| 欧美一级一级性生活免费录像| 精品裸体舞一区二区三区| 久久综合999| 亚洲美女免费视频| 日本不卡视频在线观看| 国产九色sp调教91| 91日韩在线专区| 日韩三级.com| 成人免费一区二区三区在线观看| 亚洲成人综合视频| 国内精品视频666| 91九色02白丝porn| 欧美mv日韩mv亚洲| 亚洲一区二区三区精品在线| 国产在线精品国自产拍免费| 99热精品一区二区| 欧美电影精品一区二区| 亚洲视频一二三区| 久久97超碰国产精品超碰| 色婷婷综合久久久久中文一区二区| 91精品国产综合久久国产大片| 欧美中文字幕一二三区视频| 亚洲视频中文字幕| av不卡免费在线观看| 日韩一区二区电影在线| 亚洲欧美日韩综合aⅴ视频| 日韩成人午夜精品| 日本高清无吗v一区| 久久综合色天天久久综合图片|