DragonNest/Extern/GPlusSDK/Samples/EmptyProject8/EmptyProject8.cpp

786 lines
49 KiB
C++
Raw Normal View History

2024-12-20 16:56:44 +08:00
<EFBFBD><EFBFBD>//-----------------------------------------------------------------------------
// 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<EFBFBD>vsQ(u
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() ;
/* ʑ>eGPLUS */
void UnloadGPLUS()
{
g_GPlusDx8 = NULL;
g_GPlusApp = NULL;
g_pInitialize = NULL;
if (g_pTerminal)
{ // ʑ>eDLLMR;`/fHQ<EFBFBD>(ugpTerminal
g_pTerminal();
g_pTerminal = NULL;
}
if (g_hInstGPLUSDll)
{
FreeLibrary(g_hInstGPLUSDll);
g_hInstGPLUSDll = NULL;
}
}
/* <EFBFBD>R}<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 )
{ // <EFBFBD>_0REXE@b(W_
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 )
{ // ~b0R<EFBFBD>~<EFBFBD>NR<EFBFBD>R}<EFBFBD>
g_hInstGPLUSDll = LoadLibrary(strGameWidgetDll);
if (g_hInstGPLUSDll)
{
//<EFBFBD><EFBFBD><EFBFBD>S<EFBFBD>[<EFBFBD>Q<EFBFBD>Qpe
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);
}
// <EFBFBD>laGPlusAppInfo{|<EFBFBD>W@b gW[<EFBFBD>k<EFBFBD>_{<EFBFBD>kX
GPlusAppInfo tmpAppInfo = {
sizeof(GPlusAppInfo), // <EFBFBD>~<EFBFBD>gSO'Y\
appId, // <EFBFBD>ceQ<EFBFBD>^(uID <EFBFBD><EFBFBD>N_<EFBFBD>S<EFBFBD>Q<EFBFBD>z-N3u<EFBFBD><EFBFBD>
L"<00><>moN<6F>tzOnLine", // <EFBFBD>^(u T<EFBFBD>y
L"1.0.0.1",
GPLUS_RENDERTYPE_D3D8, // <EFBFBD>[7b<EFBFBD>z/ec<EFBFBD>v<EFBFBD>Vb__<EFBFBD>d{|<EFBFBD>W
0,
1,
2,
};
//R<EFBFBD>YS
if (g_pInitialize(GPLUS_SDK_VERSION, &tmpAppInfo) == GPLUS_OK)
{ // R<EFBFBD>YS<EFBFBD>~<EFBFBD>Nb<EFBFBD>R
bLoadOk = TRUE;
// <EFBFBD><EFBFBD><EFBFBD>S<EFBFBD>~<EFBFBD>N<EFBFBD>c<EFBFBD>S
g_pGetModule(__uuidof(IGPLUSApp), (void**)&g_GPlusApp);
g_pGetModule(__uuidof(IGPLUSDx8), (void**)&g_GPlusDx8);
//<EFBFBD>la: Nb<EFBFBD>ُN<EFBFBD>k<EFBFBD>Nx,<EFBFBD>^<EFBFBD><EFBFBD>(W8nb҉r<EFBFBD>{vU_b<EFBFBD>R<EFBFBD>Q<EFBFBD>(u,ُ̑<EFBFBD>N\Oo:y(u
if ( g_GPlusDx8 && g_GPlusApp)
{
GPlusUserInfo tmpRoleInfo = { sizeof(GPlusUserInfo),
L"peW[id" ,
L"҉r<D289> T"} ;
g_GPlusApp->Login(&tmpRoleInfo);
}
}
}
}
}
if (TRUE != bLoadOk)
{
UnloadGPLUS();
}
}
/* ʑ>eIGW */
void CloseIGW()
{
if (g_SDOADx8)
{
g_SDOADx8->Release();
g_SDOADx8 = NULL;
}
if (g_SDOAApp)
{
g_SDOAApp->Release();
g_SDOAApp = NULL;
}
if (igwTerminal)
{ // ʑ>eDLLMR;`/fHQ<EFBFBD>(uigwTerminal
igwTerminal();
igwTerminal = NULL;
}
if (g_hInstIGWDll)
{
FreeLibrary(g_hInstIGWDll);
g_hInstIGWDll = 0;
}
igwInitialize = NULL;
}
/* <EFBFBD>R}<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 )
{ // <EFBFBD>_0REXE@b(W_
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) )
{ // <EFBFBD>Y<EFBFBD>g z<EFBFBD>^ЏL<EFBFBD>_-N NX[(WRbc*N_<EFBFBD>
StringCchPrintfW( strGameWidgetDll, MAX_PATH, L"%s\\..\\..\\..\\..\\bin\\GameWidget.dll", strExePath );
}
CloseIGW();
if ( GetFileAttributesW(strGameWidgetDll) != 0xFFFFFFFF )
{ // ~b0R<EFBFBD>~<EFBFBD>NR<EFBFBD>R}<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)
{
// <EFBFBD>R}<EFBFBD>b<EFBFBD>R
// <EFBFBD>laAppInfo{|<EFBFBD>W@b gW[<EFBFBD>k<EFBFBD>_{<EFBFBD>kX
AppInfo tmpAppInfo = {
sizeof(AppInfo), // <EFBFBD>~<EFBFBD>gSO'Y\ <EFBFBD><EFBFBD>e<EFBFBD>OibU\
9999, // <EFBFBD>ceQ<EFBFBD>^(uID <EFBFBD><EFBFBD>N_<EFBFBD>S<EFBFBD>Q<EFBFBD>z-N3u<EFBFBD><EFBFBD>
L"<00><>moN<6F>tzOnLine", // <EFBFBD>^(u T<EFBFBD>y
L"0.1.2.0", // <EFBFBD>^(u<EFBFBD>[7b<EFBFBD>zS_MRHr,g<EFBFBD>S
SDOA_RENDERTYPE_D3D9, // <EFBFBD>[7b<EFBFBD>z/ec<EFBFBD>v<EFBFBD>Vb__<EFBFBD>d{|<EFBFBD>W <EFBFBD>ُ̑ T<EFBFBD>e/ecd3d9<EFBFBD>Td3d8
1, // <EFBFBD>S T<EFBFBD>e(WN<EFBFBD>S:ghV
N8nb<EFBFBD>vg'Y<EFBFBD>Npe<EFBFBD><EFBFBD>8^:N1 <EFBFBD><EFBFBD>O<EFBFBD>Y:KOF<EFBFBD>^<EFBFBD><EFBFBD>/f2 <EFBFBD>
-1, // 8nb:SID <EFBFBD> N<EFBFBD>S(u<EFBFBD>e OeQ-1
-1 // 8nb<EFBFBD>~ID <EFBFBD> N<EFBFBD>S(u<EFBFBD>e OeQ-1
};
if (igwInitialize(SDOA_SDK_VERSION, &tmpAppInfo) == SDOA_OK)
{ // R<EFBFBD>YS<EFBFBD>~<EFBFBD>Nb<EFBFBD>R
// <EFBFBD><EFBFBD><EFBFBD>S<EFBFBD>~<EFBFBD>N<EFBFBD>c<EFBFBD>S
igwGetModule(__uuidof(ISDOADx8), (void**)&g_SDOADx8);
igwGetModule(__uuidof(ISDOAApp), (void**)&g_SDOAApp);
if ( (!g_SDOADx8) || (!g_SDOAApp))
CloseIGW();
}
else // R<EFBFBD>YS1Y%<EFBFBD>nd<EFBFBD><EFBFBD>s<EFBFBD>X
CloseIGW();
}
else // <EFBFBD>R}<EFBFBD>DLL1Y%<EFBFBD>nd<EFBFBD><EFBFBD>s<EFBFBD>X
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;// <EFBFBD>laGPLUS<EFBFBD>Q<EFBFBD><EFBFBD>;`/f<EFBFBD>Ǐ<EFBFBD>[<EFBFBD>S0R8nb;N<EFBFBD>z<EFBFBD>S<EFBFBD>v
// 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; // <EFBFBD>laN<EFBFBD>[<EFBFBD><EFBFBD>/fBOOL{|<EFBFBD>W <EFBFBD> N<EFBFBD><EFBFBD>:Nbool&TR<EFBFBD>S<EFBFBD><EFBFBD>O<EFBFBD>[<EFBFBD><EFBFBD><EFBFBD>
LoginResult loginResult;
BOOL CALLBACK OnLogin(int nErrorCode, const LoginResult* pLoginResult, int nUserData, int nReserved)
{ // <EFBFBD>la<EFBFBD><EFBFBD><EFBFBD>V<EFBFBD>ԏ<EFBFBD>VtrueRsQ<EFBFBD><EFBFBD>{vU_<EFBFBD>[݋Fh <EFBFBD>&TR{vU_<EFBFBD>[݋Fh<EFBFBD>N6q>f:y
isSDOLogin = (SDOA_ERRORCODE_OK == nErrorCode);
if (isSDOLogin)
{
loginResult = *pLoginResult;
// {vU_b<EFBFBD>RT,<EFBFBD>b(u7bO(u<EFBFBD>v8nb҉r<EFBFBD><EFBFBD>Oo` OeQIGW
if (g_SDOAApp)
{
RoleInfo sdoatmpRoleInfo = { sizeof(RoleInfo), L"<00><EFBFBD><7F><EFBFBD>NP[", 0 } ;
g_SDOAApp->SetRoleInfo(&sdoatmpRoleInfo); // <EFBFBD><EFBFBD>n҉r<EFBFBD><EFBFBD>Oo` <EFBFBD><EFBFBD>SY!k<EFBFBD>(u <EFBFBD><EFBFBD>S<EFBFBD><EFBFBD>(u7bRbc<EFBFBD>N҉r<EFBFBD>1\<EFBFBD>(u<EFBFBD><EFBFBD>wIGW
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)
{ // {vU_<EFBFBD>mo`Yt
if (nReserved != 0)
{
LoginMessage* pCurLoginMsg = (LoginMessage*)nReserved;
if (pCurLoginMsg->dwSize >= sizeof(LoginMessage))
{ // |Q<EFBFBD>['`Yt
// <EFBFBD>O9e<EFBFBD><EFBFBD><EFBFBD><EFBFBD>c:y<EFBFBD>[݋Fhh<EFBFBD><EFBFBD>
//SysReAllocString(pCurLoginMsg->pbstrTitle, L"[KmՋ8nb<19><><EFBFBD><EFBFBD>c:y]");
// dk<EFBFBD><EFBFBD>VFALSERO(u؞<EFBFBD><EFBFBD><EFBFBD>c:y
// dk<EFBFBD><EFBFBD>VTRUERO(uꁚ[IN<EFBFBD>v<EFBFBD>c:y
//isSDOLogin = TRUE;
//::MessageBox(0, *pCurLoginMsg->pbstrContent, *pCurLoginMsg->pbstrTitle, MB_OK);
}
}
}
return isSDOLogin; // 8^ĉ;<EFBFBD><EFBFBD><EFBFBD> <EFBFBD>{vU_b<EFBFBD>RRsQ<EFBFBD><EFBFBD>{vU_<EFBFBD>[݋Fh
}
//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
if(g_GPlusDx8)
{ // <EFBFBD>b<EFBFBD>mo`<EFBFBD>N<EFBFBD>~GPLUS!jWWYt
/* 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)
{ // <EFBFBD>b<EFBFBD>mo`<EFBFBD>N<EFBFBD>~IGW!jWWYt
LRESULT lResult;
if (g_SDOADx8->OnWindowProc( hWnd, msg, wParam, lParam, &lResult ) == SDOA_OK )
{
return lResult;
}
}
if ( (UINT)SDOA_WM_CLIENT_RUN == msg )
{
// dk;R<EFBFBD>S<EFBFBD>N_<EFBFBD>Y{vU_
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()
{
/* <EFBFBD><EFBFBD>wd3d<EFBFBD><EFBFBD>Y"N1Y */
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()
{
/* <EFBFBD><EFBFBD>wd3d<EFBFBD><EFBFBD>Y͑nb<EFBFBD>R */
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 ) ) )
{
/* <EFBFBD>R}<EFBFBD>GPLUS */
LoadGPLUS();
/* <EFBFBD>R}<EFBFBD>IGW */
OpenIGW();
if (g_pInitialize)
{ // <EFBFBD><EFBFBD>f<EFBFBD>R}<EFBFBD>b<EFBFBD>R <EFBFBD>h<EFBFBD>:y N......
SetWindowText(hWnd, L"D3D Tutorial [<00>R}<7D>GPLUS<00>~<7E>Nb<>R]");
}
if (g_GPlusDx8)
{ // R<EFBFBD>YSGPLUS<EFBFBD>Q<EFBFBD><EFBFBD><EFBFBD>Vb__<EFBFBD>d
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
{ // <EFBFBD>{USYt<EFBFBD><EFBFBD>Y"N1Y<EFBFBD>
if (g_DeviceLost)
{ // Y<EFBFBD>N<EFBFBD><EFBFBD>Y"N1Y-N<>Sba<62>pb` Y <EFBFBD><EFBFBD>MQ<EFBFBD><EFBFBD>e<EFBFBD><EFBFBD>"N1Y`S(uǏYCPU
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)
{ // ʑ>eGPLUS<EFBFBD>Q<EFBFBD><EFBFBD><EFBFBD>Vb__<EFBFBD>d
g_GPlusDx8->Finalize();
}
if (g_SDOADx8)
{
g_SDOADx8->Finalize();
}
/* ʑ>eGPLUS */
UnloadGPLUS();
/* ʑ>eIGW */
CloseIGW();
// Clean up everything and exit the app
Cleanup();
UnregisterClass( L"D3D Tutorial", wc.hInstance );
return 0;
}