本文整理汇总了C++中GLShader::AddSource方法的典型用法代码示例。如果您正苦于以下问题:C++ GLShader::AddSource方法的具体用法?C++ GLShader::AddSource怎么用?C++ GLShader::AddSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLShader
的用法示例。
在下文中一共展示了GLShader::AddSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
GLShader *GLProgramManager::CreateShader(const std::string &name) {
SPADES_MARK_FUNCTION();
SPLog("Loading GLSL shader '%s'", name.c_str());
std::string text = FileManager::ReadAllBytes(name.c_str());
GLShader::Type type;
if (name.find(".fs") != std::string::npos)
type = GLShader::FragmentShader;
else if (name.find(".vs") != std::string::npos)
type = GLShader::VertexShader;
else if (name.find(".gs") != std::string::npos)
type = GLShader::GeometryShader;
else
SPRaise("Failed to determine the type of a shader: %s", name.c_str());
GLShader *s = new GLShader(device, type);
std::string finalSource;
if (settings.r_hdr) {
finalSource += "#define USE_HDR 1\n";
finalSource += "#define LINEAR_FRAMEBUFFER 1\n";
} else {
finalSource += "#define USE_HDR 0\n";
finalSource += "#define LINEAR_FRAMEBUFFER 0\n";
}
if (settings.r_fogShadow) {
finalSource += "#define USE_VOLUMETRIC_FOG 1\n";
} else {
finalSource += "#define USE_VOLUMETRIC_FOG 0\n";
}
if (settings.r_ssao) {
finalSource += "#define USE_SSAO 1\n";
} else {
finalSource += "#define USE_SSAO 0\n";
}
finalSource += text;
s->AddSource(finalSource);
Stopwatch sw;
s->Compile();
SPLog("Successfully compiled GLSL program '%s' in %.3fms", name.c_str(), // should this be "program" or "shader"?
sw.GetTime() * 1000.);
return s;
}
示例2: if
GLShader *GLProgramManager::CreateShader(const std::string &name) {
SPADES_MARK_FUNCTION();
SPLog("Loading GLSL shader '%s'", name.c_str());
std::string text = FileManager::ReadAllBytes(name.c_str());
GLShader::Type type;
if(name.find(".fs") != std::string::npos)
type = GLShader::FragmentShader;
else if(name.find(".vs") != std::string::npos)
type = GLShader::VertexShader;
else
SPRaise("Failed to determine the type of a shader: %s",
name.c_str());
GLShader *s = new GLShader(device, type);
s->AddSource(text);
Stopwatch sw;
s->Compile();
SPLog("Successfully compiled GLSL program '%s' in %.3fms", name.c_str(),
sw.GetTime() * 1000.);
return s;
}