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,718 @@
//-----------------------------------------------------------------------------
// File: ShadowVolume.cpp
//
// Desc: Example code showing how to use stencil buffers to implement shadow
// volumes.
//
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <math.h>
#include <stdio.h>
#include <D3DX8.h>
#include "D3DApp.h"
#include "D3DUtil.h"
#include "D3DFile.h"
#include "D3DFont.h"
#include "DXUtil.h"
//-----------------------------------------------------------------------------
// External definitions and prototypes
//-----------------------------------------------------------------------------
inline DWORD FtoDW( FLOAT f ) { return *((DWORD*)&f); }
struct VERTEX
{
D3DXVECTOR3 p;
D3DXVECTOR3 n;
FLOAT tu, tv;
};
struct SHADOWVERTEX
{
D3DXVECTOR4 p;
D3DCOLOR color;
};
#define D3DFVF_VERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
#define D3DFVF_SHADOWVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)
//-----------------------------------------------------------------------------
// Name: struct ShadowVolume
// Desc: A shadow volume object
//-----------------------------------------------------------------------------
class ShadowVolume
{
D3DXVECTOR3 m_pVertices[32000]; // Vertex data for rendering shadow volume
DWORD m_dwNumVertices;
public:
VOID Reset() { m_dwNumVertices = 0L; }
HRESULT BuildFromMesh( LPD3DXMESH pObject, D3DXVECTOR3 vLight );
HRESULT Render( LPDIRECT3DDEVICE8 pd3dDevice );
};
//-----------------------------------------------------------------------------
// 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;
CD3DArcBall m_ArcBall;
CD3DMesh* m_pAirplane;
CD3DMesh* m_pTerrainObject;
ShadowVolume* m_pShadowVolume;
D3DXMATRIX m_matObjectMatrix;
D3DXMATRIX m_matTerrainMatrix;
LPDIRECT3DVERTEXBUFFER8 m_pBigSquareVB;
HRESULT DrawShadow();
HRESULT RenderShadow();
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
protected:
HRESULT OneTimeSceneInit();
HRESULT InitDeviceObjects();
HRESULT RestoreDeviceObjects();
HRESULT InvalidateDeviceObjects();
HRESULT DeleteDeviceObjects();
HRESULT Render();
HRESULT FrameMove();
HRESULT FinalCleanup();
public:
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
CMyD3DApplication();
};
//-----------------------------------------------------------------------------
// 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:
// Desc:
//-----------------------------------------------------------------------------
HRESULT ShadowVolume::Render( LPDIRECT3DDEVICE8 pd3dDevice )
{
pd3dDevice->SetVertexShader( D3DFVF_XYZ );
return pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, m_dwNumVertices/3,
m_pVertices, sizeof(D3DXVECTOR3) );
}
//-----------------------------------------------------------------------------
// Name: AddEdge()
// Desc: Adds an edge to a list of silohuette edges of a shadow volume.
//-----------------------------------------------------------------------------
VOID AddEdge( WORD* pEdges, DWORD& dwNumEdges, WORD v0, WORD v1 )
{
// Remove interior edges (which appear in the list twice)
for( DWORD i=0; i < dwNumEdges; i++ )
{
if( ( pEdges[2*i+0] == v0 && pEdges[2*i+1] == v1 ) ||
( pEdges[2*i+0] == v1 && pEdges[2*i+1] == v0 ) )
{
if( dwNumEdges > 1 )
{
pEdges[2*i+0] = pEdges[2*(dwNumEdges-1)+0];
pEdges[2*i+1] = pEdges[2*(dwNumEdges-1)+1];
}
dwNumEdges--;
return;
}
}
pEdges[2*dwNumEdges+0] = v0;
pEdges[2*dwNumEdges+1] = v1;
dwNumEdges++;
}
//-----------------------------------------------------------------------------
// Name: BuildFromMesh()
// Desc: Takes a mesh as input, and uses it to build a shadowvolume. The
// technique used considers each triangle of the mesh, and adds it's
// edges to a temporary list. The edge list is maintained, such that
// only silohuette edges are kept. Finally, the silohuette edges are
// extruded to make the shadow volume vertex list.
//-----------------------------------------------------------------------------
HRESULT ShadowVolume::BuildFromMesh( LPD3DXMESH pMesh, D3DXVECTOR3 vLight )
{
// Note: the MESHVERTEX format depends on the FVF of the mesh
struct MESHVERTEX { D3DXVECTOR3 p, n; FLOAT tu, tv; };
DWORD dwFVF = pMesh->GetFVF();
MESHVERTEX* pVertices;
WORD* pIndices;
// Lock the geometry buffers
pMesh->LockVertexBuffer( 0L, (BYTE**)&pVertices );
pMesh->LockIndexBuffer( 0L, (BYTE**)&pIndices );
DWORD dwNumVertices = pMesh->GetNumVertices();
DWORD dwNumFaces = pMesh->GetNumFaces();
// Allocate a temporary edge list
WORD* pEdges = new WORD[dwNumFaces*6];
DWORD dwNumEdges = 0;
// For each face
for( DWORD i=0; i<dwNumFaces; i++ )
{
WORD wFace0 = pIndices[3*i+0];
WORD wFace1 = pIndices[3*i+1];
WORD wFace2 = pIndices[3*i+2];
D3DXVECTOR3 v0 = pVertices[wFace0].p;
D3DXVECTOR3 v1 = pVertices[wFace1].p;
D3DXVECTOR3 v2 = pVertices[wFace2].p;
// Transform vertices or transform light?
D3DXVECTOR3 vNormal;
D3DXVec3Cross( &vNormal, &(v2-v1), &(v1-v0) );
if( D3DXVec3Dot( &vNormal, &vLight ) >= 0.0f )
{
AddEdge( pEdges, dwNumEdges, wFace0, wFace1 );
AddEdge( pEdges, dwNumEdges, wFace1, wFace2 );
AddEdge( pEdges, dwNumEdges, wFace2, wFace0 );
}
}
for( i=0; i<dwNumEdges; i++ )
{
D3DXVECTOR3 v1 = pVertices[pEdges[2*i+0]].p;
D3DXVECTOR3 v2 = pVertices[pEdges[2*i+1]].p;
D3DXVECTOR3 v3 = v1 - vLight*10;
D3DXVECTOR3 v4 = v2 - vLight*10;
// Add a quad (two triangles) to the vertex list
m_pVertices[m_dwNumVertices++] = v1;
m_pVertices[m_dwNumVertices++] = v2;
m_pVertices[m_dwNumVertices++] = v3;
m_pVertices[m_dwNumVertices++] = v2;
m_pVertices[m_dwNumVertices++] = v4;
m_pVertices[m_dwNumVertices++] = v3;
}
// Delete the temporary edge list
delete[] pEdges;
// Unlock the geometry buffers
pMesh->UnlockVertexBuffer();
pMesh->UnlockIndexBuffer();
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: CMyD3DApplication()
// Desc: Application constructor. Sets attributes for the app.
//-----------------------------------------------------------------------------
CMyD3DApplication::CMyD3DApplication()
{
m_strWindowTitle = _T("ShadowVolume: RealTime Shadows Using The StencilBuffer");
m_bUseDepthBuffer = TRUE;
m_dwMinDepthBits = 16;
m_dwMinStencilBits = 4;
m_bShowCursorWhenFullscreen = TRUE;
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
m_pAirplane = new CD3DMesh();
m_pTerrainObject = new CD3DMesh();
m_pShadowVolume = NULL;
m_pBigSquareVB = NULL;
}
//-----------------------------------------------------------------------------
// Name: OneTimeSceneInit()
// Desc: Called during initial app startup, this function performs all the
// permanent initialization.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::OneTimeSceneInit()
{
// Construct a shadow volume object;
m_pShadowVolume = new ShadowVolume();
// 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: FrameMove()
// Desc: Called once per frame, the call is the entry point for animating
// the scene.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::FrameMove()
{
// Setup the world spin matrix
D3DXMatrixTranslation( &m_matTerrainMatrix, 0.0f, 0.0f, 0.0f );
// Setup viewing postion from ArcBall
m_matObjectMatrix = *m_ArcBall.GetRotationMatrix();
D3DXMatrixMultiply( &m_matObjectMatrix, &m_matObjectMatrix, m_ArcBall.GetTranslationMatrix() );
// Move the light
FLOAT Lx = 5;
FLOAT Ly = 5;
FLOAT Lz = -5;
D3DLIGHT8 light;
D3DUtil_InitLight( light, D3DLIGHT_POINT, Lx, Ly, Lz );
light.Attenuation0 = 0.9f;
light.Attenuation1 = 0.0f;
m_pd3dDevice->SetLight( 0, &light );
// Transform the light vector to be in object space
D3DXVECTOR3 vLight;
D3DXMATRIX m;
D3DXMatrixInverse( &m, NULL, &m_matObjectMatrix );
vLight.x = Lx*m._11 + Ly*m._21 + Lz*m._31 + m._41;
vLight.y = Lx*m._12 + Ly*m._22 + Lz*m._32 + m._42;
vLight.z = Lx*m._13 + Ly*m._23 + Lz*m._33 + m._43;
// Build the shadow volume
m_pShadowVolume->Reset();
m_pShadowVolume->BuildFromMesh( m_pAirplane->GetSysMemMesh(), vLight );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: RenderShadow()
// Desc:
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::RenderShadow()
{
// Disable z-buffer writes (note: z-testing still occurs), and enable the
// stencil-buffer
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE );
// Dont bother with interpolating color
m_pd3dDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT );
// Set up stencil compare fuction, reference value, and masks.
// Stencil test passes if ((ref & mask) cmpfn (stencil & mask)) is true.
// Note: since we set up the stencil-test to always pass, the STENCILFAIL
// renderstate is really not needed.
m_pd3dDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS );
m_pd3dDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP );
m_pd3dDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP );
// If ztest passes, inc/decrement stencil buffer value
m_pd3dDevice->SetRenderState( D3DRS_STENCILREF, 0x1 );
m_pd3dDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff );
m_pd3dDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff );
m_pd3dDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_INCR );
// Make sure that no pixels get drawn to the frame buffer
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO );
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
// Draw front-side of shadow volume in stencil/z only
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matObjectMatrix );
m_pShadowVolume->Render( m_pd3dDevice );
// Now reverse cull order so back sides of shadow volume are written.
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
// Decrement stencil buffer value
m_pd3dDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_DECR );
// Draw back-side of shadow volume in stencil/z only
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matObjectMatrix );
m_pShadowVolume->Render( m_pd3dDevice );
// Restore render states
m_pd3dDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD );
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DrawShadow()
// Desc: Draws a big gray polygon over scene according to the mask in the
// stencil buffer. (Any pixel with stencil==1 is in the shadow.)
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::DrawShadow()
{
// Set renderstates (disable z-buffering, enable stencil, disable fog, and
// turn on alphablending)
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_FOGENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
// Only write where stencil val >= 1 (count indicates # of shadows that
// overlap that pixel)
m_pd3dDevice->SetRenderState( D3DRS_STENCILREF, 0x1 );
m_pd3dDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_LESSEQUAL );
m_pd3dDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP );
// Draw a big, gray square
m_pd3dDevice->SetVertexShader( D3DFVF_SHADOWVERTEX );
m_pd3dDevice->SetStreamSource( 0, m_pBigSquareVB, sizeof(SHADOWVERTEX) );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
// Restore render states
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_FOGENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Called once per frame, the call is the entry point for 3d
// rendering. This function sets up render states, clears the
// viewport, and renders the scene.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::Render()
{
// Clear the viewport, zbuffer, and stencil buffer
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL,
0xff0000ff, 1.0f, 0L );
// Begin the scene
if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
{
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matTerrainMatrix );
m_pTerrainObject->Render( m_pd3dDevice );
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matObjectMatrix );
m_pAirplane->Render( m_pd3dDevice );
/*
// Draw shadow volume
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matObjectMatrix );
m_pShadowVolume->Render( m_pd3dDevice );
*/
// Render the shadow volume into the stenicl buffer, then add it into
// the scene
RenderShadow();
DrawShadow();
// 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 );
// End the scene.
m_pd3dDevice->EndScene();
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InitDeviceObjects()
// Desc: Initialize scene objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InitDeviceObjects()
{
// Initialize the font's internal textures
m_pFont->InitDeviceObjects( m_pd3dDevice );
// Load an object to cast the shadow
if( FAILED( m_pAirplane->Create( m_pd3dDevice, _T("airplane 2.x") ) ) )
return D3DAPPERR_MEDIANOTFOUND;
// Load some terrain
if( FAILED( m_pTerrainObject->Create( m_pd3dDevice, _T("SeaFloor.x") ) ) )
return D3DAPPERR_MEDIANOTFOUND;
// Set a reasonable vertex type
m_pAirplane->SetFVF( m_pd3dDevice, D3DFVF_VERTEX );
m_pTerrainObject->SetFVF( m_pd3dDevice, D3DFVF_VERTEX );
// Tweak the terrain vertices
{
LPDIRECT3DVERTEXBUFFER8 pVB;
VERTEX* pVertices;
DWORD dwNumVertices = m_pTerrainObject->GetSysMemMesh()->GetNumVertices();
// Lock the vertex buffer to access the terrain geometry
m_pTerrainObject->GetSysMemMesh()->GetVertexBuffer( &pVB );
pVB->Lock( 0, 0, (BYTE**)&pVertices, 0 );
// Add some more bumpiness to the terrain object
for( DWORD i=0; i<dwNumVertices; i++ )
{
pVertices[i].p.y += 1*(rand()/(FLOAT)RAND_MAX);
pVertices[i].p.y += 2*(rand()/(FLOAT)RAND_MAX);
pVertices[i].p.y += 1*(rand()/(FLOAT)RAND_MAX);
}
// Release the vertex buffer
pVB->Unlock();
pVB->Release();
}
// Create a big square for rendering the stencilbuffer contents
if( FAILED( m_pd3dDevice->CreateVertexBuffer( 4*sizeof(SHADOWVERTEX),
D3DUSAGE_WRITEONLY, D3DFVF_SHADOWVERTEX,
D3DPOOL_MANAGED, &m_pBigSquareVB ) ) )
return E_FAIL;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: RestoreDeviceObjects()
// Desc: Restore device-memory objects and state after a device is created or
// resized.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::RestoreDeviceObjects()
{
m_pFont->RestoreDeviceObjects();
// Initialize the vertex buffers for the file-based objects
m_pAirplane->RestoreDeviceObjects( m_pd3dDevice );
m_pTerrainObject->RestoreDeviceObjects( m_pd3dDevice );
// Create and set up the shine materials w/ textures
D3DMATERIAL8 mtrl;
D3DUtil_InitMaterial( mtrl, 1.0f, 1.0f, 1.0f );
m_pd3dDevice->SetMaterial( &mtrl );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
// Set the transform matrices
D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f, 10.0f, -20.0f );
D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXMATRIX matWorld, matView, matProj;
D3DXMatrixIdentity( &matWorld );
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
FLOAT fAspect = m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 1.0f, 100.0f );
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
// Turn on fog
FLOAT fFogStart = 30.0f;
FLOAT fFogEnd = 80.0f;
m_pd3dDevice->SetRenderState( D3DRS_FOGENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_FOGCOLOR, 0xff0000ff );
m_pd3dDevice->SetRenderState( D3DRS_FOGTABLEMODE, D3DFOG_NONE );
m_pd3dDevice->SetRenderState( D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR );
m_pd3dDevice->SetRenderState( D3DRS_RANGEFOGENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_FOGSTART, FtoDW(fFogStart) );
m_pd3dDevice->SetRenderState( D3DRS_FOGEND, FtoDW(fFogEnd) );
// Set the ArcBall parameters
m_ArcBall.SetWindow( m_d3dsdBackBuffer.Width, m_d3dsdBackBuffer.Height, 2.0f );
m_ArcBall.SetRadius( 5.0f );
m_pd3dDevice->LightEnable( 0, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00303030 );
// Set the size of the big square shadow
SHADOWVERTEX* v;
FLOAT sx = (FLOAT)m_d3dsdBackBuffer.Width;
FLOAT sy = (FLOAT)m_d3dsdBackBuffer.Height;
m_pBigSquareVB->Lock( 0, 0, (BYTE**)&v, 0 );
v[0].p = D3DXVECTOR4( 0, sy, 0.0f, 1.0f );
v[1].p = D3DXVECTOR4( 0, 0, 0.0f, 1.0f );
v[2].p = D3DXVECTOR4( sx, sy, 0.0f, 1.0f );
v[3].p = D3DXVECTOR4( sx, 0, 0.0f, 1.0f );
v[0].color = 0x7f000000;
v[1].color = 0x7f000000;
v[2].color = 0x7f000000;
v[3].color = 0x7f000000;
m_pBigSquareVB->Unlock();
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InvalidateDeviceObjects()
// Desc: Called when the device-dependent objects are about to be lost.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
{
m_pFont->InvalidateDeviceObjects();
m_pAirplane->InvalidateDeviceObjects();
m_pTerrainObject->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()
{
m_pFont->DeleteDeviceObjects();
m_pAirplane->Destroy();
m_pTerrainObject->Destroy();
SAFE_RELEASE( m_pBigSquareVB );
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 );
SAFE_DELETE( m_pAirplane );
SAFE_DELETE( m_pTerrainObject );
SAFE_DELETE( m_pShadowVolume );
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 )
{
// Make sure device supports point lights
if( (dwBehavior & D3DCREATE_HARDWARE_VERTEXPROCESSING ) ||
(dwBehavior & D3DCREATE_MIXED_VERTEXPROCESSING ) )
{
if( 0 == ( pCaps->VertexProcessingCaps & D3DVTXPCAPS_POSITIONALLIGHTS ) )
return E_FAIL;
}
return S_OK;
}
//-----------------------------------------------------------------------------
// 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 the context menu
if( WM_CONTEXTMENU == uMsg )
return 0;
return CD3DApplication::MsgProc( hWnd, uMsg, wParam, lParam );
}

