本文整理汇总了C++中ShaderProgram::build方法的典型用法代码示例。如果您正苦于以下问题:C++ ShaderProgram::build方法的具体用法?C++ ShaderProgram::build怎么用?C++ ShaderProgram::build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderProgram
的用法示例。
在下文中一共展示了ShaderProgram::build方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createProgram
static ShaderProgram* createProgram( ShaderProgramIndex index )
{
ShaderProgram* program = nullptr;
Ptr<Data> vertex_data;
Ptr<Data> pixel_data;
switch( index )
{
case kShaderProgram_Color:
{
program = new ShaderProgram();
vertex_data = Assets::loadFile( "standard/shaders/test_vertex.glsl" );
pixel_data = Assets::loadFile( "standard/shaders/test_fragment.glsl" );
}
break;
default:
break;
}
if( vertex_data == nullptr || fragment_data == nullptr )
return nullptr;
program->setVertexSource( vertex_data->ptr() );
program->setFragmentSource( fragment_data->ptr() );
if( !program->build() )
return nullptr;
if( !program-> )
return program;
}
示例2: initialize
void initialize()
{
ChangeCurrentOpenGLContext ctx(opengl_context_ptr);
OpenGLBindings *b = new OpenGLBindings();
if (flextInit(opengl_context_ptr, b) == 0)
{
LOG_ERROR << "Failed to initialize flextGL.";
exit(-1);
}
gl(b);
input_data.allocate(352, 424 * 10);
for(int i = 0; i < 3; ++i)
stage1_data[i].allocate(512, 424);
if(do_debug) stage1_debug.allocate(512, 424);
stage1_infrared.allocate(512, 424);
for(int i = 0; i < 2; ++i)
filter1_data[i].allocate(512, 424);
filter1_max_edge_test.allocate(512, 424);
if(do_debug) filter1_debug.allocate(512, 424);
if(do_debug) stage2_debug.allocate(512, 424);
stage2_depth.allocate(512, 424);
stage2_depth_and_ir_sum.allocate(512, 424);
if(do_debug) filter2_debug.allocate(512, 424);
filter2_depth.allocate(512, 424);
stage1.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
stage1.setFragmentShader(loadShaderSource(shader_folder + "stage1.fs"));
stage1.build();
filter1.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
filter1.setFragmentShader(loadShaderSource(shader_folder + "filter1.fs"));
filter1.build();
stage2.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
stage2.setFragmentShader(loadShaderSource(shader_folder + "stage2.fs"));
stage2.build();
filter2.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
filter2.setFragmentShader(loadShaderSource(shader_folder + "filter2.fs"));
filter2.build();
if(do_debug)
{
debug.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
debug.setFragmentShader(loadShaderSource(shader_folder + "debug.fs"));
debug.build();
}
GLenum debug_attachment = do_debug ? GL_COLOR_ATTACHMENT0 : GL_NONE;
gl()->glGenFramebuffers(1, &stage1_framebuffer);
gl()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, stage1_framebuffer);
const GLenum stage1_buffers[] = { debug_attachment, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3, GL_COLOR_ATTACHMENT4 };
gl()->glDrawBuffers(5, stage1_buffers);
if(do_debug) gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, stage1_debug.texture, 0);
gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_RECTANGLE, stage1_data[0].texture, 0);
gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_RECTANGLE, stage1_data[1].texture, 0);
gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_RECTANGLE, stage1_data[2].texture, 0);
gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT4, GL_TEXTURE_RECTANGLE, stage1_infrared.texture, 0);
gl()->glGenFramebuffers(1, &filter1_framebuffer);
gl()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, filter1_framebuffer);
const GLenum filter1_buffers[] = { debug_attachment, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
gl()->glDrawBuffers(4, filter1_buffers);
if(do_debug) gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, filter1_debug.texture, 0);
gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_RECTANGLE, filter1_data[0].texture, 0);
gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_RECTANGLE, filter1_data[1].texture, 0);
gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_RECTANGLE, filter1_max_edge_test.texture, 0);
gl()->glGenFramebuffers(1, &stage2_framebuffer);
gl()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, stage2_framebuffer);
const GLenum stage2_buffers[] = { debug_attachment, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
gl()->glDrawBuffers(3, stage2_buffers);
if(do_debug) gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, stage2_debug.texture, 0);
gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_RECTANGLE, stage2_depth.texture, 0);
gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_RECTANGLE, stage2_depth_and_ir_sum.texture, 0);
gl()->glGenFramebuffers(1, &filter2_framebuffer);
gl()->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, filter2_framebuffer);
const GLenum filter2_buffers[] = { debug_attachment, GL_COLOR_ATTACHMENT1 };
gl()->glDrawBuffers(2, filter2_buffers);
if(do_debug) gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, filter2_debug.texture, 0);
gl()->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_RECTANGLE, filter2_depth.texture, 0);
//.........这里部分代码省略.........