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>
565
Library/dxx8/samples/Multimedia/Direct3D/Billboard/billboard.cpp
Normal file
@@ -0,0 +1,565 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Billboard.cpp
|
||||
//
|
||||
// Desc: Example code showing how to do billboarding. The sample uses
|
||||
// billboarding to draw some trees.
|
||||
//
|
||||
// Note: This implementation is for billboards that are fixed to rotate
|
||||
// about the Y-axis, which is good for things like trees. For
|
||||
// unconstrained billboards, like explosions in a flight sim, the
|
||||
// technique is the same, but the the billboards are positioned slightly
|
||||
// differently. Try using the inverse of the view matrix, TL-vertices, or
|
||||
// some other technique.
|
||||
//
|
||||
// Copyright (c) 1995-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <basetsd.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <D3DX8.h>
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFile.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defines, constants, and global variables
|
||||
//-----------------------------------------------------------------------------
|
||||
#define NUM_TREES 500
|
||||
|
||||
// Need global access to the eye direction used by the callback to sort trees
|
||||
D3DXVECTOR3 g_vDir;
|
||||
|
||||
// Simple function to define "hilliness" for terrain
|
||||
inline FLOAT HeightField( FLOAT x, FLOAT y )
|
||||
{
|
||||
return 9*(cosf(x/20+0.2f)*cosf(y/15-0.2f)+1.0f);
|
||||
}
|
||||
|
||||
// Custom vertex type for the trees
|
||||
struct TREEVERTEX
|
||||
{
|
||||
D3DXVECTOR3 p; // Vertex position
|
||||
DWORD color; // Vertex color
|
||||
FLOAT tu, tv; // Vertex texture coordinates
|
||||
};
|
||||
|
||||
#define D3DFVF_TREEVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
|
||||
|
||||
// Tree textures to use
|
||||
TCHAR* g_strTreeTextures[] =
|
||||
{
|
||||
_T("Tree02S.tga"),
|
||||
_T("Tree35S.tga"),
|
||||
_T("Tree01S.tga"),
|
||||
};
|
||||
|
||||
#define NUMTREETEXTURES 3
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: Tree
|
||||
// Desc: Simple structure to hold data for rendering a tree
|
||||
//-----------------------------------------------------------------------------
|
||||
struct Tree
|
||||
{
|
||||
TREEVERTEX v[4]; // Four corners of billboard quad
|
||||
D3DXVECTOR3 vPos; // Origin of tree
|
||||
DWORD dwTreeTexture; // Which texture map to use
|
||||
DWORD dwOffset; // Offset into vertex buffer of tree's vertices
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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; // Font for drawing text
|
||||
CD3DMesh* m_pTerrain; // Terrain object
|
||||
CD3DMesh* m_pSkyBox; // Skybox background object
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pTreeVB; // Vertex buffer for rendering a tree
|
||||
LPDIRECT3DTEXTURE8 m_pTreeTextures[NUMTREETEXTURES]; // Tree images
|
||||
D3DXMATRIX m_matBillboardMatrix; // Used for billboard orientation
|
||||
Tree m_Trees[NUM_TREES]; // Array of tree info
|
||||
|
||||
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
|
||||
HRESULT DrawBackground();
|
||||
HRESULT DrawTrees();
|
||||
|
||||
protected:
|
||||
HRESULT OneTimeSceneInit();
|
||||
HRESULT InitDeviceObjects();
|
||||
HRESULT RestoreDeviceObjects();
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
HRESULT DeleteDeviceObjects();
|
||||
HRESULT FinalCleanup();
|
||||
HRESULT Render();
|
||||
HRESULT FrameMove();
|
||||
|
||||
public:
|
||||
CMyD3DApplication();
|
||||
};
|
||||
|
||||
|
||||
CMyD3DApplication g_d3dApp;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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 )
|
||||
{
|
||||
|
||||
if( FAILED( g_d3dApp.Create( hInst ) ) )
|
||||
return 0;
|
||||
|
||||
return g_d3dApp.Run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CMyD3DApplication()
|
||||
// Desc: Application constructor. Sets attributes for the app.
|
||||
//-----------------------------------------------------------------------------
|
||||
CMyD3DApplication::CMyD3DApplication()
|
||||
{
|
||||
m_strWindowTitle = _T("Billboard: D3D Billboarding Example");
|
||||
m_bUseDepthBuffer = TRUE;
|
||||
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
m_pSkyBox = new CD3DMesh();
|
||||
m_pTerrain = new CD3DMesh();
|
||||
m_pTreeVB = NULL;
|
||||
|
||||
for( DWORD i=0; i<NUMTREETEXTURES; i++ )
|
||||
m_pTreeTextures[i] = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: OneTimeSceneInit()
|
||||
// Desc: Called during initial app startup, this function performs all the
|
||||
// permanent initialization.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::OneTimeSceneInit()
|
||||
{
|
||||
// Initialize the tree data
|
||||
for( WORD i=0; i<NUM_TREES; i++ )
|
||||
{
|
||||
// Position the trees randomly
|
||||
FLOAT fTheta = 2.0f*D3DX_PI*(FLOAT)rand()/RAND_MAX;
|
||||
FLOAT fRadius = 25.0f + 55.0f * (FLOAT)rand()/RAND_MAX;
|
||||
m_Trees[i].vPos.x = fRadius * sinf(fTheta);
|
||||
m_Trees[i].vPos.z = fRadius * cosf(fTheta);
|
||||
m_Trees[i].vPos.y = HeightField( m_Trees[i].vPos.x, m_Trees[i].vPos.z );
|
||||
|
||||
// Size the trees randomly
|
||||
FLOAT fWidth = 1.0f + 0.2f * (FLOAT)(rand()-rand())/RAND_MAX;
|
||||
FLOAT fHeight = 1.4f + 0.4f * (FLOAT)(rand()-rand())/RAND_MAX;
|
||||
|
||||
// Each tree is a random color between red and green
|
||||
DWORD r = (255-190) + (DWORD)(190*(FLOAT)(rand())/RAND_MAX);
|
||||
DWORD g = (255-190) + (DWORD)(190*(FLOAT)(rand())/RAND_MAX);
|
||||
DWORD b = 0;
|
||||
DWORD dwColor = 0xff000000 + (r<<16) + (g<<8) + (b<<0);
|
||||
|
||||
m_Trees[i].v[0].p = D3DXVECTOR3(-fWidth, 0*fHeight, 0.0f );
|
||||
m_Trees[i].v[0].color = dwColor;
|
||||
m_Trees[i].v[0].tu = 0.0f; m_Trees[i].v[0].tv = 1.0f;
|
||||
m_Trees[i].v[1].p = D3DXVECTOR3(-fWidth, 2*fHeight, 0.0f );
|
||||
m_Trees[i].v[1].color = dwColor;
|
||||
m_Trees[i].v[1].tu = 0.0f; m_Trees[i].v[1].tv = 0.0f;
|
||||
m_Trees[i].v[2].p = D3DXVECTOR3( fWidth, 0*fHeight, 0.0f );
|
||||
m_Trees[i].v[2].color = dwColor;
|
||||
m_Trees[i].v[2].tu = 1.0f; m_Trees[i].v[2].tv = 1.0f;
|
||||
m_Trees[i].v[3].p = D3DXVECTOR3( fWidth, 2*fHeight, 0.0f );
|
||||
m_Trees[i].v[3].color = dwColor;
|
||||
m_Trees[i].v[3].tu = 1.0f; m_Trees[i].v[3].tv = 0.0f;
|
||||
|
||||
// Pick a random texture for the tree
|
||||
m_Trees[i].dwTreeTexture = (DWORD)( ( NUMTREETEXTURES * rand() ) / (FLOAT)RAND_MAX );
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: TreeSortCB()
|
||||
// Desc: Callback function for sorting trees in back-to-front order
|
||||
//-----------------------------------------------------------------------------
|
||||
int TreeSortCB( const VOID* arg1, const VOID* arg2 )
|
||||
{
|
||||
Tree* p1 = (Tree*)arg1;
|
||||
Tree* p2 = (Tree*)arg2;
|
||||
|
||||
FLOAT d1 = p1->vPos.x * g_vDir.x + p1->vPos.z * g_vDir.z;
|
||||
FLOAT d2 = p2->vPos.x * g_vDir.x + p2->vPos.z * g_vDir.z;
|
||||
if (d1 < d2)
|
||||
return +1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FrameMove()
|
||||
// Desc: Called once per frame, the call is the entry point for animating
|
||||
// the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FrameMove()
|
||||
{
|
||||
// Get the eye and lookat points from the camera's path
|
||||
D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
|
||||
D3DXVECTOR3 vEyePt;
|
||||
D3DXVECTOR3 vLookatPt;
|
||||
|
||||
vEyePt.x = 30.0f*cosf( 0.8f * ( m_fTime ) );
|
||||
vEyePt.z = 30.0f*sinf( 0.8f * ( m_fTime ) );
|
||||
vEyePt.y = 4 + HeightField( vEyePt.x, vEyePt.z );
|
||||
|
||||
vLookatPt.x = 30.0f*cosf( 0.8f * ( m_fTime + 0.5f ) );
|
||||
vLookatPt.z = 30.0f*sinf( 0.8f * ( m_fTime + 0.5f ) );
|
||||
vLookatPt.y = vEyePt.y - 1.0f;
|
||||
|
||||
// Set the app view matrix for normal viewing
|
||||
D3DXMATRIX matView;
|
||||
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
|
||||
// Set up a rotation matrix to orient the billboard towards the camera.
|
||||
D3DXVECTOR3 vDir = vLookatPt - vEyePt;
|
||||
if( vDir.x > 0.0f )
|
||||
D3DXMatrixRotationY( &m_matBillboardMatrix, -atanf(vDir.z/vDir.x)+D3DX_PI/2 );
|
||||
else
|
||||
D3DXMatrixRotationY( &m_matBillboardMatrix, -atanf(vDir.z/vDir.x)-D3DX_PI/2 );
|
||||
|
||||
// Sort trees in back-to-front order
|
||||
g_vDir = vDir;
|
||||
qsort( m_Trees, NUM_TREES, sizeof(Tree), TreeSortCB );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DrawTrees()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::DrawTrees()
|
||||
{
|
||||
// Set diffuse blending for alpha set in vertices.
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
|
||||
|
||||
// Enable alpha testing (skips pixels with less than a certain alpha.)
|
||||
if( m_d3dCaps.AlphaCmpCaps & D3DPCMPCAPS_GREATEREQUAL )
|
||||
{
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ALPHAREF, 0x08 );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );
|
||||
}
|
||||
|
||||
// Loop through and render all trees
|
||||
m_pd3dDevice->SetStreamSource( 0, m_pTreeVB, sizeof(TREEVERTEX) );
|
||||
m_pd3dDevice->SetVertexShader( D3DFVF_TREEVERTEX );
|
||||
for( DWORD i=0; i<NUM_TREES; i++ )
|
||||
{
|
||||
// Set the tree texture
|
||||
m_pd3dDevice->SetTexture( 0, m_pTreeTextures[m_Trees[i].dwTreeTexture] );
|
||||
|
||||
// Translate the billboard into place
|
||||
m_matBillboardMatrix._41 = m_Trees[i].vPos.x;
|
||||
m_matBillboardMatrix._42 = m_Trees[i].vPos.y;
|
||||
m_matBillboardMatrix._43 = m_Trees[i].vPos.z;
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matBillboardMatrix );
|
||||
|
||||
// Render the billboard
|
||||
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, m_Trees[i].dwOffset, 2 );
|
||||
}
|
||||
|
||||
// Restore state
|
||||
D3DXMATRIX matWorld;
|
||||
D3DXMatrixIdentity( &matWorld );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, FALSE );
|
||||
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
|
||||
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0L );
|
||||
|
||||
// Begin the scene
|
||||
if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
|
||||
{
|
||||
// Render the Skybox
|
||||
{
|
||||
// Center view matrix for skybox and disable zbuffer
|
||||
D3DXMATRIX matView, matViewSave;
|
||||
m_pd3dDevice->GetTransform( D3DTS_VIEW, &matViewSave );
|
||||
matView = matViewSave;
|
||||
matView._41 = 0.0f; matView._42 = -0.3f; matView._43 = 0.0f;
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
|
||||
// Some cards do not disable writing to Z when
|
||||
// D3DRS_ZENABLE is FALSE. So do it explicitly
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
|
||||
|
||||
// Render the skybox
|
||||
m_pSkyBox->Render( m_pd3dDevice );
|
||||
|
||||
// Restore the render states
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matViewSave );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE);
|
||||
}
|
||||
|
||||
// Draw the terrain
|
||||
m_pTerrain->Render( m_pd3dDevice );
|
||||
|
||||
// Draw the trees
|
||||
DrawTrees();
|
||||
|
||||
// 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: This creates all device-dependent managed objects, such as managed
|
||||
// textures and managed vertex buffers.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
// Initialize the font's internal textures
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// Create the tree textures
|
||||
for( DWORD i=0; i<NUMTREETEXTURES; i++ )
|
||||
{
|
||||
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, g_strTreeTextures[i],
|
||||
&m_pTreeTextures[i] ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
}
|
||||
|
||||
// Create a quad for rendering each tree
|
||||
if( FAILED( m_pd3dDevice->CreateVertexBuffer( NUM_TREES*4*sizeof(TREEVERTEX),
|
||||
D3DUSAGE_WRITEONLY, D3DFVF_TREEVERTEX,
|
||||
D3DPOOL_MANAGED, &m_pTreeVB ) ) )
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Copy tree mesh data into vertexbuffer
|
||||
TREEVERTEX* v;
|
||||
m_pTreeVB->Lock( 0, 0, (BYTE**)&v, 0 );
|
||||
|
||||
INT iTree;
|
||||
DWORD dwOffset = 0;
|
||||
for( iTree = 0; iTree < NUM_TREES; iTree++ )
|
||||
{
|
||||
memcpy( &v[dwOffset], m_Trees[iTree].v, 4*sizeof(TREEVERTEX) );
|
||||
m_Trees[iTree].dwOffset = dwOffset;
|
||||
dwOffset += 4;
|
||||
}
|
||||
|
||||
m_pTreeVB->Unlock();
|
||||
|
||||
// Load the skybox
|
||||
if( FAILED( m_pSkyBox->Create( m_pd3dDevice, _T("SkyBox2.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
|
||||
// Load the terrain
|
||||
if( FAILED( m_pTerrain->Create( m_pd3dDevice, _T("SeaFloor.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
|
||||
// Add some "hilliness" to the terrain
|
||||
LPDIRECT3DVERTEXBUFFER8 pVB;
|
||||
if( SUCCEEDED( m_pTerrain->GetSysMemMesh()->GetVertexBuffer( &pVB ) ) )
|
||||
{
|
||||
struct VERTEX { FLOAT x,y,z,tu,tv; };
|
||||
VERTEX* pVertices;
|
||||
DWORD dwNumVertices = m_pTerrain->GetSysMemMesh()->GetNumVertices();
|
||||
|
||||
pVB->Lock( 0, 0, (BYTE**)&pVertices, 0 );
|
||||
|
||||
for( DWORD i=0; i<dwNumVertices; i++ )
|
||||
pVertices[i].y = HeightField( pVertices[i].x, pVertices[i].z );
|
||||
|
||||
pVB->Unlock();
|
||||
pVB->Release();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Restore device-memory objects and state after a device is created or
|
||||
// resized.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
// Restore the device objects for the meshes and fonts
|
||||
m_pTerrain->RestoreDeviceObjects( m_pd3dDevice );
|
||||
m_pSkyBox->RestoreDeviceObjects( m_pd3dDevice );
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
|
||||
// Set the transform matrices (view and world are updated per frame)
|
||||
D3DXMATRIX matProj;
|
||||
FLOAT fAspect = m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;
|
||||
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 1.0f, 100.0f );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
||||
|
||||
// Set up the default texture states
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP );
|
||||
|
||||
m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc: Called when the device-dependent objects are about to be lost.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pTerrain->InvalidateDeviceObjects();
|
||||
m_pSkyBox->InvalidateDeviceObjects();
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DeleteDeviceObjects()
|
||||
// Desc: Called when the app is exiting, or the device is being changed,
|
||||
// this function deletes any device dependent objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::DeleteDeviceObjects()
|
||||
{
|
||||
m_pFont->DeleteDeviceObjects();
|
||||
|
||||
m_pTerrain->Destroy();
|
||||
m_pSkyBox->Destroy();
|
||||
|
||||
for( DWORD i=0; i<NUMTREETEXTURES; i++ )
|
||||
SAFE_RELEASE( m_pTreeTextures[i] );
|
||||
|
||||
SAFE_RELEASE( m_pTreeVB )
|
||||
|
||||
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_pSkyBox );
|
||||
|
||||
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
|
||||
|
||||
// This sample uses alpha textures and/or straight alpha. Make sure the
|
||||
// device supports them
|
||||
if( pCaps->TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE )
|
||||
return S_OK;
|
||||
if( pCaps->TextureCaps & D3DPTEXTURECAPS_ALPHA )
|
||||
return S_OK;
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
159
Library/dxx8/samples/Multimedia/Direct3D/Billboard/billboard.dsp
Normal file
@@ -0,0 +1,159 @@
|
||||
# Microsoft Developer Studio Project File - Name="billboard" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=billboard - Win32 Release
|
||||
!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 "billboard.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 "billboard.mak" CFG="billboard - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "billboard - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "billboard - 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)" == "billboard - 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" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /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 winmm.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\framework\lib" /stack:0x200000,0x200000
|
||||
|
||||
!ELSEIF "$(CFG)" == "billboard - 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" /YX /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /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
|
||||
# ADD LINK32 d3dx8dt.lib d3d8.lib d3dxof.lib winmm.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386 /libpath:"..\..\framework\lib" /stack:0x200000,0x200000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "billboard - Win32 Release"
|
||||
# Name "billboard - Win32 Debug"
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DirectX.ico
|
||||
# End Source File
|
||||
# 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=.\billboard.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "billboard"=.\billboard.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
251
Library/dxx8/samples/Multimedia/Direct3D/Billboard/billboard.mak
Normal file
@@ -0,0 +1,251 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on billboard.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=billboard - Win32 Release
|
||||
!MESSAGE No configuration specified. Defaulting to billboard - Win32 Release.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "billboard - Win32 Release" && "$(CFG)" != "billboard - 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 "billboard.mak" CFG="billboard - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "billboard - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "billboard - 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)" == "billboard - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\billboard.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\billboard.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\billboard.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 "_AFXDLL" /Fp"$(INTDIR)\billboard.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)\billboard.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8.lib d3d8.lib d3dxof.lib winmm.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\billboard.pdb" /machine:I386 /out:"$(OUTDIR)\billboard.exe" /libpath:"..\..\framework\lib" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\billboard.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\billboard.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "billboard - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\billboard.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\billboard.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\billboard.exe"
|
||||
-@erase "$(OUTDIR)\billboard.ilk"
|
||||
-@erase "$(OUTDIR)\billboard.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" /Fp"$(INTDIR)\billboard.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)\billboard.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8dt.lib d3d8.lib d3dxof.lib winmm.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\billboard.pdb" /debug /machine:I386 /out:"$(OUTDIR)\billboard.exe" /libpath:"..\..\framework\lib" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\billboard.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\billboard.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("billboard.dep")
|
||||
!INCLUDE "billboard.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "billboard.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "billboard - Win32 Release" || "$(CFG)" == "billboard - 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=.\billboard.cpp
|
||||
|
||||
"$(INTDIR)\billboard.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
BIN
Library/dxx8/samples/Multimedia/Direct3D/Billboard/directx.ico
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,62 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: Billboard Direct3D Sample
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
The Billboard sample illustrates the billboarding technique. Rather than
|
||||
rendering complex 3D models (such as a high-polygon tree model),
|
||||
billboarding renders a 2D image of the model and rotates it to always face
|
||||
the eyepoint. This technique is commonly used to render trees, clouds,
|
||||
smoke, explosions, and more. For more information, see
|
||||
Common Techniques and Special Effects.
|
||||
|
||||
The sample has a camera fly around a 3D scene with a tree-covered hill. The
|
||||
trees look like 3D objects, but they are actually 2-D billboarded images
|
||||
that are rotated towards the eye point. The hilly terrain and the skybox
|
||||
(6-sided cube containing sky textures) are just objects loaded from .x
|
||||
files, used for visual effect, and are unrelated to the billboarding
|
||||
technique.
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\D3D\Billboard
|
||||
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
|
||||
=================
|
||||
The billboarding technique is the focus of this sample. Each frame, the
|
||||
camera is moved, so the viewpoint changes accordingly. As the viewpoint
|
||||
changes, a rotation matrix is generated to rotate the billboards about
|
||||
the y-axis so that they face the new viewpoint. The computation of the
|
||||
billboard matrix occurs in the FrameMove() function. The trees are also
|
||||
sorted in that function, as required for proper alpha blanding, since
|
||||
billboards typically have some transparent pixels. The trees are
|
||||
rendered from a vertex buffer in the DrawTrees() function.
|
||||
|
||||
Note that the billboards in this sample are constrained to rotate about the
|
||||
y-axis only, as otherwise the tree trunks would appear to not be fixed to
|
||||
the ground. In a 3D flight sim or space shooter, for effects like
|
||||
explosions, billboards are typically not constrained to one axis.
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
179
Library/dxx8/samples/Multimedia/Direct3D/Billboard/winmain.rc
Normal 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, 131
|
||||
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
|
||||
|
||||
@@ -0,0 +1,851 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: BumpEarth.cpp
|
||||
//
|
||||
// Desc: Direct3D environment mapping / bump mapping sample. The technique
|
||||
// used perturbs the environment map to simulate bump mapping.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <D3DX8.h>
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defines, constants, and global variables
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Vertex with 2nd set of tex coords (for bumpmapped environment map)
|
||||
struct BUMPVERTEX
|
||||
{
|
||||
D3DXVECTOR3 p;
|
||||
D3DXVECTOR3 n;
|
||||
FLOAT tu1, tv1;
|
||||
FLOAT tu2, tv2;
|
||||
};
|
||||
|
||||
#define D3DFVF_BUMPVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX2)
|
||||
|
||||
// Converts a FLOAT to a DWORD for use in SetRenderState() calls
|
||||
inline DWORD F2DW( FLOAT f ) { return *((DWORD*)&f); }
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CMyD3DApplication
|
||||
// Desc: Application class. The base class (CD3DApplication) provides the
|
||||
// generic functionality needed in all Direct3D samples. CMyD3DApplication
|
||||
// adds functionality specific to this sample program.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMyD3DApplication : public CD3DApplication
|
||||
{
|
||||
CD3DFont* m_pFont; // A font to output text
|
||||
|
||||
CD3DArcBall m_ArcBall; // ArcBall used for mouse input
|
||||
|
||||
LPDIRECT3DTEXTURE8 m_pBlockTexture; // A blank, gray texture
|
||||
LPDIRECT3DTEXTURE8 m_pEarthTexture; // The Earth texture
|
||||
LPDIRECT3DTEXTURE8 m_pEnvMapTexture; // The environment map
|
||||
LPDIRECT3DTEXTURE8 m_pEarthBumpTexture; // Source for the bumpmap
|
||||
LPDIRECT3DTEXTURE8 m_psBumpMap; // The actual bumpmap
|
||||
|
||||
D3DFORMAT m_BumpMapFormat; // Bumpmap texture format
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pEarthVB; // Geometry for the Earth
|
||||
DWORD m_dwNumSphereVertices;
|
||||
|
||||
BOOL m_bHighTesselation; // User options
|
||||
BOOL m_bTextureOn;
|
||||
BOOL m_bBumpMapOn;
|
||||
BOOL m_bEnvMapOn;
|
||||
BOOL m_bDeviceValidationFailed;
|
||||
|
||||
// Internal functions
|
||||
VOID SetMenuStates();
|
||||
HRESULT CreateEarthVertexBuffer();
|
||||
VOID ApplyEnvironmentMap();
|
||||
HRESULT InitBumpMap();
|
||||
|
||||
protected:
|
||||
HRESULT OneTimeSceneInit();
|
||||
HRESULT InitDeviceObjects();
|
||||
HRESULT RestoreDeviceObjects();
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
HRESULT DeleteDeviceObjects();
|
||||
HRESULT Render();
|
||||
HRESULT FrameMove();
|
||||
HRESULT FinalCleanup();
|
||||
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
|
||||
|
||||
public:
|
||||
CMyD3DApplication();
|
||||
|
||||
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: WinMain()
|
||||
// Desc: Entry point to the program. Initializes everything, and goes into a
|
||||
// message-processing loop. Idle time is used to render the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
|
||||
{
|
||||
CMyD3DApplication d3dApp;
|
||||
|
||||
if( FAILED( d3dApp.Create( hInst ) ) )
|
||||
return 0;
|
||||
|
||||
return d3dApp.Run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CMyD3DApplication()
|
||||
// Desc: Application constructor. Sets attributes for the app.
|
||||
//-----------------------------------------------------------------------------
|
||||
CMyD3DApplication::CMyD3DApplication()
|
||||
{
|
||||
m_strWindowTitle = _T("BumpEarth: Direct3D BumpMapping Demo");
|
||||
m_bUseDepthBuffer = TRUE;
|
||||
m_bShowCursorWhenFullscreen = TRUE;
|
||||
|
||||
m_psBumpMap = NULL;
|
||||
m_bTextureOn = TRUE;
|
||||
m_bBumpMapOn = TRUE;
|
||||
m_bEnvMapOn = TRUE;
|
||||
m_bHighTesselation = TRUE;
|
||||
|
||||
m_pBlockTexture = NULL;
|
||||
m_pEarthTexture = NULL;
|
||||
m_pEarthBumpTexture = NULL;
|
||||
m_pEnvMapTexture = NULL;
|
||||
m_bDeviceValidationFailed = FALSE;
|
||||
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
m_pEarthVB = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: OneTimeSceneInit()
|
||||
// Desc: Called during initial app startup, this function performs all the
|
||||
// permanent initialization.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::OneTimeSceneInit()
|
||||
{
|
||||
// Set cursor to indicate that user can move the object with the mouse
|
||||
#ifdef _WIN64
|
||||
SetClassLongPtr( m_hWnd, GCLP_HCURSOR, (LONG_PTR)LoadCursor( NULL, IDC_SIZEALL ) );
|
||||
#else
|
||||
SetClassLong( m_hWnd, GCL_HCURSOR, (LONG)LoadCursor( NULL, IDC_SIZEALL ) );
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ApplyEnvironmentMap()
|
||||
// Desc: Performs a calculation on each of the vertices' normals to determine
|
||||
// what the texture coordinates should be for the environment map.
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID CMyD3DApplication::ApplyEnvironmentMap()
|
||||
{
|
||||
// Get the World-View(WV) matrix set
|
||||
D3DXMATRIX matWorld, matView, matWorldView;
|
||||
m_pd3dDevice->GetTransform( D3DTS_WORLD, &matWorld );
|
||||
m_pd3dDevice->GetTransform( D3DTS_VIEW, &matView );
|
||||
D3DXMatrixMultiply( &matWorldView, &matWorld, &matView );
|
||||
|
||||
// Lock the vertex buffer
|
||||
BUMPVERTEX* vtx;
|
||||
m_pEarthVB->Lock( 0, 0, (BYTE**)&vtx, 0 );
|
||||
|
||||
// Establish constants used in sphere generation
|
||||
DWORD dwNumSphereRings = m_bHighTesselation ? 15 : 5;
|
||||
DWORD dwNumSphereSegments = m_bHighTesselation ? 30 : 10;
|
||||
FLOAT fDeltaRingAngle = ( D3DX_PI / dwNumSphereRings );
|
||||
FLOAT fDeltaSegAngle = ( 2.0f * D3DX_PI / dwNumSphereSegments );
|
||||
|
||||
D3DXVECTOR4 vT;
|
||||
FLOAT fScale;
|
||||
|
||||
// Generate the group of rings for the sphere
|
||||
for( DWORD ring = 0; ring < dwNumSphereRings; ring++ )
|
||||
{
|
||||
FLOAT r0 = sinf( (ring+0) * fDeltaRingAngle );
|
||||
FLOAT r1 = sinf( (ring+1) * fDeltaRingAngle );
|
||||
FLOAT y0 = cosf( (ring+0) * fDeltaRingAngle );
|
||||
FLOAT y1 = cosf( (ring+1) * fDeltaRingAngle );
|
||||
|
||||
// Generate the group of segments for the current ring
|
||||
for( DWORD seg = 0; seg < (dwNumSphereSegments+1); seg++ )
|
||||
{
|
||||
FLOAT x0 = r0 * sinf( seg * fDeltaSegAngle );
|
||||
FLOAT z0 = r0 * cosf( seg * fDeltaSegAngle );
|
||||
FLOAT x1 = r1 * sinf( seg * fDeltaSegAngle );
|
||||
FLOAT z1 = r1 * cosf( seg * fDeltaSegAngle );
|
||||
|
||||
// Add two vertices to the strip which makes up the sphere
|
||||
// (using the transformed normal to generate texture coords)
|
||||
(*vtx).p = (*vtx).n = D3DXVECTOR3(x0,y0,z0);
|
||||
(*vtx).tu1 = (*vtx).tu2 = -((FLOAT)seg)/dwNumSphereSegments;
|
||||
(*vtx).tv1 = (*vtx).tv2 = (ring+0)/(FLOAT)dwNumSphereRings;
|
||||
D3DXVec3Transform( &vT, &(*vtx).n, &matWorldView );
|
||||
fScale = 1.37f / D3DXVec4Length( &vT );
|
||||
(*vtx).tu1 = 0.5f + fScale*vT.x;
|
||||
(*vtx).tv1 = 0.5f - fScale*vT.y;
|
||||
vtx++;
|
||||
|
||||
(*vtx).p = (*vtx).n = D3DXVECTOR3(x1,y1,z1);
|
||||
(*vtx).tu1 = (*vtx).tu2 = -((FLOAT)seg)/dwNumSphereSegments;
|
||||
(*vtx).tv1 = (*vtx).tv2 = (ring+1)/(FLOAT)dwNumSphereRings;
|
||||
D3DXVec3Transform( &vT, &(*vtx).n, &matWorldView );
|
||||
fScale = 1.37f / D3DXVec4Length( &vT );
|
||||
(*vtx).tu1 = 0.5f + fScale*vT.x;
|
||||
(*vtx).tv1 = 0.5f - fScale*vT.y;
|
||||
vtx++;
|
||||
}
|
||||
}
|
||||
|
||||
m_pEarthVB->Unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FrameMove()
|
||||
// Desc: Animates the scene
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FrameMove()
|
||||
{
|
||||
// Update the Earth's rotation angle
|
||||
static FLOAT fRotationAngle = 0.0f;
|
||||
if( FALSE == m_ArcBall.IsBeingDragged() )
|
||||
fRotationAngle += m_fElapsedTime;
|
||||
|
||||
// Setup viewing postion from ArcBall
|
||||
D3DXMATRIX matWorld;
|
||||
D3DXMatrixRotationY( &matWorld, -fRotationAngle );
|
||||
D3DXMatrixMultiply( &matWorld, &matWorld, m_ArcBall.GetRotationMatrix() );
|
||||
D3DXMatrixMultiply( &matWorld, &matWorld, m_ArcBall.GetTranslationMatrix() );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
|
||||
D3DXMATRIX matView;
|
||||
D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f, 0.0f, -3.0f );
|
||||
D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
|
||||
// Apply the environment map
|
||||
ApplyEnvironmentMap();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: Render()
|
||||
// Desc: Renders the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::Render()
|
||||
{
|
||||
DWORD dwNumPasses;
|
||||
|
||||
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
|
||||
0x00000000, 1.0f, 0L );
|
||||
|
||||
if( FAILED( m_pd3dDevice->BeginScene() ) )
|
||||
return S_OK; // Don't return a "fatal" error
|
||||
|
||||
m_pd3dDevice->SetRenderState( D3DRS_WRAP0, D3DWRAP_U | D3DWRAP_V );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
|
||||
|
||||
if( m_bTextureOn )
|
||||
m_pd3dDevice->SetTexture( 0, m_pEarthTexture );
|
||||
else
|
||||
m_pd3dDevice->SetTexture( 0, m_pBlockTexture );
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 1 );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
|
||||
|
||||
if( m_bBumpMapOn && m_bEnvMapOn )
|
||||
{
|
||||
m_pd3dDevice->SetTexture( 1, m_psBumpMap );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1 );
|
||||
if( m_BumpMapFormat == D3DFMT_V8U8 )
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_BUMPENVMAP );
|
||||
else
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_BUMPENVMAPLUMINANCE );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_BUMPENVMAT00, F2DW(0.5f) );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_BUMPENVMAT01, F2DW(0.0f) );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_BUMPENVMAT10, F2DW(0.0f) );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_BUMPENVMAT11, F2DW(0.5f) );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_BUMPENVLSCALE, F2DW(4.0f) );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_BUMPENVLOFFSET, F2DW(0.0f) );
|
||||
|
||||
if( m_bEnvMapOn )
|
||||
{
|
||||
m_pd3dDevice->SetTexture( 2, m_pEnvMapTexture );
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_TEXCOORDINDEX, 0 );
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_ADD );
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLORARG2, D3DTA_CURRENT );
|
||||
}
|
||||
else
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_bEnvMapOn )
|
||||
{
|
||||
m_pd3dDevice->SetTexture( 1, m_pEnvMapTexture );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0 );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_ADD );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
|
||||
}
|
||||
else
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
|
||||
}
|
||||
|
||||
m_pd3dDevice->SetStreamSource( 0, m_pEarthVB, sizeof(BUMPVERTEX) );
|
||||
m_pd3dDevice->SetVertexShader( D3DFVF_BUMPVERTEX );
|
||||
|
||||
if( FAILED( m_pd3dDevice->ValidateDevice( &dwNumPasses ) ) )
|
||||
{
|
||||
// The right thing to do when device validation fails is to try
|
||||
// a different rendering technique. This sample just warns the user.
|
||||
m_bDeviceValidationFailed = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bDeviceValidationFailed = FALSE;
|
||||
}
|
||||
|
||||
// Finally, draw the Earth
|
||||
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, m_dwNumSphereVertices-2 );
|
||||
|
||||
// Restore texture stage states
|
||||
m_pd3dDevice->SetTexture( 0, NULL );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
|
||||
|
||||
// Output statistics
|
||||
m_pFont->DrawText( 2, 0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
|
||||
m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );
|
||||
|
||||
if( m_bDeviceValidationFailed )
|
||||
{
|
||||
m_pFont->DrawText( 2, 40, D3DCOLOR_ARGB(255,255,0,0),
|
||||
_T("Warning: Device validation failed. Rendering may not look right.") );
|
||||
}
|
||||
|
||||
m_pd3dDevice->EndScene();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitBumpMap()
|
||||
// Desc: Converts data from m_pEarthBumpTexture into the type of bump map requested
|
||||
// as m_BumpMapFormat into m_psBumpMap.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitBumpMap()
|
||||
{
|
||||
LPDIRECT3DTEXTURE8 psBumpSrc = m_pEarthBumpTexture;
|
||||
D3DSURFACE_DESC d3dsd;
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
|
||||
psBumpSrc->GetLevelDesc( 0, &d3dsd );
|
||||
// Create the bumpmap's surface and texture objects
|
||||
if( FAILED( m_pd3dDevice->CreateTexture( d3dsd.Width, d3dsd.Height, 1, 0,
|
||||
m_BumpMapFormat, D3DPOOL_MANAGED, &m_psBumpMap ) ) )
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Fill the bits of the new texture surface with bits from
|
||||
// a private format.
|
||||
psBumpSrc->LockRect( 0, &d3dlr, 0, 0 );
|
||||
DWORD dwSrcPitch = (DWORD)d3dlr.Pitch;
|
||||
BYTE* pSrcTopRow = (BYTE*)d3dlr.pBits;
|
||||
BYTE* pSrcCurRow = pSrcTopRow;
|
||||
BYTE* pSrcBotRow = pSrcTopRow + (dwSrcPitch * (d3dsd.Height - 1) );
|
||||
|
||||
m_psBumpMap->LockRect( 0, &d3dlr, 0, 0 );
|
||||
DWORD dwDstPitch = (DWORD)d3dlr.Pitch;
|
||||
BYTE* pDstTopRow = (BYTE*)d3dlr.pBits;
|
||||
BYTE* pDstCurRow = pDstTopRow;
|
||||
BYTE* pDstBotRow = pDstTopRow + (dwDstPitch * (d3dsd.Height - 1) );
|
||||
|
||||
for( DWORD y=0; y<d3dsd.Height; y++ )
|
||||
{
|
||||
BYTE* pSrcB0; // addr of current pixel
|
||||
BYTE* pSrcB1; // addr of pixel below current pixel, wrapping to top if necessary
|
||||
BYTE* pSrcB2; // addr of pixel above current pixel, wrapping to bottom if necessary
|
||||
BYTE* pDstT; // addr of dest pixel;
|
||||
|
||||
pSrcB0 = pSrcCurRow;
|
||||
|
||||
if( y == d3dsd.Height - 1)
|
||||
pSrcB1 = pSrcTopRow;
|
||||
else
|
||||
pSrcB1 = pSrcCurRow + dwSrcPitch;
|
||||
|
||||
if( y == 0 )
|
||||
pSrcB2 = pSrcBotRow;
|
||||
else
|
||||
pSrcB2 = pSrcCurRow - dwSrcPitch;
|
||||
|
||||
pDstT = pDstCurRow;
|
||||
|
||||
for( DWORD x=0; x<d3dsd.Width; x++ )
|
||||
{
|
||||
LONG v00; // Current pixel
|
||||
LONG v01; // Pixel to the right of current pixel, wrapping to left edge if necessary
|
||||
LONG vM1; // Pixel to the left of current pixel, wrapping to right edge if necessary
|
||||
LONG v10; // Pixel one line below.
|
||||
LONG v1M; // Pixel one line above.
|
||||
|
||||
v00 = *(pSrcB0+0);
|
||||
|
||||
if( x == d3dsd.Width - 1 )
|
||||
v01 = *(pSrcCurRow);
|
||||
else
|
||||
v01 = *(pSrcB0+4);
|
||||
|
||||
if( x == 0 )
|
||||
vM1 = *(pSrcCurRow + (4 * (d3dsd.Width - 1)));
|
||||
else
|
||||
vM1 = *(pSrcB0-4);
|
||||
v10 = *(pSrcB1+0);
|
||||
v1M = *(pSrcB2+0);
|
||||
|
||||
LONG iDu = (vM1-v01); // The delta-u bump value
|
||||
LONG iDv = (v1M-v10); // The delta-v bump value
|
||||
|
||||
// The luminance bump value (land masses are less shiny)
|
||||
WORD uL = ( v00>1 ) ? 63 : 127;
|
||||
|
||||
switch( m_BumpMapFormat )
|
||||
{
|
||||
case D3DFMT_V8U8:
|
||||
*pDstT++ = (BYTE)iDu;
|
||||
*pDstT++ = (BYTE)iDv;
|
||||
break;
|
||||
|
||||
case D3DFMT_L6V5U5:
|
||||
*(WORD*)pDstT = (WORD)( ( (iDu>>3) & 0x1f ) << 0 );
|
||||
*(WORD*)pDstT |= (WORD)( ( (iDv>>3) & 0x1f ) << 5 );
|
||||
*(WORD*)pDstT |= (WORD)( ( ( uL>>2) & 0x3f ) << 10 );
|
||||
pDstT += 2;
|
||||
break;
|
||||
|
||||
case D3DFMT_X8L8V8U8:
|
||||
*pDstT++ = (BYTE)iDu;
|
||||
*pDstT++ = (BYTE)iDv;
|
||||
*pDstT++ = (BYTE)uL;
|
||||
*pDstT++ = (BYTE)0L;
|
||||
break;
|
||||
}
|
||||
|
||||
// Move one pixel to the right (src is 32-bpp)
|
||||
pSrcB0+=4;
|
||||
pSrcB1+=4;
|
||||
pSrcB2+=4;
|
||||
}
|
||||
|
||||
// Move to the next line
|
||||
pSrcCurRow += dwSrcPitch;
|
||||
pDstCurRow += dwDstPitch;
|
||||
}
|
||||
|
||||
m_psBumpMap->UnlockRect(0);
|
||||
psBumpSrc->UnlockRect(0);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
|
||||
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("Block.bmp"),
|
||||
&m_pBlockTexture, D3DFMT_R5G6B5 ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("Earth.bmp"),
|
||||
&m_pEarthTexture, D3DFMT_R5G6B5 ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("Earthbump.bmp"),
|
||||
&m_pEarthBumpTexture, D3DFMT_A8R8G8B8 ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("EarthEnvMap.bmp"),
|
||||
&m_pEnvMapTexture, D3DFMT_R5G6B5 ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
|
||||
// Find out which bump map texture are supported by this device
|
||||
BOOL bCanDoV8U8 = SUCCEEDED( m_pD3D->CheckDeviceFormat( m_d3dCaps.AdapterOrdinal,
|
||||
m_d3dCaps.DeviceType, m_d3dsdBackBuffer.Format,
|
||||
0, D3DRTYPE_TEXTURE,
|
||||
D3DFMT_V8U8 ) ) &&
|
||||
(m_d3dCaps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAP );
|
||||
|
||||
BOOL bCanDoL6V5U5 = SUCCEEDED( m_pD3D->CheckDeviceFormat( m_d3dCaps.AdapterOrdinal,
|
||||
m_d3dCaps.DeviceType, m_d3dsdBackBuffer.Format,
|
||||
0, D3DRTYPE_TEXTURE,
|
||||
D3DFMT_L6V5U5 ) ) &&
|
||||
(m_d3dCaps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAPLUMINANCE );
|
||||
|
||||
BOOL bCanDoL8V8U8 = SUCCEEDED( m_pD3D->CheckDeviceFormat( m_d3dCaps.AdapterOrdinal,
|
||||
m_d3dCaps.DeviceType, m_d3dsdBackBuffer.Format,
|
||||
0, D3DRTYPE_TEXTURE,
|
||||
D3DFMT_X8L8V8U8 ) ) &&
|
||||
(m_d3dCaps.TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAPLUMINANCE );
|
||||
|
||||
if( bCanDoV8U8 ) m_BumpMapFormat = D3DFMT_V8U8;
|
||||
else if( bCanDoL6V5U5 ) m_BumpMapFormat = D3DFMT_L6V5U5;
|
||||
else if( bCanDoL8V8U8 ) m_BumpMapFormat = D3DFMT_X8L8V8U8;
|
||||
else return E_FAIL;
|
||||
|
||||
// Set menu states
|
||||
HMENU hMenu = GetMenu( m_hWnd );
|
||||
EnableMenuItem( hMenu, IDM_U8V8, bCanDoV8U8 ? MF_ENABLED : MF_GRAYED );
|
||||
EnableMenuItem( hMenu, IDM_U5V5L6, bCanDoL6V5U5 ? MF_ENABLED : MF_GRAYED );
|
||||
EnableMenuItem( hMenu, IDM_U8V8L8, bCanDoL8V8U8 ? MF_ENABLED : MF_GRAYED );
|
||||
SetMenuStates();
|
||||
|
||||
// Initialize earth geometry
|
||||
if( FAILED( CreateEarthVertexBuffer() ) )
|
||||
return E_FAIL;
|
||||
|
||||
// Create and fill the bumpmap
|
||||
if( FAILED( InitBumpMap() ) )
|
||||
return E_FAIL;
|
||||
|
||||
m_bDeviceValidationFailed = FALSE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP );
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP );
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
|
||||
// Get the aspect ratio
|
||||
FLOAT fAspect = ((FLOAT)m_d3dsdBackBuffer.Width) / m_d3dsdBackBuffer.Height;
|
||||
|
||||
// Set projection matrix
|
||||
D3DXMATRIX matProj;
|
||||
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 0.1f, 25.0f );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
||||
|
||||
// Set the ArcBall parameters
|
||||
m_ArcBall.SetWindow( m_d3dsdBackBuffer.Width, m_d3dsdBackBuffer.Height, 3.0f );
|
||||
m_ArcBall.SetRadius( 1.0f );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DeleteDeviceObjects()
|
||||
// Desc: Called when the app is exiting, or the device is being changed,
|
||||
// this function deletes any device dependent objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::DeleteDeviceObjects()
|
||||
{
|
||||
SAFE_RELEASE( m_pBlockTexture );
|
||||
SAFE_RELEASE( m_pEarthTexture );
|
||||
SAFE_RELEASE( m_pEarthBumpTexture );
|
||||
SAFE_RELEASE( m_pEnvMapTexture );
|
||||
|
||||
m_pFont->DeleteDeviceObjects();
|
||||
|
||||
SAFE_RELEASE( m_psBumpMap );
|
||||
SAFE_RELEASE( m_pEarthVB );
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FinalCleanup()
|
||||
// Desc: Called before the app exits, this function gives the app the chance
|
||||
// to cleanup after itself.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FinalCleanup()
|
||||
{
|
||||
SAFE_DELETE( m_pFont );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ConfirmDevice()
|
||||
// Desc: Called during device intialization, this code checks the device
|
||||
// for some minimum set of capabilities
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::ConfirmDevice( D3DCAPS8* pCaps, DWORD dwBehavior,
|
||||
D3DFORMAT Format )
|
||||
{
|
||||
if( dwBehavior & D3DCREATE_PUREDEVICE )
|
||||
return E_FAIL; // GetTransform doesn't work on PUREDEVICE
|
||||
|
||||
// Device must be able to do bumpmapping
|
||||
if( pCaps->TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAPLUMINANCE )
|
||||
{
|
||||
// Accept devices that can create D3DFMT_X8L8V8U8 textures
|
||||
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal,
|
||||
pCaps->DeviceType, Format,
|
||||
0, D3DRTYPE_TEXTURE,
|
||||
D3DFMT_X8L8V8U8 ) ) )
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// Accept devices that can create D3DFMT_L6V5U5 textures
|
||||
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal,
|
||||
pCaps->DeviceType, Format,
|
||||
0, D3DRTYPE_TEXTURE,
|
||||
D3DFMT_L6V5U5 ) ) )
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if( pCaps->TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAP )
|
||||
{
|
||||
// Accept devices that can create D3DFMT_V8U8 textures
|
||||
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal,
|
||||
pCaps->DeviceType, Format,
|
||||
0, D3DRTYPE_TEXTURE,
|
||||
D3DFMT_V8U8 ) ) )
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Else, reject the device
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CreateEarthVertexBuffer()
|
||||
// Desc: Sets up the vertices for a bump-mapped sphere.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::CreateEarthVertexBuffer()
|
||||
{
|
||||
SAFE_RELEASE( m_pEarthVB );
|
||||
|
||||
// Choose a tesselation level
|
||||
DWORD dwNumSphereRings = m_bHighTesselation ? 15 : 5;
|
||||
DWORD dwNumSphereSegments = m_bHighTesselation ? 30 : 10;
|
||||
m_dwNumSphereVertices = 2 * dwNumSphereRings * (dwNumSphereSegments+1);
|
||||
|
||||
// Create the vertex buffer
|
||||
if( FAILED( m_pd3dDevice->CreateVertexBuffer( m_dwNumSphereVertices*sizeof(BUMPVERTEX),
|
||||
D3DUSAGE_WRITEONLY, D3DFVF_BUMPVERTEX,
|
||||
D3DPOOL_MANAGED, &m_pEarthVB ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: SetMenuStates()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID CMyD3DApplication::SetMenuStates()
|
||||
{
|
||||
HMENU hMenu = GetMenu( m_hWnd );
|
||||
|
||||
CheckMenuItem( hMenu, IDM_TEXTURETOGGLE,
|
||||
m_bTextureOn ? MF_CHECKED : MF_UNCHECKED );
|
||||
CheckMenuItem( hMenu, IDM_BUMPMAPTOGGLE,
|
||||
m_bBumpMapOn ? MF_CHECKED : MF_UNCHECKED );
|
||||
CheckMenuItem( hMenu, IDM_ENVMAPTOGGLE,
|
||||
m_bEnvMapOn ? MF_CHECKED : MF_UNCHECKED );
|
||||
|
||||
CheckMenuItem( hMenu, IDM_U8V8L8,
|
||||
m_BumpMapFormat==D3DFMT_X8L8V8U8 ? MF_CHECKED : MF_UNCHECKED );
|
||||
CheckMenuItem( hMenu, IDM_U5V5L6,
|
||||
m_BumpMapFormat==D3DFMT_L6V5U5 ? MF_CHECKED : MF_UNCHECKED );
|
||||
CheckMenuItem( hMenu, IDM_U8V8,
|
||||
m_BumpMapFormat==D3DFMT_V8U8 ? MF_CHECKED : MF_UNCHECKED );
|
||||
|
||||
CheckMenuItem( hMenu, IDM_LOW_TESSELATION,
|
||||
(!m_bHighTesselation) ? MF_CHECKED : MF_UNCHECKED );
|
||||
CheckMenuItem( hMenu, IDM_HIGH_TESSELATION,
|
||||
m_bHighTesselation ? MF_CHECKED : MF_UNCHECKED );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: MsgProc()
|
||||
// Desc: Message proc function to handle key and menu input
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CMyD3DApplication::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
{
|
||||
// Pass mouse messages to the ArcBall so it can build internal matrices
|
||||
m_ArcBall.HandleMouseMessages( hWnd, uMsg, wParam, lParam );
|
||||
|
||||
// Trap context menu
|
||||
if( WM_CONTEXTMENU == uMsg )
|
||||
return 0;
|
||||
|
||||
// Handle menu commands
|
||||
if( WM_COMMAND == uMsg )
|
||||
{
|
||||
switch( LOWORD(wParam) )
|
||||
{
|
||||
case IDM_TEXTURETOGGLE:
|
||||
m_bTextureOn = !m_bTextureOn;
|
||||
break;
|
||||
|
||||
case IDM_BUMPMAPTOGGLE:
|
||||
m_bBumpMapOn = !m_bBumpMapOn;
|
||||
break;
|
||||
|
||||
case IDM_ENVMAPTOGGLE:
|
||||
m_bEnvMapOn = !m_bEnvMapOn;
|
||||
break;
|
||||
|
||||
case IDM_U8V8L8:
|
||||
SAFE_RELEASE( m_psBumpMap );
|
||||
m_BumpMapFormat = D3DFMT_X8L8V8U8;
|
||||
InitBumpMap();
|
||||
break;
|
||||
|
||||
case IDM_U5V5L6:
|
||||
SAFE_RELEASE( m_psBumpMap );
|
||||
m_BumpMapFormat = D3DFMT_L6V5U5;
|
||||
InitBumpMap();
|
||||
break;
|
||||
|
||||
case IDM_U8V8:
|
||||
SAFE_RELEASE( m_psBumpMap );
|
||||
m_BumpMapFormat = D3DFMT_V8U8;
|
||||
InitBumpMap();
|
||||
break;
|
||||
|
||||
case IDM_LOW_TESSELATION:
|
||||
m_bHighTesselation = FALSE;
|
||||
CreateEarthVertexBuffer();
|
||||
break;
|
||||
|
||||
case IDM_HIGH_TESSELATION:
|
||||
m_bHighTesselation = TRUE;
|
||||
CreateEarthVertexBuffer();
|
||||
break;
|
||||
}
|
||||
|
||||
// Update the menus, in case any state changes occurred
|
||||
SetMenuStates();
|
||||
}
|
||||
|
||||
// Pass remaining messages to default handler
|
||||
return CD3DApplication::MsgProc( hWnd, uMsg, wParam, lParam );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
# Microsoft Developer Studio Project File - Name="BumpEarth" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=BumpEarth - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "BumpEarth.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "BumpEarth.mak" CFG="BumpEarth - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BumpEarth - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "BumpEarth - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "BumpEarth - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 d3dx8.lib d3d8.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
|
||||
|
||||
!ELSEIF "$(CFG)" == "BumpEarth - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 d3dx8dt.lib d3d8.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /stack:0x200000,0x200000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "BumpEarth - Win32 Release"
|
||||
# Name "BumpEarth - Win32 Debug"
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\winmain.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dapp.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\include\d3dapp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dfile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\include\d3dfile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dfont.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\include\d3dfont.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\include\d3dutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\dxutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\include\dxutil.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\BumpEarth.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "BumpEarth"=.\BumpEarth.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on BumpEarth.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=BumpEarth - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to BumpEarth - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "BumpEarth - Win32 Release" && "$(CFG)" != "BumpEarth - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "BumpEarth.mak" CFG="BumpEarth - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BumpEarth - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "BumpEarth - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "BumpEarth - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\BumpEarth.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\BumpEarth.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\BumpEarth.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "..\..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\BumpEarth.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\winmain.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\BumpEarth.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8.lib d3d8.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\BumpEarth.pdb" /machine:I386 /out:"$(OUTDIR)\BumpEarth.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\BumpEarth.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\BumpEarth.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "BumpEarth - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\BumpEarth.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\BumpEarth.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\BumpEarth.exe"
|
||||
-@erase "$(OUTDIR)\BumpEarth.ilk"
|
||||
-@erase "$(OUTDIR)\BumpEarth.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "..\..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\BumpEarth.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\winmain.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\BumpEarth.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8dt.lib d3d8.lib d3dxof.lib dxguid.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\BumpEarth.pdb" /debug /machine:I386 /out:"$(OUTDIR)\BumpEarth.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\BumpEarth.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\BumpEarth.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("BumpEarth.dep")
|
||||
!INCLUDE "BumpEarth.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "BumpEarth.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "BumpEarth - Win32 Release" || "$(CFG)" == "BumpEarth - Win32 Debug"
|
||||
SOURCE=.\winmain.rc
|
||||
|
||||
"$(INTDIR)\winmain.res" : $(SOURCE) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dapp.cpp
|
||||
|
||||
"$(INTDIR)\d3dapp.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dfile.cpp
|
||||
|
||||
"$(INTDIR)\d3dfile.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dfont.cpp
|
||||
|
||||
"$(INTDIR)\d3dfont.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dutil.cpp
|
||||
|
||||
"$(INTDIR)\d3dutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\..\common\src\dxutil.cpp
|
||||
|
||||
"$(INTDIR)\dxutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=.\BumpEarth.cpp
|
||||
|
||||
"$(INTDIR)\BumpEarth.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,51 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: BumpEarth Direct3D Sample
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
The BumpEarth program demonstrates the bump mapping capabilities of Direct3D.
|
||||
Bumpmapping is a texture blending technique used to render the appearance of
|
||||
rough, bumpy surfaces. This sample renders a rotating, bumpmapped planet Earth.
|
||||
|
||||
Note that not all cards support all features for all the various bumpmapping
|
||||
techniques (some hardware has no, or limited, bumpmapping support). For more
|
||||
information on bumpmapping, refer to the DirectX SDK documentation.
|
||||
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\D3D\BumpMapping\BumpEarth
|
||||
Executable: DXSDK\Samples\Multimedia\D3D\Bin
|
||||
|
||||
|
||||
User's Guide
|
||||
============
|
||||
The following keys are implemented. The dropdown menus can be used for the
|
||||
same controls.
|
||||
<Enter> Starts and stops the scene
|
||||
<Space> Advances the scene by a small increment
|
||||
<F1> Shows help or available commands.
|
||||
<F2> Prompts user to select a new rendering device or display mode
|
||||
<Alt+Enter> Toggles between fullscreen and windowed modes
|
||||
<Esc> Exits the app.
|
||||
|
||||
|
||||
Programming Notes
|
||||
=================
|
||||
Bumpmapping is an advanced multitexture blending technique that can be used
|
||||
to render the appearance of rough, bumpy surfaces. The bump map itself is a
|
||||
texture that stores the perturbation data. Bumpmapping requires two
|
||||
textures, actually. One is an environment map, which contains the lights
|
||||
that you see in the scene. The other is the actual bumpmapping, which
|
||||
contain values (stored as du and dv) used to "bump" the environment maps
|
||||
texture coordinates. Some bumpmaps also contain luminance values to control
|
||||
the "shininess" of a particular texel.
|
||||
|
||||
This sample makes use of common DirectX code (consisting of helper functions,
|
||||
etc.) that is shared with other samples on the DirectX SDK. All common
|
||||
headers and source code can be found in the following directory:
|
||||
DXSDK\Samples\Multimedia\Common
|
||||
@@ -0,0 +1,43 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by winmain.rc
|
||||
//
|
||||
#define IDI_MAIN_ICON 101
|
||||
#define IDR_MAIN_ACCEL 113
|
||||
#define IDR_MENU 141
|
||||
#define IDR_POPUP 142
|
||||
#define IDD_SELECTDEVICE 144
|
||||
#define IDC_DEVICE_COMBO 1000
|
||||
#define IDC_MODE_COMBO 1001
|
||||
#define IDC_ADAPTER_COMBO 1002
|
||||
#define IDC_FULLSCREENMODES_COMBO 1003
|
||||
#define IDC_MULTISAMPLE_COMBO 1005
|
||||
#define IDC_WINDOWED_CHECKBOX 1012
|
||||
#define IDC_FULLSCREEN_TEXT 1014
|
||||
#define IDC_WINDOW 1016
|
||||
#define IDC_FULLSCREEN 1018
|
||||
#define IDM_CHANGEDEVICE 40002
|
||||
#define IDM_TOGGLEFULLSCREEN 40003
|
||||
#define IDM_TOGGLESTART 40004
|
||||
#define IDM_SINGLESTEP 40005
|
||||
#define IDM_EXIT 40006
|
||||
#define IDM_U8V8L8 40011
|
||||
#define IDM_U5V5L6 40012
|
||||
#define IDM_U8V8 40013
|
||||
#define IDM_TEXTURETOGGLE 40014
|
||||
#define IDM_BUMPMAPTOGGLE 40015
|
||||
#define IDM_ENVMAPTOGGLE 40016
|
||||
#define IDM_LOW_TESSELATION 40017
|
||||
#define IDM_HIGH_TESSELATION 40018
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 146
|
||||
#define _APS_NEXT_COMMAND_VALUE 40019
|
||||
#define _APS_NEXT_CONTROL_VALUE 1027
|
||||
#define _APS_NEXT_SYMED_VALUE 102
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,192 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define IDC_STATIC -1
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_MAIN_ICON ICON DISCARDABLE "DirectX.ico"
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define IDC_STATIC -1\r\n"
|
||||
"#include <windows.h>\r\n"
|
||||
"\r\n"
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE
|
||||
BEGIN
|
||||
VK_ESCAPE, IDM_EXIT, VIRTKEY, NOINVERT
|
||||
VK_F2, IDM_CHANGEDEVICE, VIRTKEY, NOINVERT
|
||||
VK_RETURN, IDM_TOGGLESTART, VIRTKEY, NOINVERT
|
||||
VK_RETURN, IDM_TOGGLEFULLSCREEN, VIRTKEY, ALT, NOINVERT
|
||||
VK_SPACE, IDM_SINGLESTEP, VIRTKEY, NOINVERT
|
||||
"X", IDM_EXIT, VIRTKEY, ALT, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_SELECTDEVICE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 259
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 143
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_SELECTDEVICE DIALOG DISCARDABLE 0, 0, 267, 138
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Select Device"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
GROUPBOX "Rendering device",IDC_STATIC,5,5,200,45
|
||||
LTEXT "&Adapter:",IDC_STATIC,22,17,65,10,SS_CENTERIMAGE
|
||||
COMBOBOX IDC_ADAPTER_COMBO,90,15,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "&Device:",IDC_STATIC,22,32,65,10,SS_CENTERIMAGE
|
||||
COMBOBOX IDC_DEVICE_COMBO,90,30,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
GROUPBOX "Rendering mode",IDC_STATIC,5,52,200,45
|
||||
CONTROL "Use desktop &window",IDC_WINDOW,"Button",
|
||||
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,10,62,85,15
|
||||
CONTROL "&Fullscreen mode:",IDC_FULLSCREEN,"Button",
|
||||
BS_AUTORADIOBUTTON,10,77,75,15
|
||||
COMBOBOX IDC_FULLSCREENMODES_COMBO,90,77,105,204,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_GROUP | WS_TABSTOP
|
||||
GROUPBOX "Multisample",IDC_STATIC,5,101,200,28
|
||||
LTEXT "&Multisample Type:",IDC_STATIC,22,113,62,10,
|
||||
SS_CENTERIMAGE
|
||||
COMBOBOX IDC_MULTISAMPLE_COMBO,90,111,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
DEFPUSHBUTTON "OK",IDOK,210,10,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,210,30,50,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Go/stop\tEnter", IDM_TOGGLESTART
|
||||
MENUITEM "&Single step\tSpace", IDM_SINGLESTEP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Change device...\tF2", IDM_CHANGEDEVICE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit\tESC", IDM_EXIT
|
||||
END
|
||||
POPUP "&Options"
|
||||
BEGIN
|
||||
MENUITEM "&Texture", IDM_TEXTURETOGGLE
|
||||
MENUITEM "Toggle &Bumpmap", IDM_BUMPMAPTOGGLE
|
||||
MENUITEM "Toggle &Envmap", IDM_ENVMAPTOGGLE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Format &1: U8V8L8", IDM_U8V8L8
|
||||
MENUITEM "Format &2: U5V5L6", IDM_U5V5L6
|
||||
MENUITEM "Format &3: U8V8", IDM_U8V8
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Low tesselation", IDM_LOW_TESSELATION
|
||||
MENUITEM "&High tesselation", IDM_HIGH_TESSELATION
|
||||
END
|
||||
END
|
||||
|
||||
IDR_POPUP MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "Popup"
|
||||
BEGIN
|
||||
MENUITEM "&Go/stop", IDM_TOGGLESTART
|
||||
MENUITEM "&Single step", IDM_SINGLESTEP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Change device...", IDM_CHANGEDEVICE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", IDM_EXIT
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,495 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: BumpLens.cpp
|
||||
//
|
||||
// Desc: Code to simulate a magnifying glass using bumpmapping.
|
||||
//
|
||||
// Note: Based on a sample from the Matrox web site
|
||||
//
|
||||
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <tchar.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include "D3DX8.h"
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Function prototypes and global (or static) variables
|
||||
//-----------------------------------------------------------------------------
|
||||
inline DWORD F2DW( FLOAT f ) { return *((DWORD*)&f); }
|
||||
|
||||
struct BUMPVERTEX // Vertex type used for bumpmap lens effect
|
||||
{
|
||||
D3DXVECTOR3 p;
|
||||
FLOAT tu1, tv1;
|
||||
FLOAT tu2, tv2;
|
||||
};
|
||||
|
||||
struct BACKGROUNDVERTEX // Vertex type used for rendering background
|
||||
{
|
||||
D3DXVECTOR4 p;
|
||||
DWORD color;
|
||||
FLOAT tu, tv;
|
||||
};
|
||||
|
||||
#define D3DFVF_BUMPVERTEX (D3DFVF_XYZ|D3DFVF_TEX2)
|
||||
#define D3DFVF_BACKGROUNDVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1)
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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_pBackgroundVB;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pLensVB;
|
||||
|
||||
FLOAT m_fLensX;
|
||||
FLOAT m_fLensY;
|
||||
|
||||
LPDIRECT3DTEXTURE8 m_pBumpMapTexture;
|
||||
LPDIRECT3DTEXTURE8 m_pBackgroundTexture;
|
||||
|
||||
BOOL m_bDeviceValidationFailed;
|
||||
|
||||
HRESULT CreateBumpMap( UINT iWidth, UINT iHeight );
|
||||
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("BumpLens: Lens Effect Using BumpMapping");
|
||||
m_bUseDepthBuffer = FALSE;
|
||||
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
|
||||
m_pBumpMapTexture = NULL;
|
||||
m_pBackgroundTexture = NULL;
|
||||
|
||||
m_pBackgroundVB = NULL;
|
||||
m_pLensVB = NULL;
|
||||
m_bDeviceValidationFailed = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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()
|
||||
{
|
||||
// Get a triangle wave between -1 and 1
|
||||
m_fLensX = 2 * fabsf( 2 * ( (m_fTime/2) - floorf(m_fTime/2) ) - 1 ) - 1;
|
||||
|
||||
// Get a regulated sine wave between -1 and 1
|
||||
m_fLensY = 2 * fabsf( sinf( m_fTime ) ) - 1;
|
||||
|
||||
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()
|
||||
{
|
||||
// Begin the scene
|
||||
if( FAILED( m_pd3dDevice->BeginScene() ) )
|
||||
return S_OK;
|
||||
|
||||
// Render the background
|
||||
m_pd3dDevice->SetTexture( 0, m_pBackgroundTexture );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
|
||||
|
||||
m_pd3dDevice->SetVertexShader( D3DFVF_BACKGROUNDVERTEX );
|
||||
m_pd3dDevice->SetStreamSource( 0, m_pBackgroundVB, sizeof(BACKGROUNDVERTEX) );
|
||||
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
|
||||
|
||||
// Render the lens
|
||||
m_pd3dDevice->SetTexture( 0, m_pBumpMapTexture );
|
||||
m_pd3dDevice->SetTexture( 1, m_pBackgroundTexture );
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_BUMPENVMAP );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVMAT00, F2DW(0.2f) );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVMAT01, F2DW(0.0f) );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVMAT10, F2DW(0.0f) );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVMAT11, F2DW(0.2f) );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVLSCALE, F2DW(1.0f) );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVLOFFSET, F2DW(0.0f) );
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
|
||||
|
||||
// Generate texture coords depending on objects camera space position
|
||||
D3DXMATRIX mat;
|
||||
mat._11 = 0.5f; mat._12 = 0.0f;
|
||||
mat._21 = 0.0f; mat._22 =-0.5f;
|
||||
mat._31 = 0.0f; mat._32 = 0.0f;
|
||||
mat._41 = 0.5f; mat._42 = 0.5f;
|
||||
|
||||
// Scale-by-z here
|
||||
D3DXMATRIX matView, matProj;
|
||||
m_pd3dDevice->GetTransform( D3DTS_VIEW, &matView );
|
||||
m_pd3dDevice->GetTransform( D3DTS_PROJECTION, &matProj );
|
||||
D3DXVECTOR3 vEyePt( matView._41, matView._42, matView._43 );
|
||||
FLOAT z = D3DXVec3Length( &vEyePt );
|
||||
mat._11 *= ( matProj._11 / ( matProj._33 * z + matProj._34 ) );
|
||||
mat._22 *= ( matProj._22 / ( matProj._33 * z + matProj._34 ) );
|
||||
|
||||
m_pd3dDevice->SetTransform( D3DTS_TEXTURE1, &mat );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION | 1);
|
||||
|
||||
// Position the lens
|
||||
D3DXMATRIX matWorld;
|
||||
D3DXMatrixTranslation( &matWorld, 0.7f * (1000.0f-256.0f)*m_fLensX,
|
||||
0.7f * (1000.0f-256.0f)*m_fLensY,
|
||||
0.0f );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
|
||||
m_pd3dDevice->SetVertexShader( D3DFVF_BUMPVERTEX );
|
||||
m_pd3dDevice->SetStreamSource( 0, m_pLensVB, sizeof(BUMPVERTEX) );
|
||||
|
||||
// Verify that the texture operations are possible on the device
|
||||
DWORD dwNumPasses;
|
||||
if( FAILED( m_pd3dDevice->ValidateDevice( &dwNumPasses ) ) )
|
||||
{
|
||||
// The right thing to do when device validation fails is to try
|
||||
// a different rendering technique. This sample just warns the user.
|
||||
m_bDeviceValidationFailed = TRUE;
|
||||
}
|
||||
|
||||
// Render the lens
|
||||
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
|
||||
|
||||
// Output statistics
|
||||
m_pFont->DrawText( 2, 0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
|
||||
m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );
|
||||
|
||||
if( m_bDeviceValidationFailed )
|
||||
{
|
||||
m_pFont->DrawText( 2, 40, D3DCOLOR_ARGB(255,255,0,0),
|
||||
_T("Warning: Device validation failed. Rendering may not look right.") );
|
||||
}
|
||||
|
||||
// End the scene.
|
||||
m_pd3dDevice->EndScene();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CreateBumpmap()
|
||||
// Desc: Create a bump map texture and fill its content to BUMPDUDV format
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::CreateBumpMap( UINT iWidth, UINT iHeight )
|
||||
{
|
||||
// Create the bumpmap's surface and texture objects
|
||||
if( FAILED( m_pd3dDevice->CreateTexture( iWidth, iHeight, 1, 0,
|
||||
D3DFMT_V8U8, D3DPOOL_MANAGED, &m_pBumpMapTexture ) ) )
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Fill the bumpmap texels to simulate a lens
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
m_pBumpMapTexture->LockRect( 0, &d3dlr, 0, 0 );
|
||||
DWORD dwDstPitch = (DWORD)d3dlr.Pitch;
|
||||
BYTE* pDst = (BYTE*)d3dlr.pBits;
|
||||
UINT mid = iWidth/2;
|
||||
|
||||
for( DWORD y0 = 0; y0 < iHeight; y0++ )
|
||||
{
|
||||
CHAR* pDst = (CHAR*)d3dlr.pBits + y0*d3dlr.Pitch;
|
||||
|
||||
for( DWORD x0 = 0; x0 < iWidth; x0++ )
|
||||
{
|
||||
DWORD x1 = ( (x0==iWidth-1) ? x0 : x0+1 );
|
||||
DWORD y1 = ( (x0==iHeight-1) ? y0 : y0+1 );
|
||||
|
||||
FLOAT fDistSq00 = (FLOAT)( (x0-mid)*(x0-mid) + (y0-mid)*(y0-mid) );
|
||||
FLOAT fDistSq01 = (FLOAT)( (x1-mid)*(x1-mid) + (y0-mid)*(y0-mid) );
|
||||
FLOAT fDistSq10 = (FLOAT)( (x0-mid)*(x0-mid) + (y1-mid)*(y1-mid) );
|
||||
|
||||
FLOAT v00 = ( fDistSq00 > (mid*mid) ) ? 0.0f : sqrtf( (mid*mid) - fDistSq00 );
|
||||
FLOAT v01 = ( fDistSq01 > (mid*mid) ) ? 0.0f : sqrtf( (mid*mid) - fDistSq01 );
|
||||
FLOAT v10 = ( fDistSq10 > (mid*mid) ) ? 0.0f : sqrtf( (mid*mid) - fDistSq10 );
|
||||
|
||||
FLOAT iDu = (128/D3DX_PI)*atanf(v00-v01); // The delta-u bump value
|
||||
FLOAT iDv = (128/D3DX_PI)*atanf(v00-v10); // The delta-v bump value
|
||||
|
||||
*pDst++ = (CHAR)(iDu);
|
||||
*pDst++ = (CHAR)(iDv);
|
||||
}
|
||||
}
|
||||
|
||||
m_pBumpMapTexture->UnlockRect(0);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitDeviceObjects()
|
||||
// Desc: Initialize scene objects
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// Load the texture for the background image
|
||||
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("Lake.bmp"),
|
||||
&m_pBackgroundTexture ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
// Create the bump map texture
|
||||
if( FAILED( CreateBumpMap( 256, 256 ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
// Create a square for rendering the background
|
||||
if( FAILED( m_pd3dDevice->CreateVertexBuffer( 4*sizeof(BACKGROUNDVERTEX),
|
||||
D3DUSAGE_WRITEONLY, D3DFVF_BACKGROUNDVERTEX,
|
||||
D3DPOOL_MANAGED, &m_pBackgroundVB ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
// Create a square for rendering the lens
|
||||
if( FAILED( m_pd3dDevice->CreateVertexBuffer( 4*sizeof(BUMPVERTEX),
|
||||
D3DUSAGE_WRITEONLY, D3DFVF_BUMPVERTEX,
|
||||
D3DPOOL_MANAGED, &m_pLensVB ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
BUMPVERTEX* vLens;
|
||||
m_pLensVB->Lock( 0, 0, (BYTE**)&vLens, 0 );
|
||||
vLens[0].p = D3DXVECTOR3(-256.0f,-256.0f, 0.0f );
|
||||
vLens[1].p = D3DXVECTOR3(-256.0f, 256.0f, 0.0f );
|
||||
vLens[2].p = D3DXVECTOR3( 256.0f,-256.0f, 0.0f );
|
||||
vLens[3].p = D3DXVECTOR3( 256.0f, 256.0f, 0.0f );
|
||||
vLens[0].tu1 = 0.0f; vLens[0].tv1 = 1.0f;
|
||||
vLens[1].tu1 = 0.0f; vLens[1].tv1 = 0.0f;
|
||||
vLens[2].tu1 = 1.0f; vLens[2].tv1 = 1.0f;
|
||||
vLens[3].tu1 = 1.0f; vLens[3].tv1 = 0.0f;
|
||||
m_pLensVB->Unlock();
|
||||
|
||||
m_bDeviceValidationFailed = FALSE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Initialize scene objects
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
|
||||
// Set the transform matrices
|
||||
D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f, 0.0f, -2001.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, 3000.0f );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
||||
|
||||
// Set any appropiate state
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_MIPFILTER, D3DTEXF_NONE );
|
||||
|
||||
// Size the background image
|
||||
BACKGROUNDVERTEX* vBackground;
|
||||
m_pBackgroundVB->Lock( 0, 0, (BYTE**)&vBackground, 0 );
|
||||
for( UINT i=0; i<4; i ++ )
|
||||
{
|
||||
vBackground[i].p = D3DXVECTOR4( 0.0f, 0.0f, 0.9f, 1.0f );
|
||||
vBackground[i].color = 0xffffffff;
|
||||
}
|
||||
vBackground[0].p.y = (FLOAT)m_d3dsdBackBuffer.Height;
|
||||
vBackground[2].p.y = (FLOAT)m_d3dsdBackBuffer.Height;
|
||||
vBackground[2].p.x = (FLOAT)m_d3dsdBackBuffer.Width;
|
||||
vBackground[3].p.x = (FLOAT)m_d3dsdBackBuffer.Width;
|
||||
vBackground[0].tu = 0.0f; vBackground[0].tv = 1.0f;
|
||||
vBackground[1].tu = 0.0f; vBackground[1].tv = 0.0f;
|
||||
vBackground[2].tu = 1.0f; vBackground[2].tv = 1.0f;
|
||||
vBackground[3].tu = 1.0f; vBackground[3].tv = 0.0f;
|
||||
m_pBackgroundVB->Unlock();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DeleteDeviceObjects()
|
||||
// Desc: Called when the app is exiting, or the device is being changed,
|
||||
// this function deletes any device dependent objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::DeleteDeviceObjects()
|
||||
{
|
||||
m_pFont->DeleteDeviceObjects();
|
||||
SAFE_RELEASE( m_pBackgroundTexture );
|
||||
SAFE_RELEASE( m_pBumpMapTexture );
|
||||
SAFE_RELEASE( m_pBackgroundVB );
|
||||
SAFE_RELEASE( m_pLensVB );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FinalCleanup()
|
||||
// Desc: Called before the app exits, this function gives the app the chance
|
||||
// to cleanup after itself.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FinalCleanup()
|
||||
{
|
||||
SAFE_DELETE( m_pFont );
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ConfirmDevice()
|
||||
// Desc: Called during device intialization, this code checks the device
|
||||
// for some minimum set of capabilities
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::ConfirmDevice( D3DCAPS8* pCaps, DWORD dwBehavior,
|
||||
D3DFORMAT Format )
|
||||
{
|
||||
if( dwBehavior & D3DCREATE_PUREDEVICE )
|
||||
return E_FAIL; // GetTransform doesn't work on PUREDEVICE
|
||||
|
||||
// Device must be able to do bumpmapping
|
||||
if( 0 == ( pCaps->TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAP ) )
|
||||
return E_FAIL;
|
||||
|
||||
// Accept devices that can create D3DFMT_V8U8 textures
|
||||
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal,
|
||||
pCaps->DeviceType, Format,
|
||||
0, D3DRTYPE_TEXTURE,
|
||||
D3DFMT_V8U8 ) ) )
|
||||
return S_OK;
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
# Microsoft Developer Studio Project File - Name="BumpLens" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=BumpLens - 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 "BumpLens.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 "BumpLens.mak" CFG="BumpLens - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BumpLens - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "BumpLens - 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)" == "BumpLens - 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)" == "BumpLens - 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 "BumpLens - Win32 Release"
|
||||
# Name "BumpLens - 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=.\BumpLens.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "BumpLens"=.\BumpLens.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on BumpLens.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=BumpLens - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to BumpLens - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "BumpLens - Win32 Release" && "$(CFG)" != "BumpLens - 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 "BumpLens.mak" CFG="BumpLens - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BumpLens - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "BumpLens - 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)" == "BumpLens - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\BumpLens.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\BumpLens.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\BumpLens.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)\BumpLens.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)\BumpLens.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)\BumpLens.pdb" /machine:I386 /out:"$(OUTDIR)\BumpLens.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\BumpLens.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\BumpLens.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "BumpLens - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\BumpLens.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\BumpLens.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\BumpLens.exe"
|
||||
-@erase "$(OUTDIR)\BumpLens.ilk"
|
||||
-@erase "$(OUTDIR)\BumpLens.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)\BumpLens.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)\BumpLens.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)\BumpLens.pdb" /debug /machine:I386 /out:"$(OUTDIR)\BumpLens.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\BumpLens.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\BumpLens.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("BumpLens.dep")
|
||||
!INCLUDE "BumpLens.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "BumpLens.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "BumpLens - Win32 Release" || "$(CFG)" == "BumpLens - 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=.\BumpLens.cpp
|
||||
|
||||
"$(INTDIR)\BumpLens.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,57 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: BumpLens Direct3D Sample
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
The BumpLens sample demonstrates a lens effect that can be acheived using
|
||||
bumpmapping. Bumpmapping is a texture blending technique used to render the
|
||||
appearance of rough, bumpy surfaces, but can also be used for other effects
|
||||
as shown here.
|
||||
|
||||
Note that not all cards support all features for all the various bumpmapping
|
||||
techniques (some hardware has no, or limited, bumpmapping support). For more
|
||||
information on bumpmapping, refer to the DirectX SDK documentation.
|
||||
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\D3D\BumpMapping\BumpLens
|
||||
Executable: DXSDK\Samples\Multimedia\D3D\Bin
|
||||
|
||||
|
||||
User's Guide
|
||||
============
|
||||
The following keys are implemented. The dropdown menus can be used for the
|
||||
same controls.
|
||||
<Enter> Starts and stops the scene
|
||||
<Space> Advances the scene by a small increment
|
||||
<F1> Shows help or available commands.
|
||||
<F2> Prompts user to select a new rendering device or display mode
|
||||
<Alt+Enter> Toggles between fullscreen and windowed modes
|
||||
<Esc> Exits the app.
|
||||
|
||||
|
||||
Programming Notes
|
||||
=================
|
||||
Bumpmapping is an advanced multitexture blending technique that can be used
|
||||
to render the appearance of rough, bumpy surfaces. The bump map itself is a
|
||||
texture that stores the perturbation data. Bumpmapping requires two
|
||||
textures, actually. One is an environment map, which contains the lights
|
||||
that you see in the scene. The other is the actual bumpmapping, which
|
||||
contain values (stored as du and dv) used to "bump" the environment maps
|
||||
texture coordinates. Some bumpmaps also contain luminance values to control
|
||||
the "shininess" of a particular texel.
|
||||
|
||||
This sample uses bumpmapping in a non-traditional fashion. Since bumpmapping
|
||||
really just perturbs an environment map, it can be used for other effects. In
|
||||
this case, perturbing a background image (which could be rendered on the fly)
|
||||
to make a lens effect.
|
||||
|
||||
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
|
||||
@@ -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 144
|
||||
#define _APS_NEXT_COMMAND_VALUE 40010
|
||||
#define _APS_NEXT_CONTROL_VALUE 1015
|
||||
#define _APS_NEXT_SYMED_VALUE 102
|
||||
#endif
|
||||
#endif
|
||||
@@ -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
|
||||
|
||||
#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
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_MAIN_ICON ICON DISCARDABLE "DirectX.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
# Microsoft Developer Studio Project File - Name="BumpSelfShadow" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=BumpSelfShadow - 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 "BumpSelfShadow.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 "BumpSelfShadow.mak" CFG="BumpSelfShadow - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BumpSelfShadow - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "BumpSelfShadow - 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)" == "BumpSelfShadow - 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 d3d8.lib d3dx8dt.lib winmm.lib 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 /stack:0x200000,0x200000
|
||||
|
||||
!ELSEIF "$(CFG)" == "BumpSelfShadow - 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 /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /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 d3d8.lib d3dx8dt.lib winmm.lib 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 /stack:0x200000,0x200000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "BumpSelfShadow - Win32 Release"
|
||||
# Name "BumpSelfShadow - Win32 Debug"
|
||||
# Begin Group "Common Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dapp.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dfont.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\dxutil.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\winmain.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bumpselfshadow.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "BumpSelfShadow"=.\BumpSelfShadow.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on BumpSelfShadow.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=BumpSelfShadow - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to BumpSelfShadow - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "BumpSelfShadow - Win32 Release" && "$(CFG)" != "BumpSelfShadow - 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 "BumpSelfShadow.mak" CFG="BumpSelfShadow - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BumpSelfShadow - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "BumpSelfShadow - 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)" == "BumpSelfShadow - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\BumpSelfShadow.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\bumpselfshadow.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\BumpSelfShadow.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)\BumpSelfShadow.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)\BumpSelfShadow.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3d8.lib d3dx8dt.lib winmm.lib 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 /incremental:no /pdb:"$(OUTDIR)\BumpSelfShadow.pdb" /machine:I386 /out:"$(OUTDIR)\BumpSelfShadow.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\bumpselfshadow.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\BumpSelfShadow.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "BumpSelfShadow - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\BumpSelfShadow.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\bumpselfshadow.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\BumpSelfShadow.exe"
|
||||
-@erase "$(OUTDIR)\BumpSelfShadow.ilk"
|
||||
-@erase "$(OUTDIR)\BumpSelfShadow.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)\BumpSelfShadow.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /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)\BumpSelfShadow.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3d8.lib d3dx8dt.lib winmm.lib 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 /incremental:yes /pdb:"$(OUTDIR)\BumpSelfShadow.pdb" /debug /machine:I386 /out:"$(OUTDIR)\BumpSelfShadow.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\bumpselfshadow.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\BumpSelfShadow.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("BumpSelfShadow.dep")
|
||||
!INCLUDE "BumpSelfShadow.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "BumpSelfShadow.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "BumpSelfShadow - Win32 Release" || "$(CFG)" == "BumpSelfShadow - Win32 Debug"
|
||||
SOURCE=..\..\..\common\src\d3dapp.cpp
|
||||
|
||||
"$(INTDIR)\d3dapp.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=.\winmain.rc
|
||||
|
||||
"$(INTDIR)\winmain.res" : $(SOURCE) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=.\bumpselfshadow.cpp
|
||||
|
||||
"$(INTDIR)\bumpselfshadow.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,47 @@
|
||||
Self Shadowed Bumpmaps
|
||||
|
||||
This projects includes all source and content for the self shadowing bump map algorithm presented at the 2001 GDC lecture by Dan Baker and Chas Boyd. This app will run without pixel shaders, as long as the hardware has rendertargets and DOT3. However, it runs much more efficently with pixel shaders and with better visual results.
|
||||
|
||||
|
||||
Source files
|
||||
|
||||
main.cpp App main file
|
||||
shadowset.cpp All the code for the self-shadowed bump map
|
||||
|
||||
d3dapp.cpp The App framework already included on the DX 8 sdk
|
||||
d3dfont.cpp These files are provided for conveince only
|
||||
d3dutil.cpp and should be replaced with newer files from the
|
||||
dxutil.cpp sdk on newer releases of DirectX.
|
||||
|
||||
bumpshader.vsh - used for pixel shader emmulation
|
||||
bumpshader2.vsh - used for pixel shader emmulation
|
||||
bumpshader3.vsh - diffuse bump map vertex shader
|
||||
bumpshader4.vsh - Shadow map vertex shader
|
||||
|
||||
shadowbumpshader.psh - horizon map basis computer pixel shader
|
||||
|
||||
|
||||
|
||||
Media files
|
||||
sphere.x - the earth
|
||||
earth.bmp - earth texture
|
||||
earthbump.bmp - heightmap for earth
|
||||
|
||||
Camera Controls:
|
||||
'S' - Zoom Out
|
||||
'W' - Zoom In
|
||||
Arrow Keys - Move camera
|
||||
NumPad arrows - pitch camera (numlock should be on)
|
||||
Numlock '7','9' - Roll camera
|
||||
|
||||
Other Controls:
|
||||
'2' - Toggle Self Shadowing
|
||||
'3' - Toggle Diffuse bump mapping
|
||||
'4' - Reset position
|
||||
'5' - Auto rotate
|
||||
|
||||
|
||||
Mouse:
|
||||
Left Mouse rotates earth
|
||||
Right Mouse moves light
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//{{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_TOGGLEHELP 40001
|
||||
#define IDM_CHANGEDEVICE 40002
|
||||
#define IDM_TOGGLEFULLSCREEN 40003
|
||||
#define IDM_TOGGLESTART 40004
|
||||
#define IDM_SINGLESTEP 40005
|
||||
#define IDM_EXIT 40006
|
||||
#define IDM_ADDDROP 40012
|
||||
#define IDM_NEXT_TECHNIQUE 40013
|
||||
#define IDM_NEXT_TECHNIQUE_NOVALIDATE 40014
|
||||
#define IDM_PREV_TECHNIQUE 40015
|
||||
#define IDM_PREV_TECHNIQUE_NOVALIDATE 40016
|
||||
|
||||
// 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 40017
|
||||
#define _APS_NEXT_CONTROL_VALUE 1027
|
||||
#define _APS_NEXT_SYMED_VALUE 102
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,180 @@
|
||||
//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
|
||||
"D", IDM_ADDDROP, VIRTKEY, NOINVERT
|
||||
VK_ESCAPE, IDM_EXIT, VIRTKEY, NOINVERT
|
||||
VK_F1, IDM_TOGGLEHELP, 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
|
||||
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
|
||||
|
||||
@@ -0,0 +1,420 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Underwater.cpp
|
||||
//
|
||||
// Desc: Code to simulate underwater distortion.
|
||||
// Games could easily make use of this technique to achieve an underwater
|
||||
// effect without affecting geometry by rendering the scene to a texture
|
||||
// and applying the bump effect on a rectangle mapped with it.
|
||||
//
|
||||
// Note: From the Matrox web site demos
|
||||
//
|
||||
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <tchar.h>
|
||||
#include "D3DX8.h"
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Function prototypes and global (or static) variables
|
||||
//-----------------------------------------------------------------------------
|
||||
inline FLOAT rnd() { return (((FLOAT)rand()-(FLOAT)rand())/(2L*RAND_MAX)); }
|
||||
inline FLOAT RND() { return (((FLOAT)rand())/RAND_MAX); }
|
||||
inline DWORD F2DW( FLOAT f ) { return *((DWORD*)&f); }
|
||||
|
||||
struct BUMPVERTEX
|
||||
{
|
||||
D3DXVECTOR3 p;
|
||||
D3DXVECTOR3 n;
|
||||
FLOAT tu1, tv1;
|
||||
FLOAT tu2, tv2;
|
||||
};
|
||||
|
||||
#define D3DFVF_BUMPVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX2)
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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_pWaterVB;
|
||||
LPDIRECT3DTEXTURE8 m_pBumpMap;
|
||||
LPDIRECT3DTEXTURE8 m_pBackgroundTexture;
|
||||
BOOL m_bDeviceValidationFailed;
|
||||
|
||||
HRESULT CreateBumpMap();
|
||||
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("BumpUnderWater: Effect Using BumpMapping");
|
||||
m_bUseDepthBuffer = TRUE;
|
||||
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
m_pWaterVB = NULL;
|
||||
m_pBumpMap = NULL;
|
||||
m_pBackgroundTexture = NULL;
|
||||
m_bDeviceValidationFailed = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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()
|
||||
{
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVMAT00, F2DW(0.01f) );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVMAT01, F2DW(0.00f) );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVMAT10, F2DW(0.00f) );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVMAT11, F2DW(0.01f) );
|
||||
|
||||
BUMPVERTEX* vWaterVertices;
|
||||
m_pWaterVB->Lock( 0, 0, (BYTE**)&vWaterVertices, 0 );
|
||||
vWaterVertices[0].tu1 = 0.000f; vWaterVertices[0].tv1 = 0.5f*m_fTime + 2.0f;
|
||||
vWaterVertices[1].tu1 = 0.000f; vWaterVertices[1].tv1 = 0.5f*m_fTime;
|
||||
vWaterVertices[2].tu1 = 1.000f; vWaterVertices[2].tv1 = 0.5f*m_fTime;
|
||||
vWaterVertices[3].tu1 = 1.000f; vWaterVertices[3].tv1 = 0.5f*m_fTime + 2.0f;
|
||||
m_pWaterVB->Unlock();
|
||||
|
||||
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 scene
|
||||
m_pd3dDevice->Clear( 0, NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
|
||||
0xff000000, 1.0f, 0L );
|
||||
|
||||
// Begin the scene
|
||||
if( FAILED( m_pd3dDevice->BeginScene() ) )
|
||||
return S_OK;
|
||||
|
||||
// Render the waves
|
||||
m_pd3dDevice->SetTexture( 0, m_pBumpMap );
|
||||
m_pd3dDevice->SetTexture( 1, m_pBackgroundTexture );
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_BUMPENVMAP );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1 );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );
|
||||
m_pd3dDevice->SetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
|
||||
|
||||
m_pd3dDevice->SetVertexShader( D3DFVF_BUMPVERTEX );
|
||||
m_pd3dDevice->SetStreamSource( 0, m_pWaterVB, sizeof(BUMPVERTEX) );
|
||||
|
||||
// Verify that the texture operations are possible on the device
|
||||
DWORD dwNumPasses;
|
||||
if( FAILED( m_pd3dDevice->ValidateDevice( &dwNumPasses ) ) )
|
||||
{
|
||||
// The right thing to do when device validation fails is to try
|
||||
// a different rendering technique. This sample just warns the user.
|
||||
m_bDeviceValidationFailed = TRUE;
|
||||
}
|
||||
|
||||
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
|
||||
|
||||
// Output statistics
|
||||
m_pFont->DrawText( 2, 0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
|
||||
m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );
|
||||
|
||||
if( m_bDeviceValidationFailed )
|
||||
{
|
||||
m_pFont->DrawText( 2, 40, D3DCOLOR_ARGB(255,255,0,0),
|
||||
_T("Warning: Device validation failed. Rendering may not look right.") );
|
||||
}
|
||||
|
||||
// End the scene.
|
||||
m_pd3dDevice->EndScene();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CreateBumpMapFromSurface()
|
||||
// Desc: Creates a bumpmap from a surface
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::CreateBumpMap()
|
||||
{
|
||||
UINT iWidth = 256;
|
||||
UINT iHeight = 256;
|
||||
|
||||
// Create the bumpmap's surface and texture objects
|
||||
if( FAILED( m_pd3dDevice->CreateTexture( iWidth, iHeight, 1, 0,
|
||||
D3DFMT_V8U8, D3DPOOL_MANAGED, &m_pBumpMap ) ) )
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Fill the bumpmap texels to simulate a lens
|
||||
D3DLOCKED_RECT lrDst;
|
||||
m_pBumpMap->LockRect( 0, &lrDst, 0, 0 );
|
||||
DWORD dwDstPitch = (DWORD)lrDst.Pitch;
|
||||
BYTE* pDst = (BYTE*)lrDst.pBits;
|
||||
|
||||
for( DWORD y=0; y<iHeight; y++ )
|
||||
{
|
||||
for( DWORD x=0; x<iWidth; x++ )
|
||||
{
|
||||
FLOAT fx = x/(FLOAT)iWidth - 0.5f;
|
||||
FLOAT fy = y/(FLOAT)iHeight - 0.5f;
|
||||
FLOAT r = sqrtf( fx*fx + fy*fy );
|
||||
|
||||
CHAR iDu = (CHAR)(64*cosf(4.0f*(fx+fy)*D3DX_PI));
|
||||
CHAR iDv = (CHAR)(64*sinf(4.0f*(fx+fy)*D3DX_PI));
|
||||
|
||||
pDst[2*x+0] = iDu;
|
||||
pDst[2*x+1] = iDv;
|
||||
}
|
||||
pDst += lrDst.Pitch;
|
||||
}
|
||||
|
||||
m_pBumpMap->UnlockRect(0);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitDeviceObjects()
|
||||
// Desc: Initialize scene objects
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
|
||||
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("LobbyXPos.bmp"),
|
||||
&m_pBackgroundTexture, D3DFMT_A8R8G8B8 ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
// create a bumpmap from info in source surface
|
||||
if( FAILED( CreateBumpMap() ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( m_pd3dDevice->CreateVertexBuffer( 4*sizeof(BUMPVERTEX),
|
||||
D3DUSAGE_WRITEONLY,
|
||||
D3DFVF_BUMPVERTEX,
|
||||
D3DPOOL_MANAGED, &m_pWaterVB ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
BUMPVERTEX* v;
|
||||
m_pWaterVB->Lock( 0, 0, (BYTE**)&v, 0 );
|
||||
v[0].p = D3DXVECTOR3(-60.0f,-60.0f, 0.0f ); v[0].n = D3DXVECTOR3( 0, 1, 0 );
|
||||
v[1].p = D3DXVECTOR3(-60.0f, 60.0f, 0.0f ); v[1].n = D3DXVECTOR3( 0, 1, 0 );
|
||||
v[2].p = D3DXVECTOR3( 60.0f,-60.0f, 0.0f ); v[2].n = D3DXVECTOR3( 0, 1, 0 );
|
||||
v[3].p = D3DXVECTOR3( 60.0f, 60.0f, 0.0f ); v[3].n = D3DXVECTOR3( 0, 1, 0 );
|
||||
v[0].tu2 = 0.000f; v[0].tv2 = 1.0f;
|
||||
v[1].tu2 = 0.000f; v[1].tv2 = 0.0f;
|
||||
v[2].tu2 = 1.000f; v[2].tv2 = 1.0f;
|
||||
v[3].tu2 = 1.000f; v[3].tv2 = 0.0f;
|
||||
m_pWaterVB->Unlock();
|
||||
|
||||
m_bDeviceValidationFailed = FALSE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Initialize scene objects
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
|
||||
// Set the transform matrices
|
||||
D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f, 0.0f, -100.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 );
|
||||
D3DXMatrixPerspectiveFovLH( &matProj, 1.00f, 1.0f, 1.0f, 3000.0f );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
||||
|
||||
// Set any appropiate state
|
||||
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xffffffff );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
|
||||
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->SetTextureStageState( 1, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DeleteDeviceObjects()
|
||||
// Desc: Called when the app is exiting, or the device is being changed,
|
||||
// this function deletes any device dependent objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::DeleteDeviceObjects()
|
||||
{
|
||||
m_pFont->DeleteDeviceObjects();
|
||||
SAFE_RELEASE( m_pWaterVB );
|
||||
SAFE_RELEASE( m_pBumpMap );
|
||||
SAFE_RELEASE( m_pBackgroundTexture );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FinalCleanup()
|
||||
// Desc: Called before the app exits, this function gives the app the chance
|
||||
// to cleanup after itself.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FinalCleanup()
|
||||
{
|
||||
SAFE_DELETE( m_pFont );
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ConfirmDevice()
|
||||
// Desc: Called during device intialization, this code checks the device
|
||||
// for some minimum set of capabilities
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::ConfirmDevice( D3DCAPS8* pCaps, DWORD dwBehavior,
|
||||
D3DFORMAT Format )
|
||||
{
|
||||
// Device must be able to do bumpmapping
|
||||
if( 0 == ( pCaps->TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAP ) )
|
||||
return E_FAIL;
|
||||
|
||||
// Accept devices that can create D3DFMT_V8U8 textures
|
||||
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal,
|
||||
pCaps->DeviceType, Format,
|
||||
0, D3DRTYPE_TEXTURE,
|
||||
D3DFMT_V8U8 ) ) )
|
||||
return S_OK;
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
# Microsoft Developer Studio Project File - Name="BumpUnderWater" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=BumpUnderWater - 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 "BumpUnderWater.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 "BumpUnderWater.mak" CFG="BumpUnderWater - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BumpUnderWater - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "BumpUnderWater - 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)" == "BumpUnderWater - 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)" == "BumpUnderWater - 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 "BumpUnderWater - Win32 Release"
|
||||
# Name "BumpUnderWater - 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=.\BumpUnderWater.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "BumpUnderWater"=.\BumpUnderWater.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on BumpUnderWater.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=BumpUnderWater - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to BumpUnderWater - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "BumpUnderWater - Win32 Release" && "$(CFG)" != "BumpUnderWater - 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 "BumpUnderWater.mak" CFG="BumpUnderWater - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BumpUnderWater - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "BumpUnderWater - 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)" == "BumpUnderWater - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\BumpUnderWater.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\BumpUnderWater.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\BumpUnderWater.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)\BumpUnderWater.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)\BumpUnderWater.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)\BumpUnderWater.pdb" /machine:I386 /out:"$(OUTDIR)\BumpUnderWater.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\BumpUnderWater.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\BumpUnderWater.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "BumpUnderWater - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\BumpUnderWater.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\BumpUnderWater.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\BumpUnderWater.exe"
|
||||
-@erase "$(OUTDIR)\BumpUnderWater.ilk"
|
||||
-@erase "$(OUTDIR)\BumpUnderWater.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)\BumpUnderWater.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)\BumpUnderWater.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)\BumpUnderWater.pdb" /debug /machine:I386 /out:"$(OUTDIR)\BumpUnderWater.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\BumpUnderWater.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\BumpUnderWater.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("BumpUnderWater.dep")
|
||||
!INCLUDE "BumpUnderWater.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "BumpUnderWater.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "BumpUnderWater - Win32 Release" || "$(CFG)" == "BumpUnderWater - 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=.\BumpUnderWater.cpp
|
||||
|
||||
"$(INTDIR)\BumpUnderWater.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,57 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: BumpUnderWater Direct3D Sample
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
The BumpUnderwater sample demonstrates an underwater effect that can be
|
||||
acheived using bumpmapping. Bumpmapping is a texture blending technique used
|
||||
to render the appearance of rough, bumpy surfaces, but can also be used for
|
||||
other effects as shown here.
|
||||
|
||||
Note that not all cards support all features for all the various bumpmapping
|
||||
techniques (some hardware has no, or limited, bumpmapping support). For more
|
||||
information on bumpmapping, refer to the DirectX SDK documentation.
|
||||
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\D3D\BumpMapping\BumpUnderWater
|
||||
Executable: DXSDK\Samples\Multimedia\D3D\Bin
|
||||
|
||||
|
||||
User's Guide
|
||||
============
|
||||
The following keys are implemented. The dropdown menus can be used for the
|
||||
same controls.
|
||||
<Enter> Starts and stops the scene
|
||||
<Space> Advances the scene by a small increment
|
||||
<F1> Shows help or available commands.
|
||||
<F2> Prompts user to select a new rendering device or display mode
|
||||
<Alt+Enter> Toggles between fullscreen and windowed modes
|
||||
<Esc> Exits the app.
|
||||
|
||||
|
||||
Programming Notes
|
||||
=================
|
||||
Bumpmapping is an advanced multitexture blending technique that can be used
|
||||
to render the appearance of rough, bumpy surfaces. The bump map itself is a
|
||||
texture that stores the perturbation data. Bumpmapping requires two
|
||||
textures, actually. One is an environment map, which contains the lights
|
||||
that you see in the scene. The other is the actual bumpmapping, which
|
||||
contain values (stored as du and dv) used to "bump" the environment maps
|
||||
texture coordinates. Some bumpmaps also contain luminance values to control
|
||||
the "shininess" of a particular texel.
|
||||
|
||||
This sample uses bumpmapping in a non-traditional fashion. Since bumpmapping
|
||||
really just perturbs an environment map, it can be used for other effects. In
|
||||
this case, perturbing a background image (which could be rendered on the fly)
|
||||
to make an underwater effect.
|
||||
|
||||
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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,637 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: BumpWaves.cpp
|
||||
//
|
||||
// Desc: Code to simulate reflections off waves using bumpmapping.
|
||||
//
|
||||
// Note: This code uses the D3D Framework helper library.
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <tchar.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <D3DX8.h>
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Function prototypes and global (or static) variables
|
||||
//-----------------------------------------------------------------------------
|
||||
inline DWORD F2DW( FLOAT f ) { return *((DWORD*)&f); }
|
||||
|
||||
struct VERTEX
|
||||
{
|
||||
D3DXVECTOR3 p;
|
||||
FLOAT tu, tv;
|
||||
};
|
||||
|
||||
#define D3DFVF_VERTEX (D3DFVF_XYZ|D3DFVF_TEX1)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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_pBackgroundVB;
|
||||
LPDIRECT3DTEXTURE8 m_pBackgroundTexture;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pWaterVB;
|
||||
LPDIRECT3DTEXTURE8 m_psBumpMap;
|
||||
D3DXMATRIX m_matBumpMat;
|
||||
|
||||
LPDIRECT3DTEXTURE8 CreateBumpMap( DWORD, DWORD, D3DFORMAT );
|
||||
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
|
||||
|
||||
protected:
|
||||
HRESULT OneTimeSceneInit();
|
||||
HRESULT InitDeviceObjects();
|
||||
HRESULT RestoreDeviceObjects();
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
HRESULT DeleteDeviceObjects();
|
||||
HRESULT Render();
|
||||
HRESULT FrameMove();
|
||||
HRESULT FinalCleanup();
|
||||
HRESULT SetEMBMStates();
|
||||
|
||||
UINT m_n; // Number of vertices in the ground grid along X
|
||||
UINT m_m; // Number of vertices in the ground grid along Z
|
||||
UINT m_nTriangles; // Number of triangles in the ground grid
|
||||
|
||||
DWORD m_dwVertexShader; // Vertex shader handle for the bump waves
|
||||
BOOL m_bUseVertexShader; // Whether to use vertex shader or FF pipeline
|
||||
|
||||
public:
|
||||
CMyD3DApplication();
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Vertex shader code for bump waves -- this is used when the fixed-function
|
||||
// approach is not supported by the device
|
||||
//
|
||||
// const[0 - 2] Transformation matrix to the camera space, combined with texture
|
||||
// transformation matrix, because position in the camera space is
|
||||
// used as texture coordinates. Texture transfoX and Y row are
|
||||
// multiplied by 0.8 to make texture transformation.
|
||||
//
|
||||
// const[3-7] Transformation matrix to the projection space
|
||||
// const[8] [0.5, -0.5, 0, 0]
|
||||
//
|
||||
// v[0] - position
|
||||
// v[1] - texture coordinates for stage 0
|
||||
//
|
||||
char g_strVertexShader[] =
|
||||
"vs.1.1\n"
|
||||
"m4x4 oPos, v0, c3 ; transform position to the projection space\n"
|
||||
"; Compute vertex position in the camera space - this is our texture coordinates\n"
|
||||
"dp4 r0.x, v0, c0 \n"
|
||||
"dp4 r0.y, v0, c1 \n"
|
||||
"dp4 r0.z, v0, c2 \n"
|
||||
"; Do the rest of texture transform (first part was combined with the camera matrix) \n"
|
||||
"rcp r0.z, r0.z \n"
|
||||
"mad oT1.x, r0.x, r0.z, c8.x \n"
|
||||
"mad oT1.y, r0.y, r0.z, c8.y \n"
|
||||
"mov oT0.xy, v1 ; Copy input texture coordinates for the stage 0\n";
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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("BumpWaves: Using BumpMapping For Waves");
|
||||
m_bUseDepthBuffer = FALSE;
|
||||
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
m_psBumpMap = NULL;
|
||||
m_pBackgroundTexture = NULL;
|
||||
m_pBackgroundVB = NULL;
|
||||
m_pWaterVB = NULL;
|
||||
|
||||
// The following are set in InitDeviceObjects
|
||||
m_n = 0;
|
||||
m_m = 0;
|
||||
m_nTriangles = 0;
|
||||
|
||||
m_dwVertexShader = 0;
|
||||
m_bUseVertexShader = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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 bump matrix
|
||||
// Min r is 0.04 if amplitude is 32 to miss temporal aliasing
|
||||
// Max r is 0.16 for amplitude is 8 to miss spatial aliasing
|
||||
FLOAT r = 0.04f;
|
||||
m_matBumpMat._11 = r * cosf( m_fTime * 9.0f );
|
||||
m_matBumpMat._12 = -r * sinf( m_fTime * 9.0f );
|
||||
m_matBumpMat._21 = r * sinf( m_fTime * 9.0f );
|
||||
m_matBumpMat._22 = r * cosf( m_fTime * 9.0f );
|
||||
|
||||
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 render target
|
||||
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET, 0x00000000, 0.0f, 0L );
|
||||
|
||||
// Begin the scene
|
||||
if( FAILED( m_pd3dDevice->BeginScene() ) )
|
||||
return S_OK;
|
||||
|
||||
// Set up texture stage states for the background
|
||||
m_pd3dDevice->SetTexture( 0, m_pBackgroundTexture );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
|
||||
|
||||
// Render the background
|
||||
m_pd3dDevice->SetVertexShader( D3DFVF_VERTEX );
|
||||
m_pd3dDevice->SetStreamSource( 0, m_pBackgroundVB, sizeof(VERTEX) );
|
||||
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
|
||||
|
||||
// Render the water
|
||||
SetEMBMStates();
|
||||
if( m_bUseVertexShader )
|
||||
m_pd3dDevice->SetVertexShader( m_dwVertexShader );
|
||||
else
|
||||
m_pd3dDevice->SetVertexShader( D3DFVF_VERTEX );
|
||||
|
||||
m_pd3dDevice->SetStreamSource( 0, m_pWaterVB, sizeof(VERTEX) );
|
||||
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, m_nTriangles );
|
||||
|
||||
// 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 );
|
||||
TCHAR strInfo[100];
|
||||
if( m_bUseVertexShader )
|
||||
lstrcpy( strInfo, TEXT("Using Vertex Shader") );
|
||||
else
|
||||
lstrcpy( strInfo, TEXT("Using Fixed-Function Vertex Pipeline") );
|
||||
m_pFont->DrawText( 2, 40, D3DCOLOR_ARGB(255,255,255,255), strInfo );
|
||||
|
||||
// End the scene.
|
||||
m_pd3dDevice->EndScene();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: SetEMBMStates()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::SetEMBMStates()
|
||||
{
|
||||
// Set up texture stage 0's states for the bumpmap
|
||||
m_pd3dDevice->SetTexture( 0, m_psBumpMap );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVMAT00, F2DW( m_matBumpMat._11 ) );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVMAT01, F2DW( m_matBumpMat._12 ) );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVMAT10, F2DW( m_matBumpMat._21 ) );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_BUMPENVMAT11, F2DW( m_matBumpMat._22 ) );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_BUMPENVMAP );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT );
|
||||
|
||||
// Set up texture stage 1's states for the environment map
|
||||
m_pd3dDevice->SetTexture( 1, m_pBackgroundTexture );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
|
||||
|
||||
if( m_bUseVertexShader )
|
||||
{
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set up projected texture coordinates
|
||||
// tu = (0.8x + 0.5z) / z
|
||||
// tv = (0.8y - 0.5z) / z
|
||||
D3DXMATRIX mat;
|
||||
mat._11 = 0.8f; mat._12 = 0.0f; mat._13 = 0.0f;
|
||||
mat._21 = 0.0f; mat._22 = 0.8f; mat._23 = 0.0f;
|
||||
mat._31 = 0.5f; mat._32 =-0.5f; mat._33 = 1.0f;
|
||||
mat._41 = 0.0f; mat._42 = 0.0f; mat._43 = 0.0f;
|
||||
|
||||
m_pd3dDevice->SetTransform( D3DTS_TEXTURE1, &mat );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3|D3DTTFF_PROJECTED );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION | 1 );
|
||||
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CreateBumpMap()
|
||||
// Desc: Creates a bumpmap
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECT3DTEXTURE8 CMyD3DApplication::CreateBumpMap( DWORD dwWidth, DWORD dwHeight,
|
||||
D3DFORMAT d3dBumpFormat )
|
||||
{
|
||||
LPDIRECT3DTEXTURE8 psBumpMap;
|
||||
|
||||
// Check if the device can create the format
|
||||
if( FAILED( m_pD3D->CheckDeviceFormat( m_d3dCaps.AdapterOrdinal,
|
||||
m_d3dCaps.DeviceType,
|
||||
m_d3dsdBackBuffer.Format,
|
||||
0, D3DRTYPE_TEXTURE, d3dBumpFormat ) ) )
|
||||
return NULL;
|
||||
|
||||
// Create the bump map texture
|
||||
if( FAILED( m_pd3dDevice->CreateTexture( dwWidth, dwHeight, 1, 0 /* Usage */,
|
||||
d3dBumpFormat, D3DPOOL_MANAGED,
|
||||
&psBumpMap ) ) )
|
||||
return NULL;
|
||||
|
||||
// Lock the surface and write in some bumps for the waves
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
psBumpMap->LockRect( 0, &d3dlr, 0, 0 );
|
||||
CHAR* pDst = (CHAR*)d3dlr.pBits;
|
||||
CHAR iDu, iDv;
|
||||
|
||||
for( DWORD y=0; y<dwHeight; y++ )
|
||||
{
|
||||
CHAR* pPixel = pDst;
|
||||
|
||||
for( DWORD x=0; x<dwWidth; x++ )
|
||||
{
|
||||
FLOAT fx = x/(FLOAT)dwWidth - 0.5f;
|
||||
FLOAT fy = y/(FLOAT)dwHeight - 0.5f;
|
||||
|
||||
FLOAT r = sqrtf( fx*fx + fy*fy );
|
||||
|
||||
iDu = (CHAR)( 64 * cosf( 300.0f * r ) * expf( -r * 5.0f ) );
|
||||
iDu += (CHAR)( 32 * cosf( 150.0f * ( fx + fy ) ) );
|
||||
iDu += (CHAR)( 16 * cosf( 140.0f * ( fx * 0.85f - fy ) ) );
|
||||
|
||||
iDv = (CHAR)( 64 * sinf( 300.0f * r ) * expf( -r * 5.0f ) );
|
||||
iDv += (CHAR)( 32 * sinf( 150.0f * ( fx + fy ) ) );
|
||||
iDv += (CHAR)( 16 * sinf( 140.0f * ( fx * 0.85f - fy ) ) );
|
||||
|
||||
*pPixel++ = iDu;
|
||||
*pPixel++ = iDv;
|
||||
}
|
||||
pDst += d3dlr.Pitch;
|
||||
}
|
||||
psBumpMap->UnlockRect(0);
|
||||
|
||||
return psBumpMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitDeviceObjects()
|
||||
// Desc: Initialize scene objects
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// Load the texture for the background image
|
||||
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("Lake.bmp"),
|
||||
&m_pBackgroundTexture, D3DFMT_R5G6B5 ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
|
||||
// Create the bumpmap.
|
||||
m_psBumpMap = CreateBumpMap( 256, 256, D3DFMT_V8U8 );
|
||||
if( NULL == m_psBumpMap )
|
||||
return E_FAIL;
|
||||
|
||||
// Create a square for rendering the background
|
||||
if( FAILED( m_pd3dDevice->CreateVertexBuffer( 4*sizeof(VERTEX),
|
||||
D3DUSAGE_WRITEONLY, D3DFVF_VERTEX,
|
||||
D3DPOOL_MANAGED, &m_pBackgroundVB ) ) )
|
||||
return E_FAIL;
|
||||
VERTEX* v;
|
||||
m_pBackgroundVB->Lock( 0, 0, (BYTE**)&v, 0 );
|
||||
v[0].p = D3DXVECTOR3(-1000.0f, 0.0f, 0.0f );
|
||||
v[1].p = D3DXVECTOR3(-1000.0f, 1000.0f, 0.0f );
|
||||
v[2].p = D3DXVECTOR3( 1000.0f, 0.0f, 0.0f );
|
||||
v[3].p = D3DXVECTOR3( 1000.0f, 1000.0f, 0.0f );
|
||||
v[0].tu = 0.0f; v[0].tv = 147/256.0f;
|
||||
v[1].tu = 0.0f; v[1].tv = 0.0f;
|
||||
v[2].tu = 1.0f; v[2].tv = 147/256.0f;
|
||||
v[3].tu = 1.0f; v[3].tv = 0.0f;
|
||||
m_pBackgroundVB->Unlock();
|
||||
|
||||
// See if EMBM and projected vertices are supported at the same time
|
||||
// in the fixed-function shader. If not, switch to using a vertex shader.
|
||||
m_bUseVertexShader = FALSE;
|
||||
SetEMBMStates();
|
||||
DWORD dwPasses;
|
||||
if( FAILED( m_pd3dDevice->ValidateDevice( &dwPasses ) ) )
|
||||
m_bUseVertexShader = TRUE;
|
||||
|
||||
// If D3DPTEXTURECAPS_PROJECTED is set, projected textures are computed
|
||||
// per pixel, so this sample will work fine with just a quad for the water
|
||||
// model. If it's not set, textures are projected per vertex rather than
|
||||
// per pixel, so distortion will be visible unless we use more vertices.
|
||||
if( m_d3dCaps.TextureCaps & D3DPTEXTURECAPS_PROJECTED && !m_bUseVertexShader)
|
||||
{
|
||||
m_n = 2; // Number of vertices in the ground grid along X
|
||||
m_m = 2; // Number of vertices in the ground grid along Z
|
||||
}
|
||||
else
|
||||
{
|
||||
m_n = 8; // Number of vertices in the ground grid along X
|
||||
m_m = 8; // Number of vertices in the ground grid along Z
|
||||
}
|
||||
m_nTriangles = (m_n-1)*(m_m-1)*2; // Number of triangles in the ground
|
||||
|
||||
// Create a square grid m_n*m_m for rendering the water
|
||||
if( FAILED( m_pd3dDevice->CreateVertexBuffer( m_nTriangles*3*sizeof(VERTEX),
|
||||
D3DUSAGE_WRITEONLY, D3DFVF_VERTEX,
|
||||
D3DPOOL_MANAGED, &m_pWaterVB ) ) )
|
||||
return E_FAIL;
|
||||
m_pWaterVB->Lock( 0, 0, (BYTE**)&v, 0 );
|
||||
float dX = 2000.0f/(m_n-1);
|
||||
float dZ = 1250.0f/(m_m-1);
|
||||
float x0 = -1000;
|
||||
float z0 = -1250;
|
||||
float dU = 1.0f/(m_n-1);
|
||||
float dV = 0.7f/(m_m-1);
|
||||
UINT k = 0;
|
||||
for (UINT z=0; z < (m_m-1); z++)
|
||||
{
|
||||
for (UINT x=0; x < (m_n-1); x++)
|
||||
{
|
||||
v[k].p = D3DXVECTOR3(x0 + x*dX, 0.0f, z0 + z*dZ );
|
||||
v[k].tu = x*dU;
|
||||
v[k].tv = z*dV;
|
||||
k++;
|
||||
v[k].p = D3DXVECTOR3(x0 + x*dX, 0.0f, z0 + (z+1)*dZ );
|
||||
v[k].tu = x*dU;
|
||||
v[k].tv = (z+1)*dV;
|
||||
k++;
|
||||
v[k].p = D3DXVECTOR3(x0 + (x+1)*dX, 0.0f, z0 + (z+1)*dZ );
|
||||
v[k].tu = (x+1)*dU;
|
||||
v[k].tv = (z+1)*dV;
|
||||
k++;
|
||||
v[k].p = D3DXVECTOR3(x0 + x*dX, 0.0f, z0 + z*dZ );
|
||||
v[k].tu = x*dU;
|
||||
v[k].tv = z*dV;
|
||||
k++;
|
||||
v[k].p = D3DXVECTOR3(x0 + (x+1)*dX, 0.0f, z0 + (z+1)*dZ );
|
||||
v[k].tu = (x+1)*dU;
|
||||
v[k].tv = (z+1)*dV;
|
||||
k++;
|
||||
v[k].p = D3DXVECTOR3(x0 + (x+1)*dX, 0.0f, z0 + z*dZ );
|
||||
v[k].tu = (x+1)*dU;
|
||||
v[k].tv = z*dV;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
m_pWaterVB->Unlock();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Initialize scene objects
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
|
||||
// Set the transform matrices
|
||||
D3DXVECTOR3 vEyePt( 0.0f, 400.0f, -1650.0f );
|
||||
D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
|
||||
D3DXMATRIX matWorld, matView, matProj;
|
||||
|
||||
D3DXMatrixIdentity( &matWorld );
|
||||
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
|
||||
D3DXMatrixPerspectiveFovLH( &matProj, 1.00f, 1.0f, 1.0f, 10000.0f );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
||||
|
||||
// Set any appropiate state
|
||||
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xffffffff );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
|
||||
|
||||
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->SetTextureStageState( 1, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
|
||||
if ( m_bUseVertexShader )
|
||||
{
|
||||
DWORD dwWaveDecl[] =
|
||||
{
|
||||
D3DVSD_STREAM( 0 ),
|
||||
D3DVSD_REG( 0, D3DVSDT_FLOAT3 ), // Position
|
||||
D3DVSD_REG( 1, D3DVSDT_FLOAT2 ), // Tex coords
|
||||
D3DVSD_END()
|
||||
};
|
||||
|
||||
LPD3DXBUFFER pCode;
|
||||
if( FAILED( hr = D3DXAssembleShader( g_strVertexShader,
|
||||
strlen(g_strVertexShader),
|
||||
0, NULL, &pCode, NULL ) ) )
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
hr = m_pd3dDevice->CreateVertexShader( dwWaveDecl,
|
||||
(DWORD*)pCode->GetBufferPointer(),
|
||||
&m_dwVertexShader, 0);
|
||||
if( FAILED( hr ) )
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
pCode->Release();
|
||||
|
||||
D3DXMATRIX matCamera, matFinal;
|
||||
D3DXMatrixMultiply( &matCamera, &matWorld, &matView );
|
||||
D3DXMatrixMultiply( &matFinal, &matCamera, &matProj );
|
||||
D3DXMatrixTranspose(&matCamera, &matCamera);
|
||||
D3DXMatrixTranspose(&matFinal, &matFinal);
|
||||
matCamera(0, 0) *= 0.8f;
|
||||
matCamera(0, 1) *= 0.8f;
|
||||
matCamera(0, 2) *= 0.8f;
|
||||
matCamera(0, 3) *= 0.8f;
|
||||
matCamera(1, 0) *= 0.8f;
|
||||
matCamera(1, 1) *= 0.8f;
|
||||
matCamera(1, 2) *= 0.8f;
|
||||
matCamera(1, 3) *= 0.8f;
|
||||
if (FAILED( hr = m_pd3dDevice->SetVertexShaderConstant(0, &matCamera, 3) ) )
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
if (FAILED( hr = m_pd3dDevice->SetVertexShaderConstant(3, &matFinal, 4) ) )
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
FLOAT data[4] = {0.5f, -0.5f, 0, 0};
|
||||
if (FAILED( hr = m_pd3dDevice->SetVertexShaderConstant(8, &data, 1) ) )
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
if( m_dwVertexShader != 0 )
|
||||
{
|
||||
m_pd3dDevice->DeleteVertexShader( m_dwVertexShader );
|
||||
m_dwVertexShader = 0;
|
||||
}
|
||||
|
||||
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();
|
||||
SAFE_RELEASE( m_pBackgroundTexture );
|
||||
SAFE_RELEASE( m_psBumpMap );
|
||||
SAFE_RELEASE( m_pBackgroundVB );
|
||||
SAFE_RELEASE( m_pWaterVB );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FinalCleanup()
|
||||
// Desc: Called before the app exits, this function gives the app the chance
|
||||
// to cleanup after itself.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FinalCleanup()
|
||||
{
|
||||
SAFE_DELETE( m_pFont );
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ConfirmDevice()
|
||||
// Desc: Called during device intialization, this code checks the device
|
||||
// for some minimum set of capabilities
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::ConfirmDevice( D3DCAPS8* pCaps, DWORD dwBehavior,
|
||||
D3DFORMAT Format )
|
||||
{
|
||||
// Device must be able to do bumpmapping
|
||||
if( 0 == ( pCaps->TextureOpCaps & D3DTEXOPCAPS_BUMPENVMAP ) )
|
||||
return E_FAIL;
|
||||
|
||||
// Accept devices that can create D3DFMT_V8U8 textures
|
||||
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal,
|
||||
pCaps->DeviceType, Format,
|
||||
0, D3DRTYPE_TEXTURE,
|
||||
D3DFMT_V8U8 ) ) )
|
||||
return S_OK;
|
||||
|
||||
// Else, reject the device
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
# Microsoft Developer Studio Project File - Name="BumpWaves" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=BumpWaves - 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 "BumpWaves.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 "BumpWaves.mak" CFG="BumpWaves - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BumpWaves - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "BumpWaves - 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)" == "BumpWaves - 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)" == "BumpWaves - 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 "BumpWaves - Win32 Release"
|
||||
# Name "BumpWaves - 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=.\BumpWaves.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "BumpWaves"=.\BumpWaves.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on BumpWaves.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=BumpWaves - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to BumpWaves - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "BumpWaves - Win32 Release" && "$(CFG)" != "BumpWaves - 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 "BumpWaves.mak" CFG="BumpWaves - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "BumpWaves - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "BumpWaves - 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)" == "BumpWaves - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\BumpWaves.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\BumpWaves.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\BumpWaves.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)\BumpWaves.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)\BumpWaves.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)\BumpWaves.pdb" /machine:I386 /out:"$(OUTDIR)\BumpWaves.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\BumpWaves.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\BumpWaves.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "BumpWaves - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\BumpWaves.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\BumpWaves.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\BumpWaves.exe"
|
||||
-@erase "$(OUTDIR)\BumpWaves.ilk"
|
||||
-@erase "$(OUTDIR)\BumpWaves.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)\BumpWaves.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)\BumpWaves.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)\BumpWaves.pdb" /debug /machine:I386 /out:"$(OUTDIR)\BumpWaves.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\BumpWaves.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\BumpWaves.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("BumpWaves.dep")
|
||||
!INCLUDE "BumpWaves.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "BumpWaves.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "BumpWaves - Win32 Release" || "$(CFG)" == "BumpWaves - 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=.\BumpWaves.cpp
|
||||
|
||||
"$(INTDIR)\BumpWaves.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,63 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: BumpWaves Direct3D Sample
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
The BumpWaves program demonstrates the bump mapping capabilities of
|
||||
Direct3D. Bump mapping is a texture blending technique used to render the
|
||||
appearance of rough, bumpy surfaces. This sample renders a waterfront scene
|
||||
with only 4 triangles. The waves in the scene are completely fabricated with
|
||||
a bumpmap.
|
||||
|
||||
Note that not all cards support all features for all the various bumpmapping
|
||||
techniques (some hardware has no, or limited, bumpmapping support). For more
|
||||
information on bumpmapping, refer to the DirectX SDK documentation.
|
||||
|
||||
This sample also uses a technique called "projected textures", which is a
|
||||
texture-coordinate generation technique and is not the focal point of the
|
||||
sample. For more information on texture-coordinate generation, refer again
|
||||
to the DirectX SDK documentation.
|
||||
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\D3D\BumpMapping\BumpWaves
|
||||
Executable: DXSDK\Samples\Multimedia\D3D\Bin
|
||||
|
||||
|
||||
User's Guide
|
||||
============
|
||||
The following keys are implemented. The dropdown menus can be used for the
|
||||
same controls.
|
||||
<Enter> Starts and stops the scene
|
||||
<Space> Advances the scene by a small increment
|
||||
<F1> Shows help or available commands.
|
||||
<F2> Prompts user to select a new rendering device or display mode
|
||||
<Alt+Enter> Toggles between fullscreen and windowed modes
|
||||
<Esc> Exits the app.
|
||||
|
||||
|
||||
Programming Notes
|
||||
=================
|
||||
Bumpmapping is an advanced multitexture blending technique that can be used
|
||||
to render the appearance of rough, bumpy surfaces. The bump map itself is a
|
||||
texture that stores the perturbation data. Bumpmapping requires two
|
||||
textures, actually. One is an environment map, which contains the lights
|
||||
that you see in the scene. The other is the actual bumpmapping, which
|
||||
contain values (stored as du and dv) used to "bump" the environment maps
|
||||
texture coordinates. Some bumpmaps also contain luminance values to control
|
||||
the "shininess" of a particular texel.
|
||||
|
||||
In this sample, bumpmapping is used to generate waves in a scene. The
|
||||
backdrop is used as a projective texture for the environment map, so it
|
||||
reflects in the waves. The waves themselves appear to be generated with lots
|
||||
of polygons, but in reality, it's just one large quad.
|
||||
|
||||
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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,535 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DotProduct3.cpp
|
||||
//
|
||||
// Desc: D3D sample showing how to do bumpmapping using the DotProduct3
|
||||
// texture operation.
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <tchar.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <D3DX8.h>
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CUSTOMVERTEX
|
||||
{
|
||||
D3DXVECTOR3 v;
|
||||
DWORD diffuse;
|
||||
DWORD specular;
|
||||
FLOAT tu, tv;
|
||||
};
|
||||
|
||||
#define CUSTOMVERTEX_FVF (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_SPECULAR|D3DFVF_TEX1)
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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;
|
||||
CUSTOMVERTEX m_QuadVertices[4];
|
||||
LPDIRECT3DTEXTURE8 m_pCustomNormalMap;
|
||||
LPDIRECT3DTEXTURE8 m_pFileBasedNormalMap;
|
||||
D3DXVECTOR3 m_vLight;
|
||||
|
||||
BOOL m_bUseFileBasedTexture;
|
||||
BOOL m_bShowNormalMap;
|
||||
|
||||
HRESULT CreateFileBasedNormalMap();
|
||||
HRESULT CreateCustomNormalMap();
|
||||
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
|
||||
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
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: VectortoRGBA()
|
||||
// Desc: Turns a normalized vector into RGBA form. Used to encode vectors into
|
||||
// a height map.
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD VectortoRGBA( D3DXVECTOR3* v, FLOAT fHeight )
|
||||
{
|
||||
DWORD r = (DWORD)( 127.0f * v->x + 128.0f );
|
||||
DWORD g = (DWORD)( 127.0f * v->y + 128.0f );
|
||||
DWORD b = (DWORD)( 127.0f * v->z + 128.0f );
|
||||
DWORD a = (DWORD)( 255.0f * fHeight );
|
||||
|
||||
return( (a<<24L) + (r<<16L) + (g<<8L) + (b<<0L) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitVertex()
|
||||
// Desc: Initializes a vertex
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID InitVertex( CUSTOMVERTEX* vtx, FLOAT x, FLOAT y, FLOAT z, FLOAT tu, FLOAT tv )
|
||||
{
|
||||
D3DXVECTOR3 v(1,1,1);
|
||||
D3DXVec3Normalize( &v, &v );
|
||||
vtx[0].v = D3DXVECTOR3( x, y, z );
|
||||
vtx[0].diffuse = VectortoRGBA( &v, 1.0f );
|
||||
vtx[0].specular = 0x40400000;
|
||||
vtx[0].tu = tu;
|
||||
vtx[0].tv = tv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CMyD3DApplication()
|
||||
// Desc: Application constructor. Sets attributes for the app.
|
||||
//-----------------------------------------------------------------------------
|
||||
CMyD3DApplication::CMyD3DApplication()
|
||||
{
|
||||
m_strWindowTitle = _T("DotProduct3: BumpMapping Technique");
|
||||
m_bUseDepthBuffer = FALSE;
|
||||
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
|
||||
m_bUseFileBasedTexture = FALSE;
|
||||
m_bShowNormalMap = FALSE;
|
||||
|
||||
m_pCustomNormalMap = NULL;
|
||||
m_pFileBasedNormalMap = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: OneTimeSceneInit()
|
||||
// Desc: Called during initial app startup, this function performs all the
|
||||
// permanent initialization.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::OneTimeSceneInit()
|
||||
{
|
||||
InitVertex( &m_QuadVertices[0],-1.0f,-1.0f,-1.0f, 0.0f, 0.0f );
|
||||
InitVertex( &m_QuadVertices[1], 1.0f,-1.0f,-1.0f, 1.0f, 0.0f );
|
||||
InitVertex( &m_QuadVertices[2],-1.0f, 1.0f,-1.0f, 0.0f, 1.0f );
|
||||
InitVertex( &m_QuadVertices[3], 1.0f, 1.0f,-1.0f, 1.0f, 1.0f );
|
||||
|
||||
m_vLight = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FrameMove()
|
||||
// Desc: Called once per frame, the call is the entry point for animating
|
||||
// the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FrameMove()
|
||||
{
|
||||
// Compute the light vector from the cursor position
|
||||
if( GetFocus() )
|
||||
{
|
||||
POINT pt;
|
||||
GetCursorPos( &pt );
|
||||
ScreenToClient( m_hWnd, &pt );
|
||||
|
||||
m_vLight.x = -( ( ( 2.0f * pt.x ) / m_d3dsdBackBuffer.Width ) - 1 );
|
||||
m_vLight.y = -( ( ( 2.0f * pt.y ) / m_d3dsdBackBuffer.Height ) - 1 );
|
||||
m_vLight.z = 0.0f;
|
||||
|
||||
if( D3DXVec3Length( &m_vLight ) > 1.0f )
|
||||
D3DXVec3Normalize( &m_vLight, &m_vLight );
|
||||
else
|
||||
m_vLight.z = sqrtf( 1.0f - m_vLight.x*m_vLight.x
|
||||
- m_vLight.y*m_vLight.y );
|
||||
}
|
||||
|
||||
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 render target
|
||||
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET, 0x00000000f, 1.0f, 0L );
|
||||
|
||||
// Begin the scene
|
||||
if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
|
||||
{
|
||||
// Store the light vector, so it can be referenced in D3DTA_TFACTOR
|
||||
DWORD dwFactor = VectortoRGBA( &m_vLight, 0.0f );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, dwFactor );
|
||||
|
||||
// Modulate the texture (the normal map) with the light vector (stored
|
||||
// above in the texture factor)
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3 );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TFACTOR );
|
||||
|
||||
// If user wants to see the normal map, override the above renderstates and
|
||||
// simply show the texture
|
||||
if( TRUE == m_bShowNormalMap )
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
|
||||
|
||||
// Select which normal map to use
|
||||
if( m_bUseFileBasedTexture )
|
||||
m_pd3dDevice->SetTexture( 0, m_pFileBasedNormalMap );
|
||||
else
|
||||
m_pd3dDevice->SetTexture( 0, m_pCustomNormalMap );
|
||||
|
||||
// Draw the bumpmapped quad
|
||||
m_pd3dDevice->SetVertexShader( CUSTOMVERTEX_FVF );
|
||||
m_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, m_QuadVertices,
|
||||
sizeof(CUSTOMVERTEX) );
|
||||
|
||||
// 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:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::CreateFileBasedNormalMap()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
// Load the texture from a file
|
||||
if( FAILED( hr = D3DUtil_CreateTexture( m_pd3dDevice, _T("EarthBump.bmp"),
|
||||
&m_pFileBasedNormalMap,
|
||||
D3DFMT_A8R8G8B8 ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
|
||||
// Lock the texture
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
D3DSURFACE_DESC d3dsd;
|
||||
m_pFileBasedNormalMap->GetLevelDesc( 0, &d3dsd );
|
||||
m_pFileBasedNormalMap->LockRect( 0, &d3dlr, 0, 0 );
|
||||
DWORD* pPixel = (DWORD*)d3dlr.pBits;
|
||||
|
||||
// For each pixel, generate a vector normal that represents the change
|
||||
// in thea height field at that pixel
|
||||
for( DWORD j=0; j<d3dsd.Height; j++ )
|
||||
{
|
||||
for( DWORD i=0; i<d3dsd.Width; i++ )
|
||||
{
|
||||
DWORD color00 = pPixel[0];
|
||||
DWORD color10 = pPixel[1];
|
||||
DWORD color01 = pPixel[d3dlr.Pitch/sizeof(DWORD)];
|
||||
|
||||
FLOAT fHeight00 = (FLOAT)((color00&0x00ff0000)>>16)/255.0f;
|
||||
FLOAT fHeight10 = (FLOAT)((color10&0x00ff0000)>>16)/255.0f;
|
||||
FLOAT fHeight01 = (FLOAT)((color01&0x00ff0000)>>16)/255.0f;
|
||||
|
||||
D3DXVECTOR3 vPoint00( i+0.0f, j+0.0f, fHeight00 );
|
||||
D3DXVECTOR3 vPoint10( i+1.0f, j+0.0f, fHeight10 );
|
||||
D3DXVECTOR3 vPoint01( i+0.0f, j+1.0f, fHeight01 );
|
||||
D3DXVECTOR3 v10 = vPoint10 - vPoint00;
|
||||
D3DXVECTOR3 v01 = vPoint01 - vPoint00;
|
||||
|
||||
D3DXVECTOR3 vNormal;
|
||||
D3DXVec3Cross( &vNormal, &v10, &v01 );
|
||||
D3DXVec3Normalize( &vNormal, &vNormal );
|
||||
|
||||
// Store the normal as an RGBA value in the normal map
|
||||
*pPixel++ = VectortoRGBA( &vNormal, fHeight00 );
|
||||
}
|
||||
}
|
||||
|
||||
// Unlock the texture and return successful
|
||||
m_pFileBasedNormalMap->UnlockRect(0);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::CreateCustomNormalMap()
|
||||
{
|
||||
DWORD dwWidth = 512;
|
||||
DWORD dwHeight = 512;
|
||||
HRESULT hr;
|
||||
|
||||
// Create a 32-bit texture for the custom normal map
|
||||
hr = m_pd3dDevice->CreateTexture( dwWidth, dwHeight, 1,
|
||||
0 /* Usage */,
|
||||
D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
|
||||
&m_pCustomNormalMap );
|
||||
if( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
// Lock the texture to fill it with our custom image
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
if( FAILED( m_pCustomNormalMap->LockRect( 0, &d3dlr, 0, 0 ) ) )
|
||||
return E_FAIL;
|
||||
DWORD* pPixel = (DWORD*)d3dlr.pBits;
|
||||
|
||||
// Fill each pixel
|
||||
for( DWORD j=0; j<dwHeight; j++ )
|
||||
{
|
||||
for( DWORD i=0; i<dwWidth; i++ )
|
||||
{
|
||||
FLOAT xp = ( (5.0f*i) / (dwWidth-1) );
|
||||
FLOAT yp = ( (5.0f*j) / (dwHeight-1) );
|
||||
FLOAT x = 2*(xp-floorf(xp))-1;
|
||||
FLOAT y = 2*(yp-floorf(yp))-1;
|
||||
FLOAT z = sqrtf( 1.0f - x*x - y*y );
|
||||
|
||||
// Make image of raised circle. Outside of circle is gray
|
||||
if( (x*x + y*y) <= 1.0f )
|
||||
{
|
||||
D3DXVECTOR3 vVector( x, y, z );
|
||||
*pPixel++ = VectortoRGBA( &vVector, 1.0f );
|
||||
}
|
||||
else
|
||||
*pPixel++ = 0x80808080;
|
||||
}
|
||||
}
|
||||
|
||||
// Unlock the map and return successful
|
||||
m_pCustomNormalMap->UnlockRect(0);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// Create the normal maps
|
||||
if( FAILED( hr = CreateFileBasedNormalMap() ) )
|
||||
return hr;
|
||||
if( FAILED( hr = CreateCustomNormalMap() ) )
|
||||
return hr;
|
||||
|
||||
// Set menu states
|
||||
CheckMenuItem( GetMenu(m_hWnd), IDM_USEFILEBASEDTEXTURE,
|
||||
m_bUseFileBasedTexture ? MF_CHECKED : MF_UNCHECKED );
|
||||
CheckMenuItem( GetMenu(m_hWnd), IDM_USECUSTOMTEXTURE,
|
||||
m_bUseFileBasedTexture ? MF_UNCHECKED : MF_CHECKED );
|
||||
CheckMenuItem( GetMenu(m_hWnd), IDM_SHOWNORMALMAP,
|
||||
m_bShowNormalMap ? MF_CHECKED : MF_UNCHECKED );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
|
||||
// Set the transform matrices
|
||||
D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f, 0.0f, 2.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, 500.0f );
|
||||
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
||||
|
||||
// Set misc render states
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc: Called when the app is exiting, or the device is being changed,
|
||||
// this function deletes any device dependent objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DeleteDeviceObjects()
|
||||
// Desc: Called when the app is exiting, or the device is being changed,
|
||||
// this function deletes any device dependent objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::DeleteDeviceObjects()
|
||||
{
|
||||
m_pFont->DeleteDeviceObjects();
|
||||
SAFE_RELEASE( m_pFileBasedNormalMap );
|
||||
SAFE_RELEASE( m_pCustomNormalMap );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FinalCleanup()
|
||||
// Desc: Called before the app exits, this function gives the app the chance
|
||||
// to cleanup after itself.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FinalCleanup()
|
||||
{
|
||||
SAFE_DELETE( m_pFont );
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ConfirmDevice()
|
||||
// Desc: Called during device intialization, this code checks the device
|
||||
// for some minimum set of capabilities
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::ConfirmDevice( D3DCAPS8* pCaps, DWORD dwBehavior,
|
||||
D3DFORMAT Format )
|
||||
{
|
||||
if( pCaps->TextureOpCaps & D3DTEXOPCAPS_DOTPRODUCT3 )
|
||||
return S_OK;
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: MsgProc()
|
||||
// Desc: Message proc function to handle key and menu input
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CMyD3DApplication::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
{
|
||||
if( uMsg == WM_COMMAND )
|
||||
{
|
||||
switch( LOWORD(wParam) )
|
||||
{
|
||||
case IDM_USEFILEBASEDTEXTURE:
|
||||
m_bUseFileBasedTexture = TRUE;
|
||||
CheckMenuItem( GetMenu(hWnd), IDM_USEFILEBASEDTEXTURE, MF_CHECKED );
|
||||
CheckMenuItem( GetMenu(hWnd), IDM_USECUSTOMTEXTURE, MF_UNCHECKED );
|
||||
break;
|
||||
|
||||
case IDM_USECUSTOMTEXTURE:
|
||||
m_bUseFileBasedTexture = FALSE;
|
||||
CheckMenuItem( GetMenu(hWnd), IDM_USEFILEBASEDTEXTURE, MF_UNCHECKED );
|
||||
CheckMenuItem( GetMenu(hWnd), IDM_USECUSTOMTEXTURE, MF_CHECKED );
|
||||
break;
|
||||
|
||||
case IDM_SHOWNORMALMAP:
|
||||
m_bShowNormalMap = !m_bShowNormalMap;
|
||||
CheckMenuItem( GetMenu(hWnd), IDM_SHOWNORMALMAP,
|
||||
m_bShowNormalMap ? MF_CHECKED : MF_UNCHECKED );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return CD3DApplication::MsgProc( hWnd, uMsg, wParam, lParam );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
# Microsoft Developer Studio Project File - Name="DotProduct3" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=DotProduct3 - 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 "dotproduct3.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 "dotproduct3.mak" CFG="DotProduct3 - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "DotProduct3 - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "DotProduct3 - 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)" == "DotProduct3 - 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 ddraw.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)" == "DotProduct3 - 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 ddraw.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 "DotProduct3 - Win32 Release"
|
||||
# Name "DotProduct3 - 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=.\directx.ico
|
||||
# End Source File
|
||||
# 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=.\DotProduct3.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "DotProduct3"=.\dotproduct3.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on dotproduct3.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=DotProduct3 - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to DotProduct3 - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "DotProduct3 - Win32 Release" && "$(CFG)" != "DotProduct3 - 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 "dotproduct3.mak" CFG="DotProduct3 - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "DotProduct3 - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "DotProduct3 - 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)" == "DotProduct3 - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\dotproduct3.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\DotProduct3.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\WinMain.res"
|
||||
-@erase "$(OUTDIR)\dotproduct3.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)\dotproduct3.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)\dotproduct3.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8.lib d3d8.lib ddraw.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)\dotproduct3.pdb" /machine:I386 /out:"$(OUTDIR)\dotproduct3.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\DotProduct3.obj" \
|
||||
"$(INTDIR)\WinMain.res"
|
||||
|
||||
"$(OUTDIR)\dotproduct3.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "DotProduct3 - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\dotproduct3.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\DotProduct3.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\WinMain.res"
|
||||
-@erase "$(OUTDIR)\dotproduct3.exe"
|
||||
-@erase "$(OUTDIR)\dotproduct3.ilk"
|
||||
-@erase "$(OUTDIR)\dotproduct3.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)\dotproduct3.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)\dotproduct3.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8dt.lib d3d8.lib ddraw.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)\dotproduct3.pdb" /debug /machine:I386 /out:"$(OUTDIR)\dotproduct3.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\DotProduct3.obj" \
|
||||
"$(INTDIR)\WinMain.res"
|
||||
|
||||
"$(OUTDIR)\dotproduct3.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("dotproduct3.dep")
|
||||
!INCLUDE "dotproduct3.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "dotproduct3.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "DotProduct3 - Win32 Release" || "$(CFG)" == "DotProduct3 - 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=.\DotProduct3.cpp
|
||||
|
||||
"$(INTDIR)\DotProduct3.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DotProduct3 Direct3D Sample
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
The DotProduct3 samples demonstrates an alternative approach to Direct3D
|
||||
bumpmapping. This technique is named after the mathematical operation which
|
||||
combines a light vector with a surface normal. The normals for a surface are
|
||||
traditional (x,y,z) vectors stored in RGBA format in a texture map (called a
|
||||
normal map, for this technique).
|
||||
|
||||
Not all cards support DotProduct3 blending teture stages, but then not all
|
||||
cards support Direct3D bumpmapping. Refer to the DirectX SDK documentation
|
||||
for more information.
|
||||
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\D3D\BumpMapping\DotProduct3
|
||||
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
|
||||
=================
|
||||
The lighting equation for simulating bump mapping invloves using the dot
|
||||
product of the surface normal and the lighting vector. The lighting vector
|
||||
is simply passed into the texture factor, and the normals are encoded in a
|
||||
texture map. The blend stages, then, look like
|
||||
SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3 );
|
||||
SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TFACTOR );
|
||||
|
||||
The only trick then, is getting the normals stored in the texture. To do
|
||||
this, the components of a vector (XYZW) are each turned from a 32-bit
|
||||
floating value into a signed 8-bit integer and packed into a texture color
|
||||
(RGBA). The code show how to do this using a custom-generated normal map,
|
||||
as well as one built from an actual bumpmapping texture image.
|
||||
|
||||
Note that not all cards support all features for all the various bumpmapping
|
||||
techniques (some hardware has no, or limited, bumpmapping support). For more
|
||||
information on bumpmapping, refer to the DirectX SDK documentation.
|
||||
|
||||
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
|
||||
@@ -0,0 +1,39 @@
|
||||
//{{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_USECUSTOMTEXTURE 40012
|
||||
#define IDM_SHOWNORMALMAP 40013
|
||||
#define IDM_USEFILEBASEDTEXTURE 40014
|
||||
#define e 40015
|
||||
|
||||
// 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 40016
|
||||
#define _APS_NEXT_CONTROL_VALUE 1027
|
||||
#define _APS_NEXT_SYMED_VALUE 102
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,189 @@
|
||||
//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
|
||||
"C", IDM_USECUSTOMTEXTURE, VIRTKEY, CONTROL, NOINVERT
|
||||
"F", IDM_USEFILEBASEDTEXTURE, VIRTKEY, CONTROL, NOINVERT
|
||||
"N", IDM_SHOWNORMALMAP, VIRTKEY, CONTROL, NOINVERT
|
||||
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 "Use &file-based texture\tCtrl+F", IDM_USEFILEBASEDTEXTURE
|
||||
MENUITEM "Use &custom texture\tCtrl+C", IDM_USECUSTOMTEXTURE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Show &normal map\tCtrl+N", IDM_SHOWNORMALMAP
|
||||
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
|
||||
|
||||
@@ -0,0 +1,585 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Emboss.cpp
|
||||
//
|
||||
// Desc: Shows how to do a bumpmapping technique called emobssing, in which a
|
||||
// heightmap is subtracted from itself, with slightly offset texture
|
||||
// coordinates for the second pass.
|
||||
//
|
||||
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <D3DX8.h>
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DFile.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defines, constants, and global variables
|
||||
//-----------------------------------------------------------------------------
|
||||
struct EMBOSSVERTEX
|
||||
{
|
||||
D3DXVECTOR3 p;
|
||||
D3DXVECTOR3 n;
|
||||
FLOAT tu, tv;
|
||||
FLOAT tu2, tv2;
|
||||
};
|
||||
|
||||
#define D3DFVF_EMBOSSVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX2)
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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; // Font for drawing text
|
||||
CD3DMesh* m_pObject; // Object to render
|
||||
D3DLIGHT8 m_Light; // The light
|
||||
BOOL m_bShowEmbossMethod; // Whether to do the embossing
|
||||
|
||||
LPDIRECT3DTEXTURE8 m_pEmbossTexture; // The emboss texture
|
||||
D3DXVECTOR3 m_vBumpLightPos; // Light position
|
||||
D3DXVECTOR3* m_pTangents; // Array of vertex tangents
|
||||
D3DXVECTOR3* m_pBinormals; // Array of vertex binormals
|
||||
|
||||
// Internal functions
|
||||
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
|
||||
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
VOID ApplyEnvironmentMap();
|
||||
VOID ComputeTangentsAndBinormals();
|
||||
|
||||
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("Emboss: BumpMapping Technique");
|
||||
m_bUseDepthBuffer = TRUE;
|
||||
m_bShowCursorWhenFullscreen = TRUE;
|
||||
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
m_pObject = new CD3DMesh();
|
||||
m_pEmbossTexture = NULL;
|
||||
m_bShowEmbossMethod = TRUE;
|
||||
m_pTangents = NULL;
|
||||
m_pBinormals = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: OneTimeSceneInit()
|
||||
// Desc: Called during initial app startup, this function performs all the
|
||||
// permanent initialization.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::OneTimeSceneInit()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ComputeTangentVector()
|
||||
// Desc: To find a tangent that heads in the direction of +tv(texcoords), find
|
||||
// the components of both vectors on the tangent surface, and add a
|
||||
// linear combination of the two projections that head in the +tv direction
|
||||
//-----------------------------------------------------------------------------
|
||||
D3DXVECTOR3 ComputeTangentVector( EMBOSSVERTEX pVtxA, EMBOSSVERTEX pVtxB,
|
||||
EMBOSSVERTEX pVtxC )
|
||||
{
|
||||
D3DXVECTOR3 vAB = pVtxB.p - pVtxA.p;
|
||||
D3DXVECTOR3 vAC = pVtxC.p - pVtxA.p;
|
||||
D3DXVECTOR3 n = pVtxA.n;
|
||||
|
||||
// Components of vectors to neghboring vertices that are orthogonal to the
|
||||
// vertex normal
|
||||
D3DXVECTOR3 vProjAB = vAB - ( D3DXVec3Dot( &n, &vAB ) * n );
|
||||
D3DXVECTOR3 vProjAC = vAC - ( D3DXVec3Dot( &n, &vAC ) * n );
|
||||
|
||||
// tu and tv texture coordinate differences
|
||||
FLOAT duAB = pVtxB.tu - pVtxA.tu;
|
||||
FLOAT duAC = pVtxC.tu - pVtxA.tu;
|
||||
FLOAT dvAB = pVtxB.tv - pVtxA.tv;
|
||||
FLOAT dvAC = pVtxC.tv - pVtxA.tv;
|
||||
|
||||
if( duAC*dvAB > duAB*dvAC )
|
||||
{
|
||||
duAC = -duAC;
|
||||
duAB = -duAB;
|
||||
}
|
||||
|
||||
D3DXVECTOR3 vTangent = duAC*vProjAB - duAB*vProjAC;
|
||||
D3DXVec3Normalize( &vTangent, &vTangent );
|
||||
return vTangent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID CMyD3DApplication::ComputeTangentsAndBinormals()
|
||||
{
|
||||
EMBOSSVERTEX* pVertices;
|
||||
WORD* pIndices;
|
||||
DWORD dwNumVertices;
|
||||
DWORD dwNumIndices;
|
||||
|
||||
// Gain access to the object's vertex and index buffers
|
||||
LPDIRECT3DVERTEXBUFFER8 pVB;
|
||||
m_pObject->GetSysMemMesh()->GetVertexBuffer( &pVB );
|
||||
pVB->Lock( 0, 0, (BYTE**)&pVertices, 0 );
|
||||
dwNumVertices = m_pObject->GetSysMemMesh()->GetNumVertices();
|
||||
|
||||
LPDIRECT3DINDEXBUFFER8 pIB;
|
||||
m_pObject->GetSysMemMesh()->GetIndexBuffer( &pIB );
|
||||
pIB->Lock( 0, 0, (BYTE**)&pIndices, 0 );
|
||||
dwNumIndices = m_pObject->GetSysMemMesh()->GetNumFaces() * 3;
|
||||
|
||||
// Allocate space for the vertices' tangents and binormals
|
||||
m_pTangents = new D3DXVECTOR3[dwNumVertices];
|
||||
m_pBinormals = new D3DXVECTOR3[dwNumVertices];
|
||||
ZeroMemory( m_pTangents, sizeof(D3DXVECTOR3)*dwNumVertices );
|
||||
ZeroMemory( m_pBinormals, sizeof(D3DXVECTOR3)*dwNumVertices );
|
||||
|
||||
// Generate the vertices' tangents and binormals
|
||||
for( DWORD i=0; i<dwNumIndices; i+=3 )
|
||||
{
|
||||
WORD a = pIndices[i+0];
|
||||
WORD b = pIndices[i+1];
|
||||
WORD c = pIndices[i+2];
|
||||
|
||||
// To find a tangent that heads in the direction of +tv(texcoords),
|
||||
// find the components of both vectors on the tangent surface ,
|
||||
// and add a linear combination of the two projections that head in the +tv direction
|
||||
m_pTangents[a] += ComputeTangentVector( pVertices[a], pVertices[b], pVertices[c] );
|
||||
m_pTangents[b] += ComputeTangentVector( pVertices[b], pVertices[a], pVertices[c] );
|
||||
m_pTangents[c] += ComputeTangentVector( pVertices[c], pVertices[a], pVertices[b] );
|
||||
}
|
||||
|
||||
for( i=0; i<dwNumVertices; i++ )
|
||||
{
|
||||
// Normalize the tangents
|
||||
D3DXVec3Normalize( &m_pTangents[i], &m_pTangents[i] );
|
||||
|
||||
// Compute the binormals
|
||||
D3DXVec3Cross( &m_pBinormals[i], &pVertices[i].n, &m_pTangents[i] );
|
||||
}
|
||||
|
||||
// Unlock and release the vertex and index buffers
|
||||
pIB->Unlock();
|
||||
pVB->Unlock();
|
||||
pIB->Release();
|
||||
pVB->Release();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ApplyEnvironmentMap()
|
||||
// Desc: Performs a calculation on each of the vertices' normals to determine
|
||||
// what the texture coordinates should be for the environment map (in this
|
||||
// case the bump map).
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID CMyD3DApplication::ApplyEnvironmentMap()
|
||||
{
|
||||
EMBOSSVERTEX* pv;
|
||||
DWORD dwNumVertices;
|
||||
dwNumVertices = m_pObject->GetLocalMesh()->GetNumVertices();
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 pVB;
|
||||
m_pObject->GetLocalMesh()->GetVertexBuffer( &pVB );
|
||||
pVB->Lock( 0, 0, (BYTE**)&pv, 0 );
|
||||
|
||||
// Get the World matrix
|
||||
D3DXMATRIX WV,InvWV;
|
||||
m_pd3dDevice->GetTransform( D3DTS_WORLD, &WV );
|
||||
D3DXMatrixInverse( &InvWV, NULL, &WV );
|
||||
|
||||
// Get the current light position in object space
|
||||
D3DXVECTOR4 vTransformed;
|
||||
D3DXVec3Transform( &vTransformed, (D3DXVECTOR3*)&m_Light.Position, &InvWV );
|
||||
m_vBumpLightPos.x = vTransformed.x;
|
||||
m_vBumpLightPos.y = vTransformed.y;
|
||||
m_vBumpLightPos.z = vTransformed.z;
|
||||
|
||||
// Dimensions of texture needed for shifting tex coords
|
||||
D3DSURFACE_DESC d3dsd;
|
||||
m_pEmbossTexture->GetLevelDesc( 0, &d3dsd );
|
||||
|
||||
// Loop through the vertices, transforming each one and calculating
|
||||
// the correct texture coordinates.
|
||||
for( WORD i = 0; i < dwNumVertices; i++ )
|
||||
{
|
||||
// Find light vector in tangent space
|
||||
D3DXVECTOR3 vLightToVertex;
|
||||
D3DXVec3Normalize( &vLightToVertex, &(m_vBumpLightPos - pv[i].p) );
|
||||
|
||||
// Create rotation matrix (rotate into tangent space)
|
||||
FLOAT r = D3DXVec3Dot( &vLightToVertex, &pv[i].n );
|
||||
|
||||
if( r < 0.f )
|
||||
{
|
||||
// Don't shift coordinates when light below surface
|
||||
pv[i].tu2 = pv[i].tu;
|
||||
pv[i].tv2 = pv[i].tv;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Shift coordinates for the emboss effect
|
||||
D3DXVECTOR2 vEmbossShift;
|
||||
vEmbossShift.x = D3DXVec3Dot( &vLightToVertex, &m_pTangents[i] );
|
||||
vEmbossShift.y = D3DXVec3Dot( &vLightToVertex, &m_pBinormals[i] );
|
||||
D3DXVec2Normalize( &vEmbossShift, &vEmbossShift );
|
||||
pv[i].tu2 = pv[i].tu + vEmbossShift.x/d3dsd.Width;
|
||||
pv[i].tv2 = pv[i].tv - vEmbossShift.y/d3dsd.Height;
|
||||
}
|
||||
}
|
||||
|
||||
pVB->Unlock();
|
||||
pVB->Release();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FrameMove()
|
||||
// Desc: Called once per frame, the call is the entry point for animating
|
||||
// the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FrameMove()
|
||||
{
|
||||
// Rotate the object
|
||||
D3DXMATRIX matWorld;
|
||||
D3DXMatrixRotationY( &matWorld, m_fTime );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
|
||||
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 backbuffer
|
||||
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
|
||||
0x00000000, 1.0f, 0L );
|
||||
|
||||
// Begin the scene
|
||||
if( FAILED( m_pd3dDevice->BeginScene() ) )
|
||||
return S_OK;
|
||||
|
||||
// Stage 0 is the base texture, with the height map in the alpha channel
|
||||
m_pd3dDevice->SetTexture( 0, m_pEmbossTexture );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
|
||||
|
||||
if( m_bShowEmbossMethod )
|
||||
{
|
||||
// Stage 1 passes through the RGB channels (SELECTARG2 = CURRENT), and
|
||||
// does a signed add with the inverted alpha channel. The texture coords
|
||||
// associated with Stage 1 are the shifted ones, so the result is:
|
||||
// (height - shifted_height) * tex.RGB * diffuse.RGB
|
||||
m_pd3dDevice->SetTexture( 1, m_pEmbossTexture );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1 );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG2 );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_ADDSIGNED );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE|D3DTA_COMPLEMENT );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
|
||||
|
||||
// Set up the alpha blender to multiply the alpha channel (monochrome emboss)
|
||||
// with the src color (lighted texture)
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ZERO );
|
||||
}
|
||||
|
||||
// Render the object
|
||||
m_pObject->Render( m_pd3dDevice );
|
||||
|
||||
// Restore render states
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
|
||||
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
|
||||
|
||||
// Draw some text
|
||||
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 );
|
||||
m_pFont->DrawText( 2, 40, 0xffffff00, _T("Move the light with the mouse") );
|
||||
m_pFont->DrawText( 2, 60, 0xffffff00, _T("Emboss-mode:") );
|
||||
m_pFont->DrawText( 130, 60, 0xffffffff, m_bShowEmbossMethod ? _T("ON") : _T("OFF") );
|
||||
|
||||
// End the scene.
|
||||
m_pd3dDevice->EndScene();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
// Init the font
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// Load texture map. Note that this is a special textures, which has a
|
||||
// height field stored in the alpha channel
|
||||
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("emboss1.tga"),
|
||||
&m_pEmbossTexture, D3DFMT_A8R8G8B8 ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
|
||||
// Load geometry
|
||||
if( FAILED( m_pObject->Create( m_pd3dDevice, _T("tiger.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
|
||||
// Set attributes for the geometry
|
||||
m_pObject->SetFVF( m_pd3dDevice, D3DFVF_EMBOSSVERTEX );
|
||||
m_pObject->UseMeshMaterials( FALSE );
|
||||
|
||||
// Compute the object's tangents and binormals, whaich are needed for the
|
||||
// emboss-tecnhique's texture-coordinate shifting calculations
|
||||
ComputeTangentsAndBinormals();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Restore device-memory objects and state after a device is created or
|
||||
// resized.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
// Restore device objects
|
||||
m_pObject->RestoreDeviceObjects( m_pd3dDevice );
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
|
||||
// Set up the 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 the view and projection matrices
|
||||
D3DXMATRIX matView, matProj;
|
||||
D3DXVECTOR3 vFromPt = D3DXVECTOR3( 0.0f, 0.0f, 3.5f );
|
||||
D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
D3DXMatrixLookAtLH( &matView, &vFromPt, &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_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 );
|
||||
|
||||
// Set up the light
|
||||
D3DUtil_InitLight( m_Light, D3DLIGHT_POINT, 5.0f, 5.0f, -20.0f );
|
||||
m_Light.Attenuation0 = 1.0f;
|
||||
m_pd3dDevice->SetLight( 0, &m_Light );
|
||||
m_pd3dDevice->LightEnable( 0, TRUE );
|
||||
|
||||
// Set miscellaneous render states
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00444444 );
|
||||
|
||||
ApplyEnvironmentMap();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc: Called when the device-dependent objects are about to be lost.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
m_pObject->InvalidateDeviceObjects();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DeleteDeviceObjects()
|
||||
// Desc: Called when the app is exiting, or the device is being changed,
|
||||
// this function deletes any device dependent objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::DeleteDeviceObjects()
|
||||
{
|
||||
SAFE_RELEASE( m_pEmbossTexture );
|
||||
|
||||
m_pObject->Destroy();
|
||||
m_pFont->DeleteDeviceObjects();
|
||||
|
||||
SAFE_DELETE_ARRAY( m_pTangents );
|
||||
SAFE_DELETE_ARRAY( m_pBinormals );
|
||||
|
||||
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_pObject );
|
||||
|
||||
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
|
||||
|
||||
// This sample uses the ADDSIGNED texture blending mode
|
||||
if( 0 == ( pCaps->TextureOpCaps & D3DTEXOPCAPS_ADDSIGNED ) )
|
||||
return E_FAIL;
|
||||
if( pCaps->MaxTextureBlendStages < 2 )
|
||||
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 msg, WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
{
|
||||
switch( msg )
|
||||
{
|
||||
case WM_COMMAND:
|
||||
if( LOWORD(wParam) == IDM_EMBOSSTOGGLE )
|
||||
m_bShowEmbossMethod = !m_bShowEmbossMethod;
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
if( m_pd3dDevice != NULL )
|
||||
{
|
||||
FLOAT w = (FLOAT)m_d3dsdBackBuffer.Width;
|
||||
FLOAT h = (FLOAT)m_d3dsdBackBuffer.Height;
|
||||
m_Light.Position.x = 200.0f * ( 0.5f - LOWORD(lParam) / w );
|
||||
m_Light.Position.y = 200.0f * ( 0.5f - HIWORD(lParam) / h );
|
||||
m_Light.Position.z = 100.0f;
|
||||
m_pd3dDevice->SetLight( 0, &m_Light );
|
||||
ApplyEnvironmentMap();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return CD3DApplication::MsgProc( hWnd, msg, wParam, lParam );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
# Microsoft Developer Studio Project File - Name="Emboss" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=Emboss - 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 "Emboss.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 "Emboss.mak" CFG="Emboss - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Emboss - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Emboss - 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)" == "Emboss - 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 dxguid.lib d3dx8.lib d3d8.lib d3dxof.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)" == "Emboss - 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 dxguid.lib d3dx8dt.lib d3d8.lib d3dxof.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 "Emboss - Win32 Release"
|
||||
# Name "Emboss - 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=.\directx.ico
|
||||
# End Source File
|
||||
# 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=.\Emboss.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Emboss"=.\Emboss.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on Emboss.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Emboss - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Emboss - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Emboss - Win32 Release" && "$(CFG)" != "Emboss - 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 "Emboss.mak" CFG="Emboss - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Emboss - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Emboss - 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)" == "Emboss - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\Emboss.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\Emboss.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\Emboss.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)\Emboss.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)\Emboss.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=dxguid.lib d3dx8.lib d3d8.lib d3dxof.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\Emboss.pdb" /machine:I386 /out:"$(OUTDIR)\Emboss.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\Emboss.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\Emboss.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Emboss - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\Emboss.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\Emboss.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\Emboss.exe"
|
||||
-@erase "$(OUTDIR)\Emboss.ilk"
|
||||
-@erase "$(OUTDIR)\Emboss.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)\Emboss.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)\Emboss.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=dxguid.lib d3dx8dt.lib d3d8.lib d3dxof.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\Emboss.pdb" /debug /machine:I386 /out:"$(OUTDIR)\Emboss.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\Emboss.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\Emboss.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("Emboss.dep")
|
||||
!INCLUDE "Emboss.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "Emboss.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "Emboss - Win32 Release" || "$(CFG)" == "Emboss - 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=.\Emboss.cpp
|
||||
|
||||
"$(INTDIR)\Emboss.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,44 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by winmain.rc
|
||||
//
|
||||
#define IDI_MAIN_ICON 101
|
||||
#define IDR_MAIN_ACCEL 113
|
||||
#define IDR_MENU 141
|
||||
#define IDR_POPUP 142
|
||||
#define IDD_SELECTDEVICE 144
|
||||
#define IDC_DEVICE_COMBO 1000
|
||||
#define IDC_MODE_COMBO 1001
|
||||
#define IDC_ADAPTER_COMBO 1002
|
||||
#define IDC_FULLSCREENMODES_COMBO 1003
|
||||
#define IDC_MULTISAMPLE_COMBO 1005
|
||||
#define IDC_WINDOWED_CHECKBOX 1012
|
||||
#define IDC_FULLSCREEN_TEXT 1014
|
||||
#define IDC_WINDOW 1016
|
||||
#define IDC_FULLSCREEN 1018
|
||||
#define IDM_CHANGEDEVICE 40002
|
||||
#define IDM_TOGGLEFULLSCREEN 40003
|
||||
#define IDM_TOGGLESTART 40004
|
||||
#define IDM_SINGLESTEP 40005
|
||||
#define IDM_EXIT 40006
|
||||
#define IDM_U8V8L8 40011
|
||||
#define IDM_U5V5L6 40012
|
||||
#define IDM_U8V8 40013
|
||||
#define IDM_TEXTURETOGGLE 40014
|
||||
#define IDM_EMBOSSTOGGLE 40014
|
||||
#define IDM_BUMPMAPTOGGLE 40015
|
||||
#define IDM_ENVMAPTOGGLE 40016
|
||||
#define IDM_LOW_TESSELATION 40017
|
||||
#define IDM_HIGH_TESSELATION 40018
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 146
|
||||
#define _APS_NEXT_COMMAND_VALUE 40019
|
||||
#define _APS_NEXT_CONTROL_VALUE 1027
|
||||
#define _APS_NEXT_SYMED_VALUE 102
|
||||
#endif
|
||||
#endif
|
||||
@@ -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
|
||||
"E", IDM_EMBOSSTOGGLE, VIRTKEY, CONTROL, NOINVERT
|
||||
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 "Toggle &emboss mode\tCtrl+E", IDM_EMBOSSTOGGLE
|
||||
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
|
||||
|
||||
@@ -0,0 +1,447 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: ClipMirror.cpp
|
||||
//
|
||||
// Desc: This sample shows how to use clip planes to implement a planar mirror.
|
||||
// The scene is reflected in a mirror and rendered in a 2nd pass. The
|
||||
// corners of the mirrors, together with the camera eye point, are used
|
||||
// to define a custom set of clip planes so that the reflected geometry
|
||||
// appears only within the mirror's boundaries.
|
||||
//
|
||||
// Note: This code uses the D3D Framework helper library.
|
||||
//
|
||||
// Copyright (c) 1999-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"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct MIRRORVERTEX
|
||||
// Desc: Custom mirror vertex type
|
||||
//-----------------------------------------------------------------------------
|
||||
struct MIRRORVERTEX
|
||||
{
|
||||
D3DXVECTOR3 p;
|
||||
D3DXVECTOR3 n;
|
||||
DWORD color;
|
||||
};
|
||||
|
||||
#define D3DFVF_MIRRORVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE)
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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; // Font for drawing text
|
||||
CD3DMesh* m_pTeapot; // The teapot object
|
||||
D3DXMATRIX m_matTeapot; // Teapot's local matrix
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pMirrorVB;
|
||||
|
||||
D3DXVECTOR3 m_vEyePt; // Vectors defining the camera
|
||||
D3DXVECTOR3 m_vLookatPt;
|
||||
D3DXVECTOR3 m_vUpVec;
|
||||
|
||||
HRESULT RenderMirror();
|
||||
HRESULT RenderScene();
|
||||
|
||||
protected:
|
||||
HRESULT OneTimeSceneInit();
|
||||
HRESULT InitDeviceObjects();
|
||||
HRESULT RestoreDeviceObjects();
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
HRESULT DeleteDeviceObjects();
|
||||
HRESULT Render();
|
||||
HRESULT FrameMove();
|
||||
HRESULT ConfirmDevice( D3DCAPS8* pCaps, DWORD dwBehavior, D3DFORMAT Format );
|
||||
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("ClipMirror: Using D3D Clip Planes");
|
||||
m_bUseDepthBuffer = TRUE;
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
m_pTeapot = new CD3DMesh;
|
||||
m_pMirrorVB = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: OneTimeSceneInit()
|
||||
// Desc: Called during initial app startup, this function performs all the
|
||||
// permanent initialization.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::OneTimeSceneInit()
|
||||
{
|
||||
// Initialize the camera's orientation
|
||||
m_vEyePt = D3DXVECTOR3( 0.0f, 2.0f, -6.5f );
|
||||
m_vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
m_vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FrameMove()
|
||||
// Desc: Called once per frame, the call is the entry point for animating
|
||||
// the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FrameMove()
|
||||
{
|
||||
// Set the teapot's local matrix (rotating about the y-axis)
|
||||
D3DXMatrixRotationY( &m_matTeapot, m_fTime );
|
||||
|
||||
// When the window has focus, let the mouse adjust the camera view
|
||||
if( GetFocus() )
|
||||
{
|
||||
D3DXQUATERNION quat = D3DUtil_GetRotationFromCursor( m_hWnd );
|
||||
m_vEyePt.x = 5*quat.y;
|
||||
m_vEyePt.y = 5*quat.x;
|
||||
m_vEyePt.z = -sqrtf( 50.0f - 25*quat.x*quat.x - 25*quat.y*quat.y );
|
||||
|
||||
D3DXMATRIX matView;
|
||||
D3DXMatrixLookAtLH( &matView, &m_vEyePt, &m_vLookatPt, &m_vUpVec );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RenderScene()
|
||||
// Desc: Renders all objects in the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RenderScene()
|
||||
{
|
||||
D3DXMATRIX matLocal, matWorldSaved;
|
||||
m_pd3dDevice->GetTransform( D3DTS_WORLD, &matWorldSaved );
|
||||
|
||||
// Build the local matrix
|
||||
D3DXMatrixMultiply( &matLocal, &m_matTeapot, &matWorldSaved );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matLocal );
|
||||
|
||||
// Render the object
|
||||
m_pTeapot->Render( m_pd3dDevice );
|
||||
|
||||
// Restore the modified render states
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorldSaved );
|
||||
|
||||
// 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 );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RenderMirror()
|
||||
// Desc: Renders the scene as reflected in a mirror. The corners of the mirror
|
||||
// define a plane, which is used to build the reflection matrix. The
|
||||
// scene is rendered with the cull-mode reversed, since all normals in
|
||||
// the scene are likewise reflected.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RenderMirror()
|
||||
{
|
||||
D3DXMATRIX matWorldSaved;
|
||||
D3DXMATRIX matReflectInMirror;
|
||||
D3DXPLANE plane;
|
||||
|
||||
// Save the world matrix so it can be restored
|
||||
m_pd3dDevice->GetTransform( D3DTS_WORLD, &matWorldSaved );
|
||||
|
||||
// Get the four corners of the mirror. (This should be dynamic rather than
|
||||
// hardcoded.)
|
||||
D3DXVECTOR3 a(-1.5f, 1.5f, 3.0f );
|
||||
D3DXVECTOR3 b( 1.5f, 1.5f, 3.0f );
|
||||
D3DXVECTOR3 c( -1.5f,-1.5f, 3.0f );
|
||||
D3DXVECTOR3 d( 1.5f,-1.5f, 3.0f );
|
||||
|
||||
// Construct the reflection matrix
|
||||
D3DXPlaneFromPoints( &plane, &a, &b, &c );
|
||||
D3DXMatrixReflect( &matReflectInMirror, &plane );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matReflectInMirror );
|
||||
|
||||
// Reverse the cull mode (since normals will be reflected)
|
||||
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
|
||||
|
||||
// Set the custom clip planes (so geometry is clipped by mirror edges).
|
||||
// This is the heart of this sample. The mirror has 4 edges, so there are
|
||||
// 4 clip planes, each defined by two mirror vertices and the eye point.
|
||||
m_pd3dDevice->SetClipPlane( 0, *D3DXPlaneFromPoints( &plane, &b, &a, &m_vEyePt ) );
|
||||
m_pd3dDevice->SetClipPlane( 1, *D3DXPlaneFromPoints( &plane, &d, &b, &m_vEyePt ) );
|
||||
m_pd3dDevice->SetClipPlane( 2, *D3DXPlaneFromPoints( &plane, &c, &d, &m_vEyePt ) );
|
||||
m_pd3dDevice->SetClipPlane( 3, *D3DXPlaneFromPoints( &plane, &a, &c, &m_vEyePt ) );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_CLIPPLANEENABLE,
|
||||
D3DCLIPPLANE0 | D3DCLIPPLANE1 | D3DCLIPPLANE2 | D3DCLIPPLANE3 );
|
||||
|
||||
// Render the scene
|
||||
RenderScene();
|
||||
|
||||
// Restore the modified render states
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorldSaved );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_CLIPPLANEENABLE, 0x00 );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
|
||||
|
||||
// Finally, render the mirror itself (as an alpha-blended quad)
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
|
||||
|
||||
m_pd3dDevice->SetStreamSource( 0, m_pMirrorVB, sizeof(MIRRORVERTEX) );
|
||||
m_pd3dDevice->SetVertexShader( D3DFVF_MIRRORVERTEX );
|
||||
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
|
||||
|
||||
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
|
||||
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
|
||||
0x000000ff, 1.0f, 0L );
|
||||
|
||||
// Begin the scene
|
||||
if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
|
||||
{
|
||||
// Render the scene
|
||||
RenderScene();
|
||||
|
||||
// Render the scene in the mirror
|
||||
RenderMirror();
|
||||
|
||||
// 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 );
|
||||
|
||||
// Set up the geometry objects
|
||||
if( FAILED( m_pTeapot->Create( m_pd3dDevice, _T("Teapot.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
|
||||
// Create a square for rendering the mirror
|
||||
if( FAILED( m_pd3dDevice->CreateVertexBuffer( 4*sizeof(MIRRORVERTEX),
|
||||
D3DUSAGE_WRITEONLY,
|
||||
D3DFVF_MIRRORVERTEX,
|
||||
D3DPOOL_MANAGED, &m_pMirrorVB ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
// Initialize the mirror's vertices
|
||||
MIRRORVERTEX* v;
|
||||
m_pMirrorVB->Lock( 0, 0, (BYTE**)&v, 0 );
|
||||
v[0].p = D3DXVECTOR3(-1.5f, 1.5f, 3.0f );
|
||||
v[2].p = D3DXVECTOR3(-1.5f,-1.5f, 3.0f );
|
||||
v[1].p = D3DXVECTOR3( 1.5f, 1.5f, 3.0f );
|
||||
v[3].p = D3DXVECTOR3( 1.5f,-1.5f, 3.0f );
|
||||
v[0].n = v[1].n = v[2].n = v[3].n = D3DXVECTOR3(0.0f,0.0f,-1.0f);
|
||||
v[0].color = v[1].color = v[2].color = v[3].color = 0x80ffffff;
|
||||
m_pMirrorVB->Unlock();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
|
||||
// Set up the geometry objects
|
||||
m_pTeapot->RestoreDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// Set up the textures
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
|
||||
// Set miscellaneous render states
|
||||
m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
|
||||
// Set up the matrices
|
||||
D3DXMATRIX matWorld, matView, matProj;
|
||||
D3DXMatrixIdentity( &matWorld );
|
||||
D3DXMatrixLookAtLH( &matView, &m_vEyePt, &m_vLookatPt, &m_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 );
|
||||
|
||||
// Set up a light
|
||||
if( ( m_d3dCaps.VertexProcessingCaps & D3DVTXPCAPS_DIRECTIONALLIGHTS ) ||
|
||||
!( m_dwCreateFlags & D3DCREATE_HARDWARE_VERTEXPROCESSING ) )
|
||||
{
|
||||
D3DLIGHT8 light;
|
||||
D3DUtil_InitLight( light, D3DLIGHT_DIRECTIONAL, 0.2f, -1.0f, -0.2f );
|
||||
m_pd3dDevice->SetLight( 0, &light );
|
||||
m_pd3dDevice->LightEnable( 0, TRUE );
|
||||
}
|
||||
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xff555555 );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
m_pTeapot->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_pTeapot->Destroy();
|
||||
|
||||
SAFE_RELEASE( m_pMirrorVB );
|
||||
|
||||
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
|
||||
|
||||
if( ( dwBehavior & D3DCREATE_HARDWARE_VERTEXPROCESSING ) ||
|
||||
( dwBehavior & D3DCREATE_MIXED_VERTEXPROCESSING ) )
|
||||
{
|
||||
if( pCaps->MaxUserClipPlanes < 4 )
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
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_pTeapot );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
# Microsoft Developer Studio Project File - Name="ClipMirror" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=ClipMirror - 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 "clipmirror.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 "clipmirror.mak" CFG="ClipMirror - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "ClipMirror - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "ClipMirror - 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)" == "ClipMirror - 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 dxguid.lib winmm.lib d3dxof.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\lib" /stack:0x200000,0x200000
|
||||
|
||||
!ELSEIF "$(CFG)" == "ClipMirror - 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 dxguid.lib winmm.lib d3dxof.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\..\lib" /stack:0x200000,0x200000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "ClipMirror - Win32 Release"
|
||||
# Name "ClipMirror - 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=.\ClipMirror.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "ClipMirror"=.\clipmirror.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on clipmirror.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=ClipMirror - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to ClipMirror - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "ClipMirror - Win32 Release" && "$(CFG)" != "ClipMirror - 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 "clipmirror.mak" CFG="ClipMirror - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "ClipMirror - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "ClipMirror - 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)" == "ClipMirror - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\clipmirror.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ClipMirror.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\clipmirror.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)\clipmirror.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)\clipmirror.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8.lib d3d8.lib dxguid.lib winmm.lib d3dxof.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\clipmirror.pdb" /machine:I386 /out:"$(OUTDIR)\clipmirror.exe" /libpath:"..\..\lib" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\ClipMirror.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\clipmirror.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "ClipMirror - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\clipmirror.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ClipMirror.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\clipmirror.exe"
|
||||
-@erase "$(OUTDIR)\clipmirror.ilk"
|
||||
-@erase "$(OUTDIR)\clipmirror.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)\clipmirror.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)\clipmirror.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8dt.lib d3d8.lib dxguid.lib winmm.lib d3dxof.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\clipmirror.pdb" /debug /machine:I386 /out:"$(OUTDIR)\clipmirror.exe" /pdbtype:sept /libpath:"..\..\lib" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\ClipMirror.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\clipmirror.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("clipmirror.dep")
|
||||
!INCLUDE "clipmirror.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "clipmirror.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "ClipMirror - Win32 Release" || "$(CFG)" == "ClipMirror - 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=.\ClipMirror.cpp
|
||||
|
||||
"$(INTDIR)\ClipMirror.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
BIN
Library/dxx8/samples/Multimedia/Direct3D/ClipMirror/directx.ico
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,50 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ClipMirror Direct3D Sample
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
The ClipMirror sample demonstrates the use of custom-defined clip planes.
|
||||
A 3D scene is rendered normally, and then again in a 2nd pass as if reflected
|
||||
in a planar mirror. Clip planes are used to clip the reflected scene to the
|
||||
edges of the mirror.
|
||||
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\D3D\ClipMirror
|
||||
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.
|
||||
|
||||
The mouse is also used in this sample to control the viewing position.
|
||||
|
||||
|
||||
Programming Notes
|
||||
=================
|
||||
The main feature of this sample is the use of clip planes. The rectangular
|
||||
mirror has four edges, so four clip planes are used. Each plane is defined
|
||||
by the eye point and two vertices of one edge of the mirror. With the clip
|
||||
planes in place, the view matrix is reflected in the mirror's plance, and
|
||||
then the scene geometry (the teapot object) can be rendered as normal.
|
||||
Afterwards, a semi-transparent rectangle is drawn to represent the mirror
|
||||
itself.
|
||||
|
||||
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
|
||||
|
||||
@@ -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
|
||||
179
Library/dxx8/samples/Multimedia/Direct3D/ClipMirror/winmain.rc
Normal 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
|
||||
|
||||
1172
Library/dxx8/samples/Multimedia/Direct3D/Cull/cull.cpp
Normal file
143
Library/dxx8/samples/Multimedia/Direct3D/Cull/cull.dsp
Normal file
@@ -0,0 +1,143 @@
|
||||
# Microsoft Developer Studio Project File - Name="Cull" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=Cull - 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 "cull.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 "cull.mak" CFG="Cull - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Cull - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Cull - 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)" == "Cull - 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 d3d8.lib d3dx8.lib winmm.lib 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 /stack:0x200000,0x200000
|
||||
|
||||
!ELSEIF "$(CFG)" == "Cull - 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 /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /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 d3d8.lib d3dx8.lib winmm.lib 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 /stack:0x200000,0x200000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Cull - Win32 Release"
|
||||
# Name "Cull - 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=.\winmain.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# 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\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=.\cull.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
29
Library/dxx8/samples/Multimedia/Direct3D/Cull/cull.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Cull"=.\Cull.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
241
Library/dxx8/samples/Multimedia/Direct3D/Cull/cull.mak
Normal file
@@ -0,0 +1,241 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on cull.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Cull - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Cull - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Cull - Win32 Release" && "$(CFG)" != "Cull - 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 "cull.mak" CFG="Cull - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Cull - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Cull - 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)" == "Cull - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\cull.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cull.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\cull.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)\cull.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)\cull.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3d8.lib d3dx8.lib winmm.lib 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 /incremental:no /pdb:"$(OUTDIR)\cull.pdb" /machine:I386 /out:"$(OUTDIR)\cull.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\cull.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\cull.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Cull - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\cull.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cull.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\cull.exe"
|
||||
-@erase "$(OUTDIR)\cull.ilk"
|
||||
-@erase "$(OUTDIR)\cull.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)\cull.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /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)\cull.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3d8.lib d3dx8.lib winmm.lib 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 /incremental:yes /pdb:"$(OUTDIR)\cull.pdb" /debug /machine:I386 /out:"$(OUTDIR)\cull.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\cull.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\cull.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("cull.dep")
|
||||
!INCLUDE "cull.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "cull.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "Cull - Win32 Release" || "$(CFG)" == "Cull - 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\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=.\cull.cpp
|
||||
|
||||
"$(INTDIR)\cull.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
BIN
Library/dxx8/samples/Multimedia/Direct3D/Cull/directx.ico
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
113
Library/dxx8/samples/Multimedia/Direct3D/Cull/readme.txt
Normal file
@@ -0,0 +1,113 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: Cull Direct3D Sample
|
||||
//
|
||||
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
The Cull sample illustrates how to cull objects whose object bounding box
|
||||
(OBB) does not intersect the view frustum. By not passing these objects
|
||||
to D3D, you save the time that would be spent by D3D transforming and
|
||||
lighting these objects which will never be visible. The time savings could
|
||||
be significant if there are many such objects, and/or if the objects contain
|
||||
many vertices.
|
||||
|
||||
More elaborate and efficient culling can be done by creating hierarchies
|
||||
of objects, with bounding boxes around groups of objects, so that not every
|
||||
object's OBB has to be compared to the view frustum.
|
||||
|
||||
It is more efficient to do this OBB/frustum intersection calculation in your
|
||||
own code than to use D3D to transform the OBB and check the resulting clip
|
||||
flags.
|
||||
|
||||
You can adapt the culling routines in this sample meet the needs of programs
|
||||
that you write.
|
||||
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\D3D\Cull
|
||||
Executable: DXSDK\Samples\Multimedia\D3D\Bin
|
||||
|
||||
|
||||
User's Guide
|
||||
============
|
||||
When you run this program, you'll see the same scene (a bunch of teapots)
|
||||
rendered into two viewports. The right viewport uses the view frustum that
|
||||
the code will cull against. The left viewport has an independent camera,
|
||||
and shows the right viewport's frustum as a visible object, so you can see
|
||||
where culling should be happening. 50 teapots are randomly placed in the
|
||||
scene, and they are rendered along with their semitransparent OBB's.
|
||||
|
||||
The teapots are colored as follows to indicate their cull status:
|
||||
|
||||
Dark Green: The object was quickly determined to be inside the frustum
|
||||
(CS_INSIDE)
|
||||
Light Green: The object was determined (after a fair bit of work) to be
|
||||
inside the frustum (CS_INSIDE_SLOW)
|
||||
Dark Red: The object was quickly determined to be outside the frustum
|
||||
(CS_OUTSIDE)
|
||||
Light Red: The object was determined (after a fair bit of work) to be
|
||||
outside the frustum (CS_OUTSIDE_SLOW)
|
||||
|
||||
You should only ever see green teapots in the right window. Note that
|
||||
most teapots are either dark green or dark red, indicating that the slower
|
||||
tests are not needed for the majority of cases.
|
||||
|
||||
To move the camera of the right viewport, click on the right side of the
|
||||
window, then use the camera keys listed below to move around.
|
||||
|
||||
To move the camera of the left viewport, click on the left side of the
|
||||
window, then use the camera keys listed below to move around.
|
||||
|
||||
You can also rotate the teapots to set up particular relationships against
|
||||
the view frustum. You cannot move the teapots, but you can get the same
|
||||
effect by moving the frustum instead.
|
||||
|
||||
The following keys are implemented. The dropdown menus can be used for the
|
||||
same controls.
|
||||
<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.
|
||||
<W, S, Arrow Keys> Move the camera
|
||||
<Q, E, A, Z> Rotate the camera
|
||||
<Y, U, H, J> Rotate the teapots
|
||||
<N> Snap the left camera to match the right camera
|
||||
<M> Snap the right camera to the original position
|
||||
|
||||
Programming Notes
|
||||
=================
|
||||
The OBB/viewport intersection algorithm used by this program is:
|
||||
1) If any OBB corner pt is inside the frustum, return CS_INSIDE
|
||||
2) Else if all OBB corner pts are outside a single frustum plane,
|
||||
return CS_OUTSIDE
|
||||
3) Else if any frustum edge penetrates a face of the OBB, return
|
||||
CS_INSIDE_SLOW
|
||||
4) Else if any OBB edge penetrates a face of the frustum, return
|
||||
CS_INSIDE_SLOW
|
||||
5) Else if any point in the frustum is outside any plane of the
|
||||
OBB, return CS_OUTSIDE_SLOW
|
||||
6) Else return CS_INSIDE_SLOW
|
||||
|
||||
The distinction between INSIDE and INSIDE_SLOW, and between OUTSIDE and
|
||||
OUTSIDE_SLOW, is only provided here for educational purposes. In a
|
||||
shipping app, you probably would combine the cullstates into just
|
||||
INSIDE and OUTSIDE, since all you usually need to know is whether the OBB
|
||||
is inside or outside the frustum.
|
||||
|
||||
The culling code shown here is written in a straightforward way for
|
||||
readability. It is not optimized for performance. Additional optimizations
|
||||
can be made, especially if the bounding box is a regular box (e.g., the front
|
||||
and back faces are parallel). Or this algorithm could be generalized to work
|
||||
for arbitrary convex bounding hulls to allow tighter fitting against the
|
||||
underlying models.
|
||||
|
||||
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
|
||||
|
||||
35
Library/dxx8/samples/Multimedia/Direct3D/Cull/resource.h
Normal 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
|
||||
179
Library/dxx8/samples/Multimedia/Direct3D/Cull/winmain.rc
Normal 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
|
||||
|
||||
112
Library/dxx8/samples/Multimedia/Direct3D/DXTex/ChildFrm.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
// ChildFrm.cpp : implementation of the CChildFrame class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "dxtex.h"
|
||||
#include "dxtexdoc.h"
|
||||
#include "dxtexview.h"
|
||||
|
||||
#include "ChildFrm.h"
|
||||
|
||||
#ifndef WM_IDLEUPDATECMDUI
|
||||
#define WM_IDLEUPDATECMDUI 0x0363 // wParam == bDisableIfNoHandler
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChildFrame
|
||||
|
||||
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
|
||||
//{{AFX_MSG_MAP(CChildFrame)
|
||||
ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChildFrame construction/destruction
|
||||
|
||||
CChildFrame::CChildFrame()
|
||||
{
|
||||
}
|
||||
|
||||
CChildFrame::~CChildFrame()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
if( !CMDIChildWnd::PreCreateWindow(cs) )
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChildFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CChildFrame::AssertValid() const
|
||||
{
|
||||
CMDIChildWnd::AssertValid();
|
||||
}
|
||||
|
||||
void CChildFrame::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CMDIChildWnd::Dump(dc);
|
||||
}
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChildFrame message handlers
|
||||
|
||||
BOOL CChildFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CMDIFrameWnd* pParentWnd, CCreateContext* pContext)
|
||||
{
|
||||
if (!CMDIChildWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, pContext))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Handle WM_IDLEUPDATECMDUI to update modified indicator if necessary.
|
||||
LRESULT CChildFrame::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM)
|
||||
{
|
||||
// Only update the title if the doc or view state has changed.
|
||||
// Otherwise, the title bar will flicker.
|
||||
CDxtexDoc* pDoc = (CDxtexDoc*)GetActiveDocument();
|
||||
CDxtexView* pView = (CDxtexView*)GetActiveView();
|
||||
if (pView->TitleModsChanged() || pDoc->TitleModsChanged())
|
||||
{
|
||||
// This will force MFC to call CChildFrame::OnUpdateTitleFrame:
|
||||
m_nIdleFlags |= idleTitle;
|
||||
pView->ClearTitleModsChanged();
|
||||
pDoc->ClearTitleModsChanged();
|
||||
}
|
||||
|
||||
// Do the default thing
|
||||
CMDIChildWnd::OnIdleUpdateCmdUI();
|
||||
return 0L;
|
||||
}
|
||||
|
||||
|
||||
void CChildFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
|
||||
{
|
||||
CMDIChildWnd::OnUpdateFrameTitle(bAddToTitle);
|
||||
CDxtexView* pView = (CDxtexView*)GetActiveView();
|
||||
{
|
||||
CString title;
|
||||
GetWindowText(title);
|
||||
title += " " + pView->GetStrTitleMods();
|
||||
SetWindowText(title);
|
||||
}
|
||||
}
|
||||
55
Library/dxx8/samples/Multimedia/Direct3D/DXTex/ChildFrm.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// ChildFrm.h : interface of the CChildFrame class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_CHILDFRM_H__712C53CD_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_)
|
||||
#define AFX_CHILDFRM_H__712C53CD_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
class CChildFrame : public CMDIChildWnd
|
||||
{
|
||||
DECLARE_DYNCREATE(CChildFrame)
|
||||
public:
|
||||
CChildFrame();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CChildFrame)
|
||||
public:
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW, const RECT& rect = rectDefault, CMDIFrameWnd* pParentWnd = NULL, CCreateContext* pContext = NULL);
|
||||
virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CChildFrame();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CChildFrame)
|
||||
afx_msg LRESULT OnIdleUpdateCmdUI(WPARAM wParam, LPARAM);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CHILDFRM_H__712C53CD_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_)
|
||||
117
Library/dxx8/samples/Multimedia/Direct3D/DXTex/MainFrm.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
// MainFrm.cpp : implementation of the CMainFrame class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "dxtex.h"
|
||||
#include "MainFrm.h"
|
||||
#include "DxtexDoc.h"
|
||||
#include "DxtexView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame
|
||||
|
||||
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
|
||||
//{{AFX_MSG_MAP(CMainFrame)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
ON_WM_CREATE()
|
||||
//}}AFX_MSG_MAP
|
||||
ON_UPDATE_COMMAND_UI(ID_INDICATOR_IMAGEINFO, OnUpdateImageInfo)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
static UINT indicators[] =
|
||||
{
|
||||
ID_SEPARATOR, // status line indicator
|
||||
ID_INDICATOR_IMAGEINFO,
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame construction/destruction
|
||||
|
||||
CMainFrame::CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
CMainFrame::~CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
{
|
||||
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
|
||||
return -1;
|
||||
|
||||
// Note: I changed the default toolbar creation code so we can still compile with VC5:
|
||||
// if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
|
||||
// | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
|
||||
// !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
|
||||
if (!m_wndToolBar.Create(this) ||
|
||||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
|
||||
{
|
||||
TRACE0("Failed to create toolbar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
if (!m_wndStatusBar.Create(this) ||
|
||||
!m_wndStatusBar.SetIndicators(indicators,
|
||||
sizeof(indicators)/sizeof(UINT)))
|
||||
{
|
||||
TRACE0("Failed to create status bar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
m_wndStatusBar.SetPaneInfo(1, ID_INDICATOR_IMAGEINFO, SBPS_NORMAL, 220);
|
||||
|
||||
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
|
||||
EnableDocking(CBRS_ALIGN_ANY);
|
||||
DockControlBar(&m_wndToolBar);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMainFrame::AssertValid() const
|
||||
{
|
||||
CMDIFrameWnd::AssertValid();
|
||||
}
|
||||
|
||||
void CMainFrame::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CMDIFrameWnd::Dump(dc);
|
||||
}
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame message handlers
|
||||
void CMainFrame::OnUpdateImageInfo(CCmdUI *pCmdUI)
|
||||
{
|
||||
CString strInfo;
|
||||
|
||||
// Get the active MDI child window.
|
||||
CMDIChildWnd *pChild = (CMDIChildWnd *)GetActiveFrame();
|
||||
|
||||
if (pChild != NULL && pChild != (CMDIChildWnd *)this)
|
||||
{
|
||||
// Get the active view attached to the active MDI child window.
|
||||
CDxtexView* pView = (CDxtexView*)pChild->GetActiveView();
|
||||
pView->GetImageInfo(strInfo);
|
||||
pCmdUI->Enable();
|
||||
pCmdUI->SetText(strInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
pCmdUI->Enable(FALSE);
|
||||
}
|
||||
}
|
||||
57
Library/dxx8/samples/Multimedia/Direct3D/DXTex/MainFrm.h
Normal file
@@ -0,0 +1,57 @@
|
||||
// MainFrm.h : interface of the CMainFrame class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_MAINFRM_H__712C53CB_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_)
|
||||
#define AFX_MAINFRM_H__712C53CB_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
class CMainFrame : public CMDIFrameWnd
|
||||
{
|
||||
DECLARE_DYNAMIC(CMainFrame)
|
||||
public:
|
||||
CMainFrame();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMainFrame)
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CMainFrame();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
protected: // control bar embedded members
|
||||
CStatusBar m_wndStatusBar;
|
||||
CToolBar m_wndToolBar;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMainFrame)
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg void OnUpdateImageInfo(CCmdUI *pCmdUI);
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_MAINFRM_H__712C53CB_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_)
|
||||
125
Library/dxx8/samples/Multimedia/Direct3D/DXTex/Resource.h
Normal file
@@ -0,0 +1,125 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by dxtex.rc
|
||||
//
|
||||
#define IDD_ABOUTBOX 100
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDR_DXTXTYPE 129
|
||||
#define IDD_CUBEMAP 131
|
||||
#define IDD_VOLUMEMAP 132
|
||||
#define IDD_CHANGEFORMAT 133
|
||||
#define IDD_NEWTEXTURE 134
|
||||
#define IDC_VERSION 1000
|
||||
#define IDC_POSX 1001
|
||||
#define IDC_NEGX 1002
|
||||
#define IDC_POSY 1003
|
||||
#define IDC_NEGY 1004
|
||||
#define IDC_POSZ 1005
|
||||
#define IDC_NEGZ 1006
|
||||
#define IDC_RADIO2 1010
|
||||
#define IDC_DXT1 1010
|
||||
#define IDC_RADIO4 1011
|
||||
#define IDC_DXT2 1011
|
||||
#define IDC_RADIO8 1012
|
||||
#define IDC_DXT3 1012
|
||||
#define IDC_RADIO16 1013
|
||||
#define IDC_DXT4 1013
|
||||
#define IDC_RADIO32 1014
|
||||
#define IDC_DXT5 1014
|
||||
#define IDC_RADIO64 1015
|
||||
#define IDC_A8R8G8B8 1015
|
||||
#define IDC_RADIO128 1016
|
||||
#define IDC_A1R5G5B5 1016
|
||||
#define IDC_RADIO256 1017
|
||||
#define IDC_R8R8G8B8 1017
|
||||
#define IDC_RADIO512 1018
|
||||
#define IDC_X1R5G5B5 1018
|
||||
#define IDC_RADIO1024 1019
|
||||
#define IDC_R3G3B2 1019
|
||||
#define IDC_A8R3G3B2 1020
|
||||
#define IDC_X4R4G4B4 1021
|
||||
#define IDC_A4R4G4B4 1022
|
||||
#define IDC_R8G8B8 1023
|
||||
#define IDC_R5G6B5 1024
|
||||
#define IDC_FMTDESC 1025
|
||||
#define IDC_TEXTURE 1026
|
||||
#define IDC_CUBEMAP 1027
|
||||
#define IDC_VOLUMETEXTURE 1028
|
||||
#define IDC_WIDTH 1029
|
||||
#define IDC_HEIGHT 1030
|
||||
#define IDC_DEPTH 1031
|
||||
#define IDC_MIPCOUNT 1032
|
||||
#define IDC_VOLUMEDEPTHLABEL 1033
|
||||
#define IDC_X8R8G8B8 1034
|
||||
#define ID_FORMAT_GENERATEMIPMAPS 32774
|
||||
#define ID_FORMAT_CHANGEIMAGEFORMAT 32775
|
||||
#define ID_FORMAT_DXT1 32779
|
||||
#define ID_VIEW_ORIGINAL 32780
|
||||
#define ID_VIEW_COMPRESSED 32781
|
||||
#define ID_VIEW_SMALLERMIPLEVEL 32782
|
||||
#define ID_VIEW_LARGERMIPLEVEL 32783
|
||||
#define ID_VIEW_ALPHACHANNEL 32784
|
||||
#define ID_VIEW_ZOOMIN 32785
|
||||
#define ID_VIEW_ZOOMOUT 32786
|
||||
#define ID_FORMAT_DXT2 32787
|
||||
#define ID_FORMAT_DXT3 32788
|
||||
#define ID_FORMAT_DXT4 32789
|
||||
#define ID_FORMAT_DXT5 32790
|
||||
#define ID_VIEW_CHANGEBACKGROUNDCOLOR 32791
|
||||
#define ID_FILE_OPENALPHA 32792
|
||||
#define ID_FILE_OPENSUBSURFACE 32794
|
||||
#define ID_FILE_OPENALPHASUBSURFACE 32795
|
||||
#define ID_FORMAT_CHANGECUBEMAPFACES 32796
|
||||
#define ID_VIEW_POSX 32797
|
||||
#define ID_VIEW_NEGX 32798
|
||||
#define ID_VIEW_POSY 32799
|
||||
#define ID_VIEW_NEGY 32800
|
||||
#define ID_VIEW_POSZ 32801
|
||||
#define ID_VIEW_NEGZ 32802
|
||||
#define ID_FILE_OPENFACE 32803
|
||||
#define ID_FILE_OPENALPHAFACE 32804
|
||||
#define ID_FORMAT_MAKEINTOVOLUMEMAP 32806
|
||||
#define ID_VIEW_HIGHERVOLUMESLICE 32807
|
||||
#define ID_VIEW_LOWERVOLUMESLICE 32808
|
||||
#define ID_FORMAT_CHANGESURFACEFMT 32811
|
||||
#define ID_INDICATOR_IMAGEINFO 61216
|
||||
#define ID_ERROR_ODDDIMENSIONS 61217
|
||||
#define ID_ERROR_NOTPOW2 61218
|
||||
#define ID_ERROR_WRONGDIMENSIONS 61219
|
||||
#define ID_ERROR_GENERATEALPHAFAILED 61220
|
||||
#define ID_ERROR_PREMULTALPHA 61221
|
||||
#define ID_ERROR_PREMULTTODXT1 61222
|
||||
#define ID_ERROR_CANTCREATEDEVICE 61223
|
||||
#define IDS_FMTDESC_A8R8G8B8 61224
|
||||
#define IDS_FMTDESC_A1R5G5B5 61225
|
||||
#define IDS_FMTDESC_A4R4G4B4 61226
|
||||
#define IDS_FMTDESC_R8G8B8 61227
|
||||
#define IDS_FMTDESC_R5G6B5 61228
|
||||
#define IDS_FMTDESC_DXT1 61229
|
||||
#define IDS_FMTDESC_DXT2 61230
|
||||
#define IDS_FMTDESC_DXT3 61231
|
||||
#define IDS_FMTDESC_DXT4 61232
|
||||
#define IDS_FMTDESC_DXT5 61233
|
||||
#define ID_ERROR_CANTCREATETEXTURE 61239
|
||||
#define ID_ERROR_D3DCREATEFAILED 61240
|
||||
#define ID_ERROR_COULDNTLOADFILE 61241
|
||||
#define ID_ERROR_COULDNTSAVEFILE 61242
|
||||
#define IDS_FMTDESC_X8R8G8B8 61243
|
||||
#define IDS_FMTDESC_X1R5G5B5 61244
|
||||
#define IDS_FMTDESC_R3G3B2 61245
|
||||
#define IDS_FMTDESC_A8R3G3B2 61246
|
||||
#define IDS_FMTDESC_X4R4G4B4 61247
|
||||
#define ID_ERROR_NULLREF 61248
|
||||
#define ID_ERROR_NEEDALPHA 61249
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 136
|
||||
#define _APS_NEXT_COMMAND_VALUE 32812
|
||||
#define _APS_NEXT_CONTROL_VALUE 1035
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// dxtx.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
|
||||
|
||||
27
Library/dxx8/samples/Multimedia/Direct3D/DXTex/StdAfx.h
Normal file
@@ -0,0 +1,27 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__712C53C9_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_)
|
||||
#define AFX_STDAFX_H__712C53C9_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions
|
||||
#include <winver.h>
|
||||
#include <basetsd.h>
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__712C53C9_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_)
|
||||
BIN
Library/dxx8/samples/Multimedia/Direct3D/DXTex/Toolbar.bmp
Normal file
|
After Width: | Height: | Size: 598 B |
100
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dds.h
Normal file
@@ -0,0 +1,100 @@
|
||||
// dds.h
|
||||
//
|
||||
// This header defines constants and structures that are useful when parsing
|
||||
// DDS files. DDS files were originally designed to use several structures
|
||||
// and constants that are native to DirectDraw and are defined in ddraw.h,
|
||||
// such as DDSURFACEDESC2 and DDSCAPS2. This file defines similar
|
||||
// (compatible) constants and structures so that one can use DDS files
|
||||
// without needing to include ddraw.h.
|
||||
|
||||
#ifndef _DDS_H_
|
||||
#define _DDS_H_
|
||||
|
||||
struct DDS_PIXELFORMAT
|
||||
{
|
||||
DWORD dwSize;
|
||||
DWORD dwFlags;
|
||||
DWORD dwFourCC;
|
||||
DWORD dwRGBBitCount;
|
||||
DWORD dwRBitMask;
|
||||
DWORD dwGBitMask;
|
||||
DWORD dwBBitMask;
|
||||
DWORD dwABitMask;
|
||||
};
|
||||
|
||||
#define DDS_FOURCC 0x00000004 // DDPF_FOURCC
|
||||
#define DDS_RGB 0x00000040 // DDPF_RGB
|
||||
#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS
|
||||
|
||||
const DDS_PIXELFORMAT DDSPF_DXT1 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 };
|
||||
|
||||
const DDS_PIXELFORMAT DDSPF_DXT2 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 };
|
||||
|
||||
const DDS_PIXELFORMAT DDSPF_DXT3 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 };
|
||||
|
||||
const DDS_PIXELFORMAT DDSPF_DXT4 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 };
|
||||
|
||||
const DDS_PIXELFORMAT DDSPF_DXT5 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 };
|
||||
|
||||
const DDS_PIXELFORMAT DDSPF_A8R8G8B8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 };
|
||||
|
||||
const DDS_PIXELFORMAT DDSPF_A1R5G5B5 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00007c00, 0x000003e0, 0x0000001f, 0x00008000 };
|
||||
|
||||
const DDS_PIXELFORMAT DDSPF_A4R4G4B4 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x0000f000, 0x000000f0, 0x0000000f, 0x0000f000 };
|
||||
|
||||
const DDS_PIXELFORMAT DDSPF_R8G8B8 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 };
|
||||
|
||||
const DDS_PIXELFORMAT DDSPF_R5G6B5 =
|
||||
{ sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000 };
|
||||
|
||||
#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
|
||||
#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT
|
||||
#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
|
||||
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
|
||||
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
|
||||
|
||||
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
|
||||
#define DDS_SURFACE_FLAGS_MIPMAP 0x00400008 // DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
|
||||
#define DDS_SURFACE_FLAGS_CUBEMAP 0x00000008 // DDSCAPS_COMPLEX
|
||||
|
||||
#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
|
||||
#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
|
||||
#define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY
|
||||
#define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY
|
||||
#define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ
|
||||
#define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ
|
||||
|
||||
#define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\
|
||||
DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\
|
||||
DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ )
|
||||
|
||||
#define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME
|
||||
|
||||
|
||||
struct DDS_HEADER
|
||||
{
|
||||
DWORD dwSize;
|
||||
DWORD dwHeaderFlags;
|
||||
DWORD dwHeight;
|
||||
DWORD dwWidth;
|
||||
DWORD dwPitchOrLinearSize;
|
||||
DWORD dwDepth; // only if DDS_HEADER_FLAGS_VOLUME is set in dwHeaderFlags
|
||||
DWORD dwMipMapCount;
|
||||
DWORD dwReserved1[11];
|
||||
DDS_PIXELFORMAT ddspf;
|
||||
DWORD dwSurfaceFlags;
|
||||
DWORD dwCubemapFlags;
|
||||
DWORD dwReserved2[3];
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
454
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dialogs.cpp
Normal file
@@ -0,0 +1,454 @@
|
||||
// Dialogs.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "dxtex.h"
|
||||
#include "dialogs.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CNewTextureDlg dialog
|
||||
|
||||
|
||||
CNewTextureDlg::CNewTextureDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CNewTextureDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CNewTextureDlg)
|
||||
m_iTexType = 0;
|
||||
m_dwWidth = 256;
|
||||
m_dwHeight = 256;
|
||||
m_dwDepth = 8;
|
||||
m_iFmt = 0;
|
||||
m_strFmtDesc = _T("");
|
||||
m_numMips = 1;
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CNewTextureDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CNewTextureDlg)
|
||||
DDX_Radio(pDX, IDC_TEXTURE, m_iTexType);
|
||||
DDX_Text(pDX, IDC_WIDTH, m_dwWidth);
|
||||
DDV_MinMaxInt(pDX, m_dwWidth, 1, 1024);
|
||||
DDX_Text(pDX, IDC_HEIGHT, m_dwHeight);
|
||||
DDV_MinMaxInt(pDX, m_dwHeight, 1, 1024);
|
||||
DDX_Text(pDX, IDC_DEPTH, m_dwDepth);
|
||||
DDV_MinMaxInt(pDX, m_dwDepth, 2, 1024);
|
||||
DDX_Radio(pDX, IDC_A8R8G8B8, m_iFmt);
|
||||
DDX_Text(pDX, IDC_FMTDESC, m_strFmtDesc);
|
||||
DDX_Text(pDX, IDC_MIPCOUNT, m_numMips);
|
||||
DDV_MinMaxInt(pDX, m_numMips, 1, 20);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CNewTextureDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CNewTextureDlg)
|
||||
ON_BN_CLICKED(IDC_TEXTURE, OnChangeTextureType)
|
||||
ON_BN_CLICKED(IDC_A8R8G8B8, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_VOLUMETEXTURE, OnChangeTextureType)
|
||||
ON_BN_CLICKED(IDC_CUBEMAP, OnChangeTextureType)
|
||||
ON_BN_CLICKED(IDC_A4R4G4B4, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_A1R5G5B5, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_R5G6B5, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_R8G8B8, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_X8R8G8B8, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_X1R5G5B5, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_R3G3B2, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_A8R3G3B2, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_X4R4G4B4, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_DXT1, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_DXT2, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_DXT3, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_DXT4, OnChangeFormat)
|
||||
ON_BN_CLICKED(IDC_DXT5, OnChangeFormat)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CNewTextureDlg message handlers
|
||||
|
||||
BOOL CNewTextureDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
OnChangeTextureType();
|
||||
OnChangeFormat();
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
void CNewTextureDlg::OnChangeTextureType()
|
||||
{
|
||||
UpdateData(TRUE);
|
||||
|
||||
if (m_iTexType == 2)
|
||||
{
|
||||
// Volume Tex
|
||||
GetDlgItem(IDC_VOLUMEDEPTHLABEL)->EnableWindow(TRUE);
|
||||
GetDlgItem(IDC_DEPTH)->EnableWindow(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Normal or Cube Tex
|
||||
GetDlgItem(IDC_VOLUMEDEPTHLABEL)->EnableWindow(FALSE);
|
||||
GetDlgItem(IDC_DEPTH)->EnableWindow(FALSE);
|
||||
}
|
||||
UpdateData(FALSE);
|
||||
OnChangeFormat();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CNewTextureDlg::OnChangeFormat()
|
||||
{
|
||||
UpdateData(TRUE);
|
||||
switch (m_iFmt)
|
||||
{
|
||||
case 0:
|
||||
m_fmt = D3DFMT_A8R8G8B8;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_A8R8G8B8);
|
||||
break;
|
||||
case 1:
|
||||
m_fmt = D3DFMT_A1R5G5B5;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_A1R5G5B5);
|
||||
break;
|
||||
case 2:
|
||||
m_fmt = D3DFMT_A4R4G4B4;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_A4R4G4B4);
|
||||
break;
|
||||
case 3:
|
||||
m_fmt = D3DFMT_R8G8B8;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_R8G8B8);
|
||||
break;
|
||||
case 4:
|
||||
m_fmt = D3DFMT_R5G6B5;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_R5G6B5);
|
||||
break;
|
||||
case 5:
|
||||
m_fmt = D3DFMT_X8R8G8B8;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_X8R8G8B8);
|
||||
break;
|
||||
case 6:
|
||||
m_fmt = D3DFMT_X1R5G5B5;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_X1R5G5B5);
|
||||
break;
|
||||
case 7:
|
||||
m_fmt = D3DFMT_R3G3B2;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_R3G3B2);
|
||||
break;
|
||||
case 8:
|
||||
m_fmt = D3DFMT_A8R3G3B2;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_A8R3G3B2);
|
||||
break;
|
||||
case 9:
|
||||
m_fmt = D3DFMT_X4R4G4B4;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_X4R4G4B4);
|
||||
break;
|
||||
case 10:
|
||||
m_fmt = D3DFMT_DXT1;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_DXT1);
|
||||
break;
|
||||
case 11:
|
||||
m_fmt = D3DFMT_DXT2;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_DXT2);
|
||||
break;
|
||||
case 12:
|
||||
m_fmt = D3DFMT_DXT3;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_DXT3);
|
||||
break;
|
||||
case 13:
|
||||
m_fmt = D3DFMT_DXT4;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_DXT4);
|
||||
break;
|
||||
case 14:
|
||||
m_fmt = D3DFMT_DXT5;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_DXT5);
|
||||
break;
|
||||
}
|
||||
UpdateData(FALSE);
|
||||
}
|
||||
|
||||
void CNewTextureDlg::OnOK()
|
||||
{
|
||||
UpdateData(TRUE);
|
||||
|
||||
// TODO: Need to do lots of validation of width/height/depth/mipcount here
|
||||
|
||||
if (m_iTexType != 2)
|
||||
m_dwDepth = 0;
|
||||
|
||||
switch (m_iFmt)
|
||||
{
|
||||
case 0: m_fmt = D3DFMT_A8R8G8B8; break;
|
||||
case 1: m_fmt = D3DFMT_A1R5G5B5; break;
|
||||
case 2: m_fmt = D3DFMT_A4R4G4B4; break;
|
||||
case 3: m_fmt = D3DFMT_R8G8B8; break;
|
||||
case 4: m_fmt = D3DFMT_R5G6B5; break;
|
||||
case 5: m_fmt = D3DFMT_X8R8G8B8; break;
|
||||
case 6: m_fmt = D3DFMT_X1R5G5B5; break;
|
||||
case 7: m_fmt = D3DFMT_R3G3B2; break;
|
||||
case 8: m_fmt = D3DFMT_A8R3G3B2; break;
|
||||
case 9: m_fmt = D3DFMT_X4R4G4B4; break;
|
||||
case 10: m_fmt = D3DFMT_DXT1; break;
|
||||
case 11: m_fmt = D3DFMT_DXT2; break;
|
||||
case 12: m_fmt = D3DFMT_DXT3; break;
|
||||
case 13: m_fmt = D3DFMT_DXT4; break;
|
||||
case 14: m_fmt = D3DFMT_DXT5; break;
|
||||
}
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCubeMapDlg dialog
|
||||
|
||||
|
||||
CCubeMapDlg::CCubeMapDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CCubeMapDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CCubeMapDlg)
|
||||
m_iFace = 0;
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CCubeMapDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CCubeMapDlg)
|
||||
DDX_Radio(pDX, IDC_POSX, m_iFace);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCubeMapDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CCubeMapDlg)
|
||||
// NOTE: the ClassWizard will add message map macros here
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CVolumeMapDlg dialog
|
||||
|
||||
|
||||
CVolumeMapDlg::CVolumeMapDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CVolumeMapDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CVolumeMapDlg)
|
||||
m_powLayers = 0;
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CVolumeMapDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CVolumeMapDlg)
|
||||
DDX_Radio(pDX, IDC_RADIO2, m_powLayers);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CVolumeMapDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CVolumeMapDlg)
|
||||
// NOTE: the ClassWizard will add message map macros here
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CVolumeMapDlg message handlers
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChangeFmtDlg dialog
|
||||
|
||||
|
||||
CChangeFmtDlg::CChangeFmtDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CChangeFmtDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CChangeFmtDlg)
|
||||
m_iFmt = -1;
|
||||
m_strFmtDesc = _T("");
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CChangeFmtDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CChangeFmtDlg)
|
||||
DDX_Radio(pDX, IDC_A8R8G8B8, m_iFmt);
|
||||
DDX_Text(pDX, IDC_FMTDESC, m_strFmtDesc);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CChangeFmtDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CChangeFmtDlg)
|
||||
ON_BN_CLICKED(IDC_A1R5G5B5, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_A4R4G4B4, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_A8R8G8B8, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_R5G6B5, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_R8G8B8, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_X8R8G8B8, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_X1R5G5B5, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_R3G3B2, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_A8R3G3B2, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_X4R4G4B4, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_DXT1, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_DXT2, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_DXT3, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_DXT4, OnChangeFmt)
|
||||
ON_BN_CLICKED(IDC_DXT5, OnChangeFmt)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChangeFmtDlg message handlers
|
||||
|
||||
BOOL CChangeFmtDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
switch (m_fmt)
|
||||
{
|
||||
case D3DFMT_A8R8G8B8:
|
||||
m_iFmt = 0;
|
||||
break;
|
||||
case D3DFMT_A1R5G5B5:
|
||||
m_iFmt = 1;
|
||||
break;
|
||||
case D3DFMT_A4R4G4B4:
|
||||
m_iFmt = 2;
|
||||
break;
|
||||
case D3DFMT_R8G8B8:
|
||||
m_iFmt = 3;
|
||||
break;
|
||||
case D3DFMT_R5G6B5:
|
||||
m_iFmt = 4;
|
||||
break;
|
||||
case D3DFMT_X8R8G8B8:
|
||||
m_iFmt = 5;
|
||||
break;
|
||||
case D3DFMT_X1R5G5B5:
|
||||
m_iFmt = 6;
|
||||
break;
|
||||
case D3DFMT_R3G3B2:
|
||||
m_iFmt = 7;
|
||||
break;
|
||||
case D3DFMT_A8R3G3B2:
|
||||
m_iFmt = 8;
|
||||
break;
|
||||
case D3DFMT_X4R4G4B4:
|
||||
m_iFmt = 9;
|
||||
break;
|
||||
case D3DFMT_DXT1:
|
||||
m_iFmt = 10;
|
||||
break;
|
||||
case D3DFMT_DXT2:
|
||||
m_iFmt = 11;
|
||||
break;
|
||||
case D3DFMT_DXT3:
|
||||
m_iFmt = 12;
|
||||
break;
|
||||
case D3DFMT_DXT4:
|
||||
m_iFmt = 13;
|
||||
break;
|
||||
case D3DFMT_DXT5:
|
||||
m_iFmt = 14;
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateFmtDesc();
|
||||
|
||||
UpdateData(FALSE);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CChangeFmtDlg::OnChangeFmt()
|
||||
{
|
||||
UpdateData(TRUE);
|
||||
UpdateFmtDesc();
|
||||
}
|
||||
|
||||
void CChangeFmtDlg::UpdateFmtDesc()
|
||||
{
|
||||
switch (m_iFmt)
|
||||
{
|
||||
case 0:
|
||||
m_fmt = D3DFMT_A8R8G8B8;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_A8R8G8B8);
|
||||
break;
|
||||
case 1:
|
||||
m_fmt = D3DFMT_A1R5G5B5;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_A1R5G5B5);
|
||||
break;
|
||||
case 2:
|
||||
m_fmt = D3DFMT_A4R4G4B4;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_A4R4G4B4);
|
||||
break;
|
||||
case 3:
|
||||
m_fmt = D3DFMT_R8G8B8;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_R8G8B8);
|
||||
break;
|
||||
case 4:
|
||||
m_fmt = D3DFMT_R5G6B5;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_R5G6B5);
|
||||
break;
|
||||
case 5:
|
||||
m_fmt = D3DFMT_X8R8G8B8;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_X8R8G8B8);
|
||||
break;
|
||||
case 6:
|
||||
m_fmt = D3DFMT_X1R5G5B5;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_X1R5G5B5);
|
||||
break;
|
||||
case 7:
|
||||
m_fmt = D3DFMT_R3G3B2;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_R3G3B2);
|
||||
break;
|
||||
case 8:
|
||||
m_fmt = D3DFMT_A8R3G3B2;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_A8R3G3B2);
|
||||
break;
|
||||
case 9:
|
||||
m_fmt = D3DFMT_X4R4G4B4;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_X4R4G4B4);
|
||||
break;
|
||||
case 10:
|
||||
m_fmt = D3DFMT_DXT1;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_DXT1);
|
||||
break;
|
||||
case 11:
|
||||
m_fmt = D3DFMT_DXT2;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_DXT2);
|
||||
break;
|
||||
case 12:
|
||||
m_fmt = D3DFMT_DXT3;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_DXT3);
|
||||
break;
|
||||
case 13:
|
||||
m_fmt = D3DFMT_DXT4;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_DXT4);
|
||||
break;
|
||||
case 14:
|
||||
m_fmt = D3DFMT_DXT5;
|
||||
m_strFmtDesc.LoadString(IDS_FMTDESC_DXT5);
|
||||
break;
|
||||
}
|
||||
UpdateData(FALSE);
|
||||
}
|
||||
|
||||
162
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dialogs.h
Normal file
@@ -0,0 +1,162 @@
|
||||
// Dialogs.h : header file
|
||||
//
|
||||
#if !defined(AFX_DIALOGS_H__14A2C924_FB41_4BB7_92E4_DBA7CAF1FA06__INCLUDED_)
|
||||
#define AFX_DIALOGS_H__14A2C924_FB41_4BB7_92E4_DBA7CAF1FA06__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CNewTextureDlg dialog
|
||||
|
||||
class CNewTextureDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CNewTextureDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CNewTextureDlg)
|
||||
enum { IDD = IDD_NEWTEXTURE };
|
||||
int m_iTexType;
|
||||
int m_dwWidth;
|
||||
int m_dwHeight;
|
||||
int m_dwDepth;
|
||||
int m_iFmt;
|
||||
CString m_strFmtDesc;
|
||||
int m_numMips;
|
||||
D3DFORMAT m_fmt;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CNewTextureDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CNewTextureDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnChangeTextureType();
|
||||
afx_msg void OnChangeFormat();
|
||||
virtual void OnOK();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CCubeMapDlg dialog
|
||||
|
||||
class CCubeMapDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CCubeMapDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CCubeMapDlg)
|
||||
enum { IDD = IDD_CUBEMAP };
|
||||
INT m_iFace;
|
||||
//}}AFX_DATA
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCubeMapDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CCubeMapDlg)
|
||||
// NOTE: the ClassWizard will add member functions here
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CVolumeMapDlg dialog
|
||||
|
||||
class CVolumeMapDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CVolumeMapDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CVolumeMapDlg)
|
||||
enum { IDD = IDD_VOLUMEMAP };
|
||||
int m_powLayers;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CVolumeMapDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CVolumeMapDlg)
|
||||
// NOTE: the ClassWizard will add member functions here
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CChangeFmtDlg dialog
|
||||
|
||||
class CChangeFmtDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CChangeFmtDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CChangeFmtDlg)
|
||||
enum { IDD = IDD_CHANGEFORMAT };
|
||||
int m_iFmt;
|
||||
CString m_strFmtDesc;
|
||||
//}}AFX_DATA
|
||||
BOOL m_bVolume;
|
||||
D3DFORMAT m_fmt;
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CChangeFmtDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CChangeFmtDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnChangeFmt();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
void UpdateFmtDesc();
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_DIALOGS_H__14A2C924_FB41_4BB7_92E4_DBA7CAF1FA06__INCLUDED_)
|
||||
373
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dxtex.cpp
Normal file
@@ -0,0 +1,373 @@
|
||||
// dxtex.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "dxtex.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
#include "ChildFrm.h"
|
||||
#include "dxtexDoc.h"
|
||||
#include "dxtexView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDxtexDocManager::DoPromptFileName - overridden to allow importing of
|
||||
// BMPs as well as DDSs into CDxtexDocs.
|
||||
BOOL CDxtexDocManager::DoPromptFileName(CString& fileName, UINT nIDSTitle,
|
||||
DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate)
|
||||
{
|
||||
CFileDialog dlgFile(bOpenFileDialog);
|
||||
|
||||
CString title;
|
||||
VERIFY(title.LoadString(nIDSTitle));
|
||||
|
||||
dlgFile.m_ofn.Flags |= lFlags;
|
||||
|
||||
CString strFilter;
|
||||
CString strDefault;
|
||||
|
||||
if (bOpenFileDialog)
|
||||
{
|
||||
strFilter += "Image Files (*.dds, *.bmp, *.tga, *.jpg, *.png, *.dib)";
|
||||
strFilter += (TCHAR)'\0'; // next string please
|
||||
strFilter += _T("*.dds;*.bmp;*.tga;*.jpg;*.png;*.dib");
|
||||
strFilter += (TCHAR)'\0'; // last string
|
||||
dlgFile.m_ofn.nMaxCustFilter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
strFilter += "Image Files (*.dds)";
|
||||
strFilter += (TCHAR)'\0'; // next string please
|
||||
strFilter += _T("*.dds");
|
||||
strFilter += (TCHAR)'\0'; // last string
|
||||
dlgFile.m_ofn.nMaxCustFilter++;
|
||||
}
|
||||
|
||||
// append the "*.*" all files filter
|
||||
CString allFilter;
|
||||
VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
|
||||
strFilter += allFilter;
|
||||
strFilter += (TCHAR)'\0'; // next string please
|
||||
strFilter += _T("*.*");
|
||||
strFilter += (TCHAR)'\0'; // last string
|
||||
dlgFile.m_ofn.nMaxCustFilter++;
|
||||
|
||||
dlgFile.m_ofn.lpstrFilter = strFilter;
|
||||
dlgFile.m_ofn.lpstrTitle = title;
|
||||
dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH);
|
||||
|
||||
INT_PTR nResult = dlgFile.DoModal();
|
||||
fileName.ReleaseBuffer();
|
||||
return nResult == IDOK;
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDxTxCommandLineInfo
|
||||
|
||||
CDxtexCommandLineInfo::CDxtexCommandLineInfo(VOID)
|
||||
{
|
||||
m_fmt = D3DFMT_UNKNOWN;
|
||||
m_bAlphaComing = FALSE;
|
||||
m_bMipMap = FALSE;
|
||||
}
|
||||
|
||||
|
||||
void CDxtexCommandLineInfo::ParseParam(const TCHAR* pszParam,BOOL bFlag,BOOL bLast)
|
||||
{
|
||||
if (lstrcmpiA(pszParam, "DXT1") == 0)
|
||||
{
|
||||
m_fmt = D3DFMT_DXT1;
|
||||
}
|
||||
else if (lstrcmpiA(pszParam, "DXT2") == 0)
|
||||
{
|
||||
m_fmt = D3DFMT_DXT2;
|
||||
}
|
||||
else if (lstrcmpiA(pszParam, "DXT3") == 0)
|
||||
{
|
||||
m_fmt = D3DFMT_DXT3;
|
||||
}
|
||||
else if (lstrcmpiA(pszParam, "DXT4") == 0)
|
||||
{
|
||||
m_fmt = D3DFMT_DXT4;
|
||||
}
|
||||
else if (lstrcmpiA(pszParam, "DXT5") == 0)
|
||||
{
|
||||
m_fmt = D3DFMT_DXT5;
|
||||
}
|
||||
else if (bFlag && tolower(pszParam[0]) == 'a')
|
||||
{
|
||||
m_bAlphaComing = TRUE;
|
||||
}
|
||||
else if (!bFlag && m_bAlphaComing)
|
||||
{
|
||||
m_strFileNameAlpha = pszParam;
|
||||
m_bAlphaComing = FALSE;
|
||||
}
|
||||
else if (bFlag && tolower(pszParam[0]) == 'm')
|
||||
{
|
||||
m_bMipMap = TRUE;
|
||||
}
|
||||
else if (!bFlag && !m_strFileName.IsEmpty())
|
||||
{
|
||||
m_strFileNameSave = pszParam;
|
||||
}
|
||||
|
||||
CCommandLineInfo::ParseParam(pszParam, bFlag, bLast);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDxtexApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDxtexApp, CWinApp)
|
||||
//{{AFX_MSG_MAP(CDxtexApp)
|
||||
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code!
|
||||
//}}AFX_MSG_MAP
|
||||
// Standard file based document commands
|
||||
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
|
||||
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDxtexApp construction
|
||||
|
||||
CDxtexApp::CDxtexApp()
|
||||
{
|
||||
// Place all significant initialization in InitInstance
|
||||
m_pd3d = NULL;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDxtexApp destruction
|
||||
|
||||
CDxtexApp::~CDxtexApp()
|
||||
{
|
||||
ReleasePpo(&m_pd3ddev);
|
||||
ReleasePpo(&m_pd3d);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// The one and only CDxtexApp object
|
||||
|
||||
CDxtexApp theApp;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDxtexApp initialization
|
||||
|
||||
BOOL CDxtexApp::InitInstance()
|
||||
{
|
||||
// Change the registry key under which our settings are stored.
|
||||
SetRegistryKey(_T("Microsoft"));
|
||||
|
||||
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
|
||||
|
||||
// Register the application's document templates. Document templates
|
||||
// serve as the connection between documents, frame windows and views.
|
||||
|
||||
m_pDocManager = new CDxtexDocManager;
|
||||
|
||||
CMultiDocTemplate* pDocTemplate;
|
||||
pDocTemplate = new CMultiDocTemplate(
|
||||
IDR_DXTXTYPE,
|
||||
RUNTIME_CLASS(CDxtexDoc),
|
||||
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
|
||||
RUNTIME_CLASS(CDxtexView));
|
||||
AddDocTemplate(pDocTemplate);
|
||||
|
||||
// create main MDI Frame window
|
||||
CMainFrame* pMainFrame = new CMainFrame;
|
||||
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
|
||||
return FALSE;
|
||||
m_pMainWnd = pMainFrame;
|
||||
|
||||
// Initialize DirectDraw
|
||||
m_pd3d = Direct3DCreate8(D3D_SDK_VERSION);
|
||||
if (m_pd3d == NULL)
|
||||
{
|
||||
AfxMessageBox(ID_ERROR_D3DCREATEFAILED, MB_OK, 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
D3DDISPLAYMODE dispMode;
|
||||
D3DPRESENT_PARAMETERS presentParams;
|
||||
D3DDEVTYPE devType;
|
||||
|
||||
m_pd3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dispMode);
|
||||
|
||||
ZeroMemory(&presentParams, sizeof(presentParams));
|
||||
presentParams.Windowed = TRUE;
|
||||
presentParams.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC;
|
||||
presentParams.BackBufferWidth = 8;
|
||||
presentParams.BackBufferHeight = 8;
|
||||
presentParams.BackBufferFormat = dispMode.Format;
|
||||
|
||||
devType = D3DDEVTYPE_REF;
|
||||
|
||||
hr = m_pd3d->CreateDevice(D3DADAPTER_DEFAULT, devType, m_pMainWnd->GetSafeHwnd(),
|
||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presentParams, &m_pd3ddev);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AfxMessageBox(ID_ERROR_CANTCREATEDEVICE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
D3DCAPS8 Caps;
|
||||
m_pd3ddev->GetDeviceCaps(&Caps);
|
||||
if (Caps.PrimitiveMiscCaps & D3DPMISCCAPS_NULLREFERENCE)
|
||||
{
|
||||
AfxMessageBox(ID_ERROR_NULLREF);
|
||||
}
|
||||
|
||||
// Parse command line for standard shell commands, DDE, file open
|
||||
CDxtexCommandLineInfo cmdInfo;
|
||||
ParseCommandLine(cmdInfo);
|
||||
// Prevent automatic "New" at startup:
|
||||
if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
|
||||
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
|
||||
|
||||
// Dispatch commands specified on the command line
|
||||
if (!ProcessShellCommand(cmdInfo))
|
||||
return FALSE;
|
||||
|
||||
// See if we loaded a document
|
||||
POSITION posTemp = GetFirstDocTemplatePosition();
|
||||
CDxtexDoc* pdoc = NULL;
|
||||
POSITION pos = pDocTemplate->GetFirstDocPosition();
|
||||
if (pos != NULL)
|
||||
pdoc = (CDxtexDoc*)pDocTemplate->GetNextDoc(pos);
|
||||
|
||||
if (!cmdInfo.m_strFileNameAlpha.IsEmpty())
|
||||
{
|
||||
if (pdoc != NULL)
|
||||
{
|
||||
pdoc->LoadAlphaBmp(cmdInfo.m_strFileNameAlpha);
|
||||
}
|
||||
}
|
||||
if (cmdInfo.m_bMipMap)
|
||||
{
|
||||
if (pdoc != NULL)
|
||||
{
|
||||
pdoc->GenerateMipMaps();
|
||||
}
|
||||
}
|
||||
if (cmdInfo.m_fmt != 0)
|
||||
{
|
||||
if (pdoc != NULL)
|
||||
{
|
||||
pdoc->Compress(cmdInfo.m_fmt, TRUE);
|
||||
}
|
||||
}
|
||||
if (!cmdInfo.m_strFileNameSave.IsEmpty())
|
||||
{
|
||||
if (pdoc != NULL)
|
||||
{
|
||||
pdoc->OnSaveDocument(cmdInfo.m_strFileNameSave);
|
||||
}
|
||||
return FALSE; // Prevent UI from coming up
|
||||
}
|
||||
|
||||
// The main window has been initialized, so show and update it.
|
||||
pMainFrame->ShowWindow(m_nCmdShow);
|
||||
pMainFrame->UpdateWindow();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAboutDlg dialog used for App About
|
||||
|
||||
class CAboutDlg : public CDialog
|
||||
{
|
||||
public:
|
||||
CAboutDlg();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CAboutDlg)
|
||||
enum { IDD = IDD_ABOUTBOX };
|
||||
CString m_strVersion;
|
||||
//}}AFX_DATA
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CAboutDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
//{{AFX_MSG(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
||||
{
|
||||
TCHAR szFile[MAX_PATH];
|
||||
CString strVersion;
|
||||
UINT cb;
|
||||
DWORD dwHandle;
|
||||
BYTE FileVersionBuffer[1024];
|
||||
VS_FIXEDFILEINFO* pVersion = NULL;
|
||||
|
||||
GetModuleFileName(NULL, szFile, MAX_PATH);
|
||||
|
||||
cb = GetFileVersionInfoSize(szFile, &dwHandle/*ignored*/);
|
||||
if (cb > 0)
|
||||
{
|
||||
if (cb > sizeof(FileVersionBuffer))
|
||||
cb = sizeof(FileVersionBuffer);
|
||||
|
||||
if (GetFileVersionInfo(szFile, 0, cb, &FileVersionBuffer))
|
||||
{
|
||||
pVersion = NULL;
|
||||
if (VerQueryValue(&FileVersionBuffer, "\\", (VOID**)&pVersion, &cb)
|
||||
&& pVersion != NULL)
|
||||
{
|
||||
strVersion.Format("Version %d.%02d.%02d.%04d",
|
||||
HIWORD(pVersion->dwFileVersionMS),
|
||||
LOWORD(pVersion->dwFileVersionMS),
|
||||
HIWORD(pVersion->dwFileVersionLS),
|
||||
LOWORD(pVersion->dwFileVersionLS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//{{AFX_DATA_INIT(CAboutDlg)
|
||||
m_strVersion = strVersion;
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CAboutDlg)
|
||||
DDX_Text(pDX, IDC_VERSION, m_strVersion);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CAboutDlg)
|
||||
// No message handlers
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
// App command to run the dialog
|
||||
void CDxtexApp::OnAppAbout()
|
||||
{
|
||||
CAboutDlg aboutDlg;
|
||||
aboutDlg.DoModal();
|
||||
}
|
||||
187
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dxtex.dsp
Normal file
@@ -0,0 +1,187 @@
|
||||
# Microsoft Developer Studio Project File - Name="dxtex" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=dxtex - 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 "dxtex.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 "dxtex.mak" CFG="dxtex - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "dxtex - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "dxtex - 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)" == "dxtex - 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 1
|
||||
# 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 /MT /W3 /GX /O2 /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 ddraw.lib d3d8.lib d3dx8.lib dxguid.lib version.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
|
||||
|
||||
!ELSEIF "$(CFG)" == "dxtex - 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 1
|
||||
# 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 /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /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 d3d8.lib d3dx8dt.lib dxguid.lib version.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /stack:0x200000,0x200000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "dxtex - Win32 Release"
|
||||
# Name "dxtex - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ChildFrm.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dialogs.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Dxtex.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Dxtex.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DxtexDoc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DxtexView.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MainFrm.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ChildFrm.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dds.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dialogs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Dxtex.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DxtexDoc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DxtexView.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MainFrm.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\StdAfx.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Dxtex.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DxtexDoc.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Toolbar.bmp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
29
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dxtex.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "dxtex"=.\dxtex.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
95
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dxtex.h
Normal file
@@ -0,0 +1,95 @@
|
||||
// dxtex.h : main header file for the DXTEX application
|
||||
//
|
||||
|
||||
#if !defined(AFX_DXTX_H__712C53C7_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_)
|
||||
#define AFX_DXTX_H__712C53C7_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error include 'stdafx.h' before including this file for PCH
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
#ifndef ReleasePpo
|
||||
#define ReleasePpo(ppo) \
|
||||
if (*(ppo) != NULL) \
|
||||
{ \
|
||||
(*(ppo))->Release(); \
|
||||
*(ppo) = NULL; \
|
||||
} \
|
||||
else (VOID)0
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDxtexDocManager:
|
||||
// I override this class to customize DoPromptFileName to allow importing of
|
||||
// BMPs as well as DDSs into CDxtexDocs.
|
||||
//
|
||||
class CDxtexDocManager : public CDocManager
|
||||
{
|
||||
public:
|
||||
virtual BOOL DoPromptFileName(CString& fileName, UINT nIDSTitle,
|
||||
DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate);
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDxtexCommandLineInfo:
|
||||
// I override this class to handle custom command-line options
|
||||
//
|
||||
class CDxtexCommandLineInfo : public CCommandLineInfo
|
||||
{
|
||||
public:
|
||||
CString m_strFileNameAlpha;
|
||||
CString m_strFileNameSave;
|
||||
D3DFORMAT m_fmt;
|
||||
BOOL m_bAlphaComing;
|
||||
BOOL m_bMipMap;
|
||||
|
||||
CDxtexCommandLineInfo::CDxtexCommandLineInfo(VOID);
|
||||
virtual void ParseParam(const TCHAR* pszParam, BOOL bFlag, BOOL bLast);
|
||||
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDxtexApp:
|
||||
// See dxtex.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class CDxtexApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
CDxtexApp();
|
||||
virtual ~CDxtexApp();
|
||||
LPDIRECT3D8 Pd3d(VOID) { return m_pd3d; }
|
||||
LPDIRECT3DDEVICE8 Pd3ddev(VOID) { return m_pd3ddev; }
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CDxtexApp)
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
//{{AFX_MSG(CDxtexApp)
|
||||
afx_msg void OnAppAbout();
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
// DO NOT EDIT what you see in these blocks of generated code !
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
LPDIRECT3D8 m_pd3d;
|
||||
LPDIRECT3DDEVICE8 m_pd3ddev;
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_DXTX_H__712C53C7_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_)
|
||||
BIN
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dxtex.ico
Normal file
|
After Width: | Height: | Size: 766 B |
352
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dxtex.mak
Normal file
@@ -0,0 +1,352 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on dxtex.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=dxtex - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to dxtex - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "dxtex - Win32 Release" && "$(CFG)" != "dxtex - 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 "dxtex.mak" CFG="dxtex - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "dxtex - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "dxtex - 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)" == "dxtex - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\dxtex.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ChildFrm.obj"
|
||||
-@erase "$(INTDIR)\dialogs.obj"
|
||||
-@erase "$(INTDIR)\Dxtex.obj"
|
||||
-@erase "$(INTDIR)\Dxtex.res"
|
||||
-@erase "$(INTDIR)\DxtexDoc.obj"
|
||||
-@erase "$(INTDIR)\DxtexView.obj"
|
||||
-@erase "$(INTDIR)\MainFrm.obj"
|
||||
-@erase "$(INTDIR)\StdAfx.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(OUTDIR)\dxtex.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\dxtex.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)\Dxtex.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\dxtex.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=ddraw.lib d3d8.lib d3dx8.lib dxguid.lib version.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\dxtex.pdb" /machine:I386 /out:"$(OUTDIR)\dxtex.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\ChildFrm.obj" \
|
||||
"$(INTDIR)\dialogs.obj" \
|
||||
"$(INTDIR)\Dxtex.obj" \
|
||||
"$(INTDIR)\DxtexDoc.obj" \
|
||||
"$(INTDIR)\DxtexView.obj" \
|
||||
"$(INTDIR)\MainFrm.obj" \
|
||||
"$(INTDIR)\StdAfx.obj" \
|
||||
"$(INTDIR)\Dxtex.res"
|
||||
|
||||
"$(OUTDIR)\dxtex.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "dxtex - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\dxtex.exe" "$(OUTDIR)\dxtex.bsc"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ChildFrm.obj"
|
||||
-@erase "$(INTDIR)\ChildFrm.sbr"
|
||||
-@erase "$(INTDIR)\dialogs.obj"
|
||||
-@erase "$(INTDIR)\dialogs.sbr"
|
||||
-@erase "$(INTDIR)\Dxtex.obj"
|
||||
-@erase "$(INTDIR)\Dxtex.res"
|
||||
-@erase "$(INTDIR)\Dxtex.sbr"
|
||||
-@erase "$(INTDIR)\DxtexDoc.obj"
|
||||
-@erase "$(INTDIR)\DxtexDoc.sbr"
|
||||
-@erase "$(INTDIR)\DxtexView.obj"
|
||||
-@erase "$(INTDIR)\DxtexView.sbr"
|
||||
-@erase "$(INTDIR)\MainFrm.obj"
|
||||
-@erase "$(INTDIR)\MainFrm.sbr"
|
||||
-@erase "$(INTDIR)\StdAfx.obj"
|
||||
-@erase "$(INTDIR)\StdAfx.sbr"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(OUTDIR)\dxtex.bsc"
|
||||
-@erase "$(OUTDIR)\dxtex.exe"
|
||||
-@erase "$(OUTDIR)\dxtex.ilk"
|
||||
-@erase "$(OUTDIR)\dxtex.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\dxtex.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)\Dxtex.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\dxtex.bsc"
|
||||
BSC32_SBRS= \
|
||||
"$(INTDIR)\ChildFrm.sbr" \
|
||||
"$(INTDIR)\dialogs.sbr" \
|
||||
"$(INTDIR)\Dxtex.sbr" \
|
||||
"$(INTDIR)\DxtexDoc.sbr" \
|
||||
"$(INTDIR)\DxtexView.sbr" \
|
||||
"$(INTDIR)\MainFrm.sbr" \
|
||||
"$(INTDIR)\StdAfx.sbr"
|
||||
|
||||
"$(OUTDIR)\dxtex.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3d8.lib d3dx8dt.lib dxguid.lib version.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\dxtex.pdb" /debug /machine:I386 /out:"$(OUTDIR)\dxtex.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\ChildFrm.obj" \
|
||||
"$(INTDIR)\dialogs.obj" \
|
||||
"$(INTDIR)\Dxtex.obj" \
|
||||
"$(INTDIR)\DxtexDoc.obj" \
|
||||
"$(INTDIR)\DxtexView.obj" \
|
||||
"$(INTDIR)\MainFrm.obj" \
|
||||
"$(INTDIR)\StdAfx.obj" \
|
||||
"$(INTDIR)\Dxtex.res"
|
||||
|
||||
"$(OUTDIR)\dxtex.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("dxtex.dep")
|
||||
!INCLUDE "dxtex.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "dxtex.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "dxtex - Win32 Release" || "$(CFG)" == "dxtex - Win32 Debug"
|
||||
SOURCE=.\ChildFrm.cpp
|
||||
|
||||
!IF "$(CFG)" == "dxtex - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\ChildFrm.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "dxtex - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\ChildFrm.obj" "$(INTDIR)\ChildFrm.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\dialogs.cpp
|
||||
|
||||
!IF "$(CFG)" == "dxtex - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\dialogs.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "dxtex - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\dialogs.obj" "$(INTDIR)\dialogs.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\Dxtex.cpp
|
||||
|
||||
!IF "$(CFG)" == "dxtex - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\Dxtex.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "dxtex - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\Dxtex.obj" "$(INTDIR)\Dxtex.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\Dxtex.rc
|
||||
|
||||
"$(INTDIR)\Dxtex.res" : $(SOURCE) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=.\DxtexDoc.cpp
|
||||
|
||||
!IF "$(CFG)" == "dxtex - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\DxtexDoc.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "dxtex - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\DxtexDoc.obj" "$(INTDIR)\DxtexDoc.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\DxtexView.cpp
|
||||
|
||||
!IF "$(CFG)" == "dxtex - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\DxtexView.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "dxtex - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\DxtexView.obj" "$(INTDIR)\DxtexView.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\MainFrm.cpp
|
||||
|
||||
!IF "$(CFG)" == "dxtex - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\MainFrm.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "dxtex - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\MainFrm.obj" "$(INTDIR)\MainFrm.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\StdAfx.cpp
|
||||
|
||||
!IF "$(CFG)" == "dxtex - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\StdAfx.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "dxtex - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\StdAfx.obj" "$(INTDIR)\StdAfx.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
667
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dxtex.rc
Normal file
@@ -0,0 +1,667 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.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
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_OLE_RESOURCES\r\n"
|
||||
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
|
||||
"\r\n"
|
||||
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
|
||||
"#ifdef _WIN32\r\n"
|
||||
"LANGUAGE 9, 1\r\n"
|
||||
"#pragma code_page(1252)\r\n"
|
||||
"#endif //_WIN32\r\n"
|
||||
"#include ""afxres.rc"" // Standard components\r\n"
|
||||
"#endif\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDR_MAINFRAME ICON DISCARDABLE "dxtex.ico"
|
||||
IDR_DXTXTYPE ICON DISCARDABLE "dxtexDoc.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDR_MAINFRAME BITMAP MOVEABLE PURE "Toolbar.bmp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Toolbar
|
||||
//
|
||||
|
||||
IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15
|
||||
BEGIN
|
||||
BUTTON ID_FILE_NEW
|
||||
BUTTON ID_FILE_OPEN
|
||||
BUTTON ID_FILE_SAVE
|
||||
SEPARATOR
|
||||
BUTTON ID_APP_ABOUT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&New Texture...\tCtrl+N", ID_FILE_NEW
|
||||
MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "&Toolbar", ID_VIEW_TOOLBAR
|
||||
MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About DxTex...", ID_APP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_DXTXTYPE MENU PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&New Texture...", ID_FILE_NEW
|
||||
MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN
|
||||
MENUITEM "O&pen Onto Alpha Channel Of This Texture...",
|
||||
ID_FILE_OPENALPHA
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Open Onto &This Surface...", ID_FILE_OPENSUBSURFACE
|
||||
MENUITEM "Open Onto Alpha Channel Of T&his Surface...",
|
||||
ID_FILE_OPENALPHASUBSURFACE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Open Onto Th&is Cubemap Face...", ID_FILE_OPENFACE
|
||||
MENUITEM "Open Onto Alpha Channel Of This C&ubemap Face...",
|
||||
ID_FILE_OPENALPHAFACE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Close", ID_FILE_CLOSE
|
||||
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE
|
||||
MENUITEM "Save &As...", ID_FILE_SAVE_AS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Recent File", ID_FILE_MRU_FILE1, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_APP_EXIT
|
||||
END
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT
|
||||
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
|
||||
MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "&Original Format\t1", ID_VIEW_ORIGINAL
|
||||
MENUITEM "&New Format\t2", ID_VIEW_COMPRESSED
|
||||
MENUITEM SEPARATOR
|
||||
POPUP "&Cube Map Face"
|
||||
BEGIN
|
||||
MENUITEM "Positive X\tX", ID_VIEW_POSX
|
||||
MENUITEM "Negative X\tx", ID_VIEW_NEGX
|
||||
MENUITEM "Positive Y\tY", ID_VIEW_POSY
|
||||
MENUITEM "Negative Y\ty", ID_VIEW_NEGY
|
||||
MENUITEM "Positive Z\tZ", ID_VIEW_POSZ
|
||||
MENUITEM "Negative Z\tz", ID_VIEW_NEGZ
|
||||
END
|
||||
MENUITEM "&Alpha Channel Only", ID_VIEW_ALPHACHANNEL
|
||||
MENUITEM "Change &Background Color...", ID_VIEW_CHANGEBACKGROUNDCOLOR
|
||||
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Higher Volume Slice\t>", ID_VIEW_HIGHERVOLUMESLICE
|
||||
MENUITEM "Lo&wer Volume Slice\t<", ID_VIEW_LOWERVOLUMESLICE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "S&maller Mip Level\tPgDn", ID_VIEW_SMALLERMIPLEVEL
|
||||
MENUITEM "&Larger Mip Level\tPgUp", ID_VIEW_LARGERMIPLEVEL
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Zoom I&n\t+", ID_VIEW_ZOOMIN
|
||||
MENUITEM "Zoom O&ut\t-", ID_VIEW_ZOOMOUT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Toolbar", ID_VIEW_TOOLBAR
|
||||
MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
|
||||
END
|
||||
POPUP "F&ormat"
|
||||
BEGIN
|
||||
MENUITEM "&Generate Mip Maps", ID_FORMAT_GENERATEMIPMAPS
|
||||
MENUITEM "&Change Surface Format...", ID_FORMAT_CHANGESURFACEFMT
|
||||
MENUITEM "&Make Into Cube Map...", ID_FORMAT_CHANGECUBEMAPFACES
|
||||
MENUITEM "M&ake Into Volume Map...", ID_FORMAT_MAKEINTOVOLUMEMAP
|
||||
END
|
||||
POPUP "&Window"
|
||||
BEGIN
|
||||
MENUITEM "&New Window", ID_WINDOW_NEW
|
||||
MENUITEM "&Cascade", ID_WINDOW_CASCADE
|
||||
MENUITEM "&Tile", ID_WINDOW_TILE_HORZ
|
||||
MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About DxTex...", ID_APP_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
|
||||
BEGIN
|
||||
"+", ID_VIEW_ZOOMIN, ASCII, NOINVERT
|
||||
"-", ID_VIEW_ZOOMOUT, ASCII, NOINVERT
|
||||
"1", ID_VIEW_ORIGINAL, VIRTKEY, NOINVERT
|
||||
"2", ID_VIEW_COMPRESSED, VIRTKEY, NOINVERT
|
||||
"<", ID_VIEW_LOWERVOLUMESLICE, ASCII, NOINVERT
|
||||
">", ID_VIEW_HIGHERVOLUMESLICE, ASCII, NOINVERT
|
||||
"C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
|
||||
"N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
|
||||
"O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
|
||||
"S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT
|
||||
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_ADD, ID_VIEW_ZOOMIN, VIRTKEY, NOINVERT
|
||||
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT
|
||||
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT
|
||||
VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT
|
||||
VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT
|
||||
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT
|
||||
VK_NEXT, ID_VIEW_SMALLERMIPLEVEL, VIRTKEY, NOINVERT
|
||||
VK_PRIOR, ID_VIEW_LARGERMIPLEVEL, VIRTKEY, NOINVERT
|
||||
VK_SUBTRACT, ID_VIEW_ZOOMOUT, VIRTKEY, NOINVERT
|
||||
"X", ID_VIEW_NEGX, VIRTKEY, NOINVERT
|
||||
"X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
|
||||
"X", ID_VIEW_POSX, VIRTKEY, SHIFT, NOINVERT
|
||||
"Y", ID_VIEW_NEGY, VIRTKEY, NOINVERT
|
||||
"Y", ID_VIEW_POSY, VIRTKEY, SHIFT, NOINVERT
|
||||
"Z", ID_VIEW_NEGZ, VIRTKEY, NOINVERT
|
||||
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT
|
||||
"Z", ID_VIEW_POSZ, VIRTKEY, SHIFT, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 286, 82
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About DirectX Texture Tool"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
|
||||
LTEXT "DirectX Texture Tool",IDC_STATIC,40,10,239,8,
|
||||
SS_NOPREFIX
|
||||
LTEXT "Copyright <20> 1999-2000 Microsoft Corporation. All rights reserved.",
|
||||
IDC_STATIC,40,35,239,8
|
||||
DEFPUSHBUTTON "OK",IDOK,121,61,43,14,WS_GROUP
|
||||
LTEXT "",IDC_VERSION,40,22,239,8
|
||||
LTEXT "See dxtex.txt for help with using this program.",
|
||||
IDC_STATIC,40,48,142,8
|
||||
END
|
||||
|
||||
IDD_CUBEMAP DIALOG DISCARDABLE 0, 0, 186, 133
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Create Cube Map"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,35,112,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,101,112,50,14
|
||||
LTEXT "Select which face you would like the current image moved to:",
|
||||
IDC_STATIC,7,7,172,20
|
||||
CONTROL "Positive X",IDC_POSX,"Button",BS_AUTORADIOBUTTON |
|
||||
WS_GROUP,7,30,172,10
|
||||
CONTROL "Negative X",IDC_NEGX,"Button",BS_AUTORADIOBUTTON,7,41,
|
||||
172,10
|
||||
CONTROL "Positive Y",IDC_POSY,"Button",BS_AUTORADIOBUTTON,7,52,
|
||||
172,10
|
||||
CONTROL "Negative Y",IDC_NEGY,"Button",BS_AUTORADIOBUTTON,7,63,
|
||||
172,10
|
||||
CONTROL "Positive Z",IDC_POSZ,"Button",BS_AUTORADIOBUTTON,7,74,
|
||||
172,10
|
||||
CONTROL "Negative Z",IDC_NEGZ,"Button",BS_AUTORADIOBUTTON,7,85,
|
||||
172,10
|
||||
END
|
||||
|
||||
IDD_VOLUMEMAP DIALOG DISCARDABLE 0, 0, 158, 122
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Create Volume Map"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
LTEXT "How many slices (layers) do you want to have in the volume map?",
|
||||
IDC_STATIC,7,7,144,20
|
||||
DEFPUSHBUTTON "OK",IDOK,21,101,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,87,101,50,14
|
||||
CONTROL "2",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON | WS_GROUP,31,
|
||||
32,20,10
|
||||
CONTROL "4",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON,31,44,20,10
|
||||
CONTROL "8",IDC_RADIO8,"Button",BS_AUTORADIOBUTTON,31,56,20,10
|
||||
CONTROL "16",IDC_RADIO16,"Button",BS_AUTORADIOBUTTON,31,68,24,10
|
||||
CONTROL "32",IDC_RADIO32,"Button",BS_AUTORADIOBUTTON,31,80,24,10
|
||||
CONTROL "64",IDC_RADIO64,"Button",BS_AUTORADIOBUTTON,85,32,24,10
|
||||
CONTROL "128",IDC_RADIO128,"Button",BS_AUTORADIOBUTTON,85,44,28,
|
||||
10
|
||||
CONTROL "256",IDC_RADIO256,"Button",BS_AUTORADIOBUTTON,85,56,28,
|
||||
10
|
||||
CONTROL "512",IDC_RADIO512,"Button",BS_AUTORADIOBUTTON,85,68,28,
|
||||
10
|
||||
CONTROL "1024",IDC_RADIO1024,"Button",BS_AUTORADIOBUTTON,85,80,
|
||||
32,10
|
||||
END
|
||||
|
||||
IDD_CHANGEFORMAT DIALOG DISCARDABLE 0, 0, 200, 154
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Change Surface Format"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
LTEXT "Select the surface format for this texture:",IDC_STATIC,
|
||||
7,7,186,15
|
||||
CONTROL "A8 R8 G8 B8",IDC_A8R8G8B8,"Button",BS_AUTORADIOBUTTON |
|
||||
WS_GROUP | WS_TABSTOP,7,30,58,10
|
||||
CONTROL "A1 R5 G5 B5",IDC_A1R5G5B5,"Button",BS_AUTORADIOBUTTON,7,
|
||||
41,58,10
|
||||
CONTROL "A4 R4 G4 B4",IDC_A4R4G4B4,"Button",BS_AUTORADIOBUTTON,7,
|
||||
52,58,10
|
||||
CONTROL "R8 G8 B8",IDC_R8G8B8,"Button",BS_AUTORADIOBUTTON,7,63,
|
||||
58,10
|
||||
CONTROL "R5 G6 B5",IDC_R5G6B5,"Button",BS_AUTORADIOBUTTON,7,74,
|
||||
58,10
|
||||
CONTROL "X8 R8 G8 B8",IDC_X8R8G8B8,"Button",BS_AUTORADIOBUTTON,
|
||||
64,30,58,10
|
||||
CONTROL "X1 R5 G5 B5",IDC_X1R5G5B5,"Button",BS_AUTORADIOBUTTON,
|
||||
64,41,58,10
|
||||
CONTROL "R3 G3 B2",IDC_R3G3B2,"Button",BS_AUTORADIOBUTTON,64,52,
|
||||
58,10
|
||||
CONTROL "A8 R3 G3 B2",IDC_A8R3G3B2,"Button",BS_AUTORADIOBUTTON,
|
||||
64,63,58,10
|
||||
CONTROL "X4 R4 G4 B4",IDC_X4R4G4B4,"Button",BS_AUTORADIOBUTTON,
|
||||
64,74,58,10
|
||||
CONTROL "DXT1",IDC_DXT1,"Button",BS_AUTORADIOBUTTON,132,30,58,10
|
||||
CONTROL "DXT2",IDC_DXT2,"Button",BS_AUTORADIOBUTTON,132,41,58,10
|
||||
CONTROL "DXT3",IDC_DXT3,"Button",BS_AUTORADIOBUTTON,132,52,58,10
|
||||
CONTROL "DXT4",IDC_DXT4,"Button",BS_AUTORADIOBUTTON,132,63,58,10
|
||||
CONTROL "DXT5",IDC_DXT5,"Button",BS_AUTORADIOBUTTON,132,74,58,10
|
||||
LTEXT "",IDC_FMTDESC,7,98,186,22
|
||||
DEFPUSHBUTTON "OK",IDOK,42,133,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,108,133,50,14
|
||||
END
|
||||
|
||||
IDD_NEWTEXTURE DIALOG DISCARDABLE 0, 0, 231, 287
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "New Texture"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,57,266,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,123,266,50,14
|
||||
GROUPBOX "Texture Type",IDC_STATIC,7,7,217,58
|
||||
CONTROL "Standard Texture",IDC_TEXTURE,"Button",
|
||||
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,18,20,193,10
|
||||
CONTROL "Cubemap Texture",IDC_CUBEMAP,"Button",
|
||||
BS_AUTORADIOBUTTON,18,33,193,10
|
||||
CONTROL "Volume Texture",IDC_VOLUMETEXTURE,"Button",
|
||||
BS_AUTORADIOBUTTON,18,46,193,10
|
||||
GROUPBOX "Dimensions",IDC_STATIC,7,70,217,62
|
||||
LTEXT "Width:",IDC_STATIC,18,86,22,8
|
||||
EDITTEXT IDC_WIDTH,53,83,40,14,ES_AUTOHSCROLL
|
||||
LTEXT "Height:",IDC_STATIC,18,106,24,8
|
||||
EDITTEXT IDC_HEIGHT,53,104,40,14,ES_AUTOHSCROLL
|
||||
LTEXT "Volume Depth:",IDC_VOLUMEDEPTHLABEL,106,86,48,8
|
||||
EDITTEXT IDC_DEPTH,164,83,40,14,ES_AUTOHSCROLL
|
||||
LTEXT "MipMap Levels:",IDC_STATIC,106,106,51,8
|
||||
EDITTEXT IDC_MIPCOUNT,164,104,40,14,ES_AUTOHSCROLL
|
||||
GROUPBOX "Surface/Volume Format",IDC_STATIC,7,139,217,112
|
||||
CONTROL "A8 R8 G8 B8",IDC_A8R8G8B8,"Button",BS_AUTORADIOBUTTON |
|
||||
WS_GROUP | WS_TABSTOP,18,159,58,10
|
||||
CONTROL "A1 R5 G5 B5",IDC_A1R5G5B5,"Button",BS_AUTORADIOBUTTON,
|
||||
18,170,58,10
|
||||
CONTROL "A4 R4 G4 B4",IDC_A4R4G4B4,"Button",BS_AUTORADIOBUTTON,
|
||||
18,181,58,10
|
||||
CONTROL "R8 G8 B8",IDC_R8G8B8,"Button",BS_AUTORADIOBUTTON,18,192,
|
||||
58,10
|
||||
CONTROL "R5 G6 B5",IDC_R5G6B5,"Button",BS_AUTORADIOBUTTON,18,203,
|
||||
58,10
|
||||
CONTROL "X8 R8 G8 B8",IDC_X8R8G8B8,"Button",BS_AUTORADIOBUTTON,
|
||||
87,159,58,10
|
||||
CONTROL "X1 R5 G5 B5",IDC_X1R5G5B5,"Button",BS_AUTORADIOBUTTON,
|
||||
87,170,58,10
|
||||
CONTROL "R3 G3 B2",IDC_R3G3B2,"Button",BS_AUTORADIOBUTTON,87,181,
|
||||
58,10
|
||||
CONTROL "A8 R3 G3 B2",IDC_A8R3G3B2,"Button",BS_AUTORADIOBUTTON,
|
||||
87,192,58,10
|
||||
CONTROL "X4 R4 G4 B4",IDC_X4R4G4B4,"Button",BS_AUTORADIOBUTTON,
|
||||
87,203,58,10
|
||||
CONTROL "DXT1",IDC_DXT1,"Button",BS_AUTORADIOBUTTON,158,159,58,
|
||||
10
|
||||
CONTROL "DXT2",IDC_DXT2,"Button",BS_AUTORADIOBUTTON,158,170,58,
|
||||
10
|
||||
CONTROL "DXT3",IDC_DXT3,"Button",BS_AUTORADIOBUTTON,158,181,58,
|
||||
10
|
||||
CONTROL "DXT4",IDC_DXT4,"Button",BS_AUTORADIOBUTTON,158,192,58,
|
||||
10
|
||||
CONTROL "DXT5",IDC_DXT5,"Button",BS_AUTORADIOBUTTON,158,203,58,
|
||||
10
|
||||
LTEXT "",IDC_FMTDESC,16,216,202,27
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_ABOUTBOX, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 279
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 75
|
||||
END
|
||||
|
||||
IDD_CUBEMAP, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 179
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 126
|
||||
END
|
||||
|
||||
IDD_VOLUMEMAP, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 151
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 115
|
||||
END
|
||||
|
||||
IDD_CHANGEFORMAT, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 193
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 147
|
||||
END
|
||||
|
||||
IDD_NEWTEXTURE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 224
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 280
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
IDR_MAINFRAME "DirectX Texture Tool"
|
||||
IDR_DXTXTYPE "\nTexture\nDDS\nDDS Files (*.dds)\n.dds\nDDS.Document\nDDS Document"
|
||||
END
|
||||
|
||||
STRINGTABLE PRELOAD DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_APP_TITLE "DirectX Texture Tool"
|
||||
AFX_IDS_IDLEMESSAGE "Ready"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_INDICATOR_EXT "EXT"
|
||||
ID_INDICATOR_CAPS "CAP"
|
||||
ID_INDICATOR_NUM "NUM"
|
||||
ID_INDICATOR_SCRL "SCRL"
|
||||
ID_INDICATOR_OVR "OVR"
|
||||
ID_INDICATOR_REC "REC"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_NEW "Create a new document\nNew"
|
||||
ID_FILE_OPEN "Open an existing texture document\nOpen"
|
||||
ID_FILE_CLOSE "Close the active document\nClose"
|
||||
ID_FILE_SAVE "Save the active document\nSave"
|
||||
ID_FILE_SAVE_AS "Save the active document with a new name\nSave As"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
|
||||
ID_APP_EXIT "Quit the application; prompts to save documents\nExit"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_MRU_FILE1 "Open this document"
|
||||
ID_FILE_MRU_FILE2 "Open this document"
|
||||
ID_FILE_MRU_FILE3 "Open this document"
|
||||
ID_FILE_MRU_FILE4 "Open this document"
|
||||
ID_FILE_MRU_FILE5 "Open this document"
|
||||
ID_FILE_MRU_FILE6 "Open this document"
|
||||
ID_FILE_MRU_FILE7 "Open this document"
|
||||
ID_FILE_MRU_FILE8 "Open this document"
|
||||
ID_FILE_MRU_FILE9 "Open this document"
|
||||
ID_FILE_MRU_FILE10 "Open this document"
|
||||
ID_FILE_MRU_FILE11 "Open this document"
|
||||
ID_FILE_MRU_FILE12 "Open this document"
|
||||
ID_FILE_MRU_FILE13 "Open this document"
|
||||
ID_FILE_MRU_FILE14 "Open this document"
|
||||
ID_FILE_MRU_FILE15 "Open this document"
|
||||
ID_FILE_MRU_FILE16 "Open this document"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_NEXT_PANE "Switch to the next window pane\nNext Pane"
|
||||
ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_WINDOW_NEW "Open another window for the active document\nNew Window"
|
||||
ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons"
|
||||
ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows"
|
||||
ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows"
|
||||
ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows"
|
||||
ID_WINDOW_SPLIT "Split the active window into panes\nSplit"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_EDIT_CLEAR "Erase the selection\nErase"
|
||||
ID_EDIT_CLEAR_ALL "Erase everything\nErase All"
|
||||
ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy"
|
||||
ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut"
|
||||
ID_EDIT_FIND "Find the specified text\nFind"
|
||||
ID_EDIT_PASTE "Insert Clipboard contents\nPaste"
|
||||
ID_EDIT_REPEAT "Repeat the last action\nRepeat"
|
||||
ID_EDIT_REPLACE "Replace specific text with different text\nReplace"
|
||||
ID_EDIT_SELECT_ALL "Select the entire document\nSelect All"
|
||||
ID_EDIT_UNDO "Undo the last action\nUndo"
|
||||
ID_EDIT_REDO "Redo the previously undone action\nRedo"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar"
|
||||
ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCSIZE "Change the window size"
|
||||
AFX_IDS_SCMOVE "Change the window position"
|
||||
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
|
||||
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
|
||||
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
|
||||
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
|
||||
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
AFX_IDS_SCRESTORE "Restore the window to normal size"
|
||||
AFX_IDS_SCTASKLIST "Activate Task List"
|
||||
AFX_IDS_MDICHILD "Activate this window"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_INDICATOR_IMAGEINFO " "
|
||||
ID_ERROR_ODDDIMENSIONS "Texture maps must have even (multiple of 2) width and height."
|
||||
ID_ERROR_NOTPOW2 "Source image width and height must be powers of 2."
|
||||
ID_ERROR_WRONGDIMENSIONS
|
||||
"This image does not have the same dimensions as the source image. Is it okay to resize it?"
|
||||
ID_ERROR_GENERATEALPHAFAILED
|
||||
"Generation of the alpha image unexpectedly failed."
|
||||
ID_ERROR_PREMULTALPHA "This operation cannot be performed because the source image uses premultiplied alpha."
|
||||
ID_ERROR_PREMULTTODXT1 "Warning: The source image contains premultiplied alpha, and the RGB values will be copied to the destination without ""unpremultiplying"" them, so the resulting colors may be affected."
|
||||
ID_ERROR_CANTCREATEDEVICE
|
||||
"Unable to create Direct3D Device. Please make sure your desktop color depth is 16 or 32 bit."
|
||||
IDS_FMTDESC_A8R8G8B8 "(A8R8G8B8: 32 bits per pixel, 8 bits per component for alpha, red, green, and blue)"
|
||||
IDS_FMTDESC_A1R5G5B5 "(A1R5G5B5: 16 bits per pixel, 1 bit of alpha, 5 bits per component for red, green, and blue)"
|
||||
IDS_FMTDESC_A4R4G4B4 "(A4R4G4B4: 16 bits per pixel, 4 bits per component for alpha, red, green, and blue)"
|
||||
IDS_FMTDESC_R8G8B8 "(R8G8B8: 24 bits per pixel, 8 bits per component for red, green, and blue)"
|
||||
IDS_FMTDESC_R5G6B5 "(R5G6B5: 16 bits per pixel, 6 bits per component for green, 5 bits per component for red and blue)"
|
||||
IDS_FMTDESC_DXT1 "(DXT1: compressed, 1-bit alpha)"
|
||||
IDS_FMTDESC_DXT2 "(DXT2: compressed, 4-bit premultiplied alpha)"
|
||||
IDS_FMTDESC_DXT3 "(DXT3: compressed, 4-bit nonpremultiplied alpha)"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FORMAT_GENERATEMIPMAPS "Generate Mip Maps"
|
||||
ID_FORMAT_CHANGEIMAGEFORMAT "Convert to a different image format"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_OPENALPHA "Loads an alpha channel onto the current texture"
|
||||
ID_FILE_OPENSUBSURFACE "Loads RGB data onto this surface of the texture"
|
||||
ID_FILE_OPENALPHASUBSURFACE
|
||||
"Loads Alpha data onto this surface of the texture"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_FILE_OPENFACE "Loads RGB data onto this face of the cubemap texture"
|
||||
ID_FILE_OPENALPHAFACE "Loads Alpha data onto this face of the cubemap texture"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_FMTDESC_DXT4 "(DXT4: compressed, interpolated premultiplied alpha)"
|
||||
IDS_FMTDESC_DXT5 "(DXT5: compressed, interpolated nonpremultiplied alpha)"
|
||||
ID_ERROR_CANTCREATETEXTURE
|
||||
"A texture could not be created with those settings."
|
||||
ID_ERROR_D3DCREATEFAILED
|
||||
"Could not initialize Direct3D. Please ensure that this program was compiled with header files matching the installed version of DirectX."
|
||||
ID_ERROR_COULDNTLOADFILE "An error occurred trying to open that file."
|
||||
ID_ERROR_COULDNTSAVEFILE "An error occurred trying to save that file."
|
||||
IDS_FMTDESC_X8R8G8B8 "(X8R8G8B8: 32 bits per pixel, 8 bits per component for red, green, and blue)"
|
||||
IDS_FMTDESC_X1R5G5B5 "(X1R5G5B5: 16 bits per pixel, 5 bits per component for red, green, and blue)"
|
||||
IDS_FMTDESC_R3G3B2 "(R3G3B2: 8 bits per pixel, 3 bits of red and green, 2 bits for blue)"
|
||||
IDS_FMTDESC_A8R3G3B2 "(A8R3G3B2: 16 bits per pixel, 8 bits of alpha, 3 bits of red and green, 2 bits for blue)"
|
||||
IDS_FMTDESC_X4R4G4B4 "(X4R4G4B4: 16 bits per pixel, 4 bits per component for red, green, and blue)"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_ERROR_NULLREF "This program uses the reference rendering device. Your computer has a reduced-functionality reference device installed. You can still use this program to manipulate textures, but the textures will not be visible in this program. Install the DirectX SDK to install the full reference device."
|
||||
ID_ERROR_NEEDALPHA "Alpha channel needed for this operation."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#define _AFX_NO_SPLITTER_RESOURCES
|
||||
#define _AFX_NO_OLE_RESOURCES
|
||||
#define _AFX_NO_TRACKER_RESOURCES
|
||||
#define _AFX_NO_PROPERTY_RESOURCES
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE 9, 1
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
#include "afxres.rc" // Standard components
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
1511
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dxtexdoc.cpp
Normal file
104
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dxtexdoc.h
Normal file
@@ -0,0 +1,104 @@
|
||||
// dxtexDoc.h : interface of the CDxtexDoc class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_DXTXDOC_H__712C53CF_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_)
|
||||
#define AFX_DXtxDOC_H__712C53CF_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
class CDxtexDoc : public CDocument
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CDxtexDoc();
|
||||
DECLARE_DYNCREATE(CDxtexDoc)
|
||||
|
||||
public:
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CDxtexDoc)
|
||||
public:
|
||||
virtual BOOL OnNewDocument();
|
||||
virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
|
||||
virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
|
||||
virtual void SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU = TRUE);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
HRESULT LoadAlphaBmp(CString& strPath);
|
||||
VOID GenerateMipMaps(VOID);
|
||||
HRESULT ChangeFormat(LPDIRECT3DBASETEXTURE8 ptexCur, D3DFORMAT fmt,
|
||||
LPDIRECT3DBASETEXTURE8* pptexNew);
|
||||
HRESULT Compress(D3DFORMAT fmt, BOOL bSwitchView);
|
||||
DWORD NumMips(VOID);
|
||||
LPDIRECT3DBASETEXTURE8 PtexOrig(VOID) { return m_ptexOrig; }
|
||||
LPDIRECT3DBASETEXTURE8 PtexNew(VOID) { return m_ptexNew; }
|
||||
DWORD DwWidth(VOID) { return m_dwWidth; }
|
||||
DWORD DwHeight(VOID) { return m_dwHeight; }
|
||||
DWORD DwDepth(VOID) { return m_dwDepth; }
|
||||
DWORD DwDepthAt(LONG lwMip);
|
||||
BOOL TitleModsChanged(VOID) { return m_bTitleModsChanged; }
|
||||
VOID ClearTitleModsChanged(VOID) { m_bTitleModsChanged = FALSE; }
|
||||
virtual ~CDxtexDoc();
|
||||
void OpenSubsurface(D3DCUBEMAP_FACES FaceType, LONG lwMip, LONG lwSlice);
|
||||
void OpenAlphaSubsurface(D3DCUBEMAP_FACES FaceType, LONG lwMip, LONG lwSlice);
|
||||
void OpenCubeFace(D3DCUBEMAP_FACES FaceType);
|
||||
void OpenAlphaCubeFace(D3DCUBEMAP_FACES FaceType);
|
||||
BOOL IsCubeMap(VOID) { return (m_dwCubeMapFlags > 0); }
|
||||
BOOL IsVolumeMap(VOID) { return (m_dwDepth > 0); }
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CDxtexDoc)
|
||||
afx_msg void OnFileOpenAlpha();
|
||||
afx_msg void OnGenerateMipMaps();
|
||||
afx_msg void OnFormatDxt1();
|
||||
afx_msg void OnFormatDxt2();
|
||||
afx_msg void OnFormatDxt3();
|
||||
afx_msg void OnFormatDxt4();
|
||||
afx_msg void OnFormatDxt5();
|
||||
afx_msg void OnFormatChangeCubeMapFaces();
|
||||
afx_msg void OnUpdateFileOpenAlpha(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateFormatGenerateMipmaps(CCmdUI* pCmdUI);
|
||||
afx_msg void OnUpdateFormatChangeCubeMapFaces(CCmdUI* pCmdUI);
|
||||
afx_msg void OnFormatMakeIntoVolumeMap();
|
||||
afx_msg void OnUpdateFormatMakeIntoVolumeMap(CCmdUI* pCmdUI);
|
||||
afx_msg void OnFormatChangeSurfaceFmt();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
LPDIRECT3DBASETEXTURE8 m_ptexOrig;
|
||||
LPDIRECT3DBASETEXTURE8 m_ptexNew;
|
||||
DWORD m_dwWidth;
|
||||
DWORD m_dwHeight;
|
||||
DWORD m_dwDepth; // For volume textures
|
||||
DWORD m_numMips;
|
||||
DWORD m_dwCubeMapFlags;
|
||||
BOOL m_bTitleModsChanged;
|
||||
|
||||
CDxtexApp* PDxtexApp(VOID) { return (CDxtexApp*)AfxGetApp(); }
|
||||
HRESULT LoadAlphaIntoSurface(CString& strPath, LPDIRECT3DSURFACE8 psurf);
|
||||
HRESULT LoadVolumeSliceFromSurface(LPDIRECT3DVOLUME8 pVolume, UINT iSlice, LPDIRECT3DSURFACE8 pSurf);
|
||||
HRESULT LoadSurfaceFromVolumeSlice(LPDIRECT3DVOLUME8 pVolume, UINT iSlice, LPDIRECT3DSURFACE8 psurf);
|
||||
HRESULT BltAllLevels(D3DCUBEMAP_FACES FaceType, LPDIRECT3DBASETEXTURE8 ptexSrc,
|
||||
LPDIRECT3DBASETEXTURE8 ptexDest);
|
||||
BOOL PromptForBmp(CString* pstrPath);
|
||||
D3DFORMAT GetFormat(LPDIRECT3DBASETEXTURE8 ptex);
|
||||
HRESULT EnsureAlpha(LPDIRECT3DBASETEXTURE8* pptex);
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_DXTXDOC_H__712C53CF_D63B_11D1_A8B5_00C04FC2DC22__INCLUDED_)
|
||||
BIN
Library/dxx8/samples/Multimedia/Direct3D/DXTex/dxtexdoc.ico
Normal file
|
After Width: | Height: | Size: 1.1 KiB |