本文整理汇总了C++中CDXUTSDKMesh::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ CDXUTSDKMesh::Create方法的具体用法?C++ CDXUTSDKMesh::Create怎么用?C++ CDXUTSDKMesh::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDXUTSDKMesh
的用法示例。
在下文中一共展示了CDXUTSDKMesh::Create方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice(ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* /*pBackBufferSurfaceDesc*/,
void* /*pUserContext*/)
{
HRESULT hr = S_OK;
V_RETURN(g_MeshPowerPlant.Create(pd3dDevice, L"powerplant\\powerplant.sdkmesh"));
V_RETURN(g_MeshTestScene.Create(pd3dDevice, L"ShadowColumns\\testscene.sdkmesh"));
g_pSelectedMesh = &g_MeshPowerPlant;
return CreateD3DComponents(pd3dDevice);
}
示例2:
//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependent on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
UNREFERENCED_PARAMETER(pBackBufferSurfaceDesc);
UNREFERENCED_PARAMETER(pUserContext);
HRESULT hr = S_OK;
V_RETURN( g_MeshPowerPlant.Create( pd3dDevice, L"powerplant\\powerplant.sdkmesh" ) );
V_RETURN( g_TeapotMesh.Create( pd3dDevice, L"teapot\\teapot.sdkmesh" ) );
return CreateD3DComponents( pd3dDevice );
}
示例3: LoadMesh
//--------------------------------------------------------------------------------------
// Helper to load a VB and IB from a mesh
//--------------------------------------------------------------------------------------
HRESULT LoadMesh( ID3D10Device* pd3dDevice )
{
HRESULT hr = S_OK;
struct OLD_VERT
{
D3DXVECTOR3 Pos;
D3DXVECTOR3 Norm;
D3DXVECTOR2 Tex;
};
V_RETURN( g_Mesh.Create( pd3dDevice, L"rook.sdkmesh", true ) );
// Load the Texture
WCHAR strPath[MAX_PATH] = {0};
DXUTFindDXSDKMediaFileCch( strPath, sizeof( strPath ) / sizeof( WCHAR ), L"rook_diff.dds" );
hr = D3DX10CreateShaderResourceViewFromFile( pd3dDevice, strPath, NULL, NULL, &g_pMeshTexRV, NULL );
return hr;
}
示例4: CDXUTTextHelper
//--------------------------------------------------------------------------------------
// Create any D3D9 resources that won't live through a device reset (D3DPOOL_DEFAULT)
// or that are tied to the back buffer size
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D9ResetDevice( IDirect3DDevice9* pd3dDevice,
const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext )
{
HRESULT hr;
V_RETURN( g_DialogResourceManager.OnD3D9ResetDevice() );
V_RETURN( g_SettingsDlg.OnD3D9ResetDevice() );
if( g_pFont9 ) V_RETURN( g_pFont9->OnResetDevice() );
if( g_pEffect9 ) V_RETURN( g_pEffect9->OnResetDevice() );
V_RETURN( D3DXCreateSprite( pd3dDevice, &g_pSprite9 ) );
g_pTxtHelper = new CDXUTTextHelper( g_pFont9, g_pSprite9, NULL, NULL, 15 );
// Setup the camera's projection parameters
float fAspectRatio = pBackBufferSurfaceDesc->Width / ( FLOAT )pBackBufferSurfaceDesc->Height;
g_Camera.SetProjParams( D3DX_PI / 4, fAspectRatio, 0.1f, 1000.0f );
g_Camera.SetWindow( pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height );
g_HUD.SetLocation( pBackBufferSurfaceDesc->Width - 170, 0 );
g_HUD.SetSize( 170, 170 );
g_SampleUI.SetLocation( pBackBufferSurfaceDesc->Width - 170, pBackBufferSurfaceDesc->Height - 350 );
g_SampleUI.SetSize( 170, 300 );
// load the mesh
V_RETURN( g_Mesh.Create( pd3dDevice, L"misc\\ball.sdkmesh" ) );
// Load the texture
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"misc\\seafloor.dds" ) );
V_RETURN( CreateDDSTextureFromFile( pd3dDevice, str, &g_pTexture9 ) );
if( DXUTIsWindowed() )
g_SampleUI.GetButton( IDC_LOAD_TEXTURE )->SetEnabled( true );
else
g_SampleUI.GetButton( IDC_LOAD_TEXTURE )->SetEnabled( false );
return S_OK;
}
示例5: vCenter
//--------------------------------------------------------------------------------------
// Create any D3D resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
HRESULT hr = S_OK;
auto pd3dImmediateContext = DXUTGetD3D11DeviceContext();
V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );
XMFLOAT3 vCenter( 0.25767413f, -28.503521f, 111.00689f );
FLOAT fObjectRadius = 378.15607f;
g_mCenterMesh = XMMatrixTranslation( -vCenter.x, -vCenter.y, -vCenter.z );
XMMATRIX m;
m = XMMatrixRotationY( XM_PI );
g_mCenterMesh *= m;
m = XMMatrixRotationX( XM_PI / 2.0f );
g_mCenterMesh *= m;
// Init the UI widget for directional lighting
V_RETURN( CDXUTDirectionWidget::StaticOnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
g_LightControl.SetRadius( fObjectRadius );
// Compile and create the effect.
DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#ifdef _DEBUG
// Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3DCOMPILE_DEBUG;
// Disable optimizations to further improve shader debugging
dwShaderFlags |= D3DCOMPILE_SKIP_OPTIMIZATION;
#endif
#if D3D_COMPILER_VERSION >= 46
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"DynamicShaderLinkageFX11.fx" ) );
ID3DBlob* pErrorBlob = nullptr;
hr = D3DX11CompileEffectFromFile( str, nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, dwShaderFlags, D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS, pd3dDevice, &g_pEffect, &pErrorBlob );
if ( pErrorBlob )
{
OutputDebugStringA( reinterpret_cast<const char*>( pErrorBlob->GetBufferPointer() ) );
pErrorBlob->Release();
}
if( FAILED(hr) )
{
return hr;
}
#else
ID3DBlob* pEffectBuffer = nullptr;
V_RETURN( DXUTCompileFromFile( L"DynamicShaderLinkageFX11.fx", nullptr, "none", "fx_5_0", dwShaderFlags, D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS, &pEffectBuffer ) );
hr = D3DX11CreateEffectFromMemory( pEffectBuffer->GetBufferPointer(), pEffectBuffer->GetBufferSize(), 0, pd3dDevice, &g_pEffect );
SAFE_RELEASE( pEffectBuffer );
if ( FAILED(hr) )
return hr;
#endif
// Get the light Class Interfaces for setting values
// and as potential binding sources.
g_pAmbientLightClass = g_pEffect->GetVariableByName( "g_ambientLight" )->AsClassInstance();
g_pAmbientLightColor = g_pAmbientLightClass->GetMemberByName( "m_vLightColor" )->AsVector();
g_pAmbientLightEnable = g_pAmbientLightClass->GetMemberByName( "m_bEnable" )->AsScalar();
g_pHemiAmbientLightClass = g_pEffect->GetVariableByName( "g_hemiAmbientLight" )->AsClassInstance();
g_pHemiAmbientLightColor = g_pHemiAmbientLightClass->GetMemberByName( "m_vLightColor" )->AsVector();
g_pHemiAmbientLightEnable = g_pHemiAmbientLightClass->GetMemberByName( "m_bEnable" )->AsScalar();
g_pHemiAmbientLightGroundColor = g_pHemiAmbientLightClass->GetMemberByName( "m_vGroundColor" )->AsVector();
g_pHemiAmbientLightDirUp = g_pHemiAmbientLightClass->GetMemberByName( "m_vDirUp" )->AsVector();
g_pDirectionalLightClass = g_pEffect->GetVariableByName( "g_directionalLight")->AsClassInstance();
g_pDirectionalLightColor = g_pDirectionalLightClass->GetMemberByName( "m_vLightColor" )->AsVector();
g_pDirectionalLightEnable = g_pDirectionalLightClass->GetMemberByName( "m_bEnable" )->AsScalar();
g_pDirectionalLightDir = g_pDirectionalLightClass->GetMemberByName( "m_vLightDir" )->AsVector();
g_pEnvironmentLightClass = g_pEffect->GetVariableByName( "g_environmentLight")->AsClassInstance();
g_pEnvironmentLightColor = g_pEnvironmentLightClass->GetMemberByName( "m_vLightColor" )->AsVector();
g_pEnvironmentLightEnable = g_pEnvironmentLightClass->GetMemberByName( "m_bEnable" )->AsScalar();
g_pEyeDir = g_pEffect->GetVariableByName( "g_vEyeDir" )->AsVector();
// Acquire the material Class Instances for all possible material settings
for( UINT i=0; i < MATERIAL_TYPE_COUNT; i++)
{
char pTechName[50];
sprintf_s( pTechName, sizeof(pTechName),
"FeatureLevel11_%s",
g_pMaterialClassNames[ i ] );
g_MaterialClasses[i].pTechnique = g_pEffect->GetTechniqueByName( pTechName );
//.........这里部分代码省略.........
示例6: vCenter
//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
g_pd3dDevice = pd3dDevice;
HRESULT hr;
ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();
V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );
D3DXVECTOR3 vCenter( 0.25767413f, -28.503521f, 111.00689f);
FLOAT fObjectRadius = 378.15607f;
D3DXMatrixTranslation( &g_mCenterMesh, -vCenter.x, -vCenter.y, -vCenter.z );
D3DXMATRIXA16 m;
D3DXMatrixRotationY( &m, D3DX_PI );
g_mCenterMesh *= m;
D3DXMatrixRotationX( &m, D3DX_PI / 2.0f );
g_mCenterMesh *= m;
// Compile the shaders to a model based on the feature level we acquired
ID3DBlob* pVertexShaderBuffer = NULL;
ID3DBlob* pGeometryShaderBuffer = NULL;
ID3DBlob* pPixelShaderBuffer = NULL;
switch( DXUTGetD3D11DeviceFeatureLevel() )
{
case D3D_FEATURE_LEVEL_11_0:
V_RETURN( CompileShaderFromFile( L"cloth_renderer_VS.hlsl", "VSMain", "vs_5_0" , &pVertexShaderBuffer ) );
V_RETURN( CompileShaderFromFile( L"cloth_renderer_PS.hlsl", "GSMain", "gs_5_0" , &pGeometryShaderBuffer ) );
V_RETURN( CompileShaderFromFile( L"cloth_renderer_PS.hlsl", "PSMain", "ps_5_0" , &pPixelShaderBuffer ) );
break;
}
// Create the shaders
V_RETURN( pd3dDevice->CreateVertexShader( pVertexShaderBuffer->GetBufferPointer(),
pVertexShaderBuffer->GetBufferSize(), NULL, &g_pVertexShader ) );
V_RETURN( pd3dDevice->CreateGeometryShader( pGeometryShaderBuffer->GetBufferPointer(),
pGeometryShaderBuffer->GetBufferSize(), NULL, &g_pGeometryShader ) );
V_RETURN( pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(),
pPixelShaderBuffer->GetBufferSize(), NULL, &g_pPixelShader ) );
V_RETURN( pd3dDevice->CreateInputLayout( layout, ARRAYSIZE( layout ), pVertexShaderBuffer->GetBufferPointer(),
pVertexShaderBuffer->GetBufferSize(), &g_pVertexLayout11 ) );
SAFE_RELEASE( pVertexShaderBuffer );
SAFE_RELEASE( pPixelShaderBuffer );
SAFE_RELEASE( pGeometryShaderBuffer );
// Load the mesh
V_RETURN( g_Mesh11.Create( pd3dDevice, L"tiny\\tiny.sdkmesh", true ) );
// Create a sampler state
D3D11_SAMPLER_DESC SamDesc;
SamDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
SamDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
SamDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
SamDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
SamDesc.MipLODBias = 0.0f;
SamDesc.MaxAnisotropy = 1;
SamDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
SamDesc.BorderColor[0] = SamDesc.BorderColor[1] = SamDesc.BorderColor[2] = SamDesc.BorderColor[3] = 0;
SamDesc.MinLOD = 0;
SamDesc.MaxLOD = D3D11_FLOAT32_MAX;
V_RETURN( pd3dDevice->CreateSamplerState( &SamDesc, &g_pSamLinear ) );
// Setup constant buffers
D3D11_BUFFER_DESC Desc;
Desc.Usage = D3D11_USAGE_DYNAMIC;
Desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
Desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
Desc.MiscFlags = 0;
Desc.ByteWidth = sizeof( CB_VS_PER_OBJECT );
V_RETURN( pd3dDevice->CreateBuffer( &Desc, NULL, &g_pcbVSPerObject ) );
Desc.ByteWidth = sizeof( CB_PS_PER_OBJECT );
V_RETURN( pd3dDevice->CreateBuffer( &Desc, NULL, &g_pcbPSPerObject ) );
Desc.ByteWidth = sizeof( CB_PS_PER_FRAME );
//.........这里部分代码省略.........
示例7: Eye
//--------------------------------------------------------------------------------------
// Create any D3D10 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D10CreateDevice( ID3D10Device* pd3dDevice, const DXGI_SURFACE_DESC* pBufferSurfaceDesc,
void* pUserContext )
{
HRESULT hr;
V_RETURN( g_DialogResourceManager.OnD3D10CreateDevice( pd3dDevice ) );
V_RETURN( g_D3DSettingsDlg.OnD3D10CreateDevice( pd3dDevice ) );
V_RETURN( D3DX10CreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
L"Arial", &g_pFont ) );
V_RETURN( D3DX10CreateSprite( pd3dDevice, 512, &g_pSprite ) );
g_pTxtHelper = new CDXUTTextHelper( NULL, NULL, g_pFont, g_pSprite, 15 );
DWORD dwShaderFlags = D3D10_SHADER_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
// Set the D3D10_SHADER_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3D10_SHADER_DEBUG;
#endif
// Read the D3DX effect file
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"Tutorial13.fx" ) );
V_RETURN( D3DX10CreateEffectFromFile( str, NULL, NULL, "fx_4_0", dwShaderFlags, 0, pd3dDevice, NULL,
NULL, &g_pEffect, NULL, NULL ) );
// Obtain the technique
g_pTechnique = g_pEffect->GetTechniqueByName( "Render" );
// Obtain the variables
g_ptxDiffuseVariable = g_pEffect->GetVariableByName( "g_txDiffuse" )->AsShaderResource();
g_pWorldVariable = g_pEffect->GetVariableByName( "World" )->AsMatrix();
g_pViewVariable = g_pEffect->GetVariableByName( "View" )->AsMatrix();
g_pProjectionVariable = g_pEffect->GetVariableByName( "Projection" )->AsMatrix();
g_pExplodeVariable = g_pEffect->GetVariableByName( "Explode" )->AsScalar();
// Set Waviness
g_pExplodeVariable->SetFloat( g_fExplode );
// Define the input layout
const D3D10_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 },
};
UINT numElements = sizeof( layout ) / sizeof( layout[0] );
// Create the input layout
D3D10_PASS_DESC PassDesc;
g_pTechnique->GetPassByIndex( 0 )->GetDesc( &PassDesc );
V_RETURN( pd3dDevice->CreateInputLayout( layout, numElements, PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &g_pVertexLayout ) );
// Set the input layout
pd3dDevice->IASetInputLayout( g_pVertexLayout );
// Load the mesh
V_RETURN( g_Mesh.Create( pd3dDevice, L"Tiny\\tiny.sdkmesh", true ) );
// Initialize the world matrices
D3DXMatrixIdentity( &g_World );
// Initialize the camera
D3DXVECTOR3 Eye( 0.0f, 0.0f, -800.0f );
D3DXVECTOR3 At( 0.0f, 0.0f, 0.0f );
g_Camera.SetViewParams( &Eye, &At );
return S_OK;
}
示例8: CDXUTTextHelper
//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
HRESULT hr = S_OK;
auto pd3dImmediateContext = DXUTGetD3D11DeviceContext();
V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
V_RETURN( g_SettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );
DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#ifdef _DEBUG
// Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3DCOMPILE_DEBUG;
// Disable optimizations to further improve shader debugging
dwShaderFlags |= D3DCOMPILE_SKIP_OPTIMIZATION;
#endif
#if D3D_COMPILER_VERSION >= 46
// Read the D3DX effect file
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"Tutorial11.fx" ) );
V_RETURN( D3DX11CompileEffectFromFile( str, nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, dwShaderFlags, 0, pd3dDevice, &g_pEffect, nullptr) );
#else
ID3DBlob* pEffectBuffer = nullptr;
V_RETURN( DXUTCompileFromFile( L"Tutorial11.fx", nullptr, "none", "fx_5_0", dwShaderFlags, 0, &pEffectBuffer ) );
hr = D3DX11CreateEffectFromMemory( pEffectBuffer->GetBufferPointer(), pEffectBuffer->GetBufferSize(), 0, pd3dDevice, &g_pEffect );
SAFE_RELEASE( pEffectBuffer );
if ( FAILED(hr) )
return hr;
#endif
// Obtain the technique
g_pTechnique = g_pEffect->GetTechniqueByName( "Render" );
// Obtain the variables
g_ptxDiffuseVariable = g_pEffect->GetVariableByName( "g_txDiffuse" )->AsShaderResource();
g_pWorldVariable = g_pEffect->GetVariableByName( "World" )->AsMatrix();
g_pViewVariable = g_pEffect->GetVariableByName( "View" )->AsMatrix();
g_pProjectionVariable = g_pEffect->GetVariableByName( "Projection" )->AsMatrix();
g_pWavinessVariable = g_pEffect->GetVariableByName( "Waviness" )->AsScalar();
g_pTimeVariable = g_pEffect->GetVariableByName( "Time" )->AsScalar();
// Set Waviness
g_pWavinessVariable->SetFloat( g_fModelWaviness );
// Define the input layout
D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
UINT numElements = ARRAYSIZE( layout );
// Create the input layout
D3DX11_PASS_DESC PassDesc;
V_RETURN( g_pTechnique->GetPassByIndex( 0 )->GetDesc( &PassDesc ) );
V_RETURN( pd3dDevice->CreateInputLayout( layout, numElements, PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &g_pVertexLayout ) );
// Set the input layout
pd3dImmediateContext->IASetInputLayout( g_pVertexLayout );
// Load the mesh
V_RETURN( g_Mesh.Create( pd3dDevice, L"Tiny\\tiny.sdkmesh" ) );
// Initialize the world matrices
g_World = XMMatrixIdentity();
// Setup the camera's view parameters
static const XMVECTORF32 s_Eye = { 0.0f, 3.0f, -800.0f, 0.f };
static const XMVECTORF32 s_At = { 0.0f, 1.0f, 0.0f, 0.f };
g_Camera.SetViewParams( s_Eye, s_At );
return S_OK;
}
示例9: vecEye
//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
HRESULT hr;
ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();
V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );
g_pTxtHelper1 = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 35 );
// textures / rts
D3D11_TEXTURE2D_DESC TDesc;
TDesc.Width = UINT(g_fShadowMapWidth);
TDesc.Height = UINT(g_fShadowMapHeight);
TDesc.MipLevels = 1;
TDesc.ArraySize = 1;
TDesc.Format = DXGI_FORMAT_R16_TYPELESS;
TDesc.SampleDesc.Count = 1;
TDesc.SampleDesc.Quality = 0;
TDesc.Usage = D3D11_USAGE_DEFAULT;
TDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
TDesc.CPUAccessFlags = 0;
TDesc.MiscFlags = 0;
pd3dDevice->CreateTexture2D( &TDesc, 0, &g_pRSMDepthStencilTexture);
DXUT_SetDebugName( g_pRSMDepthStencilTexture, "RSM" );
D3D11_DEPTH_STENCIL_VIEW_DESC DSVDesc;
DSVDesc.Format = DXGI_FORMAT_D16_UNORM;
DSVDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
DSVDesc.Flags = 0;
DSVDesc.Texture2D.MipSlice = 0;
pd3dDevice->CreateDepthStencilView( g_pRSMDepthStencilTexture, &DSVDesc, & g_pDepthStencilTextureDSV );
DXUT_SetDebugName( g_pDepthStencilTextureDSV, "RSM DSV" );
D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc;
SRVDesc.Format = DXGI_FORMAT_R16_UNORM;
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
SRVDesc.Texture2D.MipLevels = 1;
SRVDesc.Texture2D.MostDetailedMip = 0;
pd3dDevice->CreateShaderResourceView( g_pRSMDepthStencilTexture, &SRVDesc, &g_pDepthTextureSRV );
DXUT_SetDebugName( g_pDepthTextureSRV, "RSM SRV" );
// Setup constant buffers
D3D11_BUFFER_DESC Desc;
// Utility
Desc.Usage = D3D11_USAGE_DYNAMIC;
Desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
Desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
Desc.MiscFlags = 0;
Desc.ByteWidth = sizeof( CB_CONSTANTS );
V_RETURN( pd3dDevice->CreateBuffer( &Desc, NULL, &g_pcbConstants ) );
DXUT_SetDebugName( g_pcbConstants, "CB_CONSTANTS" );
// Load the scene mesh
WCHAR str[256];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, 256, L"ColumnScene\\scene.sdkmesh" ) );
g_SceneMesh.Create( pd3dDevice, str, false );
V_RETURN( DXUTFindDXSDKMediaFileCch( str, 256, L"ColumnScene\\poles.sdkmesh" ) );
g_Poles.Create( pd3dDevice, str, false );
// Setup the camera
D3DXVECTOR3 vecEye( 0.95f, 5.83f, -14.48f );
D3DXVECTOR3 vecAt ( 0.90f, 5.44f, -13.56f );
g_Camera.SetViewParams( &vecEye, &vecAt );
D3DXVECTOR3 vecEyeL = D3DXVECTOR3( 0,0,0 );
D3DXVECTOR3 vecAtL ( 0, -0.5, 1 );
g_LCamera.SetViewParams( &vecEyeL, &vecAtL );
// Create sampler states for point and linear
// PointCmp
D3D11_SAMPLER_DESC SamDesc;
SamDesc.Filter = D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT;
SamDesc.AddressU = D3D11_TEXTURE_ADDRESS_BORDER;
SamDesc.AddressV = D3D11_TEXTURE_ADDRESS_BORDER;
SamDesc.AddressW = D3D11_TEXTURE_ADDRESS_BORDER;
SamDesc.MipLODBias = 0.0f;
SamDesc.MaxAnisotropy = 1;
SamDesc.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL;
SamDesc.BorderColor[0] = SamDesc.BorderColor[1] = SamDesc.BorderColor[2] = SamDesc.BorderColor[3] = 1.0;
SamDesc.MinLOD = 0;
SamDesc.MaxLOD = D3D11_FLOAT32_MAX;
V_RETURN( pd3dDevice->CreateSamplerState( &SamDesc, &g_pSamplePointCmp ) );
DXUT_SetDebugName( g_pSamplePointCmp, "PointCmp" );
// Point
SamDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
SamDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
V_RETURN( pd3dDevice->CreateSamplerState( &SamDesc, &g_pSamplePoint ) );
DXUT_SetDebugName( g_pSamplePoint, "Point" );
//.........这里部分代码省略.........
示例10: vEye
//--------------------------------------------------------------------------------------
// Create any D3D10 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D10CreateDevice( ID3D10Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
HRESULT hr;
V_RETURN( g_DialogResourceManager.OnD3D10CreateDevice( pd3dDevice ) );
V_RETURN( g_D3DSettingsDlg.OnD3D10CreateDevice( pd3dDevice ) );
V_RETURN( D3DX10CreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
L"Arial", &g_pFont10 ) );
V_RETURN( D3DX10CreateSprite( pd3dDevice, 512, &g_pSprite10 ) );
g_pTxtHelper = new CDXUTTextHelper( NULL, NULL, g_pFont10, g_pSprite10, 15 );
V_RETURN( CDXUTDirectionWidget::StaticOnD3D10CreateDevice( pd3dDevice ) );
// Read the D3DX effect file
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"MotionBlur10.fx" ) );
DWORD dwShaderFlags = D3D10_SHADER_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
// Set the D3D10_SHADER_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3D10_SHADER_DEBUG;
#endif
V_RETURN( D3DX10CreateEffectFromFile( str, NULL, NULL, "fx_4_0", dwShaderFlags, 0, pd3dDevice, NULL,
NULL, &g_pEffect, NULL, NULL ) );
// Obtain the technique handles
g_pRenderScene = g_pEffect->GetTechniqueByName( "RenderScene" );
g_pRenderSkinnedScene = g_pEffect->GetTechniqueByName( "RenderSkinnedScene" );
g_pRenderMotionBlur = g_pEffect->GetTechniqueByName( "RenderMotionBlur" );
g_pRenderSkinnedMotionBlur = g_pEffect->GetTechniqueByName( "RenderSkinnedMotionBlur" );
// Obtain the parameter handles
g_pmWorldViewProj = g_pEffect->GetVariableByName( "g_mWorldViewProj" )->AsMatrix();
g_pmViewProj = g_pEffect->GetVariableByName( "g_mViewProj" )->AsMatrix();
g_pmWorldView = g_pEffect->GetVariableByName( "g_mWorldView" )->AsMatrix();
g_pmBlurViewProj = g_pEffect->GetVariableByName( "g_mBlurViewProj" )->AsMatrix();
g_pmBlurWorld = g_pEffect->GetVariableByName( "g_mBlurWorld" )->AsMatrix();
g_pmBoneWorld = g_pEffect->GetVariableByName( "g_mBoneWorld" )->AsMatrix();
g_ptxDiffuse = g_pEffect->GetVariableByName( "g_txDiffuse" )->AsShaderResource();
g_pfFrameTime = g_pEffect->GetVariableByName( "g_fFrameTime" )->AsScalar();
g_piNumSteps = g_pEffect->GetVariableByName( "g_iNumSteps" )->AsScalar();
g_pfFadeDist = g_pEffect->GetVariableByName( "g_fFadeDist" )->AsScalar();
// Define our vertex data layout
const D3D10_INPUT_ELEMENT_DESC staticlayout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 32, D3D10_INPUT_PER_VERTEX_DATA, 0 },
};
D3D10_PASS_DESC PassDesc;
g_pRenderScene->GetPassByIndex( 0 )->GetDesc( &PassDesc );
V_RETURN( pd3dDevice->CreateInputLayout( staticlayout, 4, PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &g_pStaticVertexLayout ) );
//Create the scene meshes
g_SceneMesh.Create( pd3dDevice, L"motionblur\\WindMillStage.sdkmesh" );
g_FanMesh.Create( pd3dDevice, L"motionblur\\Fan.sdkmesh" );
D3DXMatrixTranslation( &g_mFanWorld, 0.0f, 3.62f, 2.012f );
//Create the Linked Meshes
g_pLinkedMeshes = new CDXUTSDKMesh[ g_NumLinkedMeshes ];
if( !g_pLinkedMeshes )
return E_OUTOFMEMORY;
for( UINT iMesh = 0; iMesh < g_NumLinkedMeshes; iMesh++ )
{
g_pLinkedMeshes[iMesh].Create( pd3dDevice, g_MeshLinkages[iMesh].szMeshName );
}
const D3D10_INPUT_ELEMENT_DESC skinnedlayout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 32, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "BONES", 0, DXGI_FORMAT_R32G32B32A32_UINT, 0, 44, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "WEIGHTS", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 60, D3D10_INPUT_PER_VERTEX_DATA, 0 },
};
g_pRenderSkinnedScene->GetPassByIndex( 0 )->GetDesc( &PassDesc );
V_RETURN( pd3dDevice->CreateInputLayout( skinnedlayout, 6, PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &g_pSkinnedVertexLayout ) );
g_AnimMesh.Create( pd3dDevice, L"motionblur\\Warrior.sdkmesh" );
g_AnimMesh.LoadAnimation( L"motionblur\\Warrior.sdkmesh_anim" );
//camera
D3DXVECTOR3 vEye( 2.0f, 1.3f, -4.0f );
D3DXVECTOR3 vAt( 0.0f, 1.0f, -1.11f );
g_Camera.SetViewParams( &vEye, &vAt );
return S_OK;
//.........这里部分代码省略.........
示例11: vecEye
//--------------------------------------------------------------------------------------
// Create any D3D9 resources that will live through a device reset (D3DPOOL_MANAGED)
// and aren't tied to the back buffer size
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D10CreateDevice( ID3D10Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
HRESULT hr;
V_RETURN( g_DialogResourceManager.OnD3D10CreateDevice( pd3dDevice ) );
V_RETURN( g_SettingsDlg.OnD3D10CreateDevice( pd3dDevice ) );
V_RETURN( D3DX10CreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
L"Arial", &g_pFont10 ) );
V_RETURN( D3DX10CreateSprite( pd3dDevice, 512, &g_pSprite10 ) );
g_pTxtHelper = new CDXUTTextHelper( NULL, NULL, g_pFont10, g_pSprite10, 15 );
#define IDC_WIREFRAME 10
g_SampleUI.GetCheckBox( IDC_WIREFRAME )->SetVisible( false );
V_RETURN( LoadEffect10( pd3dDevice ) );
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\Terrain1.bmp" ) );
V_RETURN( g_Terrain.LoadTerrain( str, g_SqrtNumTiles, g_SidesPerTile, g_fWorldScale, g_fHeightScale, 1000, 1.0f,
2.0f ) );
ResetBalls();
// Create a Vertex Decl for the terrain and basic meshes
const D3D10_INPUT_ELEMENT_DESC basiclayout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 },
};
D3D10_PASS_DESC PassDesc;
g_pRenderTerrain->GetPassByIndex( 0 )->GetDesc( &PassDesc );
V_RETURN( pd3dDevice->CreateInputLayout( basiclayout, sizeof( basiclayout ) / sizeof( basiclayout[0] ),
PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &g_pBasicDecl10 ) );
// Create a Vertex Decl for the ball
const D3D10_INPUT_ELEMENT_DESC balllayout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 1, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D10_INPUT_PER_INSTANCE_DATA, 1 },
};
g_pRenderBall->GetPassByIndex( 0 )->GetDesc( &PassDesc );
V_RETURN( pd3dDevice->CreateInputLayout( balllayout, sizeof( balllayout ) / sizeof( balllayout[0] ),
PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &g_pBallDecl10 ) );
// Create a Vertex Decl for the grass
const D3D10_INPUT_ELEMENT_DESC grasslayout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 1, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D10_INPUT_PER_INSTANCE_DATA, 1 },
};
g_pRenderGrass->GetPassByIndex( 0 )->GetDesc( &PassDesc );
V_RETURN( pd3dDevice->CreateInputLayout( grasslayout, sizeof( grasslayout ) / sizeof( grasslayout[0] ),
PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &g_pGrassDecl10 ) );
// Load terrain device objects
V_RETURN( g_Terrain.OnCreateDevice( pd3dDevice ) );
// Load a mesh
g_BallMesh.Create( pd3dDevice, L"PIXWorkshop\\lowpolysphere.sdkmesh" );
g_SkyMesh.Create( pd3dDevice, L"PIXWorkshop\\desertsky.sdkmesh" );
// Create a VB for the stream data
D3D10_BUFFER_DESC BufferDesc;
BufferDesc.ByteWidth = NUM_PLAYERS * sizeof( D3DXVECTOR3 );
BufferDesc.Usage = D3D10_USAGE_DYNAMIC;
BufferDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
BufferDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
BufferDesc.MiscFlags = 0;
V_RETURN( pd3dDevice->CreateBuffer( &BufferDesc, NULL, &g_pStreamDataVB10 ) );
// Create a VB for the grass instances
BufferDesc.ByteWidth = g_SqrtNumTiles * g_SqrtNumTiles * sizeof( D3DXVECTOR3 );
V_RETURN( pd3dDevice->CreateBuffer( &BufferDesc, NULL, &g_pGrassDataVB10 ) );
// Load a texture for the mesh
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\Terrain1.bmp" ) );
V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pHeightTexRV, NULL ) );
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\Terrain1_Norm.dds" ) );
V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pNormalTexRV, NULL ) );
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\grass_v3_dark_tex.dds" ) );
V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pGrassTexRV, NULL ) );
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\Dirt_Diff.dds" ) );
V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pDirtTexRV, NULL ) );
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\Grass_Diff.dds" ) );
V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pGroundGrassTexRV, NULL ) );
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\Terrain1_Mask.dds" ) );
V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pMaskTexRV, NULL ) );
//.........这里部分代码省略.........