Hi
I am trying to build a pipeline which includes multiple shaderprograms. Each of these shaderprograms, except the first one, will render output to texture and use previous render as a source. The first one will take a picture as a source and it is loaded to m_uiTexture. Shaderprograms are also compiled and linked beforehand and they should work just fine so I didn't include them here. The samplers are defined beforehand so I can loop the actual rendering with minimal overhead.
GLuint m_uiTexture;
GLuint framebuffer;
GLuint renderbuffer;
GLuint textures[2];
glGenFramebuffers(1, &framebuffer);
glGenRenderbuffers(1, &renderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB8_OES, 512, 512);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glGenTextures(2, textures);
glUseProgram(m_ShaderProgramScale.uiId);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_uiTexture);
glUniform1i(m_ShaderProgramScale.auiLoc[eSampler], 0);
glUseProgram(m_ShaderProgramDOG.uiId);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, textures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glUniform1i(m_ShaderProgramDOG.auiLoc[eSampler], 1);
glUseProgram(m_ShaderProgramExtrema.uiId);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, textures[1]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glUniform1i(m_ShaderProgramExtrema.auiLoc[eSampler], 2);
Loop starts here
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0], 0);
glUseProgram(m_ShaderProgramScale.uiId);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1], 0);
glUseProgram(m_ShaderProgramDOG.uiId);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0], 0);
glUseProgram(m_ShaderProgramExtrema.uiId);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
For some reason this doesn't give the expected result. Could someone tell me why?
-hnyk
I have now tracked down the problem to this instruction: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
The system works fine when I load the texture from a file and then render over it, but when I try to create a blank texture with the above instruction, it doesn't work.
Any ideas what is wrong and how can I fix it?
Okay the problem was with texture filters and now it seems to work :)
hnyk2009-08-03 11:43:45