本文整理汇总了C++中GLSLProgram::log方法的典型用法代码示例。如果您正苦于以下问题:C++ GLSLProgram::log方法的具体用法?C++ GLSLProgram::log怎么用?C++ GLSLProgram::log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLSLProgram
的用法示例。
在下文中一共展示了GLSLProgram::log方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromStrings
GLSLProgram* ShaderManager::LoadFromStrings(const char* vertName, const char*fragName, std::string vertString, std::string fragString)
{
GLSLProgram* prog = new GLSLProgram();
if(!prog->compileShaderFromString(vertString, GLSLShader::VERTEX))
{
printf("Vertex shader failed to compile from string!\n%s", prog->log().c_str());
sLog(Level::Severe) << "Vertex shader <" << vertName << "> failed to compile from string." << prog->log();
assert(false && "Vertex shader failed to compile from string");
return NULL;
}
if(!prog->compileShaderFromString(fragString, GLSLShader::FRAGMENT))
{
printf("Fragment shader failed to compile from string!\n%s", prog->log().c_str());
sLog(Level::Severe) << "Fragment shader <" << fragName << "> failed to compile from string." << prog->log();
assert(false && "Fragment shader failed to compile from string");
return NULL;
}
if(!prog->link())
{
printf("Shader program failed to link!\n%s", prog->log().c_str());
sLog(Level::Severe) << "Shader program failed to link." << prog->log();
assert(false && "Shader program failed to link.");
return NULL;
}
assert(prog != NULL);
return prog;
}
示例2: LoadFromStrings
//Loads and compiles vertice and fragment shaders from strings into one GLSLProgram*
GLSLProgram* ShaderManager::LoadFromStrings(std::string vertName, std::string fragName, std::string vertString, std::string fragString)
{
GLSLProgram* prog = new GLSLProgram();
///Compile the vertex portion of the shader
if(!prog->compileShaderFromString(vertString, GLSLShader::VERTEX))
{
printf("Vertex shader failed to compile from string!\n%s", prog->log().c_str());
assert(false && "Vertex shader failed to compile from string");
return NULL;
}
///Compile the fragment portion of the shader
if(!prog->compileShaderFromString(fragString, GLSLShader::FRAGMENT))
{
printf("Fragment shader failed to compile from string!\n%s", prog->log().c_str());
assert(false && "Fragment shader failed to compile from string");
return NULL;
}
///Links the shader to OpenGL using the handle obtained during the compile
if ( !prog->link() )
{
printf("Shader program failed to link!\n%s", prog->log().c_str());
assert(false && "Shader program failed to link.");
return NULL;
}
assert(prog != NULL);
return prog;
}
示例3: printf
void SceneParticlesInstanced::compileAndLinkShader
(GLSLProgram& glslProg, const char* vertexPath, const char* fragmentPath, const char* geometryPath)
{
// "shader/particleinstanced.vs"
if( !glslProg.compileShaderFromFile(vertexPath, GLSLShader::VERTEX) )
{
printf("Vertex shader failed to compile!\n%s",
glslProg.log().c_str());
do
{
cout << '\n' << "Press a key to continue...";
} while (cin.get() != '\n');
exit(1);
}
// "shader/particleinstanced.fs"
if( !glslProg.compileShaderFromFile(fragmentPath, GLSLShader::FRAGMENT))
{
printf("Fragment shader failed to compile!\n%s",
glslProg.log().c_str());
do
{
cout << '\n' << "Press a key to continue...";
} while (cin.get() != '\n');
exit(1);
}
if (geometryPath != NULL && geometryPath[0] != '\0') {
// compile geometry shader
if (!glslProg.compileShaderFromFile(geometryPath, GLSLShader::GEOMETRY))
{
printf("Geometry shader failed to compile!\n%s",
glslProg.log().c_str());
do
{
cout << '\n' << "Press a key to continue...";
} while (cin.get() != '\n');
exit(1);
}
}
if( !glslProg.link() )
{
printf("Shader program failed to link!\n%s",
glslProg.log().c_str());
do
{
cout << '\n' << "Press a key to continue...";
} while (cin.get() != '\n');
exit(1);
}
glslProg.use();
}
示例4: loadAssets
void loadAssets()
{
loadParticles();
loadPlane();
pstack.push(glm::perspective(45.0f,
(GLfloat)window.GetWidth()/window.GetHeight(), 0.1f, 175.0f));
mstack.push(glm::lookAt(vec3(0, 2.7, 7), vec3(0, 2.4, 6), vec3(0, 1, 0)));
// Load terrain shader
if (!g_program.compileShaderFromFile(
ROOT_PATH_RELATIVE SHADER_DIR "terrain-vert.glsl",
GLSLShader::VERTEX)) {
fprintf(stderr, "%s\n", g_program.log().c_str());
exit(1);
}
if (!g_program.compileShaderFromFile(
ROOT_PATH_RELATIVE SHADER_DIR "terrain-frag.glsl",
GLSLShader::FRAGMENT)) {
fprintf(stderr, "%s\n", g_program.log().c_str());
exit(1);
}
if (!g_program.compileShaderFromFile(
ROOT_PATH_RELATIVE SHADER_DIR "terrain-tc.glsl",
GLSLShader::TESS_CONTROL)) {
fprintf(stderr, "%s\n", g_program.log().c_str());
exit(1);
}
if (!g_program.compileShaderFromFile(
ROOT_PATH_RELATIVE SHADER_DIR "terrain-te.glsl",
GLSLShader::TESS_EVALUATION)) {
fprintf(stderr, "%s\n", g_program.log().c_str());
exit(1);
}
if (!g_program.link()) {
fprintf(stderr, "%s\n", g_program.log().c_str());
exit(1);
}
// Load plane shader
if (!d_program.compileShaderFromFile(
ROOT_PATH_RELATIVE SHADER_DIR "default-vert.glsl",
GLSLShader::VERTEX)) {
fprintf(stderr, "%s\n", d_program.log().c_str());
exit(1);
}
if (!d_program.compileShaderFromFile(
ROOT_PATH_RELATIVE SHADER_DIR "default-frag.glsl",
GLSLShader::FRAGMENT)) {
fprintf(stderr, "%s\n", d_program.log().c_str());
exit(1);
}
const char *outputNames[] = { "Position" };
glTransformFeedbackVaryings(d_program.getHandle(), 1, outputNames, GL_SEPARATE_ATTRIBS);
if (!d_program.link()) {
fprintf(stderr, "%s\n", d_program.log().c_str());
exit(1);
}
g_program.use();
g_program.setUniform("Viewport", viewport);
g_program.setUniform("MinTessLevel", 1.0f);
g_program.setUniform("MaxTessLevel", max_tess);
//g_program.setUniform("MaxTessLevel", 20.0f);
g_program.setUniform("NearClip", 0.1f);
g_program.setUniform("FarClip", 175.0f);
g_program.setUniform("NearFog", 10.0f);
g_program.setUniform("FarFog", 125.0f);
g_program.setUniform("Light0.position", vec3(L0POSITION));
g_program.setUniform("Light0.La", vec3(L0AMBIENT));
g_program.setUniform("Light0.Ld", vec3(L0DIFFUSE));
GLuint terrainmap = SOIL_load_OGL_texture (
ROOT_PATH_RELATIVE TEXTURE_DIR "heightmap-vlarge.png",
SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_LOAD_L );
GLuint watermap = SOIL_load_OGL_texture (
ROOT_PATH_RELATIVE TEXTURE_DIR "watermap.jpg",
SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_LOAD_L );
GLuint ttex1 = SOIL_load_OGL_texture (
ROOT_PATH_RELATIVE TEXTURE_DIR "grass.jpg",
SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_LOAD_L );
GLuint ttex2 = SOIL_load_OGL_texture (
ROOT_PATH_RELATIVE TEXTURE_DIR "stonesnow.jpg",
SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_LOAD_L );
GLuint ttex3 = SOIL_load_OGL_texture (
ROOT_PATH_RELATIVE TEXTURE_DIR "water.jpg",
SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_LOAD_L );
//.........这里部分代码省略.........