本文整理汇总了C++中GLShader::createProgFromShaders方法的典型用法代码示例。如果您正苦于以下问题:C++ GLShader::createProgFromShaders方法的具体用法?C++ GLShader::createProgFromShaders怎么用?C++ GLShader::createProgFromShaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLShader
的用法示例。
在下文中一共展示了GLShader::createProgFromShaders方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createShader
/**
* Create a shader, optimised for the specific splat rendering used
**/
GLShader* RendererHeightmap::createShader(RenderOpenGL* render, Heightmap* heightmap)
{
CHECK_OPENGL_ERROR;
GLShader* s = new GLShader(0);
char* vertex_code = s->loadCodeFile("phong_static.glslv");
GLuint vertex = s->createShader(GL_VERTEX_SHADER, vertex_code);
free(vertex_code);
if (vertex == 0) {
GL_LOG("Invalid vertex shader");
return NULL;
}
char* base_fragment_code = s->loadCodeFile("phong_splat.glslf");
char* diffuse_code = RendererHeightmap::createShaderFunction_diffuseColor(heightmap);
const char* strings[3];
strings[0] = "#version 130\n";
strings[1] = base_fragment_code;
strings[2] = diffuse_code;
GLuint fragment = s->createShader(GL_FRAGMENT_SHADER, 3, strings);
free(base_fragment_code);
free(diffuse_code);
if (fragment == 0) {
glDeleteShader(vertex);
GL_LOG("Invalid fragment shader");
return NULL;
}
bool result = s->createProgFromShaders(vertex, fragment);
glDeleteShader(vertex);
glDeleteShader(fragment);
if (!result) {
return NULL;
}
glUseProgram(s->p());
glUniform1i(s->uniform("uTex"), 0);
glUniform1i(s->uniform("uShadowMap"), 1);
glUniform1i(s->uniform("uNormal"), 2);
glUniform1i(s->uniform("uLightmap"), 3);
glUniform1i(s->uniform("uDayNight"), 4);
glUniform1i(s->uniform("uAlphaMap"), 0);
glUniform1i(s->uniform("uLayers[0]"), 5);
glUniform1i(s->uniform("uLayers[1]"), 6);
glUniform1i(s->uniform("uLayers[2]"), 7);
glUniform1i(s->uniform("uLayers[3]"), 8);
glUniform1i(s->uniform("uLightmap"), 9);
glUniform1i(s->uniform("uDetail[0]"), 10);
glUniform1i(s->uniform("uDetail[1]"), 11);
glUniform1i(s->uniform("uDetail[2]"), 12);
glUniform1i(s->uniform("uDetail[3]"), 13);
CHECK_OPENGL_ERROR;
return s;
}