View File

@@ -0,0 +1,155 @@
# Microsoft Developer Studio Project File - Name="ShadowVolume" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=ShadowVolume - 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 "ShadowVolume.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 "ShadowVolume.mak" CFG="ShadowVolume - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "ShadowVolume - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "ShadowVolume - 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)" == "ShadowVolume - 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)" == "ShadowVolume - 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 "ShadowVolume - Win32 Release"
# Name "ShadowVolume - 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=.\readme.txt
# End Source File
# Begin Source File
SOURCE=.\ShadowVolume.cpp
# 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: "ShadowVolume"=.\ShadowVolume.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 ShadowVolume.dsp
!IF "$(CFG)" == ""
CFG=ShadowVolume - Win32 Debug
!MESSAGE No configuration specified. Defaulting to ShadowVolume - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "ShadowVolume - Win32 Release" && "$(CFG)" != "ShadowVolume - 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 "ShadowVolume.mak" CFG="ShadowVolume - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "ShadowVolume - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "ShadowVolume - 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)" == "ShadowVolume - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\ShadowVolume.exe"
CLEAN :
-@erase "$(INTDIR)\d3dapp.obj"
-@erase "$(INTDIR)\d3dfile.obj"
-@erase "$(INTDIR)\d3dfont.obj"
-@erase "$(INTDIR)\d3dutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\ShadowVolume.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\winmain.res"
-@erase "$(OUTDIR)\ShadowVolume.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)\ShadowVolume.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)\ShadowVolume.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)\ShadowVolume.pdb" /machine:I386 /out:"$(OUTDIR)\ShadowVolume.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\d3dapp.obj" \
"$(INTDIR)\d3dfile.obj" \
"$(INTDIR)\d3dfont.obj" \
"$(INTDIR)\d3dutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\ShadowVolume.obj" \
"$(INTDIR)\winmain.res"
"$(OUTDIR)\ShadowVolume.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "ShadowVolume - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\ShadowVolume.exe"
CLEAN :
-@erase "$(INTDIR)\d3dapp.obj"
-@erase "$(INTDIR)\d3dfile.obj"
-@erase "$(INTDIR)\d3dfont.obj"
-@erase "$(INTDIR)\d3dutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\ShadowVolume.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(INTDIR)\winmain.res"
-@erase "$(OUTDIR)\ShadowVolume.exe"
-@erase "$(OUTDIR)\ShadowVolume.ilk"
-@erase "$(OUTDIR)\ShadowVolume.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)\ShadowVolume.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)\ShadowVolume.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)\ShadowVolume.pdb" /debug /machine:I386 /out:"$(OUTDIR)\ShadowVolume.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\d3dapp.obj" \
"$(INTDIR)\d3dfile.obj" \
"$(INTDIR)\d3dfont.obj" \
"$(INTDIR)\d3dutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\ShadowVolume.obj" \
"$(INTDIR)\winmain.res"
"$(OUTDIR)\ShadowVolume.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("ShadowVolume.dep")
!INCLUDE "ShadowVolume.dep"
!ELSE
!MESSAGE Warning: cannot find "ShadowVolume.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "ShadowVolume - Win32 Release" || "$(CFG)" == "ShadowVolume - 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=.\ShadowVolume.cpp
"$(INTDIR)\ShadowVolume.obj" : $(SOURCE) "$(INTDIR)"
!ENDIF

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,75 @@
//-----------------------------------------------------------------------------
// Name: ShadowVolume Direct3D Sample
//
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
Description
===========
The ShadowVolume sample uses stencil buffers to implement real-time shadows.
In the sample, a complex object is rendered and used as a shadow-caster, to
cast real-time shadows on itself and on the terrain below.
Stencil buffers are a depth buffer technique that can be updated as
geometry is rendered, and used again as a mask for drawing more geometry.
Common effects include mirrors, shadows (an advanced technique), dissolves,
etc..
Note that not all cards support all features for all the various stencil
buffer techniques (some hardware has no, or limited, stencil buffer
support). For more information on stencil buffers, refer to the DirectX SDK
documentation.
Path
====
Source: DXSDK\Samples\Multimedia\D3D\StencilBuffer\ShadowVolume
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
=================
Real-time shadows is a fairly advanced technique. Each frame, or as the
geometry or lights in the scene are moves, an object called a shadow volume
is computed. A shadow volume is an actual 3D object which is the siholuette
of the shadowcasting object, as pretruded away from the light source.
In this sample, the 3D object which casts shadows is a bi-plane. Each frame,
the sihlouette of the plane is computed (using an edge detection algorithm,
in which sihlouette edges are found because the normals of adjacent polygons
will have opposing normals with respect to the light vector). The resulting
edge list (the sihlouette) is pretuded into a 3D object away from the light
source. This 3D object is known as the shadow volume, as everypoint inside
the volume is inside a shadow.
Next, the shadow volume is rendering into the stencil buffer twice. First,
only forward-facing polygons are rendering, and the stencil buffer values
are incremented each time. Then the back-facing polygons of the shadow
volume are drawm, decrementing values in the stencil buffer. Normally, all
incremented and decremented values would cancel each other out. However,
because the scene was already rendered with normal geometry (the plane and
the terrain, in this case), some pixels will fail the zbuffer test as the
shadowvolume is rendered. Any values left in the stencil buffer correspond
to pixels that are in the shadow.
Finally, these remaining stencil buffer contents are used as a mask, as a
large all-encompassing black quad is alpha-blended into the scene. With the
stencil buffer as a mask, only pixels in shadow are darkened
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,35 @@
//{{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
// 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 40011
#define _APS_NEXT_CONTROL_VALUE 1027
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif

