本文整理汇总了C++中microsoft::wrl::ComPtr::CreatePixelShader方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::CreatePixelShader方法的具体用法?C++ ComPtr::CreatePixelShader怎么用?C++ ComPtr::CreatePixelShader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类microsoft::wrl::ComPtr
的用法示例。
在下文中一共展示了ComPtr::CreatePixelShader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glShaderSource
void glShaderSource(GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths)
{
assert( count == 1 );
// shader is precompiled on windows phone, so just pass in value directly
if( g_D3DShaderArray[shader-1].m_Type == GL_VERTEX_SHADER )
{
g_pD3DDevice->CreateVertexShader( strings[0], lengths[0], nullptr, &g_D3DShaderArray[shader-1].m_pVertexShader );
}
else if( g_D3DShaderArray[shader-1].m_Type == GL_FRAGMENT_SHADER )
{
g_pD3DDevice->CreatePixelShader( strings[0], lengths[0], nullptr, &g_D3DShaderArray[shader-1].m_pFragmentShader );
}
}
示例2: createShaders
bool Shader::createShaders(const Microsoft::WRL::ComPtr<ID3D11Device> &pDevice
, const std::wstring &shaderFile, const std::string &vsFunc, const std::string &psFunc)
{
// vertex shader
{
Microsoft::WRL::ComPtr<ID3DBlob> vblob;
HRESULT hr = CompileShaderFromFile(shaderFile.c_str(), vsFunc.c_str(), "vs_4_0_level_9_1", &vblob);
if (FAILED(hr))
return false;
hr = pDevice->CreateVertexShader(vblob->GetBufferPointer(), vblob->GetBufferSize(), NULL, &m_pVsh);
if (FAILED(hr))
return false;
// vertex shader reflection
Microsoft::WRL::ComPtr<ID3D11ShaderReflection> pReflector;
hr = D3DReflect(vblob->GetBufferPointer(), vblob->GetBufferSize(), IID_ID3D11ShaderReflection, &pReflector);
if (FAILED(hr))
return false;
OutputDebugPrintfA("#### VertexShader ####\n");
if (!m_constant->Initialize(pDevice, SHADERSTAGE_VERTEX, pReflector)){
return false;
}
D3D11_SHADER_DESC shaderdesc;
pReflector->GetDesc(&shaderdesc);
// Create InputLayout
std::vector<D3D11_INPUT_ELEMENT_DESC> vbElement;
for (size_t i = 0; i < shaderdesc.InputParameters; ++i){
D3D11_SIGNATURE_PARAMETER_DESC sigdesc;
pReflector->GetInputParameterDesc(i, &sigdesc);
auto format = GetDxgiFormat(sigdesc.ComponentType, sigdesc.Mask);
D3D11_INPUT_ELEMENT_DESC eledesc = {
sigdesc.SemanticName
, sigdesc.SemanticIndex
, format
, 0 // 決め打ち
, D3D11_APPEND_ALIGNED_ELEMENT // 決め打ち
, D3D11_INPUT_PER_VERTEX_DATA // 決め打ち
, 0 // 決め打ち
};
vbElement.push_back(eledesc);
}
if (!vbElement.empty()){
hr = pDevice->CreateInputLayout(&vbElement[0], vbElement.size(),
vblob->GetBufferPointer(), vblob->GetBufferSize(), &m_pInputLayout);
if (FAILED(hr))
return false;
}
}
// pixel shader
{
Microsoft::WRL::ComPtr<ID3DBlob> pblob;
auto hr = CompileShaderFromFile(shaderFile.c_str(), psFunc.c_str(), "ps_4_0_level_9_1", &pblob);
if (FAILED(hr))
return false;
hr = pDevice->CreatePixelShader(pblob->GetBufferPointer(), pblob->GetBufferSize(), NULL, &m_pPsh);
if (FAILED(hr))
return false;
// pixel shader reflection
Microsoft::WRL::ComPtr<ID3D11ShaderReflection> pReflector;
hr = D3DReflect(pblob->GetBufferPointer(), pblob->GetBufferSize(), IID_ID3D11ShaderReflection,
&pReflector);
if (FAILED(hr))
return false;
OutputDebugPrintfA("#### PixelShader ####\n");
if (!m_constant->Initialize(pDevice, SHADERSTAGE_PIXEL, pReflector)){
return false;
}
}
return true;
}