本文整理汇总了C++中CGutModel_DX10::ConvertToDX10Model方法的典型用法代码示例。如果您正苦于以下问题:C++ CGutModel_DX10::ConvertToDX10Model方法的具体用法?C++ CGutModel_DX10::ConvertToDX10Model怎么用?C++ CGutModel_DX10::ConvertToDX10Model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGutModel_DX10
的用法示例。
在下文中一共展示了CGutModel_DX10::ConvertToDX10Model方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitResourceDX10
bool InitResourceDX10(void)
{
g_pDevice = GutGetGraphicsDeviceDX10();
ID3D10Blob *pVSCode = NULL;
for ( int i=0; i<NUM_FRAMEBUFFERS; i++ )
{
g_pTextures[i] = NULL;
g_pSRView[i] = NULL;
g_pRTView[i] = NULL;
}
// 載入Shader
{
g_pPostFX = GutLoadFXShaderDX10("../../shaders/Posteffect_dx10.fx");
if ( NULL==g_pPostFX )
return false;
g_pExposureFX = GutLoadFXShaderDX10("../../shaders/Exposure_dx10.fx");
if ( NULL==g_pExposureFX )
return false;
}
// 設定Vertex資料格式
{
ID3D10EffectTechnique *pShader = g_pExposureFX->GetTechniqueByName("AutoExposure");
D3D10_INPUT_ELEMENT_DESC layout[] =
{
{ "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 }
};
D3D10_PASS_DESC PassDesc;
pShader->GetPassByIndex(0)->GetDesc(&PassDesc);
if ( D3D_OK != g_pDevice->CreateInputLayout( layout, 2, PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &g_pVertexLayout ) )
return false;
SAFE_RELEASE(pVSCode);
}
if ( !ReInitResourceDX10() )
return false;
CGutModel_DX10::LoadDefaultShader("../../shaders/gmodel_dx10.hlsl");
g_Model_DX10.ConvertToDX10Model(&g_Model);
g_pVertexBuffer = GutCreateVertexBuffer_DX10(sizeof(Vertex_VT)*4, g_FullScreenQuad);
return true;
}
示例2: InitResourceDX10
bool InitResourceDX10(void)
{
g_pDevice = GutGetGraphicsDeviceDX10();
// 載入Shader
{
g_pRefractionFX = GutLoadFXShaderDX10("../../shaders/Refraction_dx10.fx");
if ( NULL==g_pRefractionFX )
return false;
ID3D10EffectTechnique *pShader = g_pRefractionFX->GetTechniqueByName("Refraction");
const sVertexDecl *pVertexDecl = g_Model.GetVertexFormat();
D3D10_PASS_DESC PassDesc;
pShader->GetPassByIndex(0)->GetDesc(&PassDesc);
g_pRefractionLayout = GutCreateInputLayoutDX10(pVertexDecl, PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize);
}
g_pPostFX = GutLoadFXShaderDX10("../../shaders/Posteffect_dx10.fx");
if ( NULL==g_pPostFX )
return false;
{
g_pVertexBuffer = GutCreateVertexBuffer_DX10(sizeof(Vertex_VT)*4, g_FullScreenQuad);
D3D10_INPUT_ELEMENT_DESC layout[] =
{
{ "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 }
};
ID3D10EffectTechnique *pShader = g_pPostFX->GetTechniqueByName("DrawIcon");
D3D10_PASS_DESC PassDesc;
pShader->GetPassByIndex(0)->GetDesc(&PassDesc);
if ( D3D_OK != g_pDevice->CreateInputLayout( layout, 2, PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &g_pVertexLayout ) )
return false;
}
if ( !ReInitResourceDX10() )
return false;
CGutModel_DX10::LoadDefaultShader("../../shaders/gmodel_dx10.hlsl");
g_Model_DX10.ConvertToDX10Model(&g_Model);
g_pTexture = GutLoadTexture_DX10("../../textures/lena.dds");
return true;
}
示例3: InitResourceDX10
bool InitResourceDX10(void)
{
g_pDevice = GutGetGraphicsDeviceDX10();
ID3D10Blob *pVSCode = NULL;
// 計算投影矩陣
g_proj_matrix = GutMatrixPerspectiveRH_DirectX(g_fFovW, 1.0f, g_fNear, g_fFar);
if ( !CGutModel_DX10::LoadDefaultShader("../../shaders/gmodel_dx10.hlsl") )
return false;
g_Model_DX10.ConvertToDX10Model(&g_Model);
return true;
}
示例4: InitResourceDX10
bool InitResourceDX10(void)
{
g_pDevice = GutGetGraphicsDeviceDX10();
ID3D10Blob *pVSCode = NULL;
{
// 載入Vertex Shader
g_pVertexShader = GutLoadVertexShaderDX10_HLSL("../../shaders/color_dx10.hlsl", "VS", "vs_4_0", &pVSCode);
if ( NULL==g_pVertexShader )
return false;
// 載入Pixel Shader
g_pPixelShader = GutLoadPixelShaderDX10_HLSL("../../shaders/color_dx10.hlsl", "PS", "ps_4_0");
if ( NULL==g_pPixelShader )
return false;
}
CGutModel_DX10::LoadDefaultShader("../../shaders/gmodel_dx10.hlsl");
CGutModel::SetTexturePath("../../textures/");
g_Model_DX10.ConvertToDX10Model(&g_Model);
// 設定Vertex資料格式
{
D3D10_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
};
if ( D3D_OK != g_pDevice->CreateInputLayout( layout, sizeof(layout)/sizeof(D3D10_INPUT_ELEMENT_DESC), pVSCode->GetBufferPointer(), pVSCode->GetBufferSize(), &g_pVertexLayout ) )
return false;
SAFE_RELEASE(pVSCode);
}
// 配置Shader讀取參數的記憶體空間
{
D3D10_BUFFER_DESC cbDesc;
ZeroMemory(&cbDesc, sizeof(cbDesc));
cbDesc.ByteWidth = sizeof(ShaderConstant);
cbDesc.Usage = D3D10_USAGE_DYNAMIC;
cbDesc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
cbDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
cbDesc.MiscFlags = 0;
if ( D3D_OK != g_pDevice->CreateBuffer( &cbDesc, NULL, &g_pConstantBuffer ) )
return false;
}
// 配置Vertex Buffer
{
D3D10_BUFFER_DESC cbDesc;
ZeroMemory(&cbDesc, sizeof(cbDesc));
cbDesc.ByteWidth = sizeof(Vertex_V) * 4;
cbDesc.Usage = D3D10_USAGE_DYNAMIC ;
cbDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
cbDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
cbDesc.MiscFlags = 0;
D3D10_SUBRESOURCE_DATA subDesc;
ZeroMemory(&subDesc, sizeof(subDesc));
subDesc.pSysMem = g_Quad;
if ( D3D_OK != g_pDevice->CreateBuffer( &cbDesc, &subDesc, &g_pVertexBuffer ) )
return false;
}
// rasterizer state物件
{
D3D10_RASTERIZER_DESC desc;
GutSetDX10DefaultRasterizerDesc(desc);
desc.CullMode = D3D10_CULL_NONE;
desc.FrontCounterClockwise = true;
if ( D3D_OK != g_pDevice->CreateRasterizerState(&desc, &g_pRasterizerNoCull) )
return false;
desc.CullMode = D3D10_CULL_BACK;
desc.FrontCounterClockwise = true;
if ( D3D_OK != g_pDevice->CreateRasterizerState(&desc, &g_pRasterizerCull) )
return false;
CGutModel_DX10::SetRasterizeState(g_pRasterizerCull, g_pRasterizerNoCull);
g_pDevice->RSSetState(g_pRasterizerNoCull);
}
// depth stencil object
{
D3D10_DEPTH_STENCIL_DESC desc;
GutSetDX10DefaultDepthStencilDesc(desc);
desc.StencilEnable = TRUE;
desc.FrontFace.StencilFunc = D3D10_COMPARISON_ALWAYS;
desc.FrontFace.StencilPassOp = D3D10_STENCIL_OP_INCR;
desc.BackFace = desc.FrontFace;
//.........这里部分代码省略.........
示例5: InitResourceDX10
bool InitResourceDX10(void)
{
g_pDevice = GutGetGraphicsDeviceDX10();
ID3D10Blob *pVSCode = NULL;
// 載入Vertex Shader
g_pVertexShader = GutLoadVertexShaderDX10_HLSL("../../shaders/texture_dx10.hlsl", "VS", "vs_4_0", &pVSCode);
if ( NULL==g_pVertexShader )
return false;
// 載入Pixel Shader
g_pPixelShader = GutLoadPixelShaderDX10_HLSL("../../shaders/texture_dx10.hlsl", "PS", "ps_4_0");
if ( NULL==g_pPixelShader )
return false;
CGutModel_DX10::LoadDefaultShader("../../shaders/gmodel_dx10.hlsl");
CGutModel::SetTexturePath("../../textures/");
g_Model_DX10.ConvertToDX10Model(&g_Model);
// 設定Vertex資料格式
D3D10_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 16, D3D10_INPUT_PER_VERTEX_DATA, 0 }
};
if ( D3D_OK != g_pDevice->CreateInputLayout( layout, sizeof(layout)/sizeof(D3D10_INPUT_ELEMENT_DESC),
pVSCode->GetBufferPointer(), pVSCode->GetBufferSize(), &g_pVertexLayout ) )
return false;
SAFE_RELEASE(pVSCode);
D3D10_BUFFER_DESC cbDesc;
ZeroMemory(&cbDesc, sizeof(cbDesc));
// 配置Vertex Buffer
{
cbDesc.ByteWidth = sizeof(Vertex_VT) * 4;
cbDesc.Usage = D3D10_USAGE_DYNAMIC ;
cbDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
cbDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
cbDesc.MiscFlags = 0;
D3D10_SUBRESOURCE_DATA subDesc;
ZeroMemory(&subDesc, sizeof(subDesc));
subDesc.pSysMem = g_Quad;
if ( D3D_OK != g_pDevice->CreateBuffer( &cbDesc, &subDesc, &g_pVertexBuffer ) )
return false;
}
// 配置Vertex Shader 常數記憶體
{
cbDesc.ByteWidth = sizeof(Matrix4x4);
cbDesc.Usage = D3D10_USAGE_DYNAMIC;
cbDesc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
cbDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
cbDesc.MiscFlags = 0;
if ( D3D_OK != g_pDevice->CreateBuffer( &cbDesc, NULL, &g_pVSConstBuffer ) )
return false;
}
// 配置RGBA動態貼圖
{
D3D10_TEXTURE2D_DESC dstex;
dstex.Width = 512;
dstex.Height = 512;
dstex.MipLevels = 1;
dstex.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
dstex.SampleDesc.Count = 1;
dstex.SampleDesc.Quality = 0;
dstex.Usage = D3D10_USAGE_DEFAULT;
dstex.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
dstex.CPUAccessFlags = 0;
dstex.MiscFlags = 0;
dstex.ArraySize = 1;
g_pDevice->CreateTexture2D( &dstex, NULL, &g_pTexture );
D3D10_SHADER_RESOURCE_VIEW_DESC SRVDesc;
ZeroMemory( &SRVDesc, sizeof(SRVDesc) );
SRVDesc.Format = dstex.Format;
SRVDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
SRVDesc.Texture2D.MipLevels = 1;
// for shader
g_pDevice->CreateShaderResourceView(g_pTexture, &SRVDesc, &g_pTextureView);
D3D10_RENDER_TARGET_VIEW_DESC DescRT;
DescRT.Format = dstex.Format;
DescRT.ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2D;
DescRT.Texture2D.MipSlice = 0;
// for rendertarget
g_pDevice->CreateRenderTargetView(g_pTexture, &DescRT, &g_pRGBAView);
}
// 配置DepthStencil動態貼圖
{
D3D10_TEXTURE2D_DESC desc;
ZeroMemory( &desc, sizeof(desc) );
//.........这里部分代码省略.........
示例6: InitResourceDX10
bool InitResourceDX10(void)
{
g_pDevice = GutGetGraphicsDeviceDX10();
CGutModel_DX10::LoadDefaultShader("../../shaders/gmodel_dx10.hlsl");
CGutModel::SetTexturePath("../../textures/");
g_Model_DX10.ConvertToDX10Model(&g_Model);
g_SpotLightModel_DX10.ConvertToDX10Model(&g_SpotLightModel);
// depth stencil object
{
D3D10_DEPTH_STENCIL_DESC desc;
GutSetDX10DefaultDepthStencilDesc(desc);
desc.StencilEnable = TRUE;
desc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ZERO;
desc.FrontFace.StencilFunc = D3D10_COMPARISON_ALWAYS;
desc.FrontFace.StencilPassOp = D3D10_STENCIL_OP_INCR;
desc.BackFace.StencilFunc = D3D10_COMPARISON_ALWAYS;
desc.BackFace.StencilPassOp = D3D10_STENCIL_OP_DECR;
g_pDevice->CreateDepthStencilState(&desc, &g_pZStencil_Mask);
desc.FrontFace.StencilFunc = D3D10_COMPARISON_EQUAL;
desc.FrontFace.StencilPassOp = D3D10_STENCIL_OP_KEEP;
desc.BackFace = desc.FrontFace;
g_pDevice->CreateDepthStencilState(&desc, &g_pZStencil_Test);
}
// disable rgba output
{
D3D10_BLEND_DESC desc;
GutSetDX10DefaultBlendDesc(desc);
desc.RenderTargetWriteMask[0] = 0;
g_pDevice->CreateBlendState(&desc, &g_pBlendState_ColorWriteOff);
}
// material overwrite
{
g_material_stencilpass.m_bCullFace = false;
g_material_stencilpass.m_pBlendState = g_pBlendState_ColorWriteOff;
g_material_stencilpass.m_vDiffuse.Set(0.1f);
g_material_spotlightpass.m_bCullFace = true;
g_material_spotlightpass.m_pBlendState = CGutModel_DX10::s_pBlend_Add;
g_material_spotlightpass.m_vDiffuse.Set(0.3f);
}
// sampler state / texture filter
{
D3D10_SAMPLER_DESC sampler_desc;
ZeroMemory(&sampler_desc, sizeof(sampler_desc));
sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR;
sampler_desc.AddressU = D3D10_TEXTURE_ADDRESS_WRAP;
sampler_desc.AddressV = D3D10_TEXTURE_ADDRESS_WRAP;
sampler_desc.AddressW = D3D10_TEXTURE_ADDRESS_WRAP;
g_pDevice->CreateSamplerState(&sampler_desc, &g_pSamplerState);
for ( int i=0; i<4; i++ )
{
g_pDevice->PSSetSamplers(i, 1, &g_pSamplerState);
}
}
// 投影矩陣
g_proj_matrix = GutMatrixPerspectiveRH_DirectX(g_fFOV, 1.0f, 0.1f, 100.0f);
return true;
}