Initial commit: ROW Client source code
Game client codebase including: - CharacterActionControl: Character and creature management - GlobalScript: Network, items, skills, quests, utilities - RYLClient: Main client application with GUI and event handlers - Engine: 3D rendering engine (RYLGL) - MemoryManager: Custom memory allocation - Library: Third-party dependencies (DirectX, boost, etc.) - Tools: Development utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
565
Library/dxx8/samples/Multimedia/Direct3D/Billboard/billboard.cpp
Normal file
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
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
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
BIN
Library/dxx8/samples/Multimedia/Direct3D/Billboard/directx.ico
Normal file
Binary file not shown.
|
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
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
|
||||
|
||||
Reference in New Issue
Block a user