bool Shader::CompileFromSource(const std::string& pathToFile, const EShaderStage& type, ID3D10Blob *& ref_pBob, std::string& errMsg, const std::vector<ShaderMacro>& macros) { const StrUtil::UnicodeString Path = pathToFile; const WCHAR* PathStr = Path.GetUnicodePtr(); ID3D10Blob* errorMessage = nullptr; int i = 0; std::vector<D3D10_SHADER_MACRO> d3dMacros(macros.size() + 1); std::for_each(RANGE(macros), [&](const ShaderMacro& macro) { d3dMacros[i++] = D3D10_SHADER_MACRO({ macro.name.c_str(), macro.value.c_str() }); }); d3dMacros[i] = { NULL, NULL }; if (FAILED(D3DCompileFromFile( PathStr, d3dMacros.data(), SHADER_INCLUDE_HANDLER, SHADER_ENTRY_POINT_LOOKUP.at(type), SHADER_COMPILER_VERSION_LOOKUP.at(type), SHADER_COMPILE_FLAGS, 0, &ref_pBob, &errorMessage))) { errMsg = GetCompileError(errorMessage, pathToFile); return false; } return true; }
//Compile the shader we created void Shader::CompileShader(unsigned int shader) { //Compile the shader glCompileShader(shader); //Check for errors GetCompileError(shader); }