Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (546)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  lwjgl FBO texture rendering problem  (Read 3343 times)
0 Members and 1 Guest are viewing this topic.
Offline PaidGEEK

Senior Member


Medals: 5
Projects: 3


twitter.com/PaidGEEK


« Posted 2012-02-14 21:56:13 »

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? Roll Eyes

example:

Improvisational programmer.
Online theagentd
« Reply #1 - Posted 2012-02-14 22:42:58 »

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

Myomyomyo.
Offline PaidGEEK

Senior Member


Medals: 5
Projects: 3


twitter.com/PaidGEEK


« Reply #2 - Posted 2012-02-15 14:28:32 »

No, I have glViewport before rendering to the fbo.

this is before rendering to fbo:
1  
2  
3  
4  
5  
6  
7  
8  
9  
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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
//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();
}

Improvisational programmer.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online theagentd
« Reply #3 - Posted 2012-02-16 08:56:09 »

 - 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....

Myomyomyo.
Offline PaidGEEK

Senior Member


Medals: 5
Projects: 3


twitter.com/PaidGEEK


« Reply #4 - Posted 2012-02-16 13:54:22 »

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  Tongue.
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).

Improvisational programmer.
Online theagentd
« Reply #5 - Posted 2012-02-16 18:04:41 »

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

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

Myomyomyo.
Offline PaidGEEK

Senior Member


Medals: 5
Projects: 3


twitter.com/PaidGEEK


« Reply #6 - Posted 2012-02-16 18:28:19 »

Same thing, but now screen is upside down.

Improvisational programmer.
Online theagentd
« Reply #7 - Posted 2012-02-16 19:50:50 »

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

Myomyomyo.
Offline PaidGEEK

Senior Member


Medals: 5
Projects: 3


twitter.com/PaidGEEK


« Reply #8 - Posted 2012-02-16 21:11:31 »

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

And thank you for helping.

Improvisational programmer.
Online theagentd
« Reply #9 - Posted 2012-02-17 09:48:27 »

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. >_>

Myomyomyo.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline PaidGEEK

Senior Member


Medals: 5
Projects: 3


twitter.com/PaidGEEK


« Reply #10 - Posted 2012-02-17 13:30:20 »

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

Improvisational programmer.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (20 views)
2014-08-19 09:29:53

Tekkerue (21 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (55 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (28 views)
2014-08-08 02:01:56

Norakomi (35 views)
2014-08-06 19:49:38

BurntPizza (65 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!