Initial commit: ROW Client source code

Game client codebase including:
- CharacterActionControl: Character and creature management
- GlobalScript: Network, items, skills, quests, utilities
- RYLClient: Main client application with GUI and event handlers
- Engine: 3D rendering engine (RYLGL)
- MemoryManager: Custom memory allocation
- Library: Third-party dependencies (DirectX, boost, etc.)
- Tools: Development utilities

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-29 16:24:34 +09:00
commit e067522598
5135 changed files with 1745744 additions and 0 deletions

View File

@@ -0,0 +1,851 @@
//-----------------------------------------------------------------------------
// File: BumpEarth.cpp
//
// Desc: Direct3D environment mapping / bump mapping sample. The technique
// used perturbs the environment map to simulate bump mapping.
//
//
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <math.h>
#include <stdio.h>
#include <D3DX8.h>
#include "D3DApp.h"
#include "D3DFont.h"
#include "D3DUtil.h"
#include "DXUtil.h"
#include "resource.h"
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
// Vertex with 2nd set of tex coords (for bumpmapped environment map)
struct BUMPVERTEX
{
D3DXVECTOR3 p;
D3DXVECTOR3 n;
FLOAT tu1, tv1;
FLOAT tu2, tv2;
};
#define D3DFVF_BUMPVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX2)
// Converts a FLOAT to a DWORD for use in SetRenderState() calls
inline DWORD F2DW( FLOAT f ) { return *((DWORD*)&f); }
//-----------------------------------------------------------------------------
// Name: class CMyD3DApplication
// Desc: Application class. The base class (CD3DApplication) provides the
// generic functionality needed in all Direct3D samples. CMyD3DApplication
// adds functionality specific to this sample program.
//-----------------------------------------------------------------------------
class CMyD3DApplication : public CD3DApplication
{
CD3DFont* m_pFont; // A font to output text
CD3DArcBall m_ArcBall; // ArcBall used for mouse input
LPDIRECT3DTEXTURE8 m_pBlockTexture; // A blank, gray texture
LPDIRECT3DTEXTURE8 m_pEarthTexture; // The Earth texture
LPDIRECT3DTEXTURE8 m_pEnvMapTexture; // The environment map
LPDIRECT3DTEXTURE8 m_pEarthBumpTexture; // Source for the bumpmap
LPDIRECT3DTEXTURE8 m_psBumpMap; // The actual bumpmap
D3DFORMAT m_BumpMapFormat; // Bumpmap texture format
LPDIRECT3DVERTEXBUFFER8 m_pEarthVB; // Geometry for the Earth
DWORD m_dwNumSphereVertices;
BOOL m_bHighTesselation; // User options
BOOL m_bTextureOn;
BOOL m_bBumpMapOn;
BOOL m_bEnvMapOn;
BOOL m_bDeviceValidationFailed;
// Internal functions
VOID SetMenuStates();
HRESULT CreateEarthVertexBuffer();
VOID ApplyEnvironmentMap();
HRESULT InitBumpMap();
protected:
HRESULT OneTimeSceneInit();
HRESULT InitDeviceObjects();
HRESULT RestoreDeviceObjects();
HRESULT InvalidateDeviceObjects();
HRESULT DeleteDeviceObjects();
HRESULT Render();
HRESULT FrameMove();
HRESULT FinalCleanup();
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
public:
CMyD3DApplication();
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
};
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: Entry point to the program. Initializes everything, and goes into a
// message-processing loop. Idle time is used to render the scene.
//-----------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
CMyD3DApplication d3dApp;
if( FAILED( d3dApp.Create( hInst ) ) )
return 0;
return d3dApp.Run();
}
//-----------------------------------------------------------------------------
// Name: CMyD3DApplication()
// Desc: Application constructor. Sets attributes for the app.
//-----------------------------------------------------------------------------
CMyD3DApplication::CMyD3DApplication()
{
m_strWindowTitle = _T("BumpEarth: Direct3D BumpMapping Demo");
m_bUseDepthBuffer = TRUE;
m_bShowCursorWhenFullscreen = TRUE;
m_psBumpMap = NULL;
m_bTextureOn = TRUE;
m_bBumpMapOn = TRUE;
m_bEnvMapOn = TRUE;
m_bHighTesselation = TRUE;
m_pBlockTexture = NULL;
m_pEarthTexture = NULL;
m_pEarthBumpTexture = NULL;
m_pEnvMapTexture = NULL;
m_bDeviceValidationFailed = FALSE;
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
m_pEarthVB = NULL;
}
//-----------------------------------------------------------------------------
// Name: OneTimeSceneInit()
// Desc: Called during initial app startup, this function performs all the
// permanent initialization.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::OneTimeSceneInit()
{
// Set cursor to indicate that user can move the object with the mouse
#ifdef _WIN64
SetClassLongPtr( m_hWnd, GCLP_HCURSOR, (LONG_PTR)LoadCursor( NULL, IDC_SIZEALL ) );
#else
SetClassLong( m_hWnd, GCL_HCURSOR, (LONG)LoadCursor( NULL, IDC_SIZEALL ) );
#endif
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: ApplyEnvironmentMap()
// Desc: Performs a calculation on each of the vertices' normals to determine
// what the texture coordinates should be for the environment map.
//-----------------------------------------------------------------------------
VOID CMyD3DApplication::ApplyEnvironmentMap()
{
// Get the World-View(WV) matrix set
D3DXMATRIX matWorld, matView, matWorldView;
m_pd3dDevice->GetTransform( D3DTS_WORLD, &matWorld );
m_pd3dDevice->GetTransform( D3DTS_VIEW, &matView );
D3DXMatrixMultiply( &matWorldView, &matWorld, &matView );
// Lock the vertex buffer
BUMPVERTEX* vtx;
m_pEarthVB->Lock( 0, 0, (BYTE**)&vtx, 0 );
// Establish constants used in sphere generation
DWORD dwNumSphereRings = m_bHighTesselation ? 15 : 5;
DWORD dwNumSphereSegments = m_bHighTesselation ? 30 : 10;
FLOAT fDeltaRingAngle = ( D3DX_PI / dwNumSphereRings );
FLOAT fDeltaSegAngle = ( 2.0f * D3DX_PI / dwNumSphereSegments );
D3DXVECTOR4 vT;
FLOAT fScale;
// Generate the group of rings for the sphere
for( DWORD ring = 0; ring < dwNumSphereRings; ring++ )
{
FLOAT r0 = sinf( (ring+0) * fDeltaRingAngle );
FLOAT r1 = sinf( (ring+1) * fDeltaRingAngle );
FLOAT y0 = cosf( (ring+0) * fDeltaRingAngle );
FLOAT y1 = cosf( (ring+1) * fDeltaRingAngle );
// Generate the group of segments for the current ring
for( DWORD seg = 0; seg < (dwNumSphereSegments+1); seg++ )
{
FLOAT x0 = r0 * sinf( seg * fDeltaSegAngle );
FLOAT z0 = r0 * cosf( seg * fDeltaSegAngle );
FLOAT x1 = r1 * sinf( seg * fDeltaSegAngle );
FLOAT z1 = r1 * cosf( seg * fDeltaSegAngle );
// Add two vertices to the strip which makes up the sphere
// (using the transformed normal to generate texture coords)
(*vtx).p = (*vtx).n = D3DXVECTOR3(x0,y0,z0);
(*vtx).tu1 = (*vtx).tu2 = -((FLOAT)seg)/dwNumSphereSegments;
(*vtx).tv1 = (*vtx).tv2 = (ring+0)/(FLOAT)dwNumSphereRings;
D3DXVec3Transform( &vT, &(*vtx).n, &matWorldView );
fScale = 1.37f / D3DXVec4Length( &vT );
(*vtx).tu1 = 0.5f + fScale*vT.x;
(*vtx).tv1 = 0.5f - fScale*vT.y;
vtx++;
(*vtx).p = (*vtx).n = D3DXVECTOR3(x1,y1,z1);
(*vtx).tu1 = (*vtx).tu2 = -((FLOAT)seg)/dwNumSphereSegments;
(*vtx).tv1 = (*vtx).tv2 = (ring+1)/(FLOAT)dwNumSphereRings;
D3DXVec3Transform( &vT, &(*vtx).n, &matWorldView );
fScale = 1.37f / D3DXVec4Length( &vT );
(*vtx).tu1 = 0.5f + fScale*vT.x;
(*vtx).tv1 = 0.5f - fScale*vT.y;
vtx++;
}
}
m_pEarthVB->Unlock();
}
//-----------------------------------------------------------------------------
// Name: FrameMove()
// Desc: Animates the scene
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::FrameMove()
{
// Update the Earth's rotation angle
static FLOAT fRotationAngle = 0.0f;
if( FALSE == m_ArcBall.IsBeingDragged() )
fRotationAngle += m_fElapsedTime;
// Setup viewing postion from ArcBall
D3DXMATRIX matWorld;
D3DXMatrixRotationY( &matWorld, -fRotationAngle );
D3DXMatrixMultiply( &matWorld, &matWorld, m_ArcBall.GetRotationMatrix() );
D3DXMatrixMultiply( &matWorld, &matWorld, m_ArcBall.GetTranslationMatrix() );
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
D3DXMATRIX matView;
D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f, 0.0f, -3.0f );
D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
// Apply the environment map
ApplyEnvironmentMap();
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Renders the scene.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::Render()
{
DWORD dwNumPasses;
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
0x00000000, 1.0f, 0L );
if( FAILED( m_pd3dDevice->BeginScene() ) )
return S_OK; // Don't return a "fatal" error
m_pd3dDevice->SetRenderState( D3DRS_WRAP0, D3DWRAP_U | D3DWRAP_V );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
if( m_bTextureOn )
m_pd3dDevice->SetTexture( 0, m_pEarthTexture );
else
m_pd3dDevice->SetTexture( 0, m_pBlockTexture );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 1 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
if( m_bBumpMapOn && m_bEnvMapOn )
{
m_pd3dDevice->SetTexture( 1, m_psBumpMap );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1 );
if( m_BumpMapFormat == D3DFMT_V8U8 )
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_BUMPENVMAP );
else
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_BUMPENVMAPLUMINANCE );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_BUMPENVMAT00, F2DW(0.5f) );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_BUMPENVMAT01, F2DW(0.0f) );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_BUMPENVMAT10, F2DW(0.0f) );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_BUMPENVMAT11, F2DW(0.5f) );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_BUMPENVLSCALE, F2DW(4.0f) );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_BUMPENVLOFFSET, F2DW(0.0f) );
if( m_bEnvMapOn )
{
m_pd3dDevice->SetTexture( 2, m_pEnvMapTexture );
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_TEXCOORDINDEX, 0 );
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_ADD );
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLORARG2, D3DTA_CURRENT );
}
else
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
}
else
{
if( m_bEnvMapOn )
{
m_pd3dDevice->SetTexture( 1, m_pEnvMapTexture );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0 );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_ADD );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
}
else
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
}
m_pd3dDevice->SetStreamSource( 0, m_pEarthVB, sizeof(BUMPVERTEX) );
m_pd3dDevice->SetVertexShader( D3DFVF_BUMPVERTEX );
if( FAILED( m_pd3dDevice->ValidateDevice( &dwNumPasses ) ) )
{
// The right thing to do when device validation fails is to try
// a different rendering technique. This sample just warns the user.
m_bDeviceValidationFailed = TRUE;
}
else
{
m_bDeviceValidationFailed = FALSE;
}
// Finally, draw the Earth
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, m_dwNumSphereVertices-2 );
// Restore texture stage states
m_pd3dDevice->SetTexture( 0, NULL );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
// Output statistics
m_pFont->DrawText( 2, 0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );
if( m_bDeviceValidationFailed )
{
m_pFont->DrawText( 2, 40, D3DCOLOR_ARGB(255,255,0,0),
_T("Warning: Device validation failed. Rendering may not look right.") );
}
m_pd3dDevice->EndScene();
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InitBumpMap()
// Desc: Converts data from m_pEarthBumpTexture into the type of bump map requested
// as m_BumpMapFormat into m_psBumpMap.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InitBumpMap()
{
LPDIRECT3DTEXTURE8 psBumpSrc = m_pEarthBumpTexture;
D3DSURFACE_DESC d3dsd;
D3DLOCKED_RECT d3dlr;
psBumpSrc->GetLevelDesc( 0, &d3dsd );
// Create the bumpmap's surface and texture objects
if( FAILED( m_pd3dDevice->CreateTexture( d3dsd.Width, d3dsd.Height, 1, 0,
m_BumpMapFormat, D3DPOOL_MANAGED, &m_psBumpMap ) ) )
{
return E_FAIL;
}
// Fill the bits of the new texture surface with bits from
// a private format.
psBumpSrc->LockRect( 0, &d3dlr, 0, 0 );
DWORD dwSrcPitch = (DWORD)d3dlr.Pitch;
BYTE* pSrcTopRow = (BYTE*)d3dlr.pBits;
BYTE* pSrcCurRow = pSrcTopRow;
BYTE* pSrcBotRow = pSrcTopRow + (dwSrcPitch * (d3dsd.Height - 1) );
m_psBumpMap->LockRect( 0, &d3dlr, 0, 0 );
DWORD dwDstPitch = (DWORD)d3dlr.Pitch;
BYTE* pDstTopRow = (BYTE*)d3dlr.pBits;
BYTE* pDstCurRow = pDstTopRow;
BYTE* pDstBotRow = pDstTopRow + (dwDstPitch * (d3dsd.Height - 1) );
for( DWORD y=0; y<d3dsd.Height; y++ )
{
BYTE* pSrcB0; // addr of current pixel
BYTE* pSrcB1; // addr of pixel below current pixel, wrapping to top if necessary
BYTE* pSrcB2; // addr of pixel above current pixel, wrapping to bottom if necessary
BYTE* pDstT; // addr of dest pixel;
pSrcB0 = pSrcCurRow;
if( y == d3dsd.Height - 1)
pSrcB1 = pSrcTopRow;
else
pSrcB1 = pSrcCurRow + dwSrcPitch;
if( y == 0 )
pSrcB2 = pSrcBotRow;
else
pSrcB2 = pSrcCurRow - dwSrcPitch;
pDstT = pDstCurRow;
for( DWORD x=0; x<d3dsd.Width; x++ )
{
LONG v00; // Current pixel
LONG v01; // Pixel to the right of current pixel, wrapping to left edge if necessary
LONG vM1; // Pixel to the left of current pixel, wrapping to right edge if necessary
LONG v10; // Pixel one line below.
LONG v1M; // Pixel one line above.
v00 = *(pSrcB0+0);
if( x == d3dsd.Width - 1 )
v01 = *(pSrcCurRow);
else
v01 = *(pSrcB0+4);
if( x == 0 )
vM1 = *(pSrcCurRow + (4 * (d3dsd.Width - 1)));
else
vM1 = *(pSrcB0-4);
v10 = *(pSrcB1+0);
v1M = *(pSrcB2+0);
LONG iDu = (vM1-v01); // The delta-u bump value
LONG iDv = (v1M-v10); // The delta-v bump value
// The luminance bump value (land masses are less shiny)
WORD uL = ( v00>1 ) ? 63 : 127;
switch( m_BumpMapFormat )
{
case D3DFMT_V8U8:
*pDstT++ = (BYTE)iDu;
*pDstT++ = (BYTE)iDv;
break;
case D3DFMT_L6V5U5:
*(WORD*)pDstT = (WORD)( ( (iDu>>3) & 0x1f ) << 0 );
*(WORD*)pDstT |= (WORD)( ( (iDv>>3) & 0x1f ) << 5 );
*(WORD*)pDstT |= (WORD)( ( ( uL>>2) & 0x3f ) << 10 );
pDstT += 2;
break;
case D3DFMT_X8L8V8U8:
*pDstT++ = (BYTE)iDu;
*pDstT++ = (BYTE)iDv;
*pDstT++ = (BYTE)uL;
*pDstT++ = (BYTE)0L;
break;
}
// Move one pixel to the right (src is 32-bpp)
pSrcB0+=4;
pSrcB1+=4;
pSrcB2+=4;
}
// Move to the next line
pSrcCurRow += dwSrcPitch;
pDstCurRow += dwDstPitch;
}
m_psBumpMap->UnlockRect(0);
psBumpSrc->UnlockRect(0);
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InitDeviceObjects()
// Desc: Initialize scene objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InitDeviceObjects()
{
m_pFont->InitDeviceObjects( m_pd3dDevice );
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("Block.bmp"),
&m_pBlockTexture, D3DFMT_R5G6B5 ) ) )
return D3DAPPERR_MEDIANOTFOUND;
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("Earth.bmp"),
&m_pEarthTexture, D3DFMT_R5G6B5 ) ) )
return D3DAPPERR_MEDIANOTFOUND;
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("Earthbump.bmp"),
&m_pEarthBumpTexture, D3DFMT_A8R8G8B8 ) ) )
return D3DAPPERR_MEDIANOTFOUND;
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("EarthEnvMap.bmp"),
&m_pEnvMapTexture, D3DFMT_R5G6B5 ) ) )
return D3DAPPERR_MEDIANOTFOUND;
// Find out which bump map texture are supported by this device
BOOL bCanDoV8U8 = SUCCEEDED( m_pD3D->CheckDeviceFormat( m_d3dCaps.AdapterOrdinal,
m_d3dCaps.DeviceType, m_d3dsdBackBuffer.Format,
0, D3DRTYPE_TEXTURE,
D3DFMT_V8U8 ) ) &&
(m_d3dCaps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAP );
BOOL bCanDoL6V5U5 = SUCCEEDED( m_pD3D->CheckDeviceFormat( m_d3dCaps.AdapterOrdinal,
m_d3dCaps.DeviceType, m_d3dsdBackBuffer.Format,
0, D3DRTYPE_TEXTURE,
D3DFMT_L6V5U5 ) ) &&
(m_d3dCaps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAPLUMINANCE );
BOOL bCanDoL8V8U8 = SUCCEEDED( m_pD3D->CheckDeviceFormat( m_d3dCaps.AdapterOrdinal,
m_d3dCaps.DeviceType, m_d3dsdBackBuffer.Format,
0, D3DRTYPE_TEXTURE,
D3DFMT_X8L8V8U8 ) ) &&
(m_d3dCaps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAPLUMINANCE );
if( bCanDoV8U8 ) m_BumpMapFormat = D3DFMT_V8U8;
else if( bCanDoL6V5U5 ) m_BumpMapFormat = D3DFMT_L6V5U5;
else if( bCanDoL8V8U8 ) m_BumpMapFormat = D3DFMT_X8L8V8U8;
else return E_FAIL;
// Set menu states
HMENU hMenu = GetMenu( m_hWnd );
EnableMenuItem( hMenu, IDM_U8V8, bCanDoV8U8 ? MF_ENABLED : MF_GRAYED );
EnableMenuItem( hMenu, IDM_U5V5L6, bCanDoL6V5U5 ? MF_ENABLED : MF_GRAYED );
EnableMenuItem( hMenu, IDM_U8V8L8, bCanDoL8V8U8 ? MF_ENABLED : MF_GRAYED );
SetMenuStates();
// Initialize earth geometry
if( FAILED( CreateEarthVertexBuffer() ) )
return E_FAIL;
// Create and fill the bumpmap
if( FAILED( InitBumpMap() ) )
return E_FAIL;
m_bDeviceValidationFailed = FALSE;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: RestoreDeviceObjects()
// Desc: Initialize scene objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::RestoreDeviceObjects()
{
m_pFont->RestoreDeviceObjects();
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP );
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP );
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
// Get the aspect ratio
FLOAT fAspect = ((FLOAT)m_d3dsdBackBuffer.Width) / m_d3dsdBackBuffer.Height;
// Set projection matrix
D3DXMATRIX matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 0.1f, 25.0f );
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
// Set the ArcBall parameters
m_ArcBall.SetWindow( m_d3dsdBackBuffer.Width, m_d3dsdBackBuffer.Height, 3.0f );
m_ArcBall.SetRadius( 1.0f );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InvalidateDeviceObjects()
// Desc:
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
{
m_pFont->InvalidateDeviceObjects();
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DeleteDeviceObjects()
// Desc: Called when the app is exiting, or the device is being changed,
// this function deletes any device dependent objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::DeleteDeviceObjects()
{
SAFE_RELEASE( m_pBlockTexture );
SAFE_RELEASE( m_pEarthTexture );
SAFE_RELEASE( m_pEarthBumpTexture );
SAFE_RELEASE( m_pEnvMapTexture );
m_pFont->DeleteDeviceObjects();
SAFE_RELEASE( m_psBumpMap );
SAFE_RELEASE( m_pEarthVB );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: FinalCleanup()
// Desc: Called before the app exits, this function gives the app the chance
// to cleanup after itself.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::FinalCleanup()
{
SAFE_DELETE( m_pFont );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: ConfirmDevice()
// Desc: Called during device intialization, this code checks the device
// for some minimum set of capabilities
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::ConfirmDevice( D3DCAPS8* pCaps, DWORD dwBehavior,
D3DFORMAT Format )
{
if( dwBehavior & D3DCREATE_PUREDEVICE )
return E_FAIL; // GetTransform doesn't work on PUREDEVICE
// Device must be able to do bumpmapping
if( pCaps->TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAPLUMINANCE )
{
// Accept devices that can create D3DFMT_X8L8V8U8 textures
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal,
pCaps->DeviceType, Format,
0, D3DRTYPE_TEXTURE,
D3DFMT_X8L8V8U8 ) ) )
{
return S_OK;
}
// Accept devices that can create D3DFMT_L6V5U5 textures
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal,
pCaps->DeviceType, Format,
0, D3DRTYPE_TEXTURE,
D3DFMT_L6V5U5 ) ) )
{
return S_OK;
}
}
if( pCaps->TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAP )
{
// Accept devices that can create D3DFMT_V8U8 textures
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal,
pCaps->DeviceType, Format,
0, D3DRTYPE_TEXTURE,
D3DFMT_V8U8 ) ) )
{
return S_OK;
}
}
// Else, reject the device
return E_FAIL;
}
//-----------------------------------------------------------------------------
// Name: CreateEarthVertexBuffer()
// Desc: Sets up the vertices for a bump-mapped sphere.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::CreateEarthVertexBuffer()
{
SAFE_RELEASE( m_pEarthVB );
// Choose a tesselation level
DWORD dwNumSphereRings = m_bHighTesselation ? 15 : 5;
DWORD dwNumSphereSegments = m_bHighTesselation ? 30 : 10;
m_dwNumSphereVertices = 2 * dwNumSphereRings * (dwNumSphereSegments+1);
// Create the vertex buffer
if( FAILED( m_pd3dDevice->CreateVertexBuffer( m_dwNumSphereVertices*sizeof(BUMPVERTEX),
D3DUSAGE_WRITEONLY, D3DFVF_BUMPVERTEX,
D3DPOOL_MANAGED, &m_pEarthVB ) ) )
return E_FAIL;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: SetMenuStates()
// Desc:
//-----------------------------------------------------------------------------
VOID CMyD3DApplication::SetMenuStates()
{
HMENU hMenu = GetMenu( m_hWnd );
CheckMenuItem( hMenu, IDM_TEXTURETOGGLE,
m_bTextureOn ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( hMenu, IDM_BUMPMAPTOGGLE,
m_bBumpMapOn ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( hMenu, IDM_ENVMAPTOGGLE,
m_bEnvMapOn ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( hMenu, IDM_U8V8L8,
m_BumpMapFormat==D3DFMT_X8L8V8U8 ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( hMenu, IDM_U5V5L6,
m_BumpMapFormat==D3DFMT_L6V5U5 ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( hMenu, IDM_U8V8,
m_BumpMapFormat==D3DFMT_V8U8 ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( hMenu, IDM_LOW_TESSELATION,
(!m_bHighTesselation) ? MF_CHECKED : MF_UNCHECKED );
CheckMenuItem( hMenu, IDM_HIGH_TESSELATION,
m_bHighTesselation ? MF_CHECKED : MF_UNCHECKED );
}
//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: Message proc function to handle key and menu input
//-----------------------------------------------------------------------------
LRESULT CMyD3DApplication::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam )
{
// Pass mouse messages to the ArcBall so it can build internal matrices
m_ArcBall.HandleMouseMessages( hWnd, uMsg, wParam, lParam );
// Trap context menu
if( WM_CONTEXTMENU == uMsg )
return 0;
// Handle menu commands
if( WM_COMMAND == uMsg )
{
switch( LOWORD(wParam) )
{
case IDM_TEXTURETOGGLE:
m_bTextureOn = !m_bTextureOn;
break;
case IDM_BUMPMAPTOGGLE:
m_bBumpMapOn = !m_bBumpMapOn;
break;
case IDM_ENVMAPTOGGLE:
m_bEnvMapOn = !m_bEnvMapOn;
break;
case IDM_U8V8L8:
SAFE_RELEASE( m_psBumpMap );
m_BumpMapFormat = D3DFMT_X8L8V8U8;
InitBumpMap();
break;
case IDM_U5V5L6:
SAFE_RELEASE( m_psBumpMap );
m_BumpMapFormat = D3DFMT_L6V5U5;
InitBumpMap();
break;
case IDM_U8V8:
SAFE_RELEASE( m_psBumpMap );
m_BumpMapFormat = D3DFMT_V8U8;
InitBumpMap();
break;
case IDM_LOW_TESSELATION:
m_bHighTesselation = FALSE;
CreateEarthVertexBuffer();
break;
case IDM_HIGH_TESSELATION:
m_bHighTesselation = TRUE;
CreateEarthVertexBuffer();
break;
}
// Update the menus, in case any state changes occurred
SetMenuStates();
}
// Pass remaining messages to default handler
return CD3DApplication::MsgProc( hWnd, uMsg, wParam, lParam );
}

View File

@@ -0,0 +1,155 @@
# Microsoft Developer Studio Project File - Name="BumpEarth" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=BumpEarth - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "BumpEarth.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "BumpEarth.mak" CFG="BumpEarth - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "BumpEarth - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "BumpEarth - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "BumpEarth - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 d3dx8.lib d3d8.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
!ELSEIF "$(CFG)" == "BumpEarth - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 d3dx8dt.lib d3d8.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /stack:0x200000,0x200000
!ENDIF
# Begin Target
# Name "BumpEarth - Win32 Release"
# Name "BumpEarth - Win32 Debug"
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\winmain.rc
# End Source File
# End Group
# Begin Group "Common"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\common\src\d3dapp.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\common\include\d3dapp.h
# End Source File
# Begin Source File
SOURCE=..\..\..\common\src\d3dfile.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\common\include\d3dfile.h
# End Source File
# Begin Source File
SOURCE=..\..\..\common\src\d3dfont.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\common\include\d3dfont.h
# End Source File
# Begin Source File
SOURCE=..\..\..\common\src\d3dutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\common\include\d3dutil.h
# End Source File
# Begin Source File
SOURCE=..\..\..\common\src\dxutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\common\include\dxutil.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\BumpEarth.cpp
# End Source File
# Begin Source File
SOURCE=.\readme.txt
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "BumpEarth"=.\BumpEarth.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,251 @@
# Microsoft Developer Studio Generated NMAKE File, Based on BumpEarth.dsp
!IF "$(CFG)" == ""
CFG=BumpEarth - Win32 Debug
!MESSAGE No configuration specified. Defaulting to BumpEarth - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "BumpEarth - Win32 Release" && "$(CFG)" != "BumpEarth - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "BumpEarth.mak" CFG="BumpEarth - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "BumpEarth - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "BumpEarth - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
!IF "$(CFG)" == "BumpEarth - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\BumpEarth.exe"
CLEAN :
-@erase "$(INTDIR)\BumpEarth.obj"
-@erase "$(INTDIR)\d3dapp.obj"
-@erase "$(INTDIR)\d3dfile.obj"
-@erase "$(INTDIR)\d3dfont.obj"
-@erase "$(INTDIR)\d3dutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\winmain.res"
-@erase "$(OUTDIR)\BumpEarth.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "..\..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\BumpEarth.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\winmain.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\BumpEarth.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=d3dx8.lib d3d8.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\BumpEarth.pdb" /machine:I386 /out:"$(OUTDIR)\BumpEarth.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\d3dapp.obj" \
"$(INTDIR)\d3dfile.obj" \
"$(INTDIR)\d3dfont.obj" \
"$(INTDIR)\d3dutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\BumpEarth.obj" \
"$(INTDIR)\winmain.res"
"$(OUTDIR)\BumpEarth.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "BumpEarth - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\BumpEarth.exe"
CLEAN :
-@erase "$(INTDIR)\BumpEarth.obj"
-@erase "$(INTDIR)\d3dapp.obj"
-@erase "$(INTDIR)\d3dfile.obj"
-@erase "$(INTDIR)\d3dfont.obj"
-@erase "$(INTDIR)\d3dutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(INTDIR)\winmain.res"
-@erase "$(OUTDIR)\BumpEarth.exe"
-@erase "$(OUTDIR)\BumpEarth.ilk"
-@erase "$(OUTDIR)\BumpEarth.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "..\..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\BumpEarth.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\winmain.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\BumpEarth.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=d3dx8dt.lib d3d8.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\BumpEarth.pdb" /debug /machine:I386 /out:"$(OUTDIR)\BumpEarth.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\d3dapp.obj" \
"$(INTDIR)\d3dfile.obj" \
"$(INTDIR)\d3dfont.obj" \
"$(INTDIR)\d3dutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\BumpEarth.obj" \
"$(INTDIR)\winmain.res"
"$(OUTDIR)\BumpEarth.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("BumpEarth.dep")
!INCLUDE "BumpEarth.dep"
!ELSE
!MESSAGE Warning: cannot find "BumpEarth.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "BumpEarth - Win32 Release" || "$(CFG)" == "BumpEarth - Win32 Debug"
SOURCE=.\winmain.rc
"$(INTDIR)\winmain.res" : $(SOURCE) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
SOURCE=..\..\..\common\src\d3dapp.cpp
"$(INTDIR)\d3dapp.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\..\..\common\src\d3dfile.cpp
"$(INTDIR)\d3dfile.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\..\..\common\src\d3dfont.cpp
"$(INTDIR)\d3dfont.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\..\..\common\src\d3dutil.cpp
"$(INTDIR)\d3dutil.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\..\..\common\src\dxutil.cpp
"$(INTDIR)\dxutil.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=.\BumpEarth.cpp
"$(INTDIR)\BumpEarth.obj" : $(SOURCE) "$(INTDIR)"
!ENDIF

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,51 @@
//-----------------------------------------------------------------------------
// Name: BumpEarth Direct3D Sample
//
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
Description
===========
The BumpEarth program demonstrates the bump mapping capabilities of Direct3D.
Bumpmapping is a texture blending technique used to render the appearance of
rough, bumpy surfaces. This sample renders a rotating, bumpmapped planet Earth.
Note that not all cards support all features for all the various bumpmapping
techniques (some hardware has no, or limited, bumpmapping support). For more
information on bumpmapping, refer to the DirectX SDK documentation.
Path
====
Source: DXSDK\Samples\Multimedia\D3D\BumpMapping\BumpEarth
Executable: DXSDK\Samples\Multimedia\D3D\Bin
User's Guide
============
The following keys are implemented. The dropdown menus can be used for the
same controls.
<Enter> Starts and stops the scene
<Space> Advances the scene by a small increment
<F1> Shows help or available commands.
<F2> Prompts user to select a new rendering device or display mode
<Alt+Enter> Toggles between fullscreen and windowed modes
<Esc> Exits the app.
Programming Notes
=================
Bumpmapping is an advanced multitexture blending technique that can be used
to render the appearance of rough, bumpy surfaces. The bump map itself is a
texture that stores the perturbation data. Bumpmapping requires two
textures, actually. One is an environment map, which contains the lights
that you see in the scene. The other is the actual bumpmapping, which
contain values (stored as du and dv) used to "bump" the environment maps
texture coordinates. Some bumpmaps also contain luminance values to control
the "shininess" of a particular texel.
This sample makes use of common DirectX code (consisting of helper functions,
etc.) that is shared with other samples on the DirectX SDK. All common
headers and source code can be found in the following directory:
DXSDK\Samples\Multimedia\Common

View File

@@ -0,0 +1,43 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by winmain.rc
//
#define IDI_MAIN_ICON 101
#define IDR_MAIN_ACCEL 113
#define IDR_MENU 141
#define IDR_POPUP 142
#define IDD_SELECTDEVICE 144
#define IDC_DEVICE_COMBO 1000
#define IDC_MODE_COMBO 1001
#define IDC_ADAPTER_COMBO 1002
#define IDC_FULLSCREENMODES_COMBO 1003
#define IDC_MULTISAMPLE_COMBO 1005
#define IDC_WINDOWED_CHECKBOX 1012
#define IDC_FULLSCREEN_TEXT 1014
#define IDC_WINDOW 1016
#define IDC_FULLSCREEN 1018
#define IDM_CHANGEDEVICE 40002
#define IDM_TOGGLEFULLSCREEN 40003
#define IDM_TOGGLESTART 40004
#define IDM_SINGLESTEP 40005
#define IDM_EXIT 40006
#define IDM_U8V8L8 40011
#define IDM_U5V5L6 40012
#define IDM_U8V8 40013
#define IDM_TEXTURETOGGLE 40014
#define IDM_BUMPMAPTOGGLE 40015
#define IDM_ENVMAPTOGGLE 40016
#define IDM_LOW_TESSELATION 40017
#define IDM_HIGH_TESSELATION 40018
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 146
#define _APS_NEXT_COMMAND_VALUE 40019
#define _APS_NEXT_CONTROL_VALUE 1027
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif

View File

@@ -0,0 +1,192 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define IDC_STATIC -1
#include <windows.h>
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_MAIN_ICON ICON DISCARDABLE "DirectX.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define IDC_STATIC -1\r\n"
"#include <windows.h>\r\n"
"\r\n"
"\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE
BEGIN
VK_ESCAPE, IDM_EXIT, VIRTKEY, NOINVERT
VK_F2, IDM_CHANGEDEVICE, VIRTKEY, NOINVERT
VK_RETURN, IDM_TOGGLESTART, VIRTKEY, NOINVERT
VK_RETURN, IDM_TOGGLEFULLSCREEN, VIRTKEY, ALT, NOINVERT
VK_SPACE, IDM_SINGLESTEP, VIRTKEY, NOINVERT
"X", IDM_EXIT, VIRTKEY, ALT, NOINVERT
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_SELECTDEVICE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 259
TOPMARGIN, 7
BOTTOMMARGIN, 143
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_SELECTDEVICE DIALOG DISCARDABLE 0, 0, 267, 138
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select Device"
FONT 8, "MS Shell Dlg"
BEGIN
GROUPBOX "Rendering device",IDC_STATIC,5,5,200,45
LTEXT "&Adapter:",IDC_STATIC,22,17,65,10,SS_CENTERIMAGE
COMBOBOX IDC_ADAPTER_COMBO,90,15,105,100,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "&Device:",IDC_STATIC,22,32,65,10,SS_CENTERIMAGE
COMBOBOX IDC_DEVICE_COMBO,90,30,105,100,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
GROUPBOX "Rendering mode",IDC_STATIC,5,52,200,45
CONTROL "Use desktop &window",IDC_WINDOW,"Button",
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,10,62,85,15
CONTROL "&Fullscreen mode:",IDC_FULLSCREEN,"Button",
BS_AUTORADIOBUTTON,10,77,75,15
COMBOBOX IDC_FULLSCREENMODES_COMBO,90,77,105,204,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_GROUP | WS_TABSTOP
GROUPBOX "Multisample",IDC_STATIC,5,101,200,28
LTEXT "&Multisample Type:",IDC_STATIC,22,113,62,10,
SS_CENTERIMAGE
COMBOBOX IDC_MULTISAMPLE_COMBO,90,111,105,100,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,210,10,50,14
PUSHBUTTON "Cancel",IDCANCEL,210,30,50,14
END
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Go/stop\tEnter", IDM_TOGGLESTART
MENUITEM "&Single step\tSpace", IDM_SINGLESTEP
MENUITEM SEPARATOR
MENUITEM "&Change device...\tF2", IDM_CHANGEDEVICE
MENUITEM SEPARATOR
MENUITEM "E&xit\tESC", IDM_EXIT
END
POPUP "&Options"
BEGIN
MENUITEM "&Texture", IDM_TEXTURETOGGLE
MENUITEM "Toggle &Bumpmap", IDM_BUMPMAPTOGGLE
MENUITEM "Toggle &Envmap", IDM_ENVMAPTOGGLE
MENUITEM SEPARATOR
MENUITEM "Format &1: U8V8L8", IDM_U8V8L8
MENUITEM "Format &2: U5V5L6", IDM_U5V5L6
MENUITEM "Format &3: U8V8", IDM_U8V8
MENUITEM SEPARATOR
MENUITEM "&Low tesselation", IDM_LOW_TESSELATION
MENUITEM "&High tesselation", IDM_HIGH_TESSELATION
END
END
IDR_POPUP MENU DISCARDABLE
BEGIN
POPUP "Popup"
BEGIN
MENUITEM "&Go/stop", IDM_TOGGLESTART
MENUITEM "&Single step", IDM_SINGLESTEP
MENUITEM SEPARATOR
MENUITEM "&Change device...", IDM_CHANGEDEVICE
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_EXIT
END
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED