x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
DarkPuzzle.cpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\DarkPuzzle\DarkPuzzle.cpp
旋转
特效
属性
历史版本
//-------------------------------------------------------------------------------------- // File: DarkPuzzle.cpp // // Copyright (c) Microsoft Corporation. All rights reserved. //-------------------------------------------------------------------------------------- #ifdef _DEBUG #define D3D_DEBUG_INFO //#define NDEBUG #endif // _DEBUG //#include "DXUT.h" #include "DarkPuzzle.h" #ifdef _DEBUG //must be include after precompiled header //#include "vld.h" #endif // _DEBUG #include "resource.h" #include "btBulletDynamicsCommon.h" #include "d3dx9mesh.h" //#include "BulletColladaConverter\ColladaConverter.h" #include "GameEngine/GameEngine.h" using namespace DarkBattle; //#include "SDKMisc.h" //-------------------------------------------------------------------------------------- // Rejects any D3D9 devices that aren't acceptable to the app by returning false //-------------------------------------------------------------------------------------- bool CALLBACK IsD3D9DeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext ) { // Typically want to skip back buffer formats that don't support alpha blending IDirect3D9* pD3D = DXUTGetD3D9Object(); if( FAILED( pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType, AdapterFormat, D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, BackBufferFormat ) ) ) return false; return true; } //-------------------------------------------------------------------------------------- // Before a device is created, modify the device settings as needed //-------------------------------------------------------------------------------------- bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, void* pUserContext ) { #ifdef _DEBUG pDeviceSettings->d3d9.pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; #endif // _DEBUG pDeviceSettings->d3d9.pp.EnableAutoDepthStencil = TRUE; pDeviceSettings->d3d9.pp.AutoDepthStencilFormat = D3DFMT_D24S8; pDeviceSettings->d3d9.pp.BackBufferFormat = D3DFMT_X8R8G8B8; pDeviceSettings->d3d9.pp.MultiSampleType = D3DMULTISAMPLE_NONE; pDeviceSettings->d3d9.pp.BackBufferWidth = 640; pDeviceSettings->d3d9.pp.BackBufferHeight = 480; return true; } GameEngine* myGame; //-------------------------------------------------------------------------------------- // Create any D3D9 resources that will live through a device reset (D3DPOOL_MANAGED) // and aren't tied to the back buffer size //-------------------------------------------------------------------------------------- HRESULT CALLBACK OnD3D9CreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ) { //initBullet(); myGame = new GameEngine(pd3dDevice); return S_OK; } //DWORD numMate=0; //ID3DXBuffer* mateBuffer; //ID3DXMesh* theMesh; //void loadMeshes(IDirect3DDevice9* pd3dDevice){ // // D3DXLoadMeshFromX(L"test.x",D3DXMESH_MANAGED,pd3dDevice,NULL,&mateBuffer,NULL,&numMate,&theMesh); // //CDXUT //} //-------------------------------------------------------------------------------------- // Create any D3D9 resources that won't live through a device reset (D3DPOOL_DEFAULT) // or that are tied to the back buffer size //-------------------------------------------------------------------------------------- HRESULT CALLBACK OnD3D9ResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ) { myGame->OnResetDevice(pd3dDevice); return S_OK; } //-------------------------------------------------------------------------------------- // Handle updates to the scene. This is called regardless of which D3D API is used //-------------------------------------------------------------------------------------- void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext ) { myGame->OnFrameMove(fElapsedTime); } //-------------------------------------------------------------------------------------- // Render the scene using the D3D9 device //-------------------------------------------------------------------------------------- void CALLBACK OnD3D9FrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ) { myGame->OnRender(pd3dDevice); } //-------------------------------------------------------------------------------------- // Handle messages to the application //-------------------------------------------------------------------------------------- LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing, void* pUserContext ) { GameUI* theGameUI = GameUI::GetInstance(); if (theGameUI){ CDXUTIMEEditBox::StaticMsgProc( hWnd, uMsg, wParam, lParam ); theGameUI->resourceManager.MsgProc(hWnd,uMsg,wParam,lParam); theGameUI->dialog.MsgProc(hWnd,uMsg,wParam,lParam); } return 0; } //-------------------------------------------------------------------------------------- // Release D3D9 resources created in the OnD3D9ResetDevice callback //-------------------------------------------------------------------------------------- void CALLBACK OnD3D9LostDevice( void* pUserContext ) { myGame->OnLostDevice(); } //-------------------------------------------------------------------------------------- // Release D3D9 resources created in the OnD3D9CreateDevice callback //-------------------------------------------------------------------------------------- void CALLBACK OnD3D9DestroyDevice( void* pUserContext ) { //destroyBullet(); delete myGame; } //-------------------------------------------------------------------------------------- // As a convenience, DXUT inspects the incoming windows messages for // keystroke messages and decodes the message parameters to pass relevant keyboard // messages to the application. The framework does not remove the underlying keystroke // messages, which are still passed to the application's MsgProc callback. //-------------------------------------------------------------------------------------- void CALLBACK KeyboardProc( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext ) { myGame->KeyboardProc(nChar,bKeyDown,bAltDown,pUserContext); //myConverter* converter; // if( bKeyDown ) // { // switch( nChar ) // { // case 'A'://must use capital letter // converter = new myConverter(m_dynamicsWorld); // converter->save("test.dae"); // delete converter; // DXUTShutdown(0); // break; // case 'B'://must use capital letter // converter = new myConverter(m_dynamicsWorld); // converter->load("test.dae"); // delete converter; // break; // case 'C'://must use capital letter // converter = new myConverter(m_dynamicsWorld); // converter->load("untitled.dae"); // converter->printName(); // delete converter; // break; // //case VK_F1: g_bShowHelp = !g_bShowHelp; break; // } // } } void CALLBACK MouseProc( bool bLeftButtonDown, bool bRightButtonDown, bool bMiddleButtonDown, bool bSideButton1Down, bool bSideButton2Down, int nMouseWheelDelta, int xPos, int yPos, void* pUserContext ){ myGame->MouseProc(bLeftButtonDown,bRightButtonDown,bMiddleButtonDown,bSideButton1Down,bSideButton2Down,nMouseWheelDelta,xPos,yPos,pUserContext); } //-------------------------------------------------------------------------------------- // Initialize everything and go into a render loop //-------------------------------------------------------------------------------------- INT WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int ) { //VLDEnable(); //for (int i=0;i<1000;i++){ // D3DXVECTOR3 *a; // a= new D3DXVECTOR3(0,0,0); //} //return 0; // Enable run-time memory check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // Set the callback functions DXUTSetCallbackD3D9DeviceAcceptable( IsD3D9DeviceAcceptable ); DXUTSetCallbackD3D9DeviceCreated( OnD3D9CreateDevice ); DXUTSetCallbackD3D9DeviceReset( OnD3D9ResetDevice ); DXUTSetCallbackD3D9FrameRender( OnD3D9FrameRender ); DXUTSetCallbackD3D9DeviceLost( OnD3D9LostDevice ); DXUTSetCallbackD3D9DeviceDestroyed( OnD3D9DestroyDevice ); DXUTSetCallbackDeviceChanging( ModifyDeviceSettings ); DXUTSetCallbackMsgProc( MsgProc ); DXUTSetCallbackFrameMove( OnFrameMove ); //added by INNO DXUTSetCallbackKeyboard( KeyboardProc ); DXUTSetCallbackMouse(MouseProc,true); // TODO: Perform any application-level initialization here // Initialize DXUT and create the desired Win32 window and Direct3D device for the application DXUTInit( true, true ); // Parse the command line and show msgboxes DXUTSetHotkeyHandling( true, true, true ); // handle the default hotkeys DXUTSetCursorSettings( true, true ); // Show the cursor and clip it when in full screen DXUTCreateWindow( L"DarkPuzzle" ); DXUTCreateDevice( true, 640, 480 ); // Start the render loop DXUTMainLoop(); // TODO: Perform any application-level cleanup here return DXUTGetExitCode(); }
DarkPuzzle.cpp
网页地址
文件地址
上一页
4/24
下一页
下载
( 9 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.