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

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

?? demo7_1.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
字號:
// DEMO7_1.CPP basic full-screen 16-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      16    // 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_Faster16(int x, int y, 
                                int red, int green, int blue, 
                                USHORT *video_buffer, int lpitch16)
{
// this function plots a pixel in 16-bit color mode
// assuming that the caller already locked the surface
// and is sending a pointer and byte pitch to it

// first build up color WORD
USHORT pixel = _RGB16BIT565(red,green,blue);

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

} // end Plot_Pixel_Faster16

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

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 lpitch16 = (int)(ddsd.lPitch >> 1);
USHORT *video_buffer = (USHORT *)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_Faster16(x,y,red,green,blue,video_buffer,lpitch16);       

    } // 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一区二区三区免费野_久草精品视频
亚洲激情中文1区| 亚洲福利视频三区| 中文字幕在线不卡国产视频| 午夜精品免费在线观看| 久久99精品久久久久久动态图| 国产91丝袜在线18| 欧美日韩成人一区| 国产精品久久久一本精品| 人禽交欧美网站| 在线观看精品一区| 亚洲国产激情av| 老司机免费视频一区二区| 欧美优质美女网站| 国产精品看片你懂得| 精品在线观看视频| 欧美日韩成人一区| 亚洲影院久久精品| 91在线观看视频| 国产欧美一区二区精品性| 蜜臀久久99精品久久久画质超高清| 91在线精品秘密一区二区| 国产校园另类小说区| 久久99精品久久久久婷婷| 4438成人网| 亚洲午夜免费电影| 91丨porny丨中文| 国产日韩欧美麻豆| 国产一区二区三区观看| 欧美一级免费观看| 亚洲欧美日韩国产综合| 精品国产一区二区三区不卡 | 日本高清视频一区二区| 狠狠色丁香久久婷婷综合丁香| 欧美日韩综合一区| 亚洲女同一区二区| av动漫一区二区| 国产人久久人人人人爽| 韩国欧美国产1区| 精品国产乱子伦一区| 免费观看在线色综合| 欧美一区二区三区四区在线观看| 亚洲国产精品久久人人爱蜜臀 | 国产精品一区二区不卡| 欧美一区二区精美| 视频精品一区二区| 欧美丰满美乳xxx高潮www| 性做久久久久久免费观看欧美| 美女一区二区久久| 欧美一级夜夜爽| 日本欧美久久久久免费播放网| 欧美日韩激情一区二区| 午夜精品在线视频一区| 这里只有精品99re| 久久精品国产一区二区| www国产成人免费观看视频 深夜成人网| 麻豆精品国产传媒mv男同| 日韩欧美一二三区| 国产乱国产乱300精品| 中文字幕欧美激情一区| 一本色道久久综合亚洲91| 亚洲一区视频在线观看视频| 精品视频免费在线| 麻豆成人综合网| 久久精品一二三| 99久久精品99国产精品| 亚洲午夜av在线| 欧美电影免费观看高清完整版在 | 欧美国产成人在线| 91传媒视频在线播放| 免费在线观看一区| 久久综合九色综合欧美亚洲| 成人av影院在线| 亚洲成人av资源| 久久嫩草精品久久久精品| 成人污污视频在线观看| 亚洲一区在线观看免费观看电影高清 | 国产91色综合久久免费分享| 亚洲人成精品久久久久久| 91精品国产综合久久久久久漫画| 国产一区二区三区蝌蚪| 一区二区三区四区亚洲| 日韩午夜激情av| www.爱久久.com| 日本在线不卡视频| 91丨porny丨在线| 久久综合久久鬼色中文字| 日本伊人午夜精品| 欧美精品一区二区三区一线天视频| 国产精品一区二区免费不卡| 亚洲天堂免费看| 精品成人在线观看| 在线观看免费成人| 成人99免费视频| 美女视频黄a大片欧美| 综合中文字幕亚洲| 2020国产精品久久精品美国| 色婷婷国产精品久久包臀| 九色综合狠狠综合久久| 亚洲国产wwwccc36天堂| 国产精品九色蝌蚪自拍| 欧美v日韩v国产v| 欧美日韩一区小说| 91视频xxxx| 成人av在线资源| 国产成人无遮挡在线视频| 久久国内精品自在自线400部| 一区二区三区不卡视频| 五月婷婷久久丁香| 久久久久久久久久久久电影| 国产精品国产三级国产有无不卡| 精品无人区卡一卡二卡三乱码免费卡 | 天天操天天干天天综合网| 亚洲三级小视频| 久久免费视频一区| 26uuu久久综合| 日韩视频在线你懂得| 欧美日韩大陆在线| 欧美日韩国产中文| 色菇凉天天综合网| 色综合久久中文综合久久牛| 成人黄色777网| 床上的激情91.| www.色综合.com| 99久久精品免费精品国产| 成人av午夜影院| jizz一区二区| 99re热这里只有精品视频| 欧美一级欧美三级在线观看 | 亚洲丝袜另类动漫二区| 中文字幕一区二| 亚洲女性喷水在线观看一区| 一区2区3区在线看| 亚洲午夜视频在线观看| 亚洲福利视频三区| 蜜桃久久久久久久| 麻豆一区二区在线| 国产精品小仙女| 成人av中文字幕| 91国产视频在线观看| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 色欧美日韩亚洲| 欧美日韩免费一区二区三区视频| 在线观看国产91| 日韩西西人体444www| 久久久另类综合| 国产精品久久久久aaaa樱花 | 欧美精品一区二区精品网| 国产午夜精品理论片a级大结局| 国产欧美一区二区精品性色超碰| 国产精品麻豆网站| 亚洲影院在线观看| 狠狠色丁香久久婷婷综合_中| 成人午夜精品一区二区三区| 色婷婷香蕉在线一区二区| 欧美日韩高清在线播放| 2023国产精品自拍| 亚洲你懂的在线视频| 日本不卡视频在线观看| 国产精品亚洲第一| 欧美无乱码久久久免费午夜一区 | 久久国产成人午夜av影院| 波波电影院一区二区三区| 欧美日韩另类一区| 亚洲精品一区二区三区香蕉 | 91丨九色丨尤物| 日韩欧美的一区二区| 国产精品久久久久久久久动漫| 亚洲成人午夜影院| 国产成人久久精品77777最新版本| 99riav一区二区三区| 欧美一区二区在线免费播放| 国产精品的网站| 麻豆精品国产91久久久久久| 97久久精品人人做人人爽| 欧美va亚洲va国产综合| 一区二区三区成人在线视频 | 青青草原综合久久大伊人精品优势| 国产传媒日韩欧美成人| 欧美精品vⅰdeose4hd| 欧美国产丝袜视频| 蜜臀av一区二区在线免费观看| 成人av网址在线观看| 久久久久久一级片| 日本一不卡视频| 91久久精品一区二区| 国产精品网站在线观看| 激情文学综合网| 欧美精品亚洲一区二区在线播放| 国产精品福利影院| 国产精品一区二区在线播放 | 国产成人aaaa| 精品国产百合女同互慰| 五月激情六月综合| 欧美亚洲免费在线一区| 一区二区三区久久| 91麻豆免费观看| 日韩毛片高清在线播放| 成人免费电影视频| 欧美国产丝袜视频| av中文字幕亚洲|