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

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

?? demo10_4.cpp

?? 一本外國人寫的關于3D游戲編程的書的源碼
?? CPP
字號:
// DEMO10_4.CPP DirectMusic Example

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

#define INITGUID
#define WIN32_LEAN_AND_MEAN  // just say no to MFC

#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 <direct.h>
#include <wchar.h>
#include <fcntl.h>

#include <ddraw.h>
#include <dsound.h> // include dsound, dmusic
#include <dmksctrl.h>
#include <dmusici.h>
#include <dmusicc.h>
#include <dmusicf.h>

// directx 7.0 compatibility

#ifndef DSBCAPS_CTRLDEFAULT
#define DSBCAPS_CTRLDEFAULT (DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME )
#endif


// 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      8    // bits per pixel
#define MAX_COLORS      256  // maximum colors

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

// Convert from multibyte format to Unicode using the following macro:
#define MULTI_TO_WIDE( x,y )  MultiByteToWideChar( CP_ACP,MB_PRECOMPOSED, y,-1,x,_MAX_PATH);


// initializes a direct draw struct
#define DD_INIT_STRUCT(ddstruct) { memset(&ddstruct,0,sizeof(ddstruct)); ddstruct.dwSize=sizeof(ddstruct); }

// GLOBALS ////////////////////////////////////////////////
HWND      main_window_handle = NULL; // globally track main window
HINSTANCE main_instance      = NULL; // globally track hinstance

// direct music globals
IDirectMusicPerformance    *dm_perf = NULL;
IDirectMusicLoader         *dm_loader = NULL;
IDirectMusicSegment        *dm_segment = NULL;
IDirectMusicSegmentState   *dm_segstate = NULL;

// these are overwritten globally by DD_Init()
int screen_width  = SCREEN_WIDTH,            // width of screen
    screen_height = SCREEN_HEIGHT,           // height of screen
    screen_bpp    = SCREEN_BPP;              // bits per pixel

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

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

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

// return success or failure or your own return code here
return(1);

} // end Game_Main

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

IDirectMusicPerformance* CreatePerformance(void)
{
// this function creates the performance

IDirectMusicPerformance* pPerf;     

if (FAILED(CoCreateInstance(CLSID_DirectMusicPerformance,
                            NULL,
                            CLSCTX_INPROC,
                            IID_IDirectMusicPerformance,
                            (void**)&pPerf)))    
   {
   // return null        
   pPerf = NULL;    
   } // end if

   return pPerf;

} // end CreatePerformance

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

IDirectMusicLoader* CreateLoader(void)
{
// this function creates the loader

    IDirectMusicLoader* pLoader;
 
    if (FAILED(CoCreateInstance(
            CLSID_DirectMusicLoader,
            NULL,
            CLSCTX_INPROC, 
            IID_IDirectMusicLoader,
            (void**)&pLoader)))
    {
    pLoader = NULL;
    } // end if

    return pLoader;

} // end CreateLoader

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

IDirectMusicSegment* LoadMIDISegment(IDirectMusicLoader* pLoader, 
                                     WCHAR *wszMidiFileName )
{
// this function loads a midi segment off disk

DMUS_OBJECTDESC ObjDesc; 
HRESULT hr;
IDirectMusicSegment* pSegment = NULL;
 
// get current working directory
char szDir[_MAX_PATH];
WCHAR wszDir[_MAX_PATH];
 
if(_getcwd( szDir, _MAX_PATH ) == NULL)
  {
  return NULL;
  } // end if

// convert to wide characters
MULTI_TO_WIDE(wszDir, szDir);

// set the search directory
hr = pLoader->SetSearchDirectory(GUID_DirectMusicAllTypes,wszDir, FALSE);

if (FAILED(hr)) 
   {
   return NULL;
   } // end if
 
// setup object description
ZeroMemory(&ObjDesc, sizeof(DMUS_OBJECTDESC));
ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
ObjDesc.guidClass = CLSID_DirectMusicSegment;
wcscpy(ObjDesc.wszFileName, wszMidiFileName );

ObjDesc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_FILENAME;
 
// load the object and query it for the IDirectMusicSegment interface
// This is done in a single call to IDirectMusicLoader::GetObject
// note that loading the object also initializes the tracks and does 
// everything else necessary to get the MIDI data ready for playback.

hr = pLoader->GetObject(&ObjDesc,IID_IDirectMusicSegment, (void**) &pSegment);

if (FAILED(hr))
   return(0);
 
// ensure that the segment plays as a standard MIDI file
// you now need to set a parameter on the band track
// Use the IDirectMusicSegment::SetParam method and let 
// DirectMusic find the trackby passing -1 (or 0xFFFFFFFF) in the dwGroupBits method parameter.

hr = pSegment->SetParam(GUID_StandardMIDIFile,-1, 0, 0, (void*)dm_perf);

if (FAILED(hr))
   return(0);
  
// This step is necessary because DirectMusic handles program changes and 
// bank selects differently for standard MIDI files than it does for MIDI 
// content authored specifically for DirectMusic. 
// The GUID_StandardMIDIFile parameter must be set before the instruments are downloaded. 

// The next step is to download the instruments. 
// This is necessary even for playing a simple MIDI file 
// because the default software synthesizer needs the DLS data 
// for the General MIDI instrument set
// If you skip this step, the MIDI file will play silently.
// Again, you call SetParam on the segment, this time specifying the GUID_Download parameter:

hr = pSegment->SetParam(GUID_Download, -1, 0, 0, (void*)dm_perf);

if (FAILED(hr))
   return(0);

// return the pointer
return pSegment;
 
} // end LoadSegment

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

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

