Slick Forums

Discuss the Slick 2D Library
It is currently Tue May 21, 2013 9:52 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Jan 26, 2012 10:54 pm 
Offline

Joined: Thu Apr 14, 2011 8:36 pm
Posts: 2
Hey there,

I noticed something weird when using Image.getColor.
I have an OpenGL displaylist containing my terrain. When generating the displaylist I get the color of an Image at every point of the heightmap, using getColor(xx,yy) in my for-loop. However, I've noticed that after I did that, my terrain suddenly got the heightmap texture. So I did some debugging and when I removed the getColor line for checking my height, the texture didn't change. I've looked through the source code but can't find anything that causes this.

Anyone got an idea why this happens/how this can be fixed?


Top
 Profile  
 
PostPosted: Sat May 12, 2012 8:49 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1467
Yes, it binds a texture.

The first time it's called, it copies pixels from the backing texture via glGetTexImage. The data is cached until next time you call flushPixelData() or whenever you change the image through getGraphcis().flush() -- that will set the data to null, forcing it to copy next time you try to call getColor.

Calling getColor beforehand and then being careful not to use getGraphics() will ensure that it only binds once.

For maximum performance, load the image into a byte buffer using Slick's LoadableImageData utility, and then read the pixel data directly. Using Image.getColor for your height map means an OpenGL texture has to be constructed for something that you'll never need to show on-screen and the data needs to be copied into an array using glGetTexImage.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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