View File

@@ -0,0 +1,179 @@
//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
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

View File

@@ -0,0 +1,441 @@
//-----------------------------------------------------------------------------
// File: StencilDepth.cpp
//
// Desc: Example code showing how to use stencil buffers to show the depth
// complexity of a scene.
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <D3DX8.h>
#include "D3DApp.h"
#include "D3DFile.h"
#include "D3DFont.h"
#include "D3DUtil.h"
#include "DXUtil.h"
#include "resource.h"
//-----------------------------------------------------------------------------
// 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;
BOOL m_bShowDepthComplexity;
CD3DFile* m_pFileObject;
LPDIRECT3DVERTEXBUFFER8 m_pBigSquareVB;
VOID SetStatesForRecordingDepthComplexity();
VOID ShowDepthComplexity();
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
D3DXMATRIX m_matWorldMatrix;
protected:
HRESULT OneTimeSceneInit();
HRESULT InitDeviceObjects();
HRESULT RestoreDeviceObjects();
HRESULT InvalidateDeviceObjects();
HRESULT DeleteDeviceObjects();
HRESULT Render();
HRESULT FrameMove();
HRESULT FinalCleanup();
public:
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
CMyD3DApplication();
};
//-----------------------------------------------------------------------------
// 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("StencilDepth: Displaying Depth Complexity");
m_bUseDepthBuffer = TRUE;
m_dwMinDepthBits = 16;
m_dwMinStencilBits = 4;
m_bShowDepthComplexity = TRUE;
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
m_pFileObject = new CD3DFile();
m_pBigSquareVB = NULL;
D3DXMatrixIdentity( &m_matWorldMatrix );
}
//-----------------------------------------------------------------------------
// Name: OneTimeSceneInit()
// Desc: Called during initial app startup, this function performs all the
// permanent initialization.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::OneTimeSceneInit()
{
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: FrameMove()
// Desc: Called once per frame, the call is the entry point for animating
// the scene.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::FrameMove()
{
// Setup the world spin matrix
D3DXMatrixRotationAxis( &m_matWorldMatrix, &D3DXVECTOR3(1.0f,1.0f,0.0f), m_fTime/2 );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: SetStatesForRecordingDepthComplexity()
// Desc: Turns on stencil and other states for recording the depth complexity
// during the rendering of a scene.
//-----------------------------------------------------------------------------
VOID CMyD3DApplication::SetStatesForRecordingDepthComplexity()
{
// Clear the stencil buffer
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_STENCIL, 0x0, 1.0f, 0L );
// Turn stenciling
m_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS );
m_pd3dDevice->SetRenderState( D3DRS_STENCILREF, 0 );
m_pd3dDevice->SetRenderState( D3DRS_STENCILMASK, 0x00000000 );
m_pd3dDevice->SetRenderState( D3DRS_STENCILWRITEMASK,0xffffffff );
// Increment the stencil buffer for each pixel drawn
m_pd3dDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_INCRSAT );
m_pd3dDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP );
m_pd3dDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_INCRSAT );
}
//-----------------------------------------------------------------------------
// Name: ShowDepthComplexity()
// Desc: Draws the contents of the stencil buffer in false color. Use alpha
// blending of one red, one green, and one blue rectangle to do false
// coloring of bits 1, 2, and 4 in the stencil buffer.
//-----------------------------------------------------------------------------
VOID CMyD3DApplication::ShowDepthComplexity()
{
// Turn off the buffer, and enable alpha blending
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR );
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR );
// Set up the stencil states
m_pd3dDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP );
m_pd3dDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP );
m_pd3dDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP );
m_pd3dDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_NOTEQUAL );
m_pd3dDevice->SetRenderState( D3DRS_STENCILREF, 0 );
// Set the background to black
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0L );
// Set render states for drawing a rectangle that covers the viewport.
// The color of the rectangle will be passed in D3DRS_TEXTUREFACTOR
m_pd3dDevice->SetVertexShader( D3DFVF_XYZRHW );
m_pd3dDevice->SetStreamSource( 0, m_pBigSquareVB, sizeof(D3DXVECTOR4) );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TFACTOR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
// Draw a red rectangle wherever the 1st stencil bit is set
m_pd3dDevice->SetRenderState( D3DRS_STENCILMASK, 0x01 );
m_pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, 0xffff0000 );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
// Draw a green rectangle wherever the 2nd stencil bit is set
m_pd3dDevice->SetRenderState( D3DRS_STENCILMASK, 0x02 );
m_pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, 0xff00ff00 );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
// Draw a blue rectangle wherever the 3rd stencil bit is set
m_pd3dDevice->SetRenderState( D3DRS_STENCILMASK, 0x04 );
m_pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, 0xff0000ff );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
// Restore states
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
}
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Called once per frame, the call is the entry point for 3d
// rendering. This function sets up render states, clears the
// viewport, and renders the scene.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::Render()
{
// Clear the viewport
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0x000000ff,
1.0f, 0L );
// Begin the scene
if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
{
if( m_bShowDepthComplexity )
SetStatesForRecordingDepthComplexity();
// Render the scene
m_pFileObject->Render( m_pd3dDevice, &m_matWorldMatrix );
// Show the depth complexity of the scene
if( m_bShowDepthComplexity )
ShowDepthComplexity();
// 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 );
// End the scene.
m_pd3dDevice->EndScene();
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InitDeviceObjects()
// Desc: Initialize scene objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InitDeviceObjects()
{
// Initialize the font's internal textures
m_pFont->InitDeviceObjects( m_pd3dDevice );
// Load a .X file
if( FAILED( m_pFileObject->Create( m_pd3dDevice, _T("Heli.x") ) ) )
return D3DAPPERR_MEDIANOTFOUND;
// Create a big square for rendering the stencilbuffer contents
if( FAILED( m_pd3dDevice->CreateVertexBuffer( 4*sizeof(D3DXVECTOR4),
D3DUSAGE_WRITEONLY, D3DFVF_XYZRHW,
D3DPOOL_MANAGED, &m_pBigSquareVB ) ) )
return E_FAIL;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: RestoreDeviceObjects()
// Desc: Initialize scene objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::RestoreDeviceObjects()
{
HRESULT hr;
m_pFont->RestoreDeviceObjects();
if( FAILED( hr = m_pFileObject->RestoreDeviceObjects( m_pd3dDevice ) ) )
return hr;
// Setup textures (the .X file may have textures)
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_COLORVERTEX, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00000000 );
// Set the transform matrices
D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f, 0.0f,-15.0f );
D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXMATRIX matWorld, matView, matProj;
D3DXMatrixIdentity( &m_matWorldMatrix );
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
FLOAT fAspect = m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 1.0f, 100.0f );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
// Setup a material
D3DMATERIAL8 mtrl;
D3DUtil_InitMaterial( mtrl, 1.0f, 1.0f, 1.0f );
m_pd3dDevice->SetMaterial( &mtrl );
D3DLIGHT8 light;
D3DUtil_InitLight( light, D3DLIGHT_DIRECTIONAL, 0.0f, -1.0f, 0.0f );
m_pd3dDevice->SetLight( 0, &light );
m_pd3dDevice->LightEnable( 0, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
// Resize the quad used to render the stencilbuffer contents
D3DXVECTOR4* v;
FLOAT sx = (FLOAT)m_d3dsdBackBuffer.Width;
FLOAT sy = (FLOAT)m_d3dsdBackBuffer.Height;
m_pBigSquareVB->Lock( 0, 0, (BYTE**)&v, 0 );
v[0] = D3DXVECTOR4( 0, sy, 0.0f, 1.0f );
v[1] = D3DXVECTOR4( 0, 0, 0.0f, 1.0f );
v[2] = D3DXVECTOR4( sx, sy, 0.0f, 1.0f );
v[3] = D3DXVECTOR4( sx, 0, 0.0f, 1.0f );
m_pBigSquareVB->Unlock();
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InvalidateDeviceObjects()
// Desc:
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
{
m_pFont->InvalidateDeviceObjects();
m_pFileObject->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()
{
m_pFont->DeleteDeviceObjects();
m_pFileObject->Destroy();
SAFE_RELEASE( m_pBigSquareVB );
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 );
SAFE_DELETE( m_pFileObject );
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 )
{
// Make sure device supports directional lights
if( (dwBehavior & D3DCREATE_HARDWARE_VERTEXPROCESSING ) ||
(dwBehavior & D3DCREATE_MIXED_VERTEXPROCESSING ) )
{
if( 0 == ( pCaps->VertexProcessingCaps & D3DVTXPCAPS_DIRECTIONALLIGHTS ) )
return E_FAIL;
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: Overrrides the main WndProc, so the sample can do custom message
// handling (e.g. processing mouse, keyboard, or menu commands).
//-----------------------------------------------------------------------------
LRESULT CMyD3DApplication::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam )
{
if( WM_COMMAND == uMsg )
{
switch( LOWORD(wParam) )
{
case IDM_SHOWDEPTHCOMPLEXITY:
m_bShowDepthComplexity = !m_bShowDepthComplexity;
CheckMenuItem( GetMenu(hWnd), IDM_SHOWDEPTHCOMPLEXITY,
m_bShowDepthComplexity ? MF_CHECKED : MF_UNCHECKED );
break;
}
}
return CD3DApplication::MsgProc( hWnd, uMsg, wParam, lParam );
}

View File

@@ -0,0 +1,155 @@
# Microsoft Developer Studio Project File - Name="StencilDepth" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=StencilDepth - 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 "StencilDepth.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 "StencilDepth.mak" CFG="StencilDepth - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "StencilDepth - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "StencilDepth - 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)" == "StencilDepth - 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)" == "StencilDepth - 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 "StencilDepth - Win32 Release"
# Name "StencilDepth - 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=.\readme.txt
# End Source File
# Begin Source File
SOURCE=.\StencilDepth.cpp
# 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: "StencilDepth"=.\StencilDepth.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 StencilDepth.dsp
!IF "$(CFG)" == ""
CFG=StencilDepth - Win32 Debug
!MESSAGE No configuration specified. Defaulting to StencilDepth - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "StencilDepth - Win32 Release" && "$(CFG)" != "StencilDepth - 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 "StencilDepth.mak" CFG="StencilDepth - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "StencilDepth - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "StencilDepth - 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)" == "StencilDepth - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\StencilDepth.exe"
CLEAN :
-@erase "$(INTDIR)\d3dapp.obj"
-@erase "$(INTDIR)\d3dfile.obj"
-@erase "$(INTDIR)\d3dfont.obj"
-@erase "$(INTDIR)\d3dutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\StencilDepth.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\winmain.res"
-@erase "$(OUTDIR)\StencilDepth.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)\StencilDepth.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)\StencilDepth.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)\StencilDepth.pdb" /machine:I386 /out:"$(OUTDIR)\StencilDepth.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\d3dapp.obj" \
"$(INTDIR)\d3dfile.obj" \
"$(INTDIR)\d3dfont.obj" \
"$(INTDIR)\d3dutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\StencilDepth.obj" \
"$(INTDIR)\winmain.res"
"$(OUTDIR)\StencilDepth.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "StencilDepth - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\StencilDepth.exe"
CLEAN :
-@erase "$(INTDIR)\d3dapp.obj"
-@erase "$(INTDIR)\d3dfile.obj"
-@erase "$(INTDIR)\d3dfont.obj"
-@erase "$(INTDIR)\d3dutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\StencilDepth.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(INTDIR)\winmain.res"
-@erase "$(OUTDIR)\StencilDepth.exe"
-@erase "$(OUTDIR)\StencilDepth.ilk"
-@erase "$(OUTDIR)\StencilDepth.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)\StencilDepth.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)\StencilDepth.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)\StencilDepth.pdb" /debug /machine:I386 /out:"$(OUTDIR)\StencilDepth.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\d3dapp.obj" \
"$(INTDIR)\d3dfile.obj" \
"$(INTDIR)\d3dfont.obj" \
"$(INTDIR)\d3dutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\StencilDepth.obj" \
"$(INTDIR)\winmain.res"
"$(OUTDIR)\StencilDepth.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("StencilDepth.dep")
!INCLUDE "StencilDepth.dep"
!ELSE
!MESSAGE Warning: cannot find "StencilDepth.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "StencilDepth - Win32 Release" || "$(CFG)" == "StencilDepth - 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=.\StencilDepth.cpp
"$(INTDIR)\StencilDepth.obj" : $(SOURCE) "$(INTDIR)"
!ENDIF

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,57 @@
//-----------------------------------------------------------------------------
// Name: StencilDepth Direct3D Sample
//
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
Description
===========
The StencilDepth sample uses stencil buffers to display the depth complexity
of a scene. The depth complextity of a scene is defined as the average
number of times each pixel is rendered to.
Stencil buffers are a depth buffer technique that can be updated as
geometry is rendered, and used again as a mask for drawing more geometry.
Common effects include mirrors, shadows (an advanced technique), dissolves,
etc..
Note that not all cards support all features for all the various stencil
buffer techniques (some hardware has no, or limited, stencil buffer
support). For more information on stencil buffers, refer to the DirectX SDK
documentation.
Path
====
Source: DXSDK\Samples\Multimedia\D3D\StencilBuffer\StencilDepth
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
=================
Displaying depth complexity is a valuable tool to analyze the performance of
a scene. Scenes with high amounts of overdraw could benefit from some scene
optimization, such as sorting the geometry in a front-to-back order.
Note that not all cards support all features for all the various stencil
buffer techniques (some hardware has no, or limited, stencil buffer
support). For more information on stencil buffers, refer to the DirectX SDK
documentation.
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,36 @@
//{{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_SHOWDEPTHCOMPLEXITY 40011
// 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 40012
#define _APS_NEXT_CONTROL_VALUE 1027
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif

View File

@@ -0,0 +1,184 @@
//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 "&Show &depth complexity", IDM_SHOWDEPTHCOMPLEXITY
, CHECKED
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

View File

@@ -0,0 +1,564 @@
//-----------------------------------------------------------------------------
// File: StencilMirror.cpp
//
// Desc: Example code showing how to use stencil buffers to implement planar
// mirrors.
//
// Note: This code uses the D3D Framework helper library.
//
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <math.h>
#include <D3DX8.h>
#include "D3DApp.h"
#include "D3DFile.h"
#include "D3DFont.h"
#include "D3DUtil.h"
#include "DXUtil.h"
//-----------------------------------------------------------------------------
// Custom vertex types
//-----------------------------------------------------------------------------
struct MESHVERTEX
{
D3DXVECTOR3 p;
D3DXVECTOR3 n;
FLOAT tu, tv;
};
struct MIRRORVERTEX
{
D3DXVECTOR3 p;
D3DXVECTOR3 n;
};
#define D3DFVF_MESHVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
#define D3DFVF_MIRRORVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL)
#define FOG_COLOR 0x00000080
inline DWORD FtoDW( FLOAT f ) { return *((DWORD*)&f); }
inline FLOAT HeightField( FLOAT x, FLOAT z )
{
FLOAT y = 0.0f;
y += 7.0f * cosf( 0.051f*x + 0.0f ) * sinf( 0.055f*x + 0.0f );
y += 7.0f * cosf( 0.053f*z + 0.0f ) * sinf( 0.057f*z + 0.0f );
y += 1.0f * cosf( 0.101f*x + 0.0f ) * sinf( 0.105f*x + 0.0f );
y += 1.0f * cosf( 0.103f*z + 0.0f ) * sinf( 0.107f*z + 0.0f );
y += 1.0f * cosf( 0.251f*x + 0.0f ) * sinf( 0.255f*x + 0.0f );
y += 1.0f * cosf( 0.253f*z + 0.0f ) * sinf( 0.257f*z + 0.0f );
return y;
}
//-----------------------------------------------------------------------------
// 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;
LPDIRECT3DVERTEXBUFFER8 m_pMirrorVB;
D3DMATERIAL8 m_mtrlMirrorMaterial; // Material of the mirror
D3DXMATRIX m_matMirrorMatrix; // Matrix to position mirror
CD3DFile* m_pTerrain; // X file of terrain
D3DXMATRIX m_matTerrainMatrix; // Matrix to position terrain
CD3DFile* m_pHelicopter; // X file object to render
D3DXMATRIX m_matHelicopterMatrix; // Matrix to animate X file object
HRESULT RenderScene();
HRESULT RenderMirror();
HRESULT CreateStencilBuffer();
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
protected:
HRESULT OneTimeSceneInit();
HRESULT InitDeviceObjects();
HRESULT RestoreDeviceObjects();
HRESULT InvalidateDeviceObjects();
HRESULT DeleteDeviceObjects();
HRESULT Render();
HRESULT FrameMove();
HRESULT FinalCleanup();
public:
CMyD3DApplication();
};
//-----------------------------------------------------------------------------
// 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("StencilMirror: Doing Reflections with Stencils");
m_bUseDepthBuffer = TRUE;
m_dwMinDepthBits = 16;
m_dwMinStencilBits = 4;
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
m_pTerrain = new CD3DFile();
m_pHelicopter = new CD3DFile();
m_pMirrorVB = NULL;
}
//-----------------------------------------------------------------------------
// Name: OneTimeSceneInit()
// Desc: Called during initial app startup, this function performs all the
// permanent initialization.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::OneTimeSceneInit()
{
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: FrameMove()
// Desc: Called once per frame, the call is the entry point for animating
// the scene.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::FrameMove()
{
// Position the terrain
D3DXMatrixTranslation( &m_matTerrainMatrix, 0.0f, 8.0f, 0.0f );
// Position the mirror (water polygon intersecting with terrain)
D3DXMatrixTranslation( &m_matMirrorMatrix, 0.0f, 0.0f, 0.0f );
// Position and animate the main object
FLOAT fObjectPosX = 50.0f*sinf(m_fTime/2);
FLOAT fObjectPosY = 6;
FLOAT fObjectPosZ = 10.0f*cosf(m_fTime/2);
D3DXMATRIX matRoll, matPitch, matRotate, matScale, matTranslate;
D3DXMatrixRotationZ( &matRoll, 0.2f*sinf(m_fTime/2) );
D3DXMatrixRotationY( &matRotate, m_fTime/2-D3DX_PI/2 );
D3DXMatrixRotationX( &matPitch, -0.1f * (1+cosf(m_fTime)) );
D3DXMatrixScaling( &matScale, 0.5f, 0.5f, 0.5f );
D3DXMatrixTranslation( &matTranslate, fObjectPosX, fObjectPosY, fObjectPosZ );
D3DXMatrixMultiply( &m_matHelicopterMatrix, &matScale, &matTranslate );
D3DXMatrixMultiply( &m_matHelicopterMatrix, &matRoll, &m_matHelicopterMatrix );
D3DXMatrixMultiply( &m_matHelicopterMatrix, &matRotate, &m_matHelicopterMatrix );
D3DXMatrixMultiply( &m_matHelicopterMatrix, &matPitch, &m_matHelicopterMatrix );
// Move the camera around
FLOAT fEyeX = 10.0f * sinf( m_fTime/2.0f );
FLOAT fEyeY = 3.0f * sinf( m_fTime/25.0f ) + 13.0f;
FLOAT fEyeZ = 5.0f * cosf( m_fTime/2.0f );
D3DXMATRIX matView;
D3DXVECTOR3 vEyePt = D3DXVECTOR3( fEyeX, fEyeY, fEyeZ );
D3DXVECTOR3 vLookatPt = D3DXVECTOR3( fObjectPosX, fObjectPosY, fObjectPosZ );
D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: RenderScene()
// Desc:
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::RenderScene()
{
// Render terrain
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matTerrainMatrix );
m_pTerrain->Render( m_pd3dDevice );
// Draw the mirror
m_pd3dDevice->SetTexture( 0, NULL );
m_pd3dDevice->SetMaterial( &m_mtrlMirrorMaterial );
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matMirrorMatrix );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR );
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ZERO );
m_pd3dDevice->SetVertexShader( D3DFVF_MIRRORVERTEX );
m_pd3dDevice->SetStreamSource( 0, m_pMirrorVB, sizeof(MIRRORVERTEX) );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
// Draw the object. Note: do this last, in case the object has alpha
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matHelicopterMatrix );
m_pHelicopter->Render( m_pd3dDevice );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: RenderMirror()
// Desc:
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::RenderMirror()
{
// Turn depth buffer off, and stencil buffer on
m_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS );
m_pd3dDevice->SetRenderState( D3DRS_STENCILREF, 0x1 );
m_pd3dDevice->SetRenderState( D3DRS_STENCILMASK, 0xffffffff );
m_pd3dDevice->SetRenderState( D3DRS_STENCILWRITEMASK,0xffffffff );
m_pd3dDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP );
m_pd3dDevice->SetRenderState( D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP );
m_pd3dDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_REPLACE );
// Make sure no pixels are written to the z-buffer or frame buffer
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO );
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
// Draw the reflecting surface into the stencil buffer
m_pd3dDevice->SetTexture( 0, NULL);
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matMirrorMatrix );
m_pd3dDevice->SetVertexShader( D3DFVF_MIRRORVERTEX );
m_pd3dDevice->SetStreamSource( 0, m_pMirrorVB, sizeof(MIRRORVERTEX) );
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
// Save the view matrix
D3DXMATRIX matViewSaved;
m_pd3dDevice->GetTransform( D3DTS_VIEW, &matViewSaved );
// Reflect camera in X-Z plane mirror
D3DXMATRIX matView, matReflect;
D3DXPLANE plane;
D3DXPlaneFromPointNormal( &plane, &D3DXVECTOR3(0,0,0), &D3DXVECTOR3(0,1,0) );
D3DXMatrixReflect( &matReflect, &plane );
D3DXMatrixMultiply( &matView, &matReflect, &matViewSaved );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
// Set a clip plane, so that only objects above the water are reflected
m_pd3dDevice->SetClipPlane( 0, plane );
m_pd3dDevice->SetRenderState( D3DRS_CLIPPLANEENABLE, 0x01 );
// Setup render states to a blended render scene against mask in stencil
// buffer. An important step here is to reverse the cull-order of the
// polygons, since the view matrix is being relected.
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_EQUAL );
m_pd3dDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP );
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR );
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ZERO );
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
// Clear the zbuffer (leave frame- and stencil-buffer intact)
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_ZBUFFER, 0L, 1.0f, 0L );
// Render the scene
RenderScene();
// Restore render states
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
m_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_CLIPPLANEENABLE, 0x00 );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matViewSaved );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Called once per frame, the call is the entry point for 3d
// rendering. This function sets up render states, clears the
// viewport, and renders the scene.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::Render()
{
// Clear the viewport, zbuffer, and stencil buffer
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL,
FOG_COLOR, 1.0f, 0L );
// Begin the scene
if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
{
// Render the scene
RenderScene();
// Render the reflection in the mirror
RenderMirror();
// 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 );
// End the scene.
m_pd3dDevice->EndScene();
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InitDeviceObjects()
// Desc: Initialize scene objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InitDeviceObjects()
{
// Initialize the font's internal textures
m_pFont->InitDeviceObjects( m_pd3dDevice );
// Load the main file object
if( FAILED( m_pHelicopter->Create( m_pd3dDevice, _T("Heli.x") ) ) )
return D3DAPPERR_MEDIANOTFOUND;
// Load the terrain
if( FAILED( m_pTerrain->Create( m_pd3dDevice, _T("SeaFloor.x") ) ) )
return D3DAPPERR_MEDIANOTFOUND;
// Tweak the terrain vertices to add some bumpy terrain
CD3DMesh* pMesh = m_pTerrain->FindMesh( _T("SeaFloor") );
if( pMesh )
{
// Set FVF to VertexFVF
pMesh->SetFVF( m_pd3dDevice, D3DFVF_MESHVERTEX );
// Get access to the mesh vertices
LPDIRECT3DVERTEXBUFFER8 pVB;
MESHVERTEX* pVertices;
DWORD dwNumVertices = pMesh->GetSysMemMesh()->GetNumVertices();
pMesh->GetSysMemMesh()->GetVertexBuffer( &pVB );
pVB->Lock( 0, 0, (BYTE**)&pVertices, 0 );
for( DWORD i=0; i<dwNumVertices; i++ )
{
D3DXVECTOR3 v00( pVertices[i].p.x + 0.0f, 0.0f, pVertices[i].p.z + 0.0f );
D3DXVECTOR3 v10( pVertices[i].p.x + 0.1f, 0.0f, pVertices[i].p.z + 0.0f );
D3DXVECTOR3 v01( pVertices[i].p.x + 0.0f, 0.0f, pVertices[i].p.z + 0.1f );
v00.y = HeightField( 1*v00.x, 1*v00.z );
v10.y = HeightField( 1*v10.x, 1*v10.z );
v01.y = HeightField( 1*v01.x, 1*v01.z );
D3DXVECTOR3 n;
D3DXVec3Cross( &n, &(v01-v00), &(v10-v00) );
D3DXVec3Normalize( &n, &n );
pVertices[i].p.y = v00.y;
pVertices[i].n.x = n.x;
pVertices[i].n.y = n.y;
pVertices[i].n.z = n.z;
pVertices[i].tu *= 10;
pVertices[i].tv *= 10;
}
pVB->Unlock();
pVB->Release();
}
// Create a big square for rendering the mirror
if( FAILED( m_pd3dDevice->CreateVertexBuffer( 4*sizeof(MIRRORVERTEX),
D3DUSAGE_WRITEONLY, D3DFVF_MIRRORVERTEX,
D3DPOOL_MANAGED, &m_pMirrorVB ) ) )
return E_FAIL;
MIRRORVERTEX* v;
m_pMirrorVB->Lock( 0, 0, (BYTE**)&v, 0 );
v[0].p = D3DXVECTOR3(-80.0f, 0.0f,-80.0f );
v[0].n = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
v[1].p = D3DXVECTOR3(-80.0f, 0.0f, 80.0f );
v[1].n = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
v[2].p = D3DXVECTOR3( 80.0f, 0.0f,-80.0f );
v[2].n = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
v[3].p = D3DXVECTOR3( 80.0f, 0.0f, 80.0f );
v[3].n = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
m_pMirrorVB->Unlock();
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: RestoreDeviceObjects()
// Desc: Restore device-memory objects and state after a device is created or
// resized.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::RestoreDeviceObjects()
{
m_pFont->RestoreDeviceObjects();
// Build the device objects for the file-based objecs
m_pHelicopter->RestoreDeviceObjects( m_pd3dDevice );
m_pTerrain->RestoreDeviceObjects( m_pd3dDevice );
// Set up textures
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
// Set up misc render states
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00555555 );
// Set the transform matrices
D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f, 5.5f, -15.0f );
D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 1.5f, 0.0f );
D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
D3DXMATRIX matWorld, matView, matProj;
D3DXMatrixIdentity( &matWorld );
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
FLOAT fAspect = m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 1.0f, 1000.0f );
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
// Set up a material
D3DUtil_InitMaterial( m_mtrlMirrorMaterial, 0.5f, 0.8f, 1.0f );
// Set up the light
D3DLIGHT8 light;
D3DUtil_InitLight( light, D3DLIGHT_DIRECTIONAL, 0.0f, -1.0f, 1.0f );
m_pd3dDevice->SetLight( 0, &light );
m_pd3dDevice->LightEnable( 0, TRUE );
// Turn on fog
FLOAT fFogStart = 80.0f;
FLOAT fFogEnd = 100.0f;
m_pd3dDevice->SetRenderState( D3DRS_FOGENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_FOGCOLOR, FOG_COLOR );
m_pd3dDevice->SetRenderState( D3DRS_FOGTABLEMODE, D3DFOG_NONE );
m_pd3dDevice->SetRenderState( D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR );
m_pd3dDevice->SetRenderState( D3DRS_RANGEFOGENABLE, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_FOGSTART, FtoDW(fFogStart) );
m_pd3dDevice->SetRenderState( D3DRS_FOGEND, FtoDW(fFogEnd) );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InvalidateDeviceObjects()
// Desc: Called when the device-dependent objects are about to be lost.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
{
m_pFont->InvalidateDeviceObjects();
m_pTerrain->InvalidateDeviceObjects();
m_pHelicopter->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()
{
m_pFont->DeleteDeviceObjects();
m_pTerrain->Destroy();
m_pHelicopter->Destroy();
SAFE_RELEASE( m_pMirrorVB );
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 );
SAFE_DELETE( m_pTerrain );
SAFE_DELETE( m_pHelicopter );
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
// Make sure device supports directional lights
if( (dwBehavior & D3DCREATE_HARDWARE_VERTEXPROCESSING ) ||
(dwBehavior & D3DCREATE_MIXED_VERTEXPROCESSING ) )
{
if( 0 == ( pCaps->VertexProcessingCaps & D3DVTXPCAPS_DIRECTIONALLIGHTS ) )
return E_FAIL;
}
return S_OK;
}

