Lo que necesita es poner la textura en una ranura específica, luego use una muestra para leer de ella. En su aplicación:
GLuint frameBuffer;
glGenFramebuffersEXT(1, &frameBuffer); //Create a frame buffer
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBuffer); //Bind it so we draw to it
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, yourTexture, 0); //Attach yourTexture so drawing goes into it
//Draw here and it'll go into yourTexture.
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); //Unbind the framebuffer so that you can draw normally again
//Here we put the texture in slot 1.
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, yourTexture);
glActiveTexture(GL_TEXTURE0); //Don't forget to go back to GL_TEXTURE0 if you're going to do more drawing later
//Now we tell your shader where to look.
GLint var = glGetUniformLocationARB(yourShaderProgram, "yourSampler");
glUniform1i(var, 1); //We use 1 here because we used GL_TEXTURE1 to bind our texture
Y en su fragment shader:
uniform sampler2D yourSampler;
void main()
{
gl_FragColor = texture2D(yourSampler, whateverCoordinatesYouWant);
}
Puede usar esto con GL_TEXTURE2
y así sucesivamente para acceder a más texturas en su sombreado.
y más, tendría que seleccionar el drawbuffer, ¿verdad? teniendo algo así como: glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT); \t glActiveTexture (GL_TEXTURE1); \t glBindTexture (GL_TEXTURE_2D, yourTexture); // dibuja GLint var = glGetUniformLocationARB (yourShaderProgram, "tuMuestra)"; glUniform1i (var, 1); // Usamos 1 aquí porque usamos GL_TEXTURE1 para unir nuestra textura – Donny
@Donny Estás mezclando dos cosas completamente diferentes (es decir, renderizar en un framebuffer y leer desde una textura previamente renderizada). –
Lo que estoy tratando de hacer es renderizar a un framebuffer, tomar ese resultado en un shader. La idea es que así puedo generar muchas texturas diferentes generadas en el framebuffer. Como resultado, quiero mezclar todas estas texturas. ¿Esto es posible? – Donny