View Full Version : How to bind texture and uniform block for separate shader stage?

03-15-2015, 07:03 AM
Opengl 4.1 introduce separate program:

But i have problem, how to separate set "uniform block" and "Texture" for each shader stage?

// i bind a pipeline, but how to separate set "Uniform block" and
// "Texture" for each shader stage.

//i want separate set texture for each stage
glBindTexture(GL_TEXTURE_2D, TextureID);

//Uniform block too, i want separate set for each stage.
glBindBufferBase(GL_UNIFORM_BUFFER, 0, VarBufferBlockID);

Ps: Sorry, i can't find anywhere to insert code, so i highlight it. thanks in advance.

Alfonse Reinheart
03-15-2015, 07:59 AM
Textures and uniform blocks are not per-stage; they're per-pipeline. So different programs in different stages could access the same texture image unit (https://www.opengl.org/wiki/Sampler_%28GLSL%29#Binding_textures_to_samplers) or uniform block binding point (https://www.opengl.org/wiki/Uniform_Buffer_Object#OpenGL_Usage). Or they can access different ones.

If you want them to use separate resources, it's up to you to assign each program to use separate resources.

03-15-2015, 07:58 PM
Thanks, I will assign resource for pipeline instead of shader stage. :)