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

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

?? demo11_10.cpp

?? 一個完整的基于DirectX的射擊游戲 沒有使用OO
?? CPP
字號:
// DEMO11_10.CPP - Multithreaded DirectX demo
// make sure to compile with multithreaded libraries
// and if the program doesn't work try turning optimizations
// completely off

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

#define WIN32_LEAN_AND_MEAN  

// you must #define INITGUID if not done elsewhere
#define INITGUID

#include <windows.h>   // include important windows stuff
#include <windowsx.h> 
#include <mmsystem.h>
#include <objbase.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>     // directX includes
#include <dsound.h>
#include <dmksctrl.h>
#include <dmusici.h>
#include <dmusicc.h>
#include <dmusicf.h>
#include <dinput.h>
#include "T3DLIB1.H"
#include "T3DLIB2.H"
#include "T3DLIB3.H"

// DEFINES ////////////////////////////////////////////////

// comment this out if you want to see the normal single 
// threaded version
#define USE_MULTITHREADING

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

#define BITMAP_ID            0x4D42 // universal id for a bitmap
#define MAX_COLORS_PALETTE   256

#define NUM_ALIENS 16    // number of aliens in the sim

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

// PROTOTYPES /////////////////////////////////////////////

// game console
int Game_Init(void *parms=NULL, int num_parms = 0);
int Game_Shutdown(void *parms=NULL, int num_parms = 0);
int Game_Main(void *parms=NULL,  int num_parms = 0);

DWORD WINAPI Alien_Color_Thread(LPVOID data);

// GLOBALS ////////////////////////////////////////////////

// windows vars
HWND      main_window_handle = NULL; // globally track main window
int       window_closed      = 0;    // tracks if window is closed
HINSTANCE main_instance       = NULL; // globally track hinstance

char buffer[80];             // used to print text

// demo globals
BOB aliens[NUM_ALIENS];      // the aliens, each will be a thread

HANDLE thread_handle;  // this holds the handle to the thread
DWORD  thread_id;      // this holds the id of the thread

int terminate_threads = 0;  // global message flag to terminate
int active_threads    = 0;  // number of active threads

// PROTOTYPES //////////////////////////////////////////////

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

// 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
main_instance = hinstance;

// register the window class
if (!RegisterClassEx(&winclass))
	return(0);

