Slick Forums

Discuss the Slick 2D Library
It is currently Sun Nov 19, 2017 2:49 am

All times are UTC




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Mon Mar 05, 2012 8:07 am 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
Implementing this into the texture loader is not a problem. How ever the PNG decoder does not know such formats and so graphics with this formats can't ever be loaded. I limited the enumerators I defined to those that can be used along with the PNG decoder.

Nitram

_________________
http://illarion.org


Top
 Profile  
 
PostPosted: Mon Mar 05, 2012 9:10 am 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Always write I small test "BasicGame" :) Units test are totally useless for game developement since you always want to SEE something :D IMHO!

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
PostPosted: Mon Mar 05, 2012 2:20 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
Nitram wrote:
Implementing this into the texture loader is not a problem. How ever the PNG decoder does not know such formats and so graphics with this formats can't ever be loaded. I limited the enumerators I defined to those that can be used along with the PNG decoder.

Nitram

I plan to overload InternalTextureLoader with an internalFormat parameter, allowing users to specify the internal format even if the PNG/image data is using RGBA. Useful for forcing grayscale/luminance/etc. as well as specifying an internal format for off-screen images (i.e. not loaded from file). :)


Top
 Profile  
 
PostPosted: Mon Mar 05, 2012 3:36 pm 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
Uh... careful there.
For the format of offscreen-images: all cool

Forcing the texture format of and image to something different: problems in most cases.
Doing such a thing requires to convert the textures BEFORE they are load into the textures. Else the byte data does not match.
Within limits the PNG decoder is able to perform such conversations. But not for any and all cases.

For example there is no equivalent in PNG pictures to the OpenGL mode "ALPHA" or the "INTENSITY" mode.

Nitram

_________________
http://illarion.org


Top
 Profile  
 
PostPosted: Mon Mar 05, 2012 4:52 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
Nitram wrote:
Uh... careful there.
For the format of offscreen-images: all cool

Forcing the texture format of and image to something different: problems in most cases.
Doing such a thing requires to convert the textures BEFORE they are load into the textures. Else the byte data does not match.
Within limits the PNG decoder is able to perform such conversations. But not for any and all cases.

For example there is no equivalent in PNG pictures to the OpenGL mode "ALPHA" or the "INTENSITY" mode.

Nitram

With glTexImage2D we can provide two formats:
internalFormat - Used to specify how OpenGL should store the texture internally in vram
format - Used to specify what kind of format OpenGL should expect from the input ByteBuffer (I don't plan on changing this)

In other words, say we load an RGBA image from a PNG file. The format needs to match the PNG file, so it needs to be RGBA, but we can specify a different format to store the texture internally, such as GL_LUMINANCE, GL_RGB, or GL_RGB4 (taking up less memory and usually rendering more efficiently). It also provides a simple manner of converting to grayscale on the fly.

See the bottom of this page for details:
http://www.flipcode.com/archives/Advanc ... ping.shtml


Top
 Profile  
 
PostPosted: Mon Mar 05, 2012 6:05 pm 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
I totally forgot about this one O.o

How ever the addition I created identifies the proper format. If setting the internalFormat should be done separately that doesn't have much to do with the stuff I wrote, does it?

Nitram

_________________
http://illarion.org


Top
 Profile  
 
PostPosted: Mon Mar 05, 2012 6:08 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
Nah, I don't think it affects your code. If other devs are in favour, I'll expose internalFormat and add INTENSITY/ALPHA as constants in the Format class.


Top
 Profile  
 
PostPosted: Mon Mar 05, 2012 8:04 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
If you want to load an ALPHA, LUMINANCE or INTENSITY image then just use a gray scale PNG.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Mon Mar 05, 2012 11:25 pm 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
Testcase is done and well... its working.

Image

The pull for the required changes is requested.

Nitram

_________________
http://illarion.org


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 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