lwjgl FBO texture rendering problem

Good day
I have a problem while rendering to texture using FBO. I followed tutorial on lwjgl.org and got it to work with my project, but as you can see on the bottom picture it doesn’t work as it should. You can see this funny lines on all of my textures which should not be there (top-right to bottom-left, also edges are strangely distorted). I had this problem before when i started with lwjgl and made basic textures and stuff, but i don’t remember how i fixed it.
I’m rendering cubes with VBO’s and i have blend, cull_face and gl_texture_mag_filter gl_nearest enabled, but anyway problem occurs on basic openGL texture calls too.

Help me to solve this mystery? ::slight_smile:

example:

http://img837.imageshack.us/img837/3875/fbo.png

Did you forget to set the glViewport before rendering to the FBO?

No, I have glViewport before rendering to the fbo.

this is before rendering to fbo:


glViewport (0, 0, Display.getWidth(), Display.getHeight());  
glBindTexture(GL_TEXTURE_2D, 0);                            
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, openGL.framebufferID);
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);          
glLoadIdentity ();                                       
glTranslatef (0.0f, 0.0f, intoTheScreen); //z = -6.0f

//game renders

and later to display fbo texture:


glEnable(GL_TEXTURE_2D);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);     
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
//glViewport(0, 0, Display.getWidth(), Display.getHeight());
glLoadIdentity ();                                             
glTranslatef (0.0f, 0.0f, intoTheScreen);     
glColor3f(1, 1, 1);
renderScreen();     

renderScreen method:


//don't know if this is ok to use with fbo render...
//this is how I usually render 2d HUD and stuff
public void renderScreen() {
	GL11.glPushMatrix();
	glMatrixMode(GL_PROJECTION);
	GL11.glLoadIdentity();
	GL11.glOrtho(0, Display.getWidth(),0, Display.getHeight(), -1, 1);
	glViewport(0, 0, Display.getWidth(), Display.getHeight());
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glEnable(GL_TEXTURE_2D);
		
	glBindTexture(GL_TEXTURE_2D, openGL.colorTextureID); 
	glBegin(GL_QUADS);
	glTexCoord2f(0.0f, 0.0f); glVertex2i(0,   0);  
	glTexCoord2f(1.0f, 0.0f); glVertex2i(Display.getWidth(),  0); 
	glTexCoord2f(1.0f, 1.0f); glVertex2i(Display.getWidth(), Display.getHeight()); 
	glTexCoord2f(0.0f, 1.0f); glVertex2i(0, Display.getHeight());
	glEnd();
		
	glPopMatrix();
}

  • But is your texture the same size as the screen?
  • Blending + depth testing? BUBUUUUUUUUUU!

I can’t see anything specifically that is wrong in your code…

Ok I tried making fixed display size of 1280x720, then use same size for fbo and final screen display method. I also played around with pixelformat of display and I did some optimizing for my game render methods (commented out some stuff). Result is still the same :P.
If fbo code is ok then i must have done something wrong with vbo’s, because there is nothing else that could go wrong (maybe).

Try to change

GL11.glOrtho(0, Display.getWidth(),0, Display.getHeight(), -1, 1);

to

GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, -1, 1);

Same thing, but now screen is upside down.

Ugh… I don’t know… Can you post a simplified test showing the problem that I can run on my computer? ._.

Here you go :
http://dl.dropbox.com/u/31393301/3Dproject.rar
straight from eclipse. (I removed some classes)

And thank you for helping.

I tested your code. Blending is what causes the seams everywhere, your FBO is working fine, you have an unused thread, your game loop is in the constructor of Game, you have a tendency to create a new class (with lower case names) for each function, e.t.c. >_>

I disabled gl_blend and moved game loop so its now running in a thread. It works^^