Slick Forums

Discuss the Slick 2D Library
It is currently Thu Dec 05, 2019 10:46 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Jan 13, 2012 12:22 am 
Offline

Joined: Fri Jan 06, 2012 2:15 am
Posts: 44
Matthias and I have been trying to track down what seems to be a bug in the thread posted below. I'm hoping somebody can help take a look and maybe help figure out what's going on.

"...somehow getGraphics() leaves a wrong GL_VIEWPORT size active at the time the LWJGLRenderer is syncing it's display size (eg at creation time, can manually sync later - eg for resizing support)."

viewtopic.php?f=18&t=4375


Top
 Profile  
 
PostPosted: Sat May 12, 2012 9:20 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
Image.getGraphics() will bind an FBO, i.e. glViewport will be set to that FBO's size. You need to call flush() after calling getGraphics to ensure that the FBO is no longer bound, and that the viewport is reset to the screen's dimensions. That should probably fix your problems with TWL.

In my opinion, getGraphics should ideally just return a value without binding any FBOs. However, because of the way Slick uses FBOs and multiple graphics contexts, this would mean you'd need to do the following:
Code:
g = img.getGraphics();
Graphics.setCurrent(g); //<-- needed to ensure the following line works
myImg.draw(0, 0); //<-- because we aren't using Graphics.drawImage, there is no predraw/postdraw
g.flush(); //<-- flushes/unbinds the FBO


In other words, a proper fix would lead to a lot of errors. Hopefully when it comes time to a significant Slick refactoring (if that ever happens), we can resolve this so that getGraphics isn't so ugly. :)


Top
 Profile  
 
PostPosted: Wed Dec 12, 2012 3:27 pm 
Offline

Joined: Mon Sep 10, 2012 10:47 am
Posts: 16
Hi,

I have encountered a similar problem (or I guess it's the same problem in a different guise). TWL rendering breaks after calling Image.createOffscreenImage(); for more details look here: http://slick.javaunlimited.net/viewtopic.php?f=18&t=5963. (I found this thread only afterwards.)

Calling getGraphics().flush() afterwards indeed solves the problem. I just report this so that others with similar problems can see this.

Since I have no idea how OpenGL works exactly (that's why I decided to use Slick and TWL in the first place), I can only hope that this won't have any side effects. Or will calling getGraphics() after the createOffscreenImage lead to memory leaks again?

-Kylearan


Top
 Profile  
 
PostPosted: Wed Dec 12, 2012 8:30 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
createOffscreenImage will not lead to a leak; you can then call getGraphics without any extra textures being allocated.

flush() is necessary after you're done with the offscreen image, regardless of whether you are using TWL. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group