Slick Forums

Discuss the Slick 2D Library
It is currently Fri Dec 06, 2019 12:21 am

All times are UTC




Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Wed Nov 16, 2011 4:25 pm 
Offline
Regular
User avatar

Joined: Wed Apr 27, 2011 3:29 pm
Posts: 197
Location: United State of California
That might be part of it but it still doesn't explain the whole thing. The testing I've done produced inconsistent results so I couldn't even compensate for reversed or translated coordinates. Also, there seem to be color and transform inconsistencies.

_________________
Current Testing Machine:
Windows 7 x64, 4GB RAM DDR3, 3.3ghz AMD Athlon II X3 455, AMD Radeon HD 6800 series.


Top
 Profile  
 
PostPosted: Wed Nov 16, 2011 5:24 pm 
Offline
User avatar

Joined: Fri Oct 07, 2011 11:05 pm
Posts: 97
Location: France, Nantes
raeleus wrote:
Also, there seem to be color and transform inconsistencies.
Color? :shock:

_________________
"The Keeper is aware. The Keeper understands. The Keeper has seen the enemy."


Top
 Profile  
 
PostPosted: Wed Nov 16, 2011 7:28 pm 
Offline
Regular
User avatar

Joined: Wed Apr 27, 2011 3:29 pm
Posts: 197
Location: United State of California
Yeah! I'm not in a position right now to reproduce this issue but what I remember is that I colored some other unrelated image or graphics object and it somehow affected the appearance of my next one. Truly bizarre but I didn't bother to document it because I figured it was broken and not worth anymore time.

_________________
Current Testing Machine:
Windows 7 x64, 4GB RAM DDR3, 3.3ghz AMD Athlon II X3 455, AMD Radeon HD 6800 series.


Top
 Profile  
 
PostPosted: Thu Nov 24, 2011 3:41 pm 
Offline
User avatar

Joined: Mon Jun 20, 2011 4:28 pm
Posts: 71
raeleus wrote:
Truly bizarre but I didn't bother to document it because I figured it was broken and not worth anymore time.


Yeah applies to many bugs with Slick, especially when using OpenGL directly - which, I know, isn't obviously supported


Top
 Profile  
 
PostPosted: Mon Mar 19, 2012 10:26 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
Some things to note.

  1. There is a memory leak using new Image(256, 256) and then getGraphics -- I proposed a fix in the dev branch. More details:
    bug report
    further discussion / implementation

    It looks like this:
    Code:
    img = Image.createOffscreenImage(256, 256); //<-- creates FBO-bound texture
    g2 = img.getGraphics(); //<-- FBO-bound texture already created, no memory leak

  2. When you call Graphics.flush(), the context is disabled. For example:
    Code:
    renderImage = Image.createOffscreenImage(256, 256);
    Graphics g2 = img.getGraphics();
    ... use it ...
    g2.flush(); //<-- now disabled

    From there, certain calls to g2 might not work as expected. Apparently copyArea did not check predraw/postdraw, which is why it would appear black. I've now fixed that in the dev branch; now you shouldn't need to draw your "outline" beforehand. For future reference, I would encourage using Graphics.setCurrent before rendering if you plan to switch contexts. Examples:
    Code:
    //I don't know why you'd want to do this... but let's say you do:
    g.flush(); //<-- disables the context
    Graphics.setCurrent(g); //<-- re-enables the context

    //here is a more realistic scenario
    Graphics.setCurrent(imgGraphics); //<-- anything below now safely goes to imgGraphics
    myImage.draw(0, 0, 800, 600); //<-- notice Graphics.drawImage isn't necessary
    imgGraphics.flush(); //<-- don't forget to disable once we're done...

  3. Because you are still using the same graphics context, you don't need to flush it that many times. Just flush it once and for all once you're done rendering everything to it.

Unfortunately because of the way that Kev tried to conform Slick to Java2D standards, there are a few bugs here and there that come up with context switches and other lower-level OpenGL stuff. If it were up to me the whole Slick library would be rewritten to conform to better OpenGL coding standards, but of course nobody would like that. :) I'll try to add more of these gotchas into the wikis when I get a chance.

Regarding the flipping, it's occurring because of some difference in the projection matrix between FBO graphics and on-screen graphics. Not sure, will have to look into it further. For now you can fix the image by either using offscreen rendering to copy your images, or simply flipping the image after copying it (getFlippedCopy).


Top
 Profile  
 
PostPosted: Tue Mar 20, 2012 12:25 am 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
  • Fixed in dev branch.
  • Overloaded copyArea with more parameters:
    xoffset/yoffset - Where to place the copied data on the destination/target image
    x/y - Where in the source to begin copying from
    width/height - How much to copy from the source
  • Added a test demonstrating proper copyArea vs. getGraphics technique


Top
 Profile  
 
PostPosted: Tue Mar 20, 2012 7:28 am 
Offline
Regular
User avatar

Joined: Wed Apr 27, 2011 3:29 pm
Posts: 197
Location: United State of California
Groovy! Thanks for doing that.

_________________
Current Testing Machine:
Windows 7 x64, 4GB RAM DDR3, 3.3ghz AMD Athlon II X3 455, AMD Radeon HD 6800 series.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Powered by phpBB® Forum Software © phpBB Group