// set up directmusic
if (FAILED(CoInitialize(NULL)))
   {    
   // Terminate the application.
   return(0);
   }   // end if


// create the performance
dm_perf = CreatePerformance();

if (dm_perf == NULL)
   {
   return(0);// Failure -- performance not created
   } // end if


// initialize the performance
if (FAILED(dm_perf->Init(NULL, NULL, main_window_handle)))
   {
   return(0);// Failure -- performance not initialized
   } // end if 

// add the port to the performance
if (FAILED(dm_perf->AddPort(NULL)))
   {    
   return(0);// Failure -- port not initialized
   } // end if

// create the loader to load object(s) such as midi file
dm_loader = CreateLoader();

if (dm_loader == NULL)
   {
    return(0);// Failure -- loader not created
   } // end if

// release the old segment
if (dm_segment)
   {    
   dm_segment->Release();    
   dm_segment = NULL;
   } // end if

// load the segment
if (dm_loader)
   {
   dm_segment = LoadMIDISegment(dm_loader,L"BATTLE.MID");
   } // end if

// start the song
if (dm_segment)
   {
   dm_perf->PlaySegment(dm_segment, 0, 0, &dm_segstate);
   }  // end if

// return success or failure or your own return code here
return(1);

} // end Game_Init

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

HRESULT FreeDirectMusic(void)
{
// If there is any music playing, stop it. This is 
// not really necessary, because the music will stop when
// the instruments are unloaded or the performance is    // closed down.
dm_perf->Stop( NULL, NULL, 0, 0 ); 

// Unload instruments this will cause silence.
// CloseDown unloads all instruments, so this call is also not 
// strictly necessary.
dm_segment->SetParam(GUID_Unload, -1, 0, 0, (void*)dm_perf); 

// Release the segment.    
dm_segment->Release(); 
// CloseDown and Release the performance object.    
dm_perf->CloseDown();
dm_perf->Release();     

// Release the loader object.
dm_loader->Release();     

// Release COM.    
CoUninitialize(); 
return S_OK;

} // end FreeDirectMusic

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

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

FreeDirectMusic();

