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:
@@ -0,0 +1,729 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: CubeMap.cpp
|
||||
//
|
||||
// Desc: Example code showing how to do environment mapping
|
||||
//
|
||||
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <tchar.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <D3DX8.h>
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFile.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: g_szEffect
|
||||
// Desc: String containing effect used to render shiny teapot. Two techniques
|
||||
// are shown.. one which simply uses cubemaps, and a fallback which uses
|
||||
// a vertex shader to do a sphere-map lookup.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const char g_szEffect[] =
|
||||
|
||||
"texture texCubeMap;\n"
|
||||
"texture texSphereMap;\n"
|
||||
|
||||
"matrix matWorld;\n"
|
||||
"matrix matView;\n"
|
||||
"matrix matProject;\n"
|
||||
"matrix matWorldView;\n"
|
||||
|
||||
|
||||
"technique Cube\n"
|
||||
"{\n"
|
||||
"pass P0\n"
|
||||
"{\n"
|
||||
// Vertex shate
|
||||
"VertexShader = xyz | normal;\n"
|
||||
"WorldTransform[0] = <matWorld>;\n"
|
||||
"ViewTransform = <matView>;\n"
|
||||
"ProjectionTransform = <matProject>;\n"
|
||||
|
||||
// Pixel state
|
||||
"Texture[0] = <texCubeMap>;\n"
|
||||
|
||||
"MinFilter[0] = Linear;\n"
|
||||
"MagFilter[0] = Linear;\n"
|
||||
|
||||
"AddressU[0] = Clamp;\n"
|
||||
"AddressV[0] = Clamp;\n"
|
||||
"AddressW[0] = Clamp;\n"
|
||||
|
||||
"ColorOp[0] = SelectArg1;\n"
|
||||
"ColorArg1[0] = Texture;\n"
|
||||
|
||||
"TexCoordIndex[0] = CameraSpaceReflectionVector;\n"
|
||||
"TextureTransformFlags[0] = Count3;\n"
|
||||
"}\n"
|
||||
"}\n"
|
||||
|
||||
|
||||
"technique Sphere\n"
|
||||
"{\n"
|
||||
"pass P0\n"
|
||||
"{\n"
|
||||
|
||||
// Vertex state
|
||||
"VertexShader =\n"
|
||||
"decl\n"
|
||||
"{\n"
|
||||
"float v0[3];\n" // position
|
||||
"float v1[3];\n" // normal
|
||||
"}\n"
|
||||
"asm\n"
|
||||
"{\n"
|
||||
"vs.1.0\n"
|
||||
"def c64, 0.25f, 0.5f, 1.0f, -1.0f\n"
|
||||
|
||||
// r0: camera-space position
|
||||
// r1: camera-space normal
|
||||
// r2: camera-space vertex-eye vector
|
||||
// r3: camera-space reflection vector
|
||||
// r4: texture coordinates
|
||||
|
||||
// Transform position and normal into camera-space
|
||||
"m4x4 r0, v0, c0\n"
|
||||
"m3x3 r1, v1, c0\n"
|
||||
|
||||
// Compute normalized view vector
|
||||
"mov r2, -r0\n"
|
||||
"dp3 r3, r2, r2\n"
|
||||
"rsq r3, r3\n"
|
||||
"mul r2, r2, r3\n"
|
||||
|
||||
// Compute camera-space reflection vector
|
||||
"dp3 r3, r1, r2\n"
|
||||
"mul r1, r1, r3\n"
|
||||
"add r1, r1, r1\n"
|
||||
"add r3, r1, -r2\n"
|
||||
|
||||
// Compute sphere-map texture coords
|
||||
"mad r4.w, -r3.z, c64.y, c64.y\n"
|
||||
"rsq r4, r4\n"
|
||||
"mul r4, r3, r4\n"
|
||||
"mad r4, r4, c64.x, c64.y\n"
|
||||
|
||||
// Project position
|
||||
"m4x4 oPos, r0, c4\n"
|
||||
"mul oT0.xy, r4.xy, c64.zw\n"
|
||||
"mov oT0.zw, c64.z\n"
|
||||
"};\n"
|
||||
|
||||
"VertexShaderConstant4[0] = <matWorldView>;\n"
|
||||
"VertexShaderConstant4[4] = <matProject>;\n"
|
||||
|
||||
// Pixel state
|
||||
"Texture[0] = <texSphereMap>;\n"
|
||||
"AddressU[0] = Wrap;\n"
|
||||
"AddressV[0] = Wrap;\n"
|
||||
"MinFilter[0] = Linear;\n"
|
||||
"MagFilter[0] = Linear;\n"
|
||||
"ColorOp[0] = SelectArg1;\n"
|
||||
"ColorArg1[0] = Texture;\n"
|
||||
"}\n"
|
||||
"}\n";
|
||||
|
||||
const UINT g_cchEffect = sizeof(g_szEffect) - 1;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct ENVMAPPEDVERTEX
|
||||
// Desc: D3D vertex type for environment-mapped objects
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ENVMAPPEDVERTEX
|
||||
{
|
||||
D3DXVECTOR3 p; // Position
|
||||
D3DXVECTOR3 n; // Normal
|
||||
};
|
||||
|
||||
#define D3DFVF_ENVMAPVERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL )
|
||||
|
||||
// CUBEMAP_RESOLUTION indicates how big to make the cubemap texture. Larger
|
||||
// textures will generate a better-looking reflection.
|
||||
#define CUBEMAP_RESOLUTION 256
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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
|
||||
{
|
||||
BOOL m_bCapture;
|
||||
|
||||
D3DXMATRIX m_matProject;
|
||||
D3DXMATRIX m_matView;
|
||||
D3DXMATRIX m_matWorld;
|
||||
D3DXMATRIX m_matAirplane;
|
||||
D3DXMATRIX m_matTrackBall;
|
||||
|
||||
CD3DFont* m_pFont;
|
||||
CD3DMesh* m_pShinyTeapot;
|
||||
CD3DMesh* m_pSkyBox;
|
||||
CD3DMesh* m_pAirplane;
|
||||
|
||||
ID3DXEffect* m_pEffect;
|
||||
ID3DXRenderToEnvMap* m_pRenderToEnvMap;
|
||||
|
||||
IDirect3DCubeTexture8* m_pCubeMap;
|
||||
IDirect3DTexture8* m_pSphereMap;
|
||||
|
||||
protected:
|
||||
HRESULT RenderSceneIntoEnvMap();
|
||||
HRESULT RenderScene( CONST D3DXMATRIX* pView, CONST D3DXMATRIX* pProject, BOOL bRenderTeapot );
|
||||
|
||||
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
|
||||
HRESULT OneTimeSceneInit();
|
||||
HRESULT InitDeviceObjects();
|
||||
HRESULT RestoreDeviceObjects();
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
HRESULT DeleteDeviceObjects();
|
||||
HRESULT Render();
|
||||
HRESULT FrameMove();
|
||||
HRESULT FinalCleanup();
|
||||
|
||||
public:
|
||||
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
CMyD3DApplication();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: WinMain()
|
||||
// Desc: Entry point to the program. Initializes everything, and goes into a
|
||||
// message-processing loop. Idle time is used to render the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
|
||||
{
|
||||
CMyD3DApplication d3dApp;
|
||||
|
||||
if( FAILED( d3dApp.Create( hInst ) ) )
|
||||
return 0;
|
||||
|
||||
return d3dApp.Run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CMyD3DApplication()
|
||||
// Desc: Application constructor. Sets attributes for the app.
|
||||
//-----------------------------------------------------------------------------
|
||||
CMyD3DApplication::CMyD3DApplication()
|
||||
{
|
||||
m_strWindowTitle = _T("CubeMap");
|
||||
m_bUseDepthBuffer = TRUE;
|
||||
m_bCapture = FALSE;
|
||||
|
||||
m_pFont = NULL;
|
||||
m_pShinyTeapot = NULL;
|
||||
m_pSkyBox = NULL;
|
||||
m_pAirplane = NULL;
|
||||
|
||||
m_pEffect = NULL;
|
||||
m_pRenderToEnvMap = NULL;
|
||||
|
||||
m_pCubeMap = NULL;
|
||||
m_pSphereMap = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: OneTimeSceneInit()
|
||||
// Desc: Called during initial app startup, this function performs all the
|
||||
// permanent initialization.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::OneTimeSceneInit()
|
||||
{
|
||||
D3DXMatrixIdentity( &m_matWorld );
|
||||
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
m_pShinyTeapot = new CD3DMesh();
|
||||
m_pSkyBox = new CD3DMesh();
|
||||
m_pAirplane = new CD3DMesh();
|
||||
|
||||
if( !m_pFont || !m_pShinyTeapot || !m_pSkyBox || !m_pAirplane )
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
D3DXMatrixIdentity( &m_matTrackBall );
|
||||
D3DXMatrixTranslation( &m_matView, 0.0f, 0.0f, 3.0f );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FrameMove()
|
||||
// Desc: Called once per frame, the call is the entry point for animating
|
||||
// the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FrameMove()
|
||||
{
|
||||
// Animate file object
|
||||
D3DXMATRIX mat;
|
||||
D3DXMatrixScaling( &m_matAirplane, 0.2f, 0.2f, 0.2f );
|
||||
D3DXMatrixTranslation( &mat, 0.0f, 2.0f, 0.0f );
|
||||
D3DXMatrixMultiply( &m_matAirplane, &m_matAirplane, &mat );
|
||||
D3DXMatrixRotationX( &mat, -2.9f * m_fTime );
|
||||
D3DXMatrixMultiply( &m_matAirplane, &m_matAirplane, &mat );
|
||||
D3DXMatrixRotationY( &mat, 1.055f * m_fTime );
|
||||
D3DXMatrixMultiply( &m_matAirplane, &m_matAirplane, &mat );
|
||||
|
||||
// When the window has focus, let the mouse adjust the camera view
|
||||
if( m_bCapture )
|
||||
{
|
||||
D3DXMATRIX matCursor;
|
||||
D3DXQUATERNION qCursor = D3DUtil_GetRotationFromCursor( m_hWnd );
|
||||
D3DXMatrixRotationQuaternion( &matCursor, &qCursor );
|
||||
D3DXMatrixMultiply( &m_matView, &m_matTrackBall, &matCursor );
|
||||
|
||||
D3DXMATRIX matTrans;
|
||||
D3DXMatrixTranslation( &matTrans, 0.0f, 0.0f, 3.0f );
|
||||
D3DXMatrixMultiply( &m_matView, &m_matView, &matTrans );
|
||||
}
|
||||
|
||||
|
||||
// Render the scene into the surfaces of the cubemap
|
||||
if( FAILED( RenderSceneIntoEnvMap() ) )
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RenderSceneIntoEnvMap()
|
||||
// Desc: Renders the scene to each of the 6 faces of the cube map
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RenderSceneIntoEnvMap()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
// Set the projection matrix for a field of view of 90 degrees
|
||||
D3DXMATRIX matProj;
|
||||
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI * 0.5f, 1.0f, 0.5f, 1000.0f );
|
||||
|
||||
|
||||
// Get the current view matrix, to concat it with the cubemap view vectors
|
||||
D3DXMATRIX matViewDir( m_matView );
|
||||
matViewDir._41 = 0.0f; matViewDir._42 = 0.0f; matViewDir._43 = 0.0f;
|
||||
|
||||
|
||||
|
||||
// Render the six cube faces into the environment map
|
||||
if( m_pCubeMap )
|
||||
hr = m_pRenderToEnvMap->BeginCube( m_pCubeMap );
|
||||
else
|
||||
hr = m_pRenderToEnvMap->BeginSphere( m_pSphereMap );
|
||||
|
||||
if(FAILED(hr))
|
||||
return hr;
|
||||
|
||||
for( UINT i = 0; i < 6; i++ )
|
||||
{
|
||||
m_pRenderToEnvMap->Face( (D3DCUBEMAP_FACES) i );
|
||||
|
||||
// Set the view transform for this cubemap surface
|
||||
D3DXMATRIX matView;
|
||||
matView = D3DUtil_GetCubeMapViewMatrix( (D3DCUBEMAP_FACES) i );
|
||||
D3DXMatrixMultiply( &matView, &matViewDir, &matView );
|
||||
|
||||
// Render the scene (except for the teapot)
|
||||
RenderScene( &matView, &matProj, FALSE );
|
||||
}
|
||||
|
||||
m_pRenderToEnvMap->End();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RenderScene()
|
||||
// Desc: Renders all visual elements in the scene. This is called by the main
|
||||
// Render() function, and also by the RenderIntoCubeMap() function.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RenderScene( CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pProject,
|
||||
BOOL bRenderTeapot )
|
||||
{
|
||||
// Render the Skybox
|
||||
{
|
||||
D3DXMATRIX matWorld;
|
||||
D3DXMatrixScaling( &matWorld, 10.0f, 10.0f, 10.0f );
|
||||
|
||||
D3DXMATRIX matView(*pView);
|
||||
matView._41 = matView._42 = matView._43 = 0.0f;
|
||||
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, pProject );
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_MIRROR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_MIRROR );
|
||||
|
||||
// Always pass Z-test, so we can avoid clearing color and depth buffers
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_ALWAYS );
|
||||
m_pSkyBox->Render( m_pd3dDevice );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
|
||||
}
|
||||
|
||||
|
||||
// Render the Airplane
|
||||
{
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matAirplane );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, pView );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, pProject );
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP );
|
||||
|
||||
m_pAirplane->Render( m_pd3dDevice );
|
||||
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matWorld);
|
||||
}
|
||||
|
||||
|
||||
// Render the environment-mapped ShinyTeapot
|
||||
if( bRenderTeapot )
|
||||
{
|
||||
// Set transform state
|
||||
if( m_pCubeMap )
|
||||
{
|
||||
m_pEffect->SetMatrix( "matWorld", &m_matWorld );
|
||||
m_pEffect->SetMatrix( "matView", (D3DXMATRIX*) pView );
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DXMATRIX matWorldView;
|
||||
D3DXMatrixMultiply( &matWorldView, &m_matWorld, pView );
|
||||
m_pEffect->SetMatrix( "matWorldView", &matWorldView );
|
||||
}
|
||||
|
||||
m_pEffect->SetMatrix( "matProject", (D3DXMATRIX*) pProject );
|
||||
|
||||
|
||||
// Draw teapot
|
||||
LPDIRECT3DVERTEXBUFFER8 pVB;
|
||||
LPDIRECT3DINDEXBUFFER8 pIB;
|
||||
|
||||
m_pShinyTeapot->m_pLocalMesh->GetVertexBuffer(&pVB);
|
||||
m_pShinyTeapot->m_pLocalMesh->GetIndexBuffer(&pIB);
|
||||
|
||||
m_pd3dDevice->SetStreamSource(0, pVB, sizeof(ENVMAPPEDVERTEX));
|
||||
m_pd3dDevice->SetIndices(pIB, 0);
|
||||
|
||||
UINT uPasses;
|
||||
m_pEffect->Begin( &uPasses, 0 );
|
||||
|
||||
for( UINT iPass = 0; iPass < uPasses; iPass++ )
|
||||
{
|
||||
m_pEffect->Pass( iPass );
|
||||
|
||||
m_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
|
||||
0, m_pShinyTeapot->m_pLocalMesh->GetNumVertices(),
|
||||
0, m_pShinyTeapot->m_pLocalMesh->GetNumFaces());
|
||||
|
||||
}
|
||||
|
||||
m_pEffect->End();
|
||||
|
||||
SAFE_RELEASE(pVB);
|
||||
SAFE_RELEASE(pIB);
|
||||
}
|
||||
|
||||
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( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
|
||||
{
|
||||
// Render the scene, including the teapot
|
||||
RenderScene( &m_matView, &m_matProject, TRUE );
|
||||
|
||||
// Output statistics
|
||||
m_pFont->DrawText( 2, 0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
|
||||
m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );
|
||||
|
||||
// End the scene.
|
||||
m_pd3dDevice->EndScene();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
// Load the file objects
|
||||
if( FAILED( m_pShinyTeapot->Create( m_pd3dDevice, _T("teapot.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
if( FAILED( m_pSkyBox->Create( m_pd3dDevice, _T("lobby_skybox.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
if( FAILED( m_pAirplane->Create( m_pd3dDevice, _T("airplane 2.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
|
||||
// Set mesh properties
|
||||
m_pAirplane->SetFVF( m_pd3dDevice, D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1 );
|
||||
m_pShinyTeapot->SetFVF( m_pd3dDevice, D3DFVF_ENVMAPVERTEX );
|
||||
|
||||
// Restore the device-dependent objects
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// Create Effect object
|
||||
if( FAILED( D3DXCreateEffect( m_pd3dDevice, g_szEffect, g_cchEffect, &m_pEffect, NULL ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Restore device-memory objects and state after a device is created or
|
||||
// resized.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
// InitDeviceObjects for file objects (build textures and vertex buffers)
|
||||
m_pShinyTeapot->RestoreDeviceObjects( m_pd3dDevice );
|
||||
m_pSkyBox->RestoreDeviceObjects( m_pd3dDevice );
|
||||
m_pAirplane->RestoreDeviceObjects( m_pd3dDevice );
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
m_pEffect->OnResetDevice();
|
||||
|
||||
|
||||
|
||||
// Create RenderToEnvMap object
|
||||
if( FAILED( D3DXCreateRenderToEnvMap( m_pd3dDevice, CUBEMAP_RESOLUTION,
|
||||
m_d3dsdBackBuffer.Format, TRUE, D3DFMT_D16, &m_pRenderToEnvMap ) ) )
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
// Create the cubemap, with a format that matches the backbuffer
|
||||
if( m_d3dCaps.TextureCaps & D3DPTEXTURECAPS_CUBEMAP )
|
||||
{
|
||||
if( FAILED( D3DXCreateCubeTexture( m_pd3dDevice, CUBEMAP_RESOLUTION, 1,
|
||||
D3DUSAGE_RENDERTARGET, m_d3dsdBackBuffer.Format, D3DPOOL_DEFAULT, &m_pCubeMap ) ) )
|
||||
{
|
||||
if( FAILED( D3DXCreateCubeTexture( m_pd3dDevice, CUBEMAP_RESOLUTION, 1,
|
||||
0, m_d3dsdBackBuffer.Format, D3DPOOL_DEFAULT, &m_pCubeMap ) ) )
|
||||
{
|
||||
m_pCubeMap = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Create the spheremap, with a format that matches the backbuffer
|
||||
if( !m_pCubeMap )
|
||||
{
|
||||
if( FAILED( D3DXCreateTexture( m_pd3dDevice, CUBEMAP_RESOLUTION, CUBEMAP_RESOLUTION,
|
||||
1, D3DUSAGE_RENDERTARGET, m_d3dsdBackBuffer.Format, D3DPOOL_DEFAULT, &m_pSphereMap ) ) )
|
||||
{
|
||||
if( FAILED( D3DXCreateTexture( m_pd3dDevice, CUBEMAP_RESOLUTION, CUBEMAP_RESOLUTION,
|
||||
1, 0, m_d3dsdBackBuffer.Format, D3DPOOL_DEFAULT, &m_pSphereMap ) ) )
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Initialize effect
|
||||
m_pEffect->SetTexture( "texCubeMap", m_pCubeMap );
|
||||
m_pEffect->SetTexture( "texSphereMap", m_pSphereMap );
|
||||
|
||||
if( m_pCubeMap )
|
||||
{
|
||||
m_pEffect->SetTechnique( "Cube" );
|
||||
SetWindowText( m_hWnd, _T("CubeMap: Environment cube-mapping") );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pEffect->SetTechnique( "Sphere" );
|
||||
SetWindowText( m_hWnd, _T("CubeMap: Environment cube-mapping (using dynamic spheremap)") );
|
||||
}
|
||||
|
||||
|
||||
// Set the transform matrices
|
||||
FLOAT fAspect = (FLOAT) m_d3dsdBackBuffer.Width / (FLOAT) m_d3dsdBackBuffer.Height;
|
||||
D3DXMatrixPerspectiveFovLH( &m_matProject, D3DX_PI * 0.4f, fAspect, 0.5f, 100.0f );
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc: Called when the device-dependent objects are about to be lost.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pShinyTeapot->InvalidateDeviceObjects();
|
||||
m_pSkyBox->InvalidateDeviceObjects();
|
||||
m_pAirplane->InvalidateDeviceObjects();
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
|
||||
if(m_pEffect)
|
||||
m_pEffect->OnLostDevice();
|
||||
|
||||
SAFE_RELEASE( m_pRenderToEnvMap );
|
||||
SAFE_RELEASE( m_pCubeMap );
|
||||
SAFE_RELEASE( m_pSphereMap );
|
||||
|
||||
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_pShinyTeapot->Destroy();
|
||||
m_pSkyBox->Destroy();
|
||||
m_pAirplane->Destroy();
|
||||
|
||||
SAFE_RELEASE( m_pEffect );
|
||||
|
||||
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_pShinyTeapot );
|
||||
SAFE_DELETE( m_pSkyBox );
|
||||
SAFE_DELETE( m_pAirplane );
|
||||
|
||||
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;
|
||||
|
||||
if( !(pCaps->TextureCaps & D3DPTEXTURECAPS_CUBEMAP) &&
|
||||
!(dwBehavior & D3DCREATE_SOFTWARE_VERTEXPROCESSING) &&
|
||||
!(pCaps->VertexShaderVersion >= D3DVS_VERSION(1, 0)) )
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: MsgProc()
|
||||
// Desc: Message proc function to handle key and menu input
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CMyD3DApplication::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
{
|
||||
// Capture mouse when clicked
|
||||
if( WM_LBUTTONDOWN == uMsg )
|
||||
{
|
||||
D3DXMATRIX matCursor;
|
||||
D3DXQUATERNION qCursor = D3DUtil_GetRotationFromCursor( m_hWnd );
|
||||
D3DXMatrixRotationQuaternion( &matCursor, &qCursor );
|
||||
D3DXMatrixTranspose( &matCursor, &matCursor );
|
||||
D3DXMatrixMultiply( &m_matTrackBall, &m_matTrackBall, &matCursor );
|
||||
|
||||
SetCapture( m_hWnd );
|
||||
m_bCapture = TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( WM_LBUTTONUP == uMsg )
|
||||
{
|
||||
D3DXMATRIX matCursor;
|
||||
D3DXQUATERNION qCursor = D3DUtil_GetRotationFromCursor( m_hWnd );
|
||||
D3DXMatrixRotationQuaternion( &matCursor, &qCursor );
|
||||
D3DXMatrixMultiply( &m_matTrackBall, &m_matTrackBall, &matCursor );
|
||||
|
||||
ReleaseCapture();
|
||||
m_bCapture = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Pass remaining messages to default handler
|
||||
return CD3DApplication::MsgProc( hWnd, uMsg, wParam, lParam );
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
# Microsoft Developer Studio Project File - Name="CubeMap" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=CubeMap - 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 "cubemap.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 "cubemap.mak" CFG="CubeMap - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "CubeMap - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "CubeMap - 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)" == "CubeMap - 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 winmm.lib d3dxof.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
|
||||
|
||||
!ELSEIF "$(CFG)" == "CubeMap - 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 winmm.lib d3dxof.lib dxguid.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 /stack:0x200000,0x200000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "CubeMap - Win32 Release"
|
||||
# Name "CubeMap - 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=.\cubemap.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: "CubeMap"=.\cubemap.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 cubemap.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=CubeMap - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to CubeMap - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "CubeMap - Win32 Release" && "$(CFG)" != "CubeMap - 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 "cubemap.mak" CFG="CubeMap - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "CubeMap - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "CubeMap - 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)" == "CubeMap - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\cubemap.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cubemap.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)\cubemap.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)\cubemap.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)\cubemap.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8.lib d3d8.lib winmm.lib d3dxof.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\cubemap.pdb" /machine:I386 /out:"$(OUTDIR)\cubemap.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\cubemap.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\cubemap.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "CubeMap - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\cubemap.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\cubemap.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)\cubemap.exe"
|
||||
-@erase "$(OUTDIR)\cubemap.ilk"
|
||||
-@erase "$(OUTDIR)\cubemap.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)\cubemap.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)\cubemap.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8dt.lib d3d8.lib winmm.lib d3dxof.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\cubemap.pdb" /debug /machine:I386 /out:"$(OUTDIR)\cubemap.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\cubemap.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\cubemap.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("cubemap.dep")
|
||||
!INCLUDE "cubemap.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "cubemap.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "CubeMap - Win32 Release" || "$(CFG)" == "CubeMap - 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=.\cubemap.cpp
|
||||
|
||||
"$(INTDIR)\cubemap.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,62 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CubeMap Direct3D Sample
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
The CubeMap sample demonstrates an enviroment-mapping technique called
|
||||
cube-mapping. Environment-mapping is a technique in which the environment
|
||||
surrounding a 3D object (such as the lights, etc.) are put into a texture
|
||||
map, so that the object can have complex lighting effects without expensive
|
||||
lighting calculations.
|
||||
|
||||
Note that not all cards support all features for all the various environment
|
||||
mapping techniques (such as cubemapping and projected textures). For more
|
||||
information on environment mapping, cubemapping, and projected textures,
|
||||
refer to the DirectX SDK documentation.
|
||||
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\D3D\EnvMapping\CubeMap
|
||||
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
|
||||
<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
|
||||
=================
|
||||
Cube-mapping is a technique which employs a 6-sided texture. Think of the
|
||||
being inside a wall-papered room, and having the wallpaper shrink-wrapped
|
||||
around an object. Cube-mapping is superior to sphere-mapping because the
|
||||
latter is inherently view-dependant (spheremaps are constructed for one
|
||||
particular viewpoint in mind). Cubemaps also have no geometry
|
||||
distortions, so they can be generated on the fly using SetRenderTarget()
|
||||
for each of the 6 cubemap's faces.
|
||||
|
||||
Cube-mapping works with Direct3D texture coordinate generation. By setting
|
||||
D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR, Direct3D will generate cubemap
|
||||
texture coordinates from the reflection vector for a vertex, thereby making
|
||||
this technique easy for environment-mapping effects where the environment
|
||||
is reflected in the object.
|
||||
|
||||
On hardware which does not support cube-maps, this sample will dynamically
|
||||
create a spheremap each frame, and use that instead. Creation of the
|
||||
spheremap is done using the ID3DXRenderToEnvMap interface.
|
||||
|
||||
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
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,559 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: FishEye.cpp
|
||||
//
|
||||
// Desc: Example code showing how to do a fisheye lens effect with cubemapping.
|
||||
// The scene is rendering into a cubemap each frame, and then a
|
||||
// funky-shaped object is rendered using the cubemap and an environment
|
||||
// map.
|
||||
//
|
||||
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <D3DX8.h>
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFile.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct ENVMAPPEDVERTEX
|
||||
// Desc: D3D vertex type for environment-mapped objects
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ENVMAPPEDVERTEX
|
||||
{
|
||||
D3DXVECTOR3 p; // Position
|
||||
D3DXVECTOR3 n; // Normal
|
||||
};
|
||||
|
||||
#define D3DFVF_ENVMAPVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL)
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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
|
||||
{
|
||||
// Font for drawing text
|
||||
CD3DFont* m_pFont;
|
||||
|
||||
CD3DMesh* m_pSkyBoxObject;
|
||||
LPDIRECT3DCUBETEXTURE8 m_pCubeMap;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pFishEyeLensVB;
|
||||
LPDIRECT3DINDEXBUFFER8 m_pFishEyeLensIB;
|
||||
DWORD m_dwNumFishEyeLensVertices;
|
||||
DWORD m_dwNumFishEyeLensFaces;
|
||||
|
||||
HRESULT RenderScene();
|
||||
HRESULT RenderSceneIntoCubeMap();
|
||||
HRESULT GenerateFishEyeLens( DWORD, DWORD, FLOAT );
|
||||
|
||||
protected:
|
||||
HRESULT OneTimeSceneInit();
|
||||
HRESULT InitDeviceObjects();
|
||||
HRESULT RestoreDeviceObjects();
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
HRESULT DeleteDeviceObjects();
|
||||
HRESULT Render();
|
||||
HRESULT FrameMove();
|
||||
HRESULT FinalCleanup();
|
||||
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
|
||||
|
||||
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("FishEye: Environment mapping");
|
||||
m_bUseDepthBuffer = TRUE;
|
||||
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
m_pSkyBoxObject = new CD3DMesh();
|
||||
m_pCubeMap = NULL;
|
||||
m_pFishEyeLensVB = NULL;
|
||||
m_pFishEyeLensIB = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: OneTimeSceneInit()
|
||||
// Desc: Called during initial app startup, this function performs all the
|
||||
// permanent initialization.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::OneTimeSceneInit()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FrameMove()
|
||||
// Desc: Called once per frame, the call is the entry point for animating
|
||||
// the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FrameMove()
|
||||
{
|
||||
// When the window has focus, let the mouse adjust the scene
|
||||
if( GetFocus() )
|
||||
{
|
||||
D3DXQUATERNION quat = D3DUtil_GetRotationFromCursor( m_hWnd );
|
||||
D3DXMATRIX matTrackBall;
|
||||
D3DXMatrixRotationQuaternion( &matTrackBall, &quat );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matTrackBall );
|
||||
|
||||
// Render the scene into the surfaces of the cubemap
|
||||
if( FAILED( RenderSceneIntoCubeMap() ) )
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RenderScene()
|
||||
// Desc: Renders all visual elements in the scene. This is called by the main
|
||||
// Render() function, and also by the RenderIntoCubeMap() function.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RenderScene()
|
||||
{
|
||||
// Render the skybox
|
||||
{
|
||||
// Save current state
|
||||
D3DXMATRIX matViewSave, matProjSave;
|
||||
m_pd3dDevice->GetTransform( D3DTS_VIEW, &matViewSave );
|
||||
m_pd3dDevice->GetTransform( D3DTS_PROJECTION, &matProjSave );
|
||||
|
||||
// Disable zbuffer, center view matrix, and set FOV to 90 degrees
|
||||
D3DXMATRIX matView = matViewSave;
|
||||
D3DXMATRIX matProj = matViewSave;
|
||||
matView._41 = matView._42 = matView._43 = 0.0f;
|
||||
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/2, 1.0f, 0.5f, 10000.0f );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
|
||||
|
||||
// Render the skybox
|
||||
m_pSkyBoxObject->Render( m_pd3dDevice );
|
||||
|
||||
// Restore the render states
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matViewSave );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProjSave );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
}
|
||||
|
||||
// Render any other elements of the scene here. In this sample, only a
|
||||
// skybox is render, but a much more interesting scene could be rendered
|
||||
// instead.
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RenderSceneIntoCubeMap()
|
||||
// Desc: Renders the scene to each of the 6 faces of the cube map
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RenderSceneIntoCubeMap()
|
||||
{
|
||||
// Save transformation matrices of the device
|
||||
D3DXMATRIX matProjSave, matViewSave;
|
||||
m_pd3dDevice->GetTransform( D3DTS_VIEW, &matViewSave );
|
||||
m_pd3dDevice->GetTransform( D3DTS_PROJECTION, &matProjSave );
|
||||
|
||||
// Set the projection matrix for a field of view of 90 degrees
|
||||
D3DXMATRIX matProj;
|
||||
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/2, 1.0f, 0.5f, 100.0f );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
||||
|
||||
// Get the current view matrix, to concat it with the cubemap view vectors
|
||||
D3DXMATRIX matViewDir;
|
||||
m_pd3dDevice->GetTransform( D3DTS_VIEW, &matViewDir );
|
||||
matViewDir._41 = 0.0f; matViewDir._42 = 0.0f; matViewDir._43 = 0.0f;
|
||||
|
||||
// Store the current backbuffer and zbuffer
|
||||
LPDIRECT3DSURFACE8 pBackBuffer, pZBuffer;
|
||||
m_pd3dDevice->GetRenderTarget( &pBackBuffer );
|
||||
m_pd3dDevice->GetDepthStencilSurface( &pZBuffer );
|
||||
|
||||
// Render to the six faces of the cube map
|
||||
for( DWORD i=0; i<6; i++ )
|
||||
{
|
||||
// Set the view transform for this cubemap surface
|
||||
D3DXMATRIX matView;
|
||||
matView = D3DUtil_GetCubeMapViewMatrix( (D3DCUBEMAP_FACES)i );
|
||||
D3DXMatrixMultiply( &matView, &matViewDir, &matView );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
|
||||
// Set the rendertarget to the i'th cubemap surface
|
||||
LPDIRECT3DSURFACE8 pCubeMapFace;
|
||||
m_pCubeMap->GetCubeMapSurface( (D3DCUBEMAP_FACES)i, 0, &pCubeMapFace );
|
||||
m_pd3dDevice->SetRenderTarget( pCubeMapFace, NULL );
|
||||
pCubeMapFace->Release();
|
||||
|
||||
// Render the scene
|
||||
m_pd3dDevice->BeginScene();
|
||||
RenderScene();
|
||||
m_pd3dDevice->EndScene();
|
||||
}
|
||||
|
||||
// Change the rendertarget back to the main backbuffer
|
||||
m_pd3dDevice->SetRenderTarget( pBackBuffer, pZBuffer );
|
||||
pBackBuffer->Release();
|
||||
pZBuffer->Release();
|
||||
|
||||
// Restore the original transformation matrices
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matViewSave );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProjSave );
|
||||
|
||||
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;
|
||||
|
||||
// Set the states we want: identity matrix, no z-buffer, and cubemap texture
|
||||
// coordinate generation
|
||||
D3DXMATRIX matWorld;
|
||||
D3DXMatrixIdentity( &matWorld );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3 );
|
||||
|
||||
// Render the fisheye lens object with the environment-mapped body.
|
||||
m_pd3dDevice->SetTexture( 0, m_pCubeMap );
|
||||
m_pd3dDevice->SetVertexShader( D3DFVF_ENVMAPVERTEX );
|
||||
m_pd3dDevice->SetStreamSource( 0, m_pFishEyeLensVB, sizeof(ENVMAPPEDVERTEX) );
|
||||
m_pd3dDevice->SetIndices( m_pFishEyeLensIB, 0 );
|
||||
m_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,
|
||||
0, m_dwNumFishEyeLensVertices,
|
||||
0, m_dwNumFishEyeLensFaces );
|
||||
|
||||
// Restore the render states
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
|
||||
// Output statistics
|
||||
m_pFont->DrawText( 2, 0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
|
||||
m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );
|
||||
|
||||
// End the scene.
|
||||
m_pd3dDevice->EndScene();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
// Initialize the font's internal textures
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// Load the file objects
|
||||
if( FAILED( hr = m_pSkyBoxObject->Create( m_pd3dDevice, _T("Lobby_skybox.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
|
||||
// Create the fisheye lens
|
||||
if( FAILED( hr = GenerateFishEyeLens( 20, 20, 1.0f ) ) )
|
||||
return hr;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Restore device-memory objects and state after a device is created or
|
||||
// resized.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
|
||||
// Restore device objects for the skybox
|
||||
m_pSkyBoxObject->RestoreDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// Create the cubemap
|
||||
if( FAILED( hr = m_pd3dDevice->CreateCubeTexture( 256, 1, D3DUSAGE_RENDERTARGET,
|
||||
m_d3dsdBackBuffer.Format,
|
||||
D3DPOOL_DEFAULT, &m_pCubeMap ) ) )
|
||||
return hr;
|
||||
|
||||
// Set default render states
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_MIRROR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_MIRROR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTEXF_NONE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xffffffff );
|
||||
|
||||
// Set the transforms
|
||||
D3DXVECTOR3 m_vEyePt = D3DXVECTOR3( 0.0f, 0.0f,-5.0f );
|
||||
D3DXVECTOR3 m_vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 m_vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
|
||||
D3DXMATRIX matWorld, matView, matProj;
|
||||
D3DXMatrixIdentity( &matWorld );
|
||||
D3DXMatrixLookAtLH( &matView, &m_vEyePt, &m_vLookatPt, &m_vUpVec );
|
||||
D3DXMatrixOrthoLH( &matProj, 2.0f, 2.0f, 0.5f, 100.0f );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc: Called when the device-dependent objects are about to be lost.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
m_pSkyBoxObject->InvalidateDeviceObjects();
|
||||
|
||||
SAFE_RELEASE( m_pCubeMap );
|
||||
|
||||
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_pSkyBoxObject->Destroy();
|
||||
|
||||
SAFE_RELEASE( m_pFishEyeLensVB );
|
||||
SAFE_RELEASE( m_pFishEyeLensIB );
|
||||
|
||||
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_pSkyBoxObject );
|
||||
|
||||
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
|
||||
|
||||
// Check for cubemapping devices
|
||||
if( 0 == ( pCaps->TextureCaps & D3DPTEXTURECAPS_CUBEMAP ) )
|
||||
return E_FAIL;
|
||||
|
||||
// Check that we can create a cube texture that we can render into
|
||||
if( FAILED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal,
|
||||
pCaps->DeviceType, Format, D3DUSAGE_RENDERTARGET,
|
||||
D3DRTYPE_CUBETEXTURE, Format ) ) )
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: GenerateFishEyeLens()
|
||||
// Desc: Makes vertex and index data for a fish eye lens
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::GenerateFishEyeLens( DWORD dwNumRings, DWORD dwNumSections,
|
||||
FLOAT fScale )
|
||||
{
|
||||
ENVMAPPEDVERTEX* pVertices;
|
||||
WORD* pIndices;
|
||||
DWORD dwNumTriangles = (dwNumRings+1) * dwNumSections * 2;
|
||||
DWORD dwNumVertices = (dwNumRings+1) * dwNumSections + 2;
|
||||
DWORD i, j, m;
|
||||
|
||||
// Generate space for the required triangles and vertices.
|
||||
if( FAILED( m_pd3dDevice->CreateVertexBuffer( dwNumVertices*sizeof(ENVMAPPEDVERTEX),
|
||||
D3DUSAGE_WRITEONLY, D3DFVF_ENVMAPVERTEX,
|
||||
D3DPOOL_MANAGED, &m_pFishEyeLensVB ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( m_pd3dDevice->CreateIndexBuffer( dwNumTriangles*3*sizeof(WORD),
|
||||
D3DUSAGE_WRITEONLY, D3DFMT_INDEX16,
|
||||
D3DPOOL_MANAGED, &m_pFishEyeLensIB ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
m_pFishEyeLensVB->Lock( 0, 0, (BYTE**)&pVertices, 0 );
|
||||
m_pFishEyeLensIB->Lock( 0, 0, (BYTE**)&pIndices, 0 );
|
||||
|
||||
// Generate vertices at the end points.
|
||||
pVertices->p = D3DXVECTOR3( 0.0f, 0.0f, fScale );
|
||||
pVertices->n = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
|
||||
pVertices++;
|
||||
|
||||
// Generate vertex points for rings
|
||||
FLOAT r = 0.0f;
|
||||
for( i = 0; i < (dwNumRings+1); i++ )
|
||||
{
|
||||
FLOAT phi = 0.0f;
|
||||
|
||||
for( j = 0; j < dwNumSections; j++ )
|
||||
{
|
||||
FLOAT x = r * sinf(phi);
|
||||
FLOAT y = r * cosf(phi);
|
||||
FLOAT z = 0.5f - 0.5f * ( x*x + y*y );
|
||||
|
||||
FLOAT nx = -x;
|
||||
FLOAT ny = -y;
|
||||
FLOAT nz = 1.0f;
|
||||
|
||||
pVertices->p = D3DXVECTOR3( x, y, z );
|
||||
pVertices->n = D3DXVECTOR3( nx, ny, nz );
|
||||
pVertices++;
|
||||
|
||||
phi += (FLOAT)(2*D3DX_PI / dwNumSections);
|
||||
}
|
||||
|
||||
r += 1.5f/dwNumRings;
|
||||
}
|
||||
|
||||
// Generate triangles for the centerpiece
|
||||
for( i = 0; i < 2*dwNumSections; i++ )
|
||||
{
|
||||
*pIndices++ = (WORD)(0);
|
||||
*pIndices++ = (WORD)(i + 1);
|
||||
*pIndices++ = (WORD)(1 + ((i + 1) % dwNumSections));
|
||||
}
|
||||
|
||||
// Generate triangles for the rings
|
||||
m = 1; // 1st vertex begins at 1 to skip top point
|
||||
|
||||
for( i = 0; i < dwNumRings; i++ )
|
||||
{
|
||||
for( j = 0; j < dwNumSections; j++ )
|
||||
{
|
||||
*pIndices++ = (WORD)(m + j);
|
||||
*pIndices++ = (WORD)(m + dwNumSections + j);
|
||||
*pIndices++ = (WORD)(m + dwNumSections + ((j + 1) % dwNumSections));
|
||||
|
||||
*pIndices++ = (WORD)(m + j);
|
||||
*pIndices++ = (WORD)(m + dwNumSections + ((j + 1) % dwNumSections));
|
||||
*pIndices++ = (WORD)(m + ((j + 1) % dwNumSections));
|
||||
}
|
||||
m += dwNumSections;
|
||||
}
|
||||
|
||||
m_pFishEyeLensVB->Unlock();
|
||||
m_pFishEyeLensIB->Unlock();
|
||||
m_dwNumFishEyeLensVertices = dwNumVertices;
|
||||
m_dwNumFishEyeLensFaces = dwNumTriangles;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
# Microsoft Developer Studio Project File - Name="FishEye" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=FishEye - 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 "fisheye.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 "fisheye.mak" CFG="FishEye - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "FishEye - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "FishEye - 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)" == "FishEye - 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 dxguid.lib winmm.lib d3dxof.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)" == "FishEye - 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 dxguid.lib winmm.lib d3dxof.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 "FishEye - Win32 Release"
|
||||
# Name "FishEye - 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=.\fisheye.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: "FishEye"=.\fisheye.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 fisheye.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=FishEye - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to FishEye - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "FishEye - Win32 Release" && "$(CFG)" != "FishEye - 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 "fisheye.mak" CFG="FishEye - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "FishEye - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "FishEye - 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)" == "FishEye - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\fisheye.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\fisheye.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\fisheye.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)\fisheye.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)\fisheye.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8.lib d3d8.lib ddraw.lib dxguid.lib winmm.lib d3dxof.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\fisheye.pdb" /machine:I386 /out:"$(OUTDIR)\fisheye.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\fisheye.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\fisheye.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "FishEye - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\fisheye.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\fisheye.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\winmain.res"
|
||||
-@erase "$(OUTDIR)\fisheye.exe"
|
||||
-@erase "$(OUTDIR)\fisheye.ilk"
|
||||
-@erase "$(OUTDIR)\fisheye.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)\fisheye.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)\fisheye.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8dt.lib d3d8.lib ddraw.lib dxguid.lib winmm.lib d3dxof.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\fisheye.pdb" /debug /machine:I386 /out:"$(OUTDIR)\fisheye.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\fisheye.obj" \
|
||||
"$(INTDIR)\winmain.res"
|
||||
|
||||
"$(OUTDIR)\fisheye.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("fisheye.dep")
|
||||
!INCLUDE "fisheye.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "fisheye.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "FishEye - Win32 Release" || "$(CFG)" == "FishEye - 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=.\fisheye.cpp
|
||||
|
||||
"$(INTDIR)\fisheye.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FishEye Direct3D Sample
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
The FishEye sample shows a fish eye lens effect that can be achieved using
|
||||
cubemaps.
|
||||
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\D3D\EnvMapping\FishEye
|
||||
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 scene is actually rendered into the surfaces of a cubemap (rather than
|
||||
the back buffer). Then, the cubemap is used as an environment-map (see the
|
||||
CubeMap sample for more information about cube-mapping) to reflect the
|
||||
scene in some distorted geometry...in this case, some geometry approximating
|
||||
a fish eye lens.
|
||||
|
||||
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,38 @@
|
||||
//{{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_CUBEMAPPING 40010
|
||||
#define IDM_SPHEREMAPPING 40011
|
||||
#define IDM_PARABOLICMAPPING 40012
|
||||
|
||||
// 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 40013
|
||||
#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
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,56 @@
|
||||
F//-----------------------------------------------------------------------------
|
||||
// Name: SphereMap Direct3D Sample
|
||||
//
|
||||
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
The SphereMap sample demonstrates an enviroment-mapping technique called
|
||||
sphere-mapping. Environment-mapping is a technique in which the environment
|
||||
surrounding a 3D object (such as the lights, etc.) are put into a texture
|
||||
map, so that the object can have complex lighting effects without expensive
|
||||
lighting calculations.
|
||||
|
||||
Note that not all cards support all features for all the various environment
|
||||
mapping techniques (such as cubemapping and projected textures). For more
|
||||
information on environment mapping, cubemapping, and projected textures,
|
||||
refer to the DirectX SDK documentation.
|
||||
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\D3D\EnvMapping\SphereMap
|
||||
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
|
||||
<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
|
||||
=================
|
||||
Sphere-mapping uses a precomputed (at model time) texture map which contains
|
||||
the entire environment as reflected by a chrome sphere. The idea is to
|
||||
consider each vertex, compute it's normal, find where the normal matches up
|
||||
on the chrome sphere, and then assign that texture coordinate to the vertex.
|
||||
|
||||
The math involves computations for each vertex for every frame. This sample
|
||||
uses a vertex shader to perform these calculations. Basically, the vertex
|
||||
shader computes a camera-space reflection vector, given the camera position,
|
||||
vertex position, and vertex normal. Then, it computes the half-angle vector
|
||||
between the reflection vector, and the view direction. This vector can then
|
||||
be scaled and offset by 0.5 to index into the spheremap texture.
|
||||
|
||||
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,515 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: SphereMap.cpp
|
||||
//
|
||||
// Desc: Example code showing how to use sphere-mapping in D3D, using generated
|
||||
// texture coordinates.
|
||||
//
|
||||
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <tchar.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <D3DX8.h>
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFile.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: g_szEffect
|
||||
// Desc: String containing effect used to render shiny teapot.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const char g_szEffect[] =
|
||||
|
||||
"texture texSphereMap;\n"
|
||||
"matrix matWorld;\n"
|
||||
"matrix matViewProject;\n"
|
||||
"vector vecPosition;\n"
|
||||
|
||||
|
||||
"technique Sphere\n"
|
||||
"{\n"
|
||||
"pass P0\n"
|
||||
"{\n"
|
||||
|
||||
// Vertex state
|
||||
"VertexShader =\n"
|
||||
"decl\n"
|
||||
"{\n"
|
||||
"float v0[3];\n" // position
|
||||
"float v1[3];\n" // normal
|
||||
"}\n"
|
||||
"asm\n"
|
||||
"{\n"
|
||||
"vs.1.0\n"
|
||||
"def c64, 0.25f, 0.5f, 1.0f, -1.0f\n"
|
||||
|
||||
// r0: camera-space position
|
||||
// r1: camera-space normal
|
||||
// r2: camera-space vertex-eye vector
|
||||
// r3: camera-space reflection vector
|
||||
// r4: texture coordinates
|
||||
|
||||
// Transform position and normal into camera-space
|
||||
"m4x4 r0, v0, c0\n"
|
||||
"m3x3 r1, v1, c0\n"
|
||||
|
||||
// Compute normalized view vector
|
||||
"add r2, c8, -r0\n"
|
||||
"dp3 r3, r2, r2\n"
|
||||
"rsq r3, r3\n"
|
||||
"mul r2, r2, r3\n"
|
||||
|
||||
// Compute camera-space reflection vector
|
||||
"dp3 r3, r1, r2\n"
|
||||
"mul r1, r1, r3\n"
|
||||
"add r1, r1, r1\n"
|
||||
"add r3, r1, -r2\n"
|
||||
|
||||
// Compute sphere-map texture coords
|
||||
"mad r4.w, -r3.z, c64.y, c64.y\n"
|
||||
"rsq r4, r4\n"
|
||||
"mul r4, r3, r4\n"
|
||||
"mad r4, r4, c64.x, c64.y\n"
|
||||
|
||||
// Project position
|
||||
"m4x4 oPos, r0, c4\n"
|
||||
"mul oT0.xy, r4.xy, c64.zw\n"
|
||||
"mov oT0.zw, c64.z\n"
|
||||
"};\n"
|
||||
|
||||
"VertexShaderConstant4[0] = <matWorld>;\n"
|
||||
"VertexShaderConstant4[4] = <matViewProject>;\n"
|
||||
"VertexShaderConstant1[8] = <vecPosition>;\n"
|
||||
|
||||
// Pixel state
|
||||
"Texture[0] = <texSphereMap>;\n"
|
||||
"AddressU[0] = Wrap;\n"
|
||||
"AddressV[0] = Wrap;\n"
|
||||
"MinFilter[0] = Linear;\n"
|
||||
"MagFilter[0] = Linear;\n"
|
||||
"ColorOp[0] = SelectArg1;\n"
|
||||
"ColorArg1[0] = Texture;\n"
|
||||
"}\n"
|
||||
"}\n";
|
||||
|
||||
const UINT g_cchEffect = sizeof(g_szEffect) - 1;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct ENVMAPPEDVERTEX
|
||||
// Desc: D3D vertex type for environment-mapped objects
|
||||
//-----------------------------------------------------------------------------
|
||||
struct ENVMAPPEDVERTEX
|
||||
{
|
||||
D3DXVECTOR3 p; // Position
|
||||
D3DXVECTOR3 n; // Normal
|
||||
};
|
||||
|
||||
#define D3DFVF_ENVMAPVERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL )
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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
|
||||
{
|
||||
BOOL m_bCapture;
|
||||
|
||||
D3DXMATRIX m_matProject;
|
||||
D3DXMATRIX m_matView;
|
||||
D3DXMATRIX m_matWorld;
|
||||
D3DXMATRIX m_matTrackBall;
|
||||
|
||||
CD3DFont* m_pFont;
|
||||
CD3DMesh* m_pShinyTeapot;
|
||||
CD3DMesh* m_pSkyBox;
|
||||
|
||||
ID3DXEffect* m_pEffect;
|
||||
IDirect3DTexture8* m_pSphereMap;
|
||||
|
||||
protected:
|
||||
HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
|
||||
HRESULT OneTimeSceneInit();
|
||||
HRESULT InitDeviceObjects();
|
||||
HRESULT RestoreDeviceObjects();
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
HRESULT DeleteDeviceObjects();
|
||||
HRESULT Render();
|
||||
HRESULT FrameMove();
|
||||
HRESULT FinalCleanup();
|
||||
|
||||
public:
|
||||
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
CMyD3DApplication();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: WinMain()
|
||||
// Desc: Entry point to the program. Initializes everything, and goes into a
|
||||
// message-processing loop. Idle time is used to render the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
|
||||
{
|
||||
CMyD3DApplication d3dApp;
|
||||
|
||||
if( FAILED( d3dApp.Create( hInst ) ) )
|
||||
return 0;
|
||||
|
||||
return d3dApp.Run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CMyD3DApplication()
|
||||
// Desc: Application constructor. Sets attributes for the app.
|
||||
//-----------------------------------------------------------------------------
|
||||
CMyD3DApplication::CMyD3DApplication()
|
||||
{
|
||||
m_strWindowTitle = _T("SphereMap: Environment Mapping Technique");
|
||||
m_bUseDepthBuffer = TRUE;
|
||||
m_bCapture = FALSE;
|
||||
|
||||
m_pFont = NULL;
|
||||
m_pShinyTeapot = NULL;
|
||||
m_pSkyBox = NULL;
|
||||
|
||||
m_pEffect = NULL;
|
||||
m_pSphereMap = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: OneTimeSceneInit()
|
||||
// Desc: Called during initial app startup, this function performs all the
|
||||
// permanent initialization.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::OneTimeSceneInit()
|
||||
{
|
||||
D3DXMatrixIdentity( &m_matWorld );
|
||||
|
||||
m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
|
||||
m_pShinyTeapot = new CD3DMesh();
|
||||
m_pSkyBox = new CD3DMesh();
|
||||
|
||||
if( !m_pFont || !m_pShinyTeapot || !m_pSkyBox )
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
D3DXMatrixIdentity( &m_matTrackBall );
|
||||
D3DXMatrixTranslation( &m_matView, 0.0f, 0.0f, 3.0f );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FrameMove()
|
||||
// Desc: Called once per frame, the call is the entry point for animating
|
||||
// the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FrameMove()
|
||||
{
|
||||
// When the window has focus, let the mouse adjust the camera view
|
||||
if( m_bCapture )
|
||||
{
|
||||
D3DXMATRIX matCursor;
|
||||
D3DXQUATERNION qCursor = D3DUtil_GetRotationFromCursor( m_hWnd );
|
||||
D3DXMatrixRotationQuaternion( &matCursor, &qCursor );
|
||||
D3DXMatrixMultiply( &m_matView, &m_matTrackBall, &matCursor );
|
||||
|
||||
D3DXMATRIX matTrans;
|
||||
D3DXMatrixTranslation( &matTrans, 0.0f, 0.0f, 3.0f );
|
||||
D3DXMatrixMultiply( &m_matView, &m_matView, &matTrans );
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DXMATRIX matRotation;
|
||||
D3DXMatrixRotationY( &matRotation, -m_fElapsedTime );
|
||||
D3DXMatrixMultiply( &m_matWorld, &m_matWorld, &matRotation );
|
||||
}
|
||||
|
||||
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( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
|
||||
{
|
||||
// Render the Skybox
|
||||
{
|
||||
D3DXMATRIX matWorld;
|
||||
D3DXMatrixScaling( &matWorld, 10.0f, 10.0f, 10.0f );
|
||||
|
||||
D3DXMATRIX matView(m_matView);
|
||||
matView._41 = matView._42 = matView._43 = 0.0f;
|
||||
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &m_matProject );
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_MIRROR );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_MIRROR );
|
||||
|
||||
// Always pass Z-test, so we can avoid clearing color and depth buffers
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_ALWAYS );
|
||||
m_pSkyBox->Render( m_pd3dDevice );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
|
||||
}
|
||||
|
||||
|
||||
// Render the environment-mapped ShinyTeapot
|
||||
{
|
||||
// Set transform state
|
||||
D3DXMATRIX matViewProject;
|
||||
D3DXMatrixMultiply( &matViewProject, &m_matView, &m_matProject );
|
||||
|
||||
D3DXMATRIX matViewInv;
|
||||
D3DXMatrixInverse( &matViewInv, NULL, &m_matView );
|
||||
D3DXVECTOR4 vecPosition( matViewInv._41, matViewInv._42, matViewInv._43, 1.0f );
|
||||
|
||||
|
||||
m_pEffect->SetMatrix( "matWorld", &m_matWorld );
|
||||
m_pEffect->SetMatrix( "matViewProject", &matViewProject );
|
||||
m_pEffect->SetVector( "vecPosition", &vecPosition );
|
||||
|
||||
|
||||
// Draw teapot
|
||||
LPDIRECT3DVERTEXBUFFER8 pVB;
|
||||
LPDIRECT3DINDEXBUFFER8 pIB;
|
||||
|
||||
m_pShinyTeapot->m_pLocalMesh->GetVertexBuffer( &pVB );
|
||||
m_pShinyTeapot->m_pLocalMesh->GetIndexBuffer( &pIB );
|
||||
|
||||
m_pd3dDevice->SetStreamSource( 0, pVB, sizeof(ENVMAPPEDVERTEX) );
|
||||
m_pd3dDevice->SetIndices( pIB, 0 );
|
||||
|
||||
UINT uPasses;
|
||||
m_pEffect->Begin( &uPasses, 0 );
|
||||
|
||||
for( UINT iPass = 0; iPass < uPasses; iPass++ )
|
||||
{
|
||||
m_pEffect->Pass( iPass );
|
||||
|
||||
m_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,
|
||||
0, m_pShinyTeapot->m_pLocalMesh->GetNumVertices(),
|
||||
0, m_pShinyTeapot->m_pLocalMesh->GetNumFaces() );
|
||||
|
||||
}
|
||||
|
||||
m_pEffect->End();
|
||||
|
||||
SAFE_RELEASE( pVB );
|
||||
SAFE_RELEASE( pIB );
|
||||
}
|
||||
|
||||
|
||||
// Output statistics
|
||||
m_pFont->DrawText( 2, 0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
|
||||
m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );
|
||||
|
||||
|
||||
// End the scene.
|
||||
m_pd3dDevice->EndScene();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitDeviceObjects()
|
||||
// Desc: Initialize scene objects.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
// Load the file objects
|
||||
if( FAILED( m_pShinyTeapot->Create( m_pd3dDevice, _T("teapot.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
if( FAILED( m_pSkyBox->Create( m_pd3dDevice, _T("lobby_skybox.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
if( FAILED( D3DUtil_CreateTexture( m_pd3dDevice, _T("spheremap.bmp"), &m_pSphereMap ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
|
||||
// Set mesh properties
|
||||
m_pShinyTeapot->SetFVF( m_pd3dDevice, D3DFVF_ENVMAPVERTEX );
|
||||
|
||||
// Restore the device-dependent objects
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// Create Effect object
|
||||
if( FAILED( D3DXCreateEffect( m_pd3dDevice, g_szEffect, g_cchEffect, &m_pEffect, NULL ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreDeviceObjects()
|
||||
// Desc: Restore device-memory objects and state after a device is created or
|
||||
// resized.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
// InitDeviceObjects for file objects (build textures and vertex buffers)
|
||||
m_pShinyTeapot->RestoreDeviceObjects( m_pd3dDevice );
|
||||
m_pSkyBox->RestoreDeviceObjects( m_pd3dDevice );
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
m_pEffect->OnResetDevice();
|
||||
m_pEffect->SetTexture( "texSphereMap", m_pSphereMap );
|
||||
|
||||
// Set the transform matrices
|
||||
FLOAT fAspect = (FLOAT) m_d3dsdBackBuffer.Width / (FLOAT) m_d3dsdBackBuffer.Height;
|
||||
D3DXMatrixPerspectiveFovLH( &m_matProject, D3DX_PI * 0.4f, fAspect, 0.5f, 100.0f );
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InvalidateDeviceObjects()
|
||||
// Desc: Called when the device-dependent objects are about to be lost.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pShinyTeapot->InvalidateDeviceObjects();
|
||||
m_pSkyBox->InvalidateDeviceObjects();
|
||||
m_pFont->InvalidateDeviceObjects();
|
||||
|
||||
if(m_pEffect)
|
||||
m_pEffect->OnLostDevice();
|
||||
|
||||
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_pShinyTeapot->Destroy();
|
||||
m_pSkyBox->Destroy();
|
||||
|
||||
SAFE_RELEASE( m_pSphereMap );
|
||||
SAFE_RELEASE( m_pEffect );
|
||||
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_pShinyTeapot );
|
||||
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_SOFTWARE_VERTEXPROCESSING) &&
|
||||
!(pCaps->VertexShaderVersion >= D3DVS_VERSION(1, 0)) )
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: MsgProc()
|
||||
// Desc: Message proc function to handle key and menu input
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CMyD3DApplication::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
{
|
||||
// Capture mouse when clicked
|
||||
if( WM_LBUTTONDOWN == uMsg )
|
||||
{
|
||||
D3DXMATRIX matCursor;
|
||||
D3DXQUATERNION qCursor = D3DUtil_GetRotationFromCursor( m_hWnd );
|
||||
D3DXMatrixRotationQuaternion( &matCursor, &qCursor );
|
||||
D3DXMatrixTranspose( &matCursor, &matCursor );
|
||||
D3DXMatrixMultiply( &m_matTrackBall, &m_matTrackBall, &matCursor );
|
||||
|
||||
SetCapture( m_hWnd );
|
||||
m_bCapture = TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( WM_LBUTTONUP == uMsg )
|
||||
{
|
||||
D3DXMATRIX matCursor;
|
||||
D3DXQUATERNION qCursor = D3DUtil_GetRotationFromCursor( m_hWnd );
|
||||
D3DXMatrixRotationQuaternion( &matCursor, &qCursor );
|
||||
D3DXMatrixMultiply( &m_matTrackBall, &m_matTrackBall, &matCursor );
|
||||
|
||||
ReleaseCapture();
|
||||
m_bCapture = FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Pass remaining messages to default handler
|
||||
return CD3DApplication::MsgProc( hWnd, uMsg, wParam, lParam );
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
# Microsoft Developer Studio Project File - Name="SphereMap" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=SphereMap - 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 "spheremap.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 "spheremap.mak" CFG="SphereMap - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "SphereMap - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "SphereMap - 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)" == "SphereMap - 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 uuid.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
|
||||
|
||||
!ELSEIF "$(CFG)" == "SphereMap - 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 uuid.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /stack:0x200000,0x200000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "SphereMap - Win32 Release"
|
||||
# Name "SphereMap - Win32 Debug"
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WinMain.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dapp.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\include\d3dapp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dfile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\include\d3dfile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dfont.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\include\d3dfont.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\d3dutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\include\d3dutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\src\dxutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\common\include\dxutil.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\readme.txt
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\spheremap.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: "SphereMap"=.\spheremap.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 spheremap.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=SphereMap - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to SphereMap - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "SphereMap - Win32 Release" && "$(CFG)" != "SphereMap - 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 "spheremap.mak" CFG="SphereMap - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "SphereMap - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "SphereMap - 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)" == "SphereMap - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\spheremap.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\spheremap.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\WinMain.res"
|
||||
-@erase "$(OUTDIR)\spheremap.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)\spheremap.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)\spheremap.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 uuid.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\spheremap.pdb" /machine:I386 /out:"$(OUTDIR)\spheremap.exe" /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\spheremap.obj" \
|
||||
"$(INTDIR)\WinMain.res"
|
||||
|
||||
"$(OUTDIR)\spheremap.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "SphereMap - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\spheremap.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\spheremap.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(INTDIR)\WinMain.res"
|
||||
-@erase "$(OUTDIR)\spheremap.exe"
|
||||
-@erase "$(OUTDIR)\spheremap.ilk"
|
||||
-@erase "$(OUTDIR)\spheremap.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)\spheremap.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)\spheremap.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 uuid.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\spheremap.pdb" /debug /machine:I386 /out:"$(OUTDIR)\spheremap.exe" /pdbtype:sept /stack:0x200000,0x200000
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\spheremap.obj" \
|
||||
"$(INTDIR)\WinMain.res"
|
||||
|
||||
"$(OUTDIR)\spheremap.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("spheremap.dep")
|
||||
!INCLUDE "spheremap.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "spheremap.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "SphereMap - Win32 Release" || "$(CFG)" == "SphereMap - 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=.\spheremap.cpp
|
||||
|
||||
"$(INTDIR)\spheremap.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!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
|
||||
|
||||
Reference in New Issue
Block a user