I’m sorry about all the questions, but this one has been bothering for some hours now
Why is it that when I display my fbo attached texture, it is all stretched vertically? When I render directly to the framebuffer all is fine…
Here is OpenGl init code (2D as you can see):
void initGL() {
glGetIntegerv(GL_VIEWPORT, vPort.ptr);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0f, vPort[2], vPort[3],0f, -1f, 1f);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_DITHER);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(0.0f);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glAlphaFunc(GL_GREATER,0.1);
glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glShadeModel(GL_FLAT);
glPolygonMode(GL_FRONT,GL_FILL);
}
Here the FBO binding unbinding code:
public void bindFbo()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbo);
glPushAttrib(GL_VIEWPORT_BIT | GL_COLOR_BUFFER_BIT);
glViewport( 0, 0, fbo.w, fbo.h);
}
public void unbindFbo()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glPopAttrib();
}
And last my texture display code:
glBindTexture(GL_TEXTURE_2D, fbo.texture);
glLoadIdentity();
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2d(1f,1f); glVertex3f(fbo.w,0f,0f);
glTexCoord2d(0f,1f); glVertex3f(0f,0f,0f);
glTexCoord2d(1f,0f); glVertex3f(fbo.w,fbo.h,0f);
glTexCoord2d(0f,0f); glVertex3f(0f,fbo.h,0f);
glEnd();