604 lines
19 KiB
C++
604 lines
19 KiB
C++
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
// File: EmptyProject.cpp
|
|||
|
|
//
|
|||
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
|
|||
|
|
#if _MSC_VER == 1600
|
|||
|
|
#define POINTER_64 __ptr64
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#include "DXUT.h"
|
|||
|
|
#include "DXUTgui.h"
|
|||
|
|
#include "resource.h"
|
|||
|
|
#include <strsafe.h>
|
|||
|
|
#include <GPLUSDx9.h>
|
|||
|
|
#include <GPLUSClient.h>
|
|||
|
|
|
|||
|
|
#include <SDOA4Client.h>
|
|||
|
|
#include <SDOADx9.h>
|
|||
|
|
|
|||
|
|
CDXUTDialogResourceManager g_DialogResourceManager;
|
|||
|
|
CDXUTDialog g_UI;
|
|||
|
|
#define IDC_BUTTON_LOGOUT 1
|
|||
|
|
|
|||
|
|
|
|||
|
|
HINSTANCE g_hInstGPLUSDll = 0;
|
|||
|
|
LPGPlusInitialize g_pInitialize = NULL;
|
|||
|
|
LPGPlusGetModule g_pGetModule = NULL;
|
|||
|
|
LPGPlusTerminal g_pTerminal = NULL;
|
|||
|
|
|
|||
|
|
|
|||
|
|
IGPLUSApp* g_GPlusApp = NULL;
|
|||
|
|
IGPLUSDx9* g_GPlusDx9 = NULL;
|
|||
|
|
|
|||
|
|
HINSTANCE g_hInstIGWDll = 0;
|
|||
|
|
LPigwInitialize igwInitialize = NULL;
|
|||
|
|
LPigwGetModule igwGetModule = NULL;
|
|||
|
|
LPigwTerminal igwTerminal = NULL;
|
|||
|
|
|
|||
|
|
ISDOADx9* g_SDOADx9 = NULL;
|
|||
|
|
ISDOAApp* g_SDOAApp = NULL;
|
|||
|
|
|
|||
|
|
|
|||
|
|
/* <20>ͷ<EFBFBD>GPLUS */
|
|||
|
|
void UnloadGPLUS()
|
|||
|
|
{
|
|||
|
|
g_GPlusDx9 = 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_D3D9, // <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(IGPLUSDx9), (void**)&g_GPlusDx9);
|
|||
|
|
|
|||
|
|
/* ע<><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_GPlusDx9 && 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_SDOADx9)
|
|||
|
|
{
|
|||
|
|
g_SDOADx9->Release();
|
|||
|
|
g_SDOADx9 = 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(ISDOADx9), (void**)&g_SDOADx9);
|
|||
|
|
igwGetModule(__uuidof(ISDOAApp), (void**)&g_SDOAApp);
|
|||
|
|
|
|||
|
|
if ( (!g_SDOADx9) || (!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();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
// 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 )
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
// 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 )
|
|||
|
|
{
|
|||
|
|
if (g_GPlusDx9)
|
|||
|
|
{ // <20><>ʼ<EFBFBD><CABC>GPLUS<55>ڲ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
D3DPRESENT_PARAMETERS d3dpp = DXUTGetD3D9PresentParameters ();
|
|||
|
|
g_GPlusDx9->Initialize( pd3dDevice, &d3dpp, FALSE );
|
|||
|
|
}
|
|||
|
|
if (g_SDOADx9)
|
|||
|
|
{ // <20><>ʼ<EFBFBD><CABC>IGW<47>ڲ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
D3DPRESENT_PARAMETERS d3dpp = DXUTGetD3D9PresentParameters ();
|
|||
|
|
g_SDOADx9->Initialize( pd3dDevice, &d3dpp, FALSE );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
HRESULT hr;
|
|||
|
|
V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) );
|
|||
|
|
|
|||
|
|
return S_OK;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
// 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 )
|
|||
|
|
{
|
|||
|
|
if(g_GPlusDx9)
|
|||
|
|
{ // ֪ͨGPLUS d3d<33>豸<EFBFBD><E8B1B8><EFBFBD>óɹ<C3B3>
|
|||
|
|
D3DPRESENT_PARAMETERS d3dpp = DXUTGetD3D9PresentParameters () ;
|
|||
|
|
g_GPlusDx9->OnDeviceReset ( &d3dpp ) ;
|
|||
|
|
}
|
|||
|
|
if(g_SDOADx9)
|
|||
|
|
{ // ֪ͨIGW d3d<33>豸<EFBFBD><E8B1B8><EFBFBD>óɹ<C3B3>
|
|||
|
|
D3DPRESENT_PARAMETERS d3dpp = DXUTGetD3D9PresentParameters () ;
|
|||
|
|
g_SDOADx9->OnDeviceReset ( &d3dpp ) ;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
HRESULT hr;
|
|||
|
|
V_RETURN( g_DialogResourceManager.OnD3D9ResetDevice() );
|
|||
|
|
|
|||
|
|
g_UI.SetLocation( 0, 0 );
|
|||
|
|
g_UI.SetSize( pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height );
|
|||
|
|
|
|||
|
|
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 )
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
// Render the scene using the D3D9 device
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
void CALLBACK OnD3D9FrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
|
|||
|
|
{
|
|||
|
|
HRESULT hr;
|
|||
|
|
|
|||
|
|
// Clear the render target and the zbuffer
|
|||
|
|
V( pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 45, 50, 170 ), 1.0f, 0 ) );
|
|||
|
|
|
|||
|
|
// Render the scene
|
|||
|
|
if( SUCCEEDED( pd3dDevice->BeginScene() ) )
|
|||
|
|
{
|
|||
|
|
/* <20><><EFBFBD><EFBFBD>GPLUS<55><53><EFBFBD><EFBFBD> */
|
|||
|
|
if (g_GPlusDx9)
|
|||
|
|
g_GPlusDx9->RenderEx();
|
|||
|
|
|
|||
|
|
/* <20><><EFBFBD><EFBFBD>IGW<47><57><EFBFBD><EFBFBD> */
|
|||
|
|
if (g_SDOADx9)
|
|||
|
|
g_SDOADx9->RenderEx();
|
|||
|
|
|
|||
|
|
V( g_UI.OnRender( fElapsedTime ) );
|
|||
|
|
V( pd3dDevice->EndScene() );
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
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_GPlusDx9 && 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>
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
// Handle messages to the application
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
|
|||
|
|
bool* pbNoFurtherProcessing, void* pUserContext )
|
|||
|
|
{
|
|||
|
|
if(g_GPlusDx9)
|
|||
|
|
{ // <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;
|
|||
|
|
if (g_GPlusApp->OnWindowProc( hWnd, uMsg, wParam, lParam, &lResult ) == GPLUS_OK )
|
|||
|
|
{
|
|||
|
|
*pbNoFurtherProcessing = true;// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
return lResult;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(g_SDOADx9)
|
|||
|
|
{ // <20><><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>IGWģ<57>鴦<EFBFBD><E9B4A6>
|
|||
|
|
LRESULT lResult;
|
|||
|
|
if (g_SDOADx9->OnWindowProc( hWnd, uMsg, wParam, lParam, &lResult ) == SDOA_OK )
|
|||
|
|
{
|
|||
|
|
*pbNoFurtherProcessing = true;// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
return lResult;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ( (UINT)SDOA_WM_CLIENT_RUN == uMsg )
|
|||
|
|
{
|
|||
|
|
// <20>˿̿<CBBF><CCBF>Կ<EFBFBD>ʼ<EFBFBD><CABC>¼
|
|||
|
|
if (g_SDOAApp)
|
|||
|
|
{
|
|||
|
|
g_SDOAApp->ShowLoginDialog(OnLogin, 0, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
*pbNoFurtherProcessing = g_DialogResourceManager.MsgProc( hWnd, uMsg, wParam, lParam );
|
|||
|
|
if( *pbNoFurtherProcessing )
|
|||
|
|
return 0;
|
|||
|
|
|
|||
|
|
*pbNoFurtherProcessing = g_UI.MsgProc( hWnd, uMsg, wParam, lParam );
|
|||
|
|
if( *pbNoFurtherProcessing )
|
|||
|
|
return 0;
|
|||
|
|
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
// Release D3D9 resources created in the OnD3D9ResetDevice callback
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
void CALLBACK OnD3D9LostDevice( void* pUserContext )
|
|||
|
|
{
|
|||
|
|
/* ֪ͨGPLUS d3d<33>豸<EFBFBD><E8B1B8>ʧ */
|
|||
|
|
if(g_GPlusDx9)
|
|||
|
|
g_GPlusDx9->OnDeviceLost();
|
|||
|
|
/* ֪ͨIGW d3d<33>豸<EFBFBD><E8B1B8>ʧ */
|
|||
|
|
if(g_SDOADx9)
|
|||
|
|
g_SDOADx9->OnDeviceLost();
|
|||
|
|
|
|||
|
|
g_DialogResourceManager.OnD3D9LostDevice();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
// Release D3D9 resources created in the OnD3D9CreateDevice callback
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
void CALLBACK OnD3D9DestroyDevice( void* pUserContext )
|
|||
|
|
{
|
|||
|
|
/* <20>ͷ<EFBFBD>GPLUSͼ<53><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
|
if (g_GPlusDx9)
|
|||
|
|
g_GPlusDx9->Finalize();
|
|||
|
|
/* <20>ͷ<EFBFBD>IGWͼ<57><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
|
if (g_SDOADx9)
|
|||
|
|
g_SDOADx9->Finalize();
|
|||
|
|
|
|||
|
|
g_DialogResourceManager.OnD3D9DestroyDevice();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext );
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
// Initialize everything and go into a render loop
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
INT WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int )
|
|||
|
|
{
|
|||
|
|
// Enable run-time memory check for debug builds.
|
|||
|
|
#if defined(DEBUG) | defined(_DEBUG)
|
|||
|
|
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
/* <20><><EFBFBD><EFBFBD>GPLUS */
|
|||
|
|
LoadGPLUS();
|
|||
|
|
|
|||
|
|
/* <20><><EFBFBD><EFBFBD>IGW */
|
|||
|
|
OpenIGW();
|
|||
|
|
// Set the callback functions
|
|||
|
|
DXUTSetCallbackD3D9DeviceAcceptable( IsD3D9DeviceAcceptable );
|
|||
|
|
DXUTSetCallbackD3D9DeviceCreated( OnD3D9CreateDevice );
|
|||
|
|
DXUTSetCallbackD3D9DeviceReset( OnD3D9ResetDevice );
|
|||
|
|
DXUTSetCallbackD3D9FrameRender( OnD3D9FrameRender );
|
|||
|
|
DXUTSetCallbackD3D9DeviceLost( OnD3D9LostDevice );
|
|||
|
|
DXUTSetCallbackD3D9DeviceDestroyed( OnD3D9DestroyDevice );
|
|||
|
|
DXUTSetCallbackDeviceChanging( ModifyDeviceSettings );
|
|||
|
|
DXUTSetCallbackMsgProc( MsgProc );
|
|||
|
|
DXUTSetCallbackFrameMove( OnFrameMove );
|
|||
|
|
|
|||
|
|
|
|||
|
|
// TODO: Perform any application-level initialization here
|
|||
|
|
|
|||
|
|
g_UI.Init( &g_DialogResourceManager );
|
|||
|
|
g_UI.SetCallback( OnGUIEvent );
|
|||
|
|
g_UI.AddButton( IDC_BUTTON_LOGOUT, L"ע<EFBFBD><EFBFBD>", 200, 10, 125, 22 );
|
|||
|
|
g_UI.SetVisible(false);
|
|||
|
|
|
|||
|
|
// 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"EmptyProject_dx9" );
|
|||
|
|
DXUTCreateDevice( true, 800, 600 );
|
|||
|
|
|
|||
|
|
if (g_pInitialize)
|
|||
|
|
{ // <20><><EFBFBD>سɹ<D8B3>
|
|||
|
|
wchar_t wszCaption[256];
|
|||
|
|
swprintf_s(wszCaption, _countof(wszCaption), L"%d:EmptyProject [<5B><><EFBFBD><EFBFBD>GPLUS<55>ɹ<EFBFBD>]", GetCurrentProcessId());
|
|||
|
|
SetWindowTextW(DXUTGetHWND(), wszCaption);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Start the render loop
|
|||
|
|
DXUTMainLoop();
|
|||
|
|
|
|||
|
|
/* <20>ͷ<EFBFBD>GPLUS */
|
|||
|
|
UnloadGPLUS();
|
|||
|
|
|
|||
|
|
|
|||
|
|
/* <20>ͷ<EFBFBD>IGW */
|
|||
|
|
CloseIGW();
|
|||
|
|
|
|||
|
|
|
|||
|
|
return DXUTGetExitCode();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
// Handles the GUI events
|
|||
|
|
//--------------------------------------------------------------------------------------
|
|||
|
|
void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext )
|
|||
|
|
{
|
|||
|
|
switch( nControlID )
|
|||
|
|
{
|
|||
|
|
case IDC_BUTTON_LOGOUT:
|
|||
|
|
g_SDOAApp->Logout();
|
|||
|
|
g_GPlusApp->Logout();
|
|||
|
|
g_UI.SetVisible(false);
|
|||
|
|
g_SDOAApp->ShowLoginDialog(OnLogin, 0, 0);
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|