// 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
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
						    "DirectMusic Demo", // title
						    WS_OVERLAPPEDWINDOW | WS_VISIBLE,
					 	    0,0,	  // initial x,y
						    400,300,  // 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| 日韩午夜激情电影| 午夜久久久影院| 这里只有精品视频在线观看| 亚洲chinese男男1069| 欧美亚洲综合久久| 一区二区三区在线视频免费观看| 在线视频国产一区| 久久国产精品72免费观看| 欧美精品一区二区久久久| 国产成人精品影视| 亚洲欧美一区二区三区久本道91| 欧美综合一区二区| 久久精品国产第一区二区三区| 亚洲精品在线观看网站| 成人小视频在线| 亚洲制服丝袜av| 欧美mv日韩mv国产网站app| 国产suv一区二区三区88区| 国产精品久久久久毛片软件| 欧美色视频一区| 日韩高清一区二区| 中文字幕第一区第二区| 欧美老女人第四色| 玖玖九九国产精品| 亚洲乱码国产乱码精品精小说| 欧美色图在线观看| 国产精品夜夜嗨| 天天色图综合网| 久久久久久一二三区| 91香蕉视频mp4| 日韩高清在线电影| 欧美卡1卡2卡| 色94色欧美sute亚洲线路一久 | av电影在线观看不卡| 午夜精品福利一区二区三区av | 五月激情综合色| 精品理论电影在线| 成人激情小说乱人伦| 日韩av在线免费观看不卡| 中文字幕一区二区在线播放| 欧美一区二区三区免费在线看 | 制服丝袜国产精品| 成人av电影在线| 欧美日免费三级在线| 99精品国产视频| 99视频精品全部免费在线| 免费高清在线一区| 亚洲国产精品自拍| 中文字幕欧美一| 久久久一区二区| 日韩无一区二区| 欧美日韩成人激情| 日本丶国产丶欧美色综合| 国产大陆a不卡| 日本视频在线一区| 亚洲一区二区三区不卡国产欧美| 国产日韩欧美精品综合| 日韩欧美电影在线| 欧美日韩视频第一区| 91猫先生在线| 成人av电影在线观看| 久久成人免费网站| 男人的j进女人的j一区| 亚洲另类一区二区| 国产午夜精品一区二区三区嫩草| 在线播放中文一区| 欧美日韩精品二区第二页| 91偷拍与自偷拍精品| 国产精品99久久久久久久女警| 亚洲成人在线观看视频| 亚洲综合一区二区| 亚洲国产欧美在线| 亚洲男女一区二区三区| 久久久综合视频| 久久久久久久综合色一本| 久久一夜天堂av一区二区三区| 日韩精品一区二区在线| 91精品国产综合久久久久久久| 欧美日韩在线一区二区| 欧美日韩一级二级三级| 欧美日免费三级在线| 538prom精品视频线放| 欧美日韩国产一区二区三区地区| 欧美色综合天天久久综合精品| 欧美日韩一区在线| 欧美一卡二卡三卡四卡| 日韩欧美美女一区二区三区| 日韩一区二区免费高清| 精品少妇一区二区三区| 久久这里只有精品首页| 国产日韩欧美精品在线| 中文字幕制服丝袜一区二区三区| 日韩一区在线免费观看| 亚洲黄网站在线观看| 日韩成人精品视频| 国产一区二区不卡| 国产成人精品免费网站| 99在线精品观看| 欧美日韩免费不卡视频一区二区三区| 欧美日韩成人综合| 精品国产免费视频| 中文字幕在线观看一区| 亚洲va天堂va国产va久| 国精产品一区一区三区mba桃花| 福利一区福利二区| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 日韩电影免费一区| 精久久久久久久久久久| 99热精品一区二区| 欧美系列一区二区| 久久日一线二线三线suv| 中文字幕第一区综合| 婷婷久久综合九色综合绿巨人| 久久精品久久99精品久久| 成人av影院在线| 777午夜精品视频在线播放| 国产日韩精品一区二区浪潮av| 久久无码av三级| 亚洲另类色综合网站| 免费一级欧美片在线观看| 国产成人免费视频| 3d动漫精品啪啪| 18欧美亚洲精品| 免费在线观看视频一区| 国产精品88av| 欧美日韩成人一区二区| 精品国内片67194| 亚洲男人电影天堂| 久久9热精品视频| 欧美性生活影院| 日本一区二区三级电影在线观看 | 国产亚洲欧美一级| 亚欧色一区w666天堂| 成人av动漫网站| 久久午夜电影网| 日韩福利电影在线观看| 91久久国产最好的精华液| 26uuu亚洲婷婷狠狠天堂| 亚洲愉拍自拍另类高清精品| 国产成人自拍在线| 日韩精品一区二区三区中文不卡| 亚洲欧美日韩国产手机在线 | 国产精品久久久久久久久快鸭 | 另类的小说在线视频另类成人小视频在线 | 美女在线一区二区| 欧美性xxxxxxxx| 亚洲人成小说网站色在线 | 国产精品亚洲综合一区在线观看| 欧美日韩不卡视频| 亚洲美女视频在线观看| 国产一区二区不卡老阿姨| 欧美三片在线视频观看| 国产欧美日韩在线观看| 丝袜a∨在线一区二区三区不卡| 色综合一个色综合亚洲| 中文字幕一区二区不卡| 成人性生交大片免费看视频在线| 久久一区二区三区四区| 毛片av一区二区三区| 制服丝袜成人动漫| 日韩av电影天堂| 在线不卡中文字幕| 水野朝阳av一区二区三区| 91精品国产91综合久久蜜臀| 久久99在线观看| 欧美国产一区在线| 日本精品一级二级| 偷偷要91色婷婷| 久久免费国产精品| 91香蕉视频mp4| 日本少妇一区二区| 中文字幕免费一区| 欧美体内she精高潮| 麻豆91免费看| 中文字幕一区二区视频| 欧美日韩在线综合| 国产激情视频一区二区在线观看| 日韩美女视频一区| 日韩免费观看高清完整版在线观看| 国产在线观看一区二区| 亚洲特黄一级片|