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:
Binary file not shown.
|
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
|
||||
|
||||
Reference in New Issue
Block a user