bool Shader::Init(const std::string& fileName, unsigned int additionalAttributes, const std::string& vertexFunctionName, const std::string& pixelFunctionName){ LOG_("Shaders: Init... "); pVertexShader = InitVertexShader(fileName, vertexFunctionName); pPixelShader = InitPixelShader (fileName, pixelFunctionName); if (! ConstructInputLayout(additionalAttributes) ){ LOG("Error!"); return false; } matrixBuffer = CreateShaderConstantsBuffer(sizeof(MatrixBufferType)); if (!matrixBuffer){ LOG("Error!"); return false; } lightBuffer = CreateShaderConstantsBuffer(sizeof(LightBufferType)); if (!lightBuffer){ LOG("Error!"); return false; } LOG("OK!"); return true; }
HRESULT PixelShaderDynamic::CreatePixelShader(ID3D11Device* pDevice, const void* pShaderBytecode, SIZE_T unBytecodeLength) { HRESULT retVal = S_OK; // Will Return S_OK if device is NULL just in case we want a NULL shader // so that we can set the stages of the pipeline as wanted if(pDevice) { InitClassLinkage(pDevice); retVal = InitPixelShader(pDevice, pShaderBytecode, unBytecodeLength); if(FAILED(retVal)) return retVal; retVal = InitShaderReflection(pShaderBytecode, unBytecodeLength); if(FAILED(retVal)) { MessageBox(NULL, L"Failed To Create Pixel Shader Reflection (Dynamic Linked PS)" , L"", MB_OK | MB_ICONERROR); return retVal; } return S_OK; } else return E_ABORT; }