// create the window
if (!(hwnd = CreateWindowEx(NULL,                  // extended style
                            WINDOW_CLASS_NAME,     // class
						    "Multithreaded DirectDraw 8-Bit 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

// GAME PROGRAMMING CONSOLE FUNCTIONS ////////////////

int Game_Init(void *parms,  int num_parms)
{
// this function is where you do all the initialization 
// for your game

int index;         // looping var
char filename[80]; // used to build up files names

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

// initialize directdraw, very important that in the call
// to setcooperativelevel that the flag DDSCL_MULTITHREADED is used
// which increases the response of directX graphics to
// take the global critical section more frequently
DDraw_Init(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP);

// load in the alien bob image
Load_Bitmap_File(&bitmap8bit, "ALIENSGLOW.BMP");

// set the palette to the palette of the aliens
Set_Palette(bitmap8bit.palette);

// create the master alien bob
if (!Create_BOB(&aliens[0],0,0,48,47,1, 
                BOB_ATTR_VISIBLE | BOB_ATTR_SINGLE_FRAME | BOB_ATTR_BOUNCE,DDSCAPS_SYSTEMMEMORY ))
   return(0);

// load the bitmap for alien -- only 1
Load_Frame_BOB(&aliens[0],&bitmap8bit,0,0,0,BITMAP_EXTRACT_MODE_CELL); 

// unload the map bitmap
Unload_Bitmap_File(&bitmap8bit);

// now create all the alien clones :)
for (index = 1; index < NUM_ALIENS; index++)
    Clone_BOB(&aliens[0],&aliens[index]);

// at this point everything has been cloned, now set up aliens at
// random positions
for (index = 0; index < NUM_ALIENS; index++)
    {
    // set position
    Set_Pos_BOB(&aliens[index], rand()%screen_width, rand()%screen_height);

    // set motion velocities
    Set_Vel_BOB(&aliens[index],-4+rand()%8, -4+rand()%8);

    } // end for index

// set clipping rectangle to screen extents so mouse cursor
// doens't mess up at edges
RECT screen_rect = {0,0,screen_width,screen_height}; 
lpddclipper = DDraw_Attach_Clipper(lpddsback,1,&screen_rect);

// hide the mouse
ShowCursor(FALSE);

#ifdef USE_MULTITHREADING
// create the animation thread for color rotation
thread_handle = CreateThread(NULL,               // default security
			                    0,				    // default stack 
								Alien_Color_Thread,// use this thread function
								(LPVOID)index,      // user data sent to thread
								0,				    // creation flags, 0=start now.
								&thread_id);	// send id back in this var

    // increment number of active threads
    active_threads++;

#endif
 
// return success
return(1);

} // end Game_Init

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

int Game_Shutdown(void *parms,  int num_parms)
{
// this function is where you shutdown your game and
// release all resources that you allocated

#ifdef USE_MULTITHREADING
// kill all threads first

// set global termination flag
terminate_threads = 1;

// wait for all threads to terminate, when all are terminated active_threads==0
while(active_threads); 

// at this point the threads should all be dead, so close handles
CloseHandle(thread_handle);
#endif

// kill objects

// only need to kill master BOB
Destroy_BOB(&aliens[0]);

// shutdown directdraw
DDraw_Shutdown();

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

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

int Game_Main(void *parms, int num_parms)
{
// this is the workhorse of your game it will be called
// continuously in real-time this is like main() in C
// all the calls for you game go here!

int index, index_x, index_y;  // looping vars

// check of user is trying to exit
if (KEY_DOWN(VK_ESCAPE) || KEY_DOWN(VK_SPACE))
    PostMessage(main_window_handle, WM_DESTROY,0,0);

// start the timing clock
Start_Clock();

// clear the drawing surface
DDraw_Fill_Surface(lpddsback, 0);

// move the aliens
for (index = 0; index<NUM_ALIENS; index++)
    Move_BOB(&aliens[index]);

// draw the aliens
for (index = 0; index<NUM_ALIENS; index++)
    Draw_BOB(&aliens[index], lpddsback);       

#ifndef USE_MULTITHREADING
// animate the aliens -- color animation
Rotate_Colors(249, 253);  
#endif

// draw some info
Draw_Text_GDI("<ESC> to Exit.",8,8,RGB(0,255,0),lpddsback);

// flip the surfaces
DDraw_Flip();

// sync to 30 fps
Wait_Clock(30);

// return success
return(1);

} // end Game_Main

// THREADING FUNCTION////////////////////////////////////

DWORD WINAPI Alien_Color_Thread(LPVOID data)
{
// this thread animates the colors of the aliens
// note there are a number of things to consider, such as 
// are the calls to the sub-functions re-entrant, are there
// any deadlocks? is the a potential of confusing DirectX
// etc. also, this function is going to free run, so
// it needs it's own internal timing

for(;;)
	{
	// test for temination message
	if (terminate_threads)
		break;

    // test for next frame message from main event loop
    DWORD start_time = Get_Clock();

    // animate the aliens -- color animation
    // this function happens to be re-entrant, however only one thread is ever
    // calling it, so it doesnt matter, but if multiple threads were
    // then it would HAVE to be re-entrant
    Rotate_Colors(249, 253);  

    // wait for 30 fps
    while((Get_Clock() - start_time) < 30);
	
    } // end for ;;

// decrement number of active threads
if (active_threads > 0) 
   active_threads--;

// just return the data sent to the thread function
return((DWORD)data);

} // end Alien_Color_Thread

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产乱码一区二区三区| 一区二区三区资源| 国产精品资源在线| 26uuu国产在线精品一区二区| 美女视频一区在线观看| 精品国产乱码久久久久久蜜臀| 日本欧美韩国一区三区| 精品伦理精品一区| 国产精品乡下勾搭老头1| 日本一区二区电影| 色伊人久久综合中文字幕| 亚洲在线观看免费视频| 日韩欧美视频在线| 国产伦精一区二区三区| 国产精品美女久久久久久2018| 日本久久电影网| 青青草视频一区| 国产色爱av资源综合区| 91捆绑美女网站| 亚洲不卡一区二区三区| 久久免费偷拍视频| 色综合久久中文字幕综合网| 日韩va欧美va亚洲va久久| 亚洲国产电影在线观看| 欧美日韩亚洲丝袜制服| 九九在线精品视频| 一区二区三区在线播放| 日韩精品最新网址| 99视频有精品| 美女一区二区视频| 亚洲精品国产第一综合99久久| 在线播放亚洲一区| 不卡av在线免费观看| 日韩中文欧美在线| 综合自拍亚洲综合图不卡区| 欧美一级日韩免费不卡| 不卡av电影在线播放| 日韩在线观看一区二区| 国产精品高潮呻吟| 日韩欧美中文一区| 色欧美日韩亚洲| 国产精品自拍网站| 婷婷综合在线观看| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 三级欧美在线一区| 亚洲国产精品t66y| 日韩精品一区二区在线观看| 在线观看精品一区| 成人app下载| 国产一区二区精品久久| 偷拍日韩校园综合在线| 亚洲精品免费一二三区| 国产视频在线观看一区二区三区| 欧美精品免费视频| 91精品办公室少妇高潮对白| 国产成人av在线影院| 蜜臀久久久久久久| 午夜伦理一区二区| 一区二区三区精品久久久| 国产日韩欧美精品在线| 欧美成人三级在线| 日韩欧美在线一区二区三区| 欧美裸体一区二区三区| 91精品福利视频| 色播五月激情综合网| 成人a级免费电影| 国产成人亚洲精品青草天美| 久久99国产精品成人| 日韩不卡免费视频| 视频一区在线播放| 亚洲v日本v欧美v久久精品| 亚洲精品成人天堂一二三| 国产精品国产三级国产普通话三级| 久久精品亚洲国产奇米99| 久久综合九色欧美综合狠狠| 精品国产三级电影在线观看| 精品久久久久久久久久久院品网| 日韩一区二区三区精品视频| 欧美一区二区视频在线观看| 欧美一级xxx| 日韩你懂的在线观看| 精品久久五月天| 国产欧美日韩精品a在线观看| 久久久www免费人成精品| 国产亚洲1区2区3区| 国产欧美视频在线观看| 亚洲国产精品精华液2区45| 国产色一区二区| 亚洲日本在线视频观看| 一区二区三区四区av| 夜夜亚洲天天久久| 成人精品视频一区二区三区 | 国产精品嫩草影院com| 国产精品网友自拍| 久久毛片高清国产| 国产日产欧产精品推荐色 | 亚洲影视资源网| 亚洲va欧美va国产va天堂影院| 日韩国产欧美三级| 国产自产视频一区二区三区 | 中文字幕视频一区| 亚洲精品视频在线观看网站| 亚洲一区二区三区视频在线| 日韩精品一卡二卡三卡四卡无卡| 久久黄色级2电影| 国产成人综合视频| 日本韩国一区二区三区视频| 欧美日本国产视频| 久久精品亚洲一区二区三区浴池| 一区精品在线播放| 亚洲va国产va欧美va观看| 久久精品国产一区二区| 成人动漫在线一区| 在线精品视频免费播放| 精品蜜桃在线看| 亚洲日本在线天堂| 免费成人性网站| caoporen国产精品视频| 欧美日韩亚洲高清一区二区| www欧美成人18+| 一区二区三国产精华液| 国产一区美女在线| 日本道免费精品一区二区三区| 日韩一区二区三区视频| 亚洲视频免费看| 韩国精品免费视频| 欧美在线三级电影| 国产欧美久久久精品影院| 亚洲高清免费在线| 丁香激情综合国产| 欧美一区二区三区思思人| 国产精品国产三级国产aⅴ入口 | 欧美精品一区二区久久婷婷| 亚洲欧美日韩国产成人精品影院| 精久久久久久久久久久| 在线精品观看国产| 国产性色一区二区| 美女视频免费一区| 欧美亚一区二区| 国产精品久久久久久久第一福利| 久久成人18免费观看| 欧美三级资源在线| 国产精品久久久久aaaa樱花| 久久99久久99精品免视看婷婷 | 99视频精品在线| 久久久亚洲欧洲日产国码αv| 婷婷一区二区三区| 欧洲av在线精品| 日韩美女视频一区| 国产69精品久久99不卡| 2021久久国产精品不只是精品 | 韩国女主播成人在线观看| 欧美三级韩国三级日本一级| 亚洲精品美腿丝袜| 99精品国产91久久久久久| 国产精品五月天| 国产精品亚洲午夜一区二区三区 | 亚洲成av人影院在线观看网| 91丝袜呻吟高潮美腿白嫩在线观看| 久久久久国产一区二区三区四区| 秋霞午夜av一区二区三区| 欧美日韩的一区二区| 亚洲成人一区二区| 欧美丝袜自拍制服另类| 一区二区三区日韩欧美| 在线一区二区三区做爰视频网站| 日韩久久一区二区| 国产不卡在线视频| 国产精品视频线看| 成人av高清在线| 综合久久国产九一剧情麻豆| 97精品超碰一区二区三区| 国产精品电影院| 色老头久久综合| 亚洲自拍偷拍麻豆| 欧美在线观看视频一区二区| 亚洲bdsm女犯bdsm网站| 91精品国产综合久久国产大片 | 精品少妇一区二区三区| 狠狠色狠狠色合久久伊人| 久久综合给合久久狠狠狠97色69| 国产在线一区观看| 日本一区二区三区在线不卡| 成人av电影在线网| 亚洲午夜久久久久中文字幕久| 在线播放中文一区| 国产一区二区网址| 国产精品国产三级国产a| 欧美性感一区二区三区| 亚洲国产精品久久久久秋霞影院 | 免费看日韩精品| 久久久久国色av免费看影院| 99视频国产精品| 亚洲va国产天堂va久久en| 欧美xxxx老人做受| 粉嫩嫩av羞羞动漫久久久| 亚洲精品免费视频| 日韩一级片在线播放| 成人在线一区二区三区| 亚洲精品久久久久久国产精华液|