View File

@@ -0,0 +1,155 @@
# Microsoft Developer Studio Project File - Name="StencilMirror" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=StencilMirror - 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 "StencilMirror.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 "StencilMirror.mak" CFG="StencilMirror - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "StencilMirror - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "StencilMirror - 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)" == "StencilMirror - 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)" == "StencilMirror - 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 "StencilMirror - Win32 Release"
# Name "StencilMirror - 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=.\readme.txt
# End Source File
# Begin Source File
SOURCE=.\StencilMirror.cpp
# 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: "StencilMirror"=.\StencilMirror.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 StencilMirror.dsp
!IF "$(CFG)" == ""
CFG=StencilMirror - Win32 Debug
!MESSAGE No configuration specified. Defaulting to StencilMirror - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "StencilMirror - Win32 Release" && "$(CFG)" != "StencilMirror - 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 "StencilMirror.mak" CFG="StencilMirror - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "StencilMirror - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "StencilMirror - 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)" == "StencilMirror - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\StencilMirror.exe"
CLEAN :
-@erase "$(INTDIR)\d3dapp.obj"
-@erase "$(INTDIR)\d3dfile.obj"
-@erase "$(INTDIR)\d3dfont.obj"
-@erase "$(INTDIR)\d3dutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\StencilMirror.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\winmain.res"
-@erase "$(OUTDIR)\StencilMirror.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)\StencilMirror.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)\StencilMirror.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)\StencilMirror.pdb" /machine:I386 /out:"$(OUTDIR)\StencilMirror.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\d3dapp.obj" \
"$(INTDIR)\d3dfile.obj" \
"$(INTDIR)\d3dfont.obj" \
"$(INTDIR)\d3dutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\StencilMirror.obj" \
"$(INTDIR)\winmain.res"
"$(OUTDIR)\StencilMirror.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "StencilMirror - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\StencilMirror.exe"
CLEAN :
-@erase "$(INTDIR)\d3dapp.obj"
-@erase "$(INTDIR)\d3dfile.obj"
-@erase "$(INTDIR)\d3dfont.obj"
-@erase "$(INTDIR)\d3dutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\StencilMirror.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(INTDIR)\winmain.res"
-@erase "$(OUTDIR)\StencilMirror.exe"
-@erase "$(OUTDIR)\StencilMirror.ilk"
-@erase "$(OUTDIR)\StencilMirror.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)\StencilMirror.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)\StencilMirror.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)\StencilMirror.pdb" /debug /machine:I386 /out:"$(OUTDIR)\StencilMirror.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\d3dapp.obj" \
"$(INTDIR)\d3dfile.obj" \
"$(INTDIR)\d3dfont.obj" \
"$(INTDIR)\d3dutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\StencilMirror.obj" \
"$(INTDIR)\winmain.res"
"$(OUTDIR)\StencilMirror.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("StencilMirror.dep")
!INCLUDE "StencilMirror.dep"
!ELSE
!MESSAGE Warning: cannot find "StencilMirror.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "StencilMirror - Win32 Release" || "$(CFG)" == "StencilMirror - 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=.\StencilMirror.cpp
"$(INTDIR)\StencilMirror.obj" : $(SOURCE) "$(INTDIR)"
!ENDIF

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,54 @@
//-----------------------------------------------------------------------------
// Name: StencilMirror Direct3D Sample
//
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
Description
===========
The StencilMirror sample uses stencil buffers to implement a mirror effect.
In the sample, a watery terrain scene is rendered with the water reflecting
a helicopter that flies above.
Stencil buffers are a depth buffer technique that can be updated as
geometry is rendered, and used again as a mask for drawing more geometry.
Common effects include mirrors, shadows (an advanced technique), dissolves,
etc..
Note that not all cards support all features for all the various stencil
buffer techniques (some hardware has no, or limited, stencil buffer
support). For more information on stencil buffers, refer to the DirectX SDK
documentation.
Path
====
Source: DXSDK\Samples\Multimedia\D3D\StencilBuffer\StencilMirror
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
=================
In this sample, a stencil buffer is used to create the effect of a
reflection coming off the water. The geometry of the water is rendered into
the stencil buffer. Then, the stencil buffer is used as a mask to render the
scene again, this time with the geometry translated and rendered upside
down, to appear as if it was reflected in the mirror.
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,35 @@
//{{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
// 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 40011
#define _APS_NEXT_CONTROL_VALUE 1027
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif

View File

@@ -0,0 +1,179 @@
//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
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