785 lines
24 KiB
C++
785 lines
24 KiB
C++
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
// File: Lights.cpp
|
|||
|
|
//
|
|||
|
|
// Desc: Rendering 3D geometry is much more interesting when dynamic lighting
|
|||
|
|
// is added to the scene. To use lighting in D3D, you must create one or
|
|||
|
|
// lights, setup a material, and make sure your geometry contains surface
|
|||
|
|
// normals. Lights may have a position, a color, and be of a certain type
|
|||
|
|
// such as directional (light comes from one direction), point (light
|
|||
|
|
// comes from a specific x,y,z coordinate and radiates in all directions)
|
|||
|
|
// or spotlight. Materials describe the surface of your geometry,
|
|||
|
|
// specifically, how it gets lit (diffuse color, ambient color, etc.).
|
|||
|
|
// Surface normals are part of a vertex, and are needed for the D3D's
|
|||
|
|
// internal lighting calculations.
|
|||
|
|
//
|
|||
|
|
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
// If app hasn't choosen, set to work with Windows 98, Windows Me, Windows 2000, Windows XP and beyond
|
|||
|
|
|
|||
|
|
#if _MSC_VER == 1600
|
|||
|
|
#define POINTER_64 __ptr64
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#include <Windows.h>
|
|||
|
|
#include <d3dx8.h>
|
|||
|
|
#include <mmsystem.h>
|
|||
|
|
#include <stdio.h>
|
|||
|
|
#include <stdlib.h>
|
|||
|
|
#include <strsafe.h> // StringCch<63><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
void CALLBACK OnLostDevice();
|
|||
|
|
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
// Global variables
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
LPDIRECT3D8 g_pD3D = NULL; // Used to create the D3DDevice
|
|||
|
|
LPDIRECT3DDEVICE8 g_pd3dDevice = NULL; // Our rendering device
|
|||
|
|
LPDIRECT3DVERTEXBUFFER8 g_pVB = NULL; // Buffer to hold vertices
|
|||
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
|||
|
|
bool g_DeviceLost = false;
|
|||
|
|
|
|||
|
|
// A structure for our custom vertex type. We added a normal, and omitted the
|
|||
|
|
// color (which is provided by the material)
|
|||
|
|
struct CUSTOMVERTEX
|
|||
|
|
{
|
|||
|
|
D3DXVECTOR3 position; // The 3D position for the vertex
|
|||
|
|
D3DXVECTOR3 normal; // The surface normal for the vertex
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// Our custom FVF, which describes our custom vertex structure
|
|||
|
|
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL)
|
|||
|
|
|
|||
|
|
#include <GPLUSDx8.h>
|
|||
|
|
#include <GPLUSClient.h>
|
|||
|
|
|
|||
|
|
#include <SDOA4Client.h>
|
|||
|
|
#include <SDOADx8.h>
|
|||
|
|
|
|||
|
|
HINSTANCE g_hInstGPLUSDll = 0;
|
|||
|
|
LPGPlusInitialize g_pInitialize = NULL;
|
|||
|
|
LPGPlusGetModule g_pGetModule = NULL;
|
|||
|
|
LPGPlusTerminal g_pTerminal = NULL;
|
|||
|
|
|
|||
|
|
|
|||
|
|
IGPLUSApp* g_GPlusApp = NULL;
|
|||
|
|
IGPLUSDx8* g_GPlusDx8 = NULL;
|
|||
|
|
|
|||
|
|
HINSTANCE g_hInstIGWDll = 0;
|
|||
|
|
LPigwInitialize igwInitialize = NULL;
|
|||
|
|
LPigwGetModule igwGetModule = NULL;
|
|||
|
|
LPigwTerminal igwTerminal = NULL;
|
|||
|
|
|
|||
|
|
ISDOADx8* g_SDOADx8 = NULL;
|
|||
|
|
ISDOAApp* g_SDOAApp = NULL;
|
|||
|
|
|
|||
|
|
void CALLBACK OnResetDevice() ;
|
|||
|
|
|
|||
|
|
|
|||
|
|
/* <20>ͷ<EFBFBD>GPLUS */
|
|||
|
|
void UnloadGPLUS()
|
|||
|
|
{
|
|||
|
|
g_GPlusDx8 = NULL;
|
|||
|
|
g_GPlusApp = NULL;
|
|||
|
|
|
|||
|
|
g_pInitialize = NULL;
|
|||
|
|
if (g_pTerminal)
|
|||
|
|
{ // <20>ͷ<EFBFBD>DLLǰ<4C><C7B0><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>gpTerminal
|
|||
|
|
g_pTerminal();
|
|||
|
|
g_pTerminal = NULL;
|
|||
|
|
}
|
|||
|
|
if (g_hInstGPLUSDll)
|
|||
|
|
{
|
|||
|
|
FreeLibrary(g_hInstGPLUSDll);
|
|||
|
|
g_hInstGPLUSDll = NULL;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/* <20><><EFBFBD><EFBFBD>GPLUS */
|
|||
|
|
void LoadGPLUS()
|
|||
|
|
{
|
|||
|
|
WCHAR strExePath[MAX_PATH] = {0};
|
|||
|
|
WCHAR strExeName[MAX_PATH] = {0};
|
|||
|
|
WCHAR* strLastSlash = NULL;
|
|||
|
|
GetModuleFileNameW( NULL, strExePath, MAX_PATH );
|
|||
|
|
strExePath[MAX_PATH-1]=0;
|
|||
|
|
strLastSlash = wcsrchr( strExePath, TEXT('\\') );
|
|||
|
|
if( strLastSlash )
|
|||
|
|
{ // <20>õ<EFBFBD>EXE<58><45><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
|||
|
|
StringCchCopyW( strExeName, MAX_PATH, &strLastSlash[1] );
|
|||
|
|
*strLastSlash = 0;
|
|||
|
|
strLastSlash = wcsrchr( strExeName, TEXT('.') );
|
|||
|
|
if( strLastSlash )
|
|||
|
|
*strLastSlash = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WCHAR strGameWidgetDll[MAX_PATH] = {0};
|
|||
|
|
|
|||
|
|
StringCchPrintfW( strGameWidgetDll, MAX_PATH, L"%s\\GPlus\\GPlusBridge.dll", strExePath );
|
|||
|
|
|
|||
|
|
int appId = 200010900;
|
|||
|
|
FILE* f = fopen("./appid.txt","r");
|
|||
|
|
if(f != NULL){
|
|||
|
|
char value[1024] = {0};
|
|||
|
|
if(fgets(value,1024,f))
|
|||
|
|
{
|
|||
|
|
appId = atoi(value);
|
|||
|
|
}
|
|||
|
|
fclose(f);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UnloadGPLUS();
|
|||
|
|
BOOL bLoadOk = FALSE;
|
|||
|
|
|
|||
|
|
if ( GetFileAttributesW(strGameWidgetDll) != 0xFFFFFFFF )
|
|||
|
|
{ // <20>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
g_hInstGPLUSDll = LoadLibrary(strGameWidgetDll);
|
|||
|
|
if (g_hInstGPLUSDll)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
g_pInitialize = (LPGPlusInitialize)GetProcAddress( g_hInstGPLUSDll, "GPlusInitialize" );
|
|||
|
|
g_pGetModule = (LPGPlusGetModule)GetProcAddress( g_hInstGPLUSDll, "GPlusGetModule" );
|
|||
|
|
g_pTerminal = (LPGPlusTerminal)GetProcAddress( g_hInstGPLUSDll, "GPlusTerminal" );
|
|||
|
|
if ( g_pInitialize && g_pGetModule && g_pTerminal)
|
|||
|
|
{
|
|||
|
|
int appId = 200010900;
|
|||
|
|
FILE* f = fopen("./appid.txt","r");
|
|||
|
|
if(f != NULL){
|
|||
|
|
char value[1024] = {0};
|
|||
|
|
if(fgets(value,1024,f))
|
|||
|
|
{
|
|||
|
|
appId = atoi(value);
|
|||
|
|
}
|
|||
|
|
fclose(f);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ע<><D7A2>GPlusAppInfo<66><6F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶα<D6B6><CEB1><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
GPlusAppInfo tmpAppInfo = {
|
|||
|
|
sizeof(GPlusAppInfo), // <20>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>С
|
|||
|
|
appId, // <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>ID<49><44><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>վ<EFBFBD><D5BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
L"<EFBFBD><EFBFBD>̶<EFBFBD><EFBFBD>ѨOnLine", // Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
L"1.0.0.1",
|
|||
|
|
GPLUS_RENDERTYPE_D3D8, // <20>ͻ<EFBFBD><CDBB><EFBFBD>֧<EFBFBD>ֵ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
0,
|
|||
|
|
1,
|
|||
|
|
2,
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//<2F><>ʼ<EFBFBD><CABC>
|
|||
|
|
if (g_pInitialize(GPLUS_SDK_VERSION, &tmpAppInfo) == GPLUS_OK)
|
|||
|
|
{ // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|||
|
|
|
|||
|
|
bLoadOk = TRUE;
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
|
|||
|
|
g_pGetModule(__uuidof(IGPLUSApp), (void**)&g_GPlusApp);
|
|||
|
|
g_pGetModule(__uuidof(IGPLUSDx8), (void**)&g_GPlusDx8);
|
|||
|
|
|
|||
|
|
//ע<><D7A2>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>δ<EFBFBD><CEB4><EFBFBD>,Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7>ɫ<EFBFBD><C9AB>¼<EFBFBD>ɹ<EFBFBD><C9B9>ٵ<EFBFBD><D9B5><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>
|
|||
|
|
if ( g_GPlusDx8 && g_GPlusApp)
|
|||
|
|
{
|
|||
|
|
GPlusUserInfo tmpRoleInfo = { sizeof(GPlusUserInfo),
|
|||
|
|
L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>id" ,
|
|||
|
|
L"<EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD>"} ;
|
|||
|
|
|
|||
|
|
g_GPlusApp->Login(&tmpRoleInfo);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (TRUE != bLoadOk)
|
|||
|
|
{
|
|||
|
|
UnloadGPLUS();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/* <20>ͷ<EFBFBD>IGW */
|
|||
|
|
void CloseIGW()
|
|||
|
|
{
|
|||
|
|
if (g_SDOADx8)
|
|||
|
|
{
|
|||
|
|
g_SDOADx8->Release();
|
|||
|
|
g_SDOADx8 = NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (g_SDOAApp)
|
|||
|
|
{
|
|||
|
|
g_SDOAApp->Release();
|
|||
|
|
g_SDOAApp = NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (igwTerminal)
|
|||
|
|
{ // <20>ͷ<EFBFBD>DLLǰ<4C><C7B0><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>igwTerminal
|
|||
|
|
igwTerminal();
|
|||
|
|
igwTerminal = NULL;
|
|||
|
|
}
|
|||
|
|
if (g_hInstIGWDll)
|
|||
|
|
{
|
|||
|
|
FreeLibrary(g_hInstIGWDll);
|
|||
|
|
g_hInstIGWDll = 0;
|
|||
|
|
}
|
|||
|
|
igwInitialize = NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/* <20><><EFBFBD><EFBFBD>IGW */
|
|||
|
|
void OpenIGW()
|
|||
|
|
{
|
|||
|
|
WCHAR strExePath[MAX_PATH] = {0};
|
|||
|
|
WCHAR strExeName[MAX_PATH] = {0};
|
|||
|
|
WCHAR* strLastSlash = NULL;
|
|||
|
|
GetModuleFileNameW( NULL, strExePath, MAX_PATH );
|
|||
|
|
strExePath[MAX_PATH-1]=0;
|
|||
|
|
strLastSlash = wcsrchr( strExePath, TEXT('\\') );
|
|||
|
|
if( strLastSlash )
|
|||
|
|
{ // <20>õ<EFBFBD>EXE<58><45><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
|||
|
|
StringCchCopyW( strExeName, MAX_PATH, &strLastSlash[1] );
|
|||
|
|
*strLastSlash = 0;
|
|||
|
|
strLastSlash = wcsrchr( strExeName, TEXT('.') );
|
|||
|
|
if( strLastSlash )
|
|||
|
|
*strLastSlash = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WCHAR strGameWidgetDll[MAX_PATH] = {0};
|
|||
|
|
StringCchPrintfW( strGameWidgetDll, MAX_PATH, L"%s\\GameWidget.dll", strExePath );
|
|||
|
|
|
|||
|
|
if ( !(GetFileAttributesW(strGameWidgetDll) != 0xFFFFFFFF) )
|
|||
|
|
{ // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
StringCchPrintfW( strGameWidgetDll, MAX_PATH, L"%s\\..\\..\\..\\..\\bin\\GameWidget.dll", strExePath );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CloseIGW();
|
|||
|
|
|
|||
|
|
if ( GetFileAttributesW(strGameWidgetDll) != 0xFFFFFFFF )
|
|||
|
|
{ // <20>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
g_hInstIGWDll = LoadLibraryW(strGameWidgetDll);
|
|||
|
|
if (g_hInstIGWDll)
|
|||
|
|
{
|
|||
|
|
igwInitialize = (LPigwInitialize)GetProcAddress( g_hInstIGWDll, "igwInitialize" );
|
|||
|
|
igwGetModule = (LPigwGetModule)GetProcAddress( g_hInstIGWDll, "igwGetModule" );
|
|||
|
|
igwTerminal = (LPigwTerminal)GetProcAddress( g_hInstIGWDll, "igwTerminal" );
|
|||
|
|
if ( igwInitialize && igwGetModule && igwTerminal)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>سɹ<D8B3>
|
|||
|
|
|
|||
|
|
// ע<><D7A2>AppInfo<66><6F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶα<D6B6><CEB1><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
AppInfo tmpAppInfo = {
|
|||
|
|
sizeof(AppInfo), // <20>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ
|
|||
|
|
9999, // <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>ID<49><44><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>վ<EFBFBD><D5BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
L"<EFBFBD><EFBFBD>̶<EFBFBD><EFBFBD>ѨOnLine", // Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
L"0.1.2.0", // Ӧ<>ÿͻ<C3BF><CDBB>˵<EFBFBD>ǰ<EFBFBD>汾<EFBFBD><E6B1BE>
|
|||
|
|
SDOA_RENDERTYPE_D3D9, // <20>ͻ<EFBFBD><CDBB><EFBFBD>֧<EFBFBD>ֵ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>ͬʱ֧<CAB1><D6A7>d3d9<64><39>d3d8
|
|||
|
|
1, // <20><>ͬʱ<CDAC><CAB1>һ̨<D2BB><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>Ϊ1<CEAA><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:KOFӦ<46><D3A6><EFBFBD><EFBFBD>2<EFBFBD><32>
|
|||
|
|
-1, // <20><>Ϸ<EFBFBD><CFB7>ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>-1
|
|||
|
|
-1 // <20><>Ϸ<EFBFBD><CFB7>ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>-1
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
if (igwInitialize(SDOA_SDK_VERSION, &tmpAppInfo) == SDOA_OK)
|
|||
|
|
{ // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
|
|||
|
|
igwGetModule(__uuidof(ISDOADx8), (void**)&g_SDOADx8);
|
|||
|
|
igwGetModule(__uuidof(ISDOAApp), (void**)&g_SDOAApp);
|
|||
|
|
|
|||
|
|
if ( (!g_SDOADx8) || (!g_SDOAApp))
|
|||
|
|
CloseIGW();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else // <20><>ʼ<EFBFBD><CABC>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CloseIGW();
|
|||
|
|
}
|
|||
|
|
else // <20><><EFBFBD><EFBFBD>DLLʧ<4C><CAA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CloseIGW();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
// Name: InitD3D()
|
|||
|
|
// Desc: Initializes Direct3D
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
HRESULT InitD3D( HWND hWnd )
|
|||
|
|
{
|
|||
|
|
// Create the D3D object.
|
|||
|
|
if( NULL == ( g_pD3D = Direct3DCreate8( D3D_SDK_VERSION ) ) )
|
|||
|
|
return E_FAIL;
|
|||
|
|
|
|||
|
|
// Get the current desktop display mode, so we can set up a back
|
|||
|
|
// buffer of the same format
|
|||
|
|
D3DDISPLAYMODE d3ddm;
|
|||
|
|
if( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) )
|
|||
|
|
return E_FAIL;
|
|||
|
|
|
|||
|
|
// Set up the structure used to create the D3DDevice. Since we are now
|
|||
|
|
// using more complex geometry, we will create a device with a zbuffer.
|
|||
|
|
ZeroMemory( &d3dpp, sizeof(d3dpp) );
|
|||
|
|
d3dpp.Windowed = TRUE;
|
|||
|
|
// d3dpp.BackBufferWidth = 0;
|
|||
|
|
// d3dpp.BackBufferHeight = 0;
|
|||
|
|
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|||
|
|
d3dpp.BackBufferFormat = d3ddm.Format;
|
|||
|
|
d3dpp.EnableAutoDepthStencil = TRUE;
|
|||
|
|
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
|
|||
|
|
d3dpp.hDeviceWindow = hWnd;// ע<><D7A2>GPLUS<55>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
|||
|
|
|
|||
|
|
// Create the D3DDevice
|
|||
|
|
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
|
|||
|
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
|
|||
|
|
&d3dpp, &g_pd3dDevice ) ) )
|
|||
|
|
{
|
|||
|
|
return E_FAIL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Turn off culling
|
|||
|
|
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
|
|||
|
|
|
|||
|
|
// Turn on the zbuffer
|
|||
|
|
g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
|||
|
|
|
|||
|
|
return S_OK;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
// Name: InitGeometry()
|
|||
|
|
// Desc: Creates the scene geometry
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
HRESULT InitGeometry()
|
|||
|
|
{
|
|||
|
|
// Create the vertex buffer.
|
|||
|
|
if( FAILED( g_pd3dDevice->CreateVertexBuffer( 50*2*sizeof(CUSTOMVERTEX),
|
|||
|
|
0, D3DFVF_CUSTOMVERTEX,
|
|||
|
|
D3DPOOL_DEFAULT, &g_pVB ) ) )
|
|||
|
|
{
|
|||
|
|
return E_FAIL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Fill the vertex buffer. We are algorithmically generating a cylinder
|
|||
|
|
// here, including the normals, which are used for lighting.
|
|||
|
|
CUSTOMVERTEX* pVertices;
|
|||
|
|
if( FAILED( g_pVB->Lock( 0, 0, (BYTE**)&pVertices, 0 ) ) )
|
|||
|
|
return E_FAIL;
|
|||
|
|
for( DWORD i=0; i<50; i++ )
|
|||
|
|
{
|
|||
|
|
FLOAT theta = (2*D3DX_PI*i)/(50-1);
|
|||
|
|
pVertices[2*i+0].position = D3DXVECTOR3( sinf(theta),-1.0f, cosf(theta) );
|
|||
|
|
pVertices[2*i+0].normal = D3DXVECTOR3( sinf(theta), 0.0f, cosf(theta) );
|
|||
|
|
pVertices[2*i+1].position = D3DXVECTOR3( sinf(theta), 1.0f, cosf(theta) );
|
|||
|
|
pVertices[2*i+1].normal = D3DXVECTOR3( sinf(theta), 0.0f, cosf(theta) );
|
|||
|
|
}
|
|||
|
|
g_pVB->Unlock();
|
|||
|
|
|
|||
|
|
return S_OK;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
// Name: Cleanup()
|
|||
|
|
// Desc: Releases all previously initialized objects
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
VOID Cleanup()
|
|||
|
|
{
|
|||
|
|
if( g_pVB != NULL )
|
|||
|
|
g_pVB->Release();
|
|||
|
|
|
|||
|
|
if( g_pd3dDevice != NULL )
|
|||
|
|
g_pd3dDevice->Release();
|
|||
|
|
|
|||
|
|
if( g_pD3D != NULL )
|
|||
|
|
g_pD3D->Release();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
// Name: SetupMatrices()
|
|||
|
|
// Desc: Sets up the world, view, and projection transform matrices.
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
VOID SetupMatrices()
|
|||
|
|
{
|
|||
|
|
// For our world matrix, we will just leave it as the identity
|
|||
|
|
D3DXMATRIX matWorld;
|
|||
|
|
D3DXMatrixIdentity( &matWorld );
|
|||
|
|
D3DXMatrixRotationX( &matWorld, timeGetTime()/500.0f );
|
|||
|
|
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
|||
|
|
|
|||
|
|
// Set up our view matrix. A view matrix can be defined given an eye point,
|
|||
|
|
// a point to lookat, and a direction for which way is up. Here, we set the
|
|||
|
|
// eye five units back along the z-axis and up three units, look at the
|
|||
|
|
// origin, and define "up" to be in the y-direction.
|
|||
|
|
D3DXMATRIX matView;
|
|||
|
|
D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( 0.0f, 3.0f,-5.0f ),
|
|||
|
|
&D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),
|
|||
|
|
&D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) );
|
|||
|
|
g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
|||
|
|
|
|||
|
|
// For the projection matrix, we set up a perspective transform (which
|
|||
|
|
// transforms geometry from 3D view space to 2D viewport space, with
|
|||
|
|
// a perspective divide making objects smaller in the distance). To build
|
|||
|
|
// a perpsective transform, we need the field of view (1/4 pi is common),
|
|||
|
|
// the aspect ratio, and the near and far clipping planes (which define at
|
|||
|
|
// what distances geometry should be no longer be rendered).
|
|||
|
|
D3DXMATRIX matProj;
|
|||
|
|
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );
|
|||
|
|
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
// Name: SetupLights()
|
|||
|
|
// Desc: Sets up the lights and materials for the scene.
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
VOID SetupLights()
|
|||
|
|
{
|
|||
|
|
// Set up a material. The material here just has the diffuse and ambient
|
|||
|
|
// colors set to yellow. Note that only one material can be used at a time.
|
|||
|
|
D3DMATERIAL8 mtrl;
|
|||
|
|
ZeroMemory( &mtrl, sizeof(D3DMATERIAL8) );
|
|||
|
|
mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
|
|||
|
|
mtrl.Diffuse.g = mtrl.Ambient.g = 1.0f;
|
|||
|
|
mtrl.Diffuse.b = mtrl.Ambient.b = 0.0f;
|
|||
|
|
mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
|
|||
|
|
g_pd3dDevice->SetMaterial( &mtrl );
|
|||
|
|
|
|||
|
|
// Set up a white, directional light, with an oscillating direction.
|
|||
|
|
// Note that many lights may be active at a time (but each one slows down
|
|||
|
|
// the rendering of our scene). However, here we are just using one. Also,
|
|||
|
|
// we need to set the D3DRS_LIGHTING renderstate to enable lighting
|
|||
|
|
D3DXVECTOR3 vecDir;
|
|||
|
|
D3DLIGHT8 light;
|
|||
|
|
ZeroMemory( &light, sizeof(D3DLIGHT8) );
|
|||
|
|
light.Type = D3DLIGHT_DIRECTIONAL;
|
|||
|
|
light.Diffuse.r = 1.0f;
|
|||
|
|
light.Diffuse.g = 1.0f;
|
|||
|
|
light.Diffuse.b = 1.0f;
|
|||
|
|
vecDir = D3DXVECTOR3(cosf(timeGetTime()/350.0f),
|
|||
|
|
1.0f,
|
|||
|
|
sinf(timeGetTime()/350.0f) );
|
|||
|
|
D3DXVec3Normalize( (D3DXVECTOR3*)&light.Direction, &vecDir );
|
|||
|
|
light.Range = 1000.0f;
|
|||
|
|
g_pd3dDevice->SetLight( 0, &light );
|
|||
|
|
g_pd3dDevice->LightEnable( 0, TRUE );
|
|||
|
|
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
|
|||
|
|
|
|||
|
|
// Finally, turn on some ambient light.
|
|||
|
|
g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00202020 );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
// Name: Render()
|
|||
|
|
// Desc: Draws the scene
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
VOID Render()
|
|||
|
|
{
|
|||
|
|
// Clear the backbuffer and the zbuffer
|
|||
|
|
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
|
|||
|
|
D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
|
|||
|
|
|
|||
|
|
// Begin the scene
|
|||
|
|
g_pd3dDevice->BeginScene();
|
|||
|
|
|
|||
|
|
// Setup the lights and materials
|
|||
|
|
SetupLights();
|
|||
|
|
|
|||
|
|
// Setup the world, view, and projection matrices
|
|||
|
|
SetupMatrices();
|
|||
|
|
|
|||
|
|
// Render the vertex buffer contents
|
|||
|
|
g_pd3dDevice->SetStreamSource( 0, g_pVB, sizeof(CUSTOMVERTEX) );
|
|||
|
|
g_pd3dDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );
|
|||
|
|
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2*50-2 );
|
|||
|
|
|
|||
|
|
if (g_GPlusDx8)
|
|||
|
|
g_GPlusDx8->RenderEx();
|
|||
|
|
|
|||
|
|
if (g_SDOADx8)
|
|||
|
|
g_SDOADx8->RenderEx();
|
|||
|
|
|
|||
|
|
// End the scene
|
|||
|
|
g_pd3dDevice->EndScene();
|
|||
|
|
|
|||
|
|
// Present the backbuffer contents to the display
|
|||
|
|
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
BOOL isSDOLogin = false; // ע<><D7A2>һ<EFBFBD><D2BB>Ҫ<EFBFBD><D2AA>BOOL<4F><4C><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>Ϊbool<6F><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܻᵼ<DCBB><E1B5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
LoginResult loginResult;
|
|||
|
|
|
|||
|
|
BOOL CALLBACK OnLogin(int nErrorCode, const LoginResult* pLoginResult, int nUserData, int nReserved)
|
|||
|
|
{ // ע<><D7A2><EFBFBD>ûص<C3BB><D8B5><EFBFBD><EFBFBD><EFBFBD>true<75><65><EFBFBD>رյ<D8B1>¼<EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><F2A3ACB7><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB>ʾ
|
|||
|
|
|
|||
|
|
isSDOLogin = (SDOA_ERRORCODE_OK == nErrorCode);
|
|||
|
|
if (isSDOLogin)
|
|||
|
|
{
|
|||
|
|
loginResult = *pLoginResult;
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>,<2C><><EFBFBD>û<EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>Ϸ<EFBFBD><CFB7>ɫ<EFBFBD><C9AB>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>IGW
|
|||
|
|
if (g_SDOAApp)
|
|||
|
|
{
|
|||
|
|
RoleInfo sdoatmpRoleInfo = { sizeof(RoleInfo), L"<EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", 0 } ;
|
|||
|
|
g_SDOAApp->SetRoleInfo(&sdoatmpRoleInfo); // <20><><EFBFBD>ý<EFBFBD>ɫ<EFBFBD><C9AB>Ϣ<EFBFBD><CFA2><EFBFBD>ɶ<EFBFBD><C9B6>ε<EFBFBD><CEB5>ã<EFBFBD>ֻҪ<D6BB>û<EFBFBD><C3BB>л<EFBFBD><D0BB>˽<EFBFBD>ɫ<EFBFBD>͵<EFBFBD><CDB5><EFBFBD>֪ͨIGW
|
|||
|
|
|
|||
|
|
if ( g_GPlusDx8 && g_GPlusApp)
|
|||
|
|
{
|
|||
|
|
wchar_t ID[256]={0};
|
|||
|
|
MultiByteToWideChar(CP_ACP, 0, pLoginResult->szSndaid, -1, ID, _countof(ID));
|
|||
|
|
GPlusUserInfo gplustmpRoleInfo = { sizeof(GPlusUserInfo),
|
|||
|
|
ID ,
|
|||
|
|
sdoatmpRoleInfo.pwcsRoleName} ;
|
|||
|
|
|
|||
|
|
g_GPlusApp->Login(&gplustmpRoleInfo);
|
|||
|
|
|
|||
|
|
// g_UI.SetVisible(true);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (SDOA_ERRORCODE_SHOWMESSAGE == nErrorCode)
|
|||
|
|
{ // <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
|||
|
|
if (nReserved != 0)
|
|||
|
|
{
|
|||
|
|
LoginMessage* pCurLoginMsg = (LoginMessage*)nReserved;
|
|||
|
|
if (pCurLoginMsg->dwSize >= sizeof(LoginMessage))
|
|||
|
|
{ // <20><><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>
|
|||
|
|
// <20>Ĵ<DEB8><C4B4><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
//SysReAllocString(pCurLoginMsg->pbstrTitle, L"[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ]");
|
|||
|
|
|
|||
|
|
// <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>FALSE<53><45>ʹ<EFBFBD><CAB9>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD>ʾ
|
|||
|
|
|
|||
|
|
// <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>TRUE<55><45>ʹ<EFBFBD><CAB9><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|||
|
|
//isSDOLogin = TRUE;
|
|||
|
|
//::MessageBox(0, *pCurLoginMsg->pbstrContent, *pCurLoginMsg->pbstrTitle, MB_OK);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return isSDOLogin; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD>رյ<D8B1>¼<EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
// Name: MsgProc()
|
|||
|
|
// Desc: The window's message handler
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
|||
|
|
{
|
|||
|
|
if(g_GPlusDx8)
|
|||
|
|
{ // <20><><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>GPLUSģ<53>鴦<EFBFBD><E9B4A6>
|
|||
|
|
/* if (uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST)
|
|||
|
|
{
|
|||
|
|
POINT pt;
|
|||
|
|
GetCursorPos(&pt);
|
|||
|
|
ScreenToClient(h, &pt);
|
|||
|
|
if (FALSE == g_SDOADx9->HasUI(&pt)) {
|
|||
|
|
return FALSE;
|
|||
|
|
}
|
|||
|
|
}*/
|
|||
|
|
LRESULT lResult = 0;
|
|||
|
|
if (g_GPlusApp->OnWindowProc( hWnd, msg, wParam, lParam, &lResult ) == GPLUS_OK )
|
|||
|
|
{
|
|||
|
|
return lResult;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(g_SDOADx8)
|
|||
|
|
{ // <20><><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>IGWģ<57>鴦<EFBFBD><E9B4A6>
|
|||
|
|
LRESULT lResult;
|
|||
|
|
if (g_SDOADx8->OnWindowProc( hWnd, msg, wParam, lParam, &lResult ) == SDOA_OK )
|
|||
|
|
{
|
|||
|
|
return lResult;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ( (UINT)SDOA_WM_CLIENT_RUN == msg )
|
|||
|
|
{
|
|||
|
|
// <20>˿̿<CBBF><CCBF>Կ<EFBFBD>ʼ<EFBFBD><CABC>¼
|
|||
|
|
if (g_SDOAApp)
|
|||
|
|
{
|
|||
|
|
g_SDOAApp->ShowLoginDialog(OnLogin, 0, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
switch( msg )
|
|||
|
|
{
|
|||
|
|
case WM_SIZE:
|
|||
|
|
{
|
|||
|
|
OnLostDevice();
|
|||
|
|
g_pd3dDevice->Reset(&d3dpp);
|
|||
|
|
OnResetDevice();
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case WM_DESTROY:
|
|||
|
|
PostQuitMessage( 0 );
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
return DefWindowProc( hWnd, msg, wParam, lParam );
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CALLBACK OnLostDevice()
|
|||
|
|
{
|
|||
|
|
/* ֪ͨd3d<33>豸<EFBFBD><E8B1B8>ʧ */
|
|||
|
|
if( g_pVB != NULL )
|
|||
|
|
{
|
|||
|
|
g_pVB->Release();
|
|||
|
|
g_pVB = NULL;
|
|||
|
|
}
|
|||
|
|
if (g_GPlusDx8)
|
|||
|
|
g_GPlusDx8->OnDeviceLost();
|
|||
|
|
|
|||
|
|
if (g_SDOADx8)
|
|||
|
|
g_SDOADx8->OnDeviceLost();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CALLBACK OnResetDevice()
|
|||
|
|
{
|
|||
|
|
/* ֪ͨd3d<33>豸<EFBFBD><E8B1B8><EFBFBD>óɹ<C3B3> */
|
|||
|
|
InitGeometry();
|
|||
|
|
// Turn off culling
|
|||
|
|
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
|
|||
|
|
// // Turn on the zbuffer
|
|||
|
|
g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
|||
|
|
|
|||
|
|
if (g_GPlusDx8)
|
|||
|
|
g_GPlusDx8->OnDeviceReset(&d3dpp);
|
|||
|
|
|
|||
|
|
if (g_SDOADx8)
|
|||
|
|
g_SDOADx8->OnDeviceReset(&d3dpp);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
// Name: WinMain()
|
|||
|
|
// Desc: The application's entry point
|
|||
|
|
//-----------------------------------------------------------------------------
|
|||
|
|
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
|
|||
|
|
{
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|
|||
|
|
|
|||
|
|
|
|||
|
|
// Register the window class
|
|||
|
|
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
|
|||
|
|
GetModuleHandle(NULL), NULL, LoadCursor( NULL, IDC_ARROW ), NULL, NULL,
|
|||
|
|
L"D3D Tutorial", NULL };
|
|||
|
|
RegisterClassEx( &wc );
|
|||
|
|
|
|||
|
|
// Create the application's window
|
|||
|
|
HWND hWnd = CreateWindow( L"D3D Tutorial", L"D3D Tutorial 04: Lights",
|
|||
|
|
WS_OVERLAPPEDWINDOW, 100, 100, 800, 600,
|
|||
|
|
GetDesktopWindow(), NULL, wc.hInstance, NULL );
|
|||
|
|
|
|||
|
|
|
|||
|
|
// Initialize Direct3D
|
|||
|
|
if( SUCCEEDED( InitD3D( hWnd ) ) )
|
|||
|
|
{
|
|||
|
|
/* <20><><EFBFBD><EFBFBD>GPLUS */
|
|||
|
|
LoadGPLUS();
|
|||
|
|
|
|||
|
|
/* <20><><EFBFBD><EFBFBD>IGW */
|
|||
|
|
OpenIGW();
|
|||
|
|
|
|||
|
|
if (g_pInitialize)
|
|||
|
|
{ // ˵<><CBB5><EFBFBD><EFBFBD><EFBFBD>سɹ<D8B3><C9B9><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>......
|
|||
|
|
SetWindowText(hWnd, L"D3D Tutorial [<5B><><EFBFBD><EFBFBD>GPLUS<55><53><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>]");
|
|||
|
|
}
|
|||
|
|
if (g_GPlusDx8)
|
|||
|
|
{ // <20><>ʼ<EFBFBD><CABC>GPLUS<55>ڲ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
g_GPlusDx8->Initialize(g_pd3dDevice, &d3dpp, false);
|
|||
|
|
}
|
|||
|
|
if (g_SDOADx8)
|
|||
|
|
{
|
|||
|
|
g_SDOADx8->Initialize(g_pd3dDevice, &d3dpp, false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Create the geometry
|
|||
|
|
if( SUCCEEDED( InitGeometry() ) )
|
|||
|
|
{
|
|||
|
|
// Show the window
|
|||
|
|
ShowWindow( hWnd, SW_SHOWDEFAULT );
|
|||
|
|
UpdateWindow( hWnd );
|
|||
|
|
|
|||
|
|
// Enter the message loop
|
|||
|
|
MSG msg;
|
|||
|
|
ZeroMemory( &msg, sizeof(msg) );
|
|||
|
|
while( msg.message!=WM_QUIT )
|
|||
|
|
{
|
|||
|
|
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
|
|||
|
|
{
|
|||
|
|
TranslateMessage( &msg );
|
|||
|
|
DispatchMessage( &msg );
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{ // <20><EFBFBD><F2B5A5B4><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD>
|
|||
|
|
if (g_DeviceLost)
|
|||
|
|
{ // <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>ʧ<EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⳤʱ<E2B3A4>䶪ʧռ<CAA7>ù<EFBFBD><C3B9><EFBFBD>CPU
|
|||
|
|
Sleep(50);
|
|||
|
|
}
|
|||
|
|
switch (g_pd3dDevice->TestCooperativeLevel())
|
|||
|
|
{
|
|||
|
|
case D3D_OK:
|
|||
|
|
{ //
|
|||
|
|
Render();
|
|||
|
|
g_DeviceLost = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
case D3DERR_DEVICELOST:
|
|||
|
|
{
|
|||
|
|
if ( !g_DeviceLost )
|
|||
|
|
{
|
|||
|
|
OnLostDevice();
|
|||
|
|
g_DeviceLost = true;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case D3DERR_DEVICENOTRESET:
|
|||
|
|
{
|
|||
|
|
if ( g_pd3dDevice->Reset( &d3dpp ) == D3D_OK )
|
|||
|
|
{
|
|||
|
|
OnResetDevice();
|
|||
|
|
g_DeviceLost = false;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (g_GPlusDx8)
|
|||
|
|
{ // <20>ͷ<EFBFBD>GPLUS<55>ڲ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
g_GPlusDx8->Finalize();
|
|||
|
|
}
|
|||
|
|
if (g_SDOADx8)
|
|||
|
|
{
|
|||
|
|
g_SDOADx8->Finalize();
|
|||
|
|
}
|
|||
|
|
/* <20>ͷ<EFBFBD>GPLUS */
|
|||
|
|
UnloadGPLUS();
|
|||
|
|
|
|||
|
|
/* <20>ͷ<EFBFBD>IGW */
|
|||
|
|
CloseIGW();
|
|||
|
|
|
|||
|
|
// Clean up everything and exit the app
|
|||
|
|
Cleanup();
|
|||
|
|
UnregisterClass( L"D3D Tutorial", wc.hInstance );
|
|||
|
|
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|