Hello,
i'm just starting to explore LWJGL and want to try it using for making an isometric 2D game.
My general question is how i can load an image from disk and display it with glDrawPixels(). glDrawPixels() is straight forward enough but it's all these pixel formats and types i get confused about. I created a picture with Paint.NET with some transparent parts and saved it as .png image with pixeldepth 32. Now if i load this imagedata into memory, what format/type is it in? Furthermore, what format/type must the screenpixels have to properly display the image or is this irrelevant?
I realised that i could also use a quad and project the image as a texture on it. This has the advantage in that i can load the image easily as a texture with the Slick-util library (i haven't found a tool in Slick-util that can load images into memory). However, it seems to me that displaying images as a textured quad is slower than glDrawPixels() since it can be rotated, scaled and translated. This is why i thought i use glDrawPixels() which also seems the more natural thing to do when creating isometric 2D games.
Can somebody help me?
Cheers,
-Harry
The proper way to draw images in opengl is with a textured quad. Its not slow. I have been told that glDrawPixels can be slow. I have not tested this however.
As for image formats, when you bind your texture you tell opengl what that format is. I currently use TWLs PNGLoader than loads the data directly into a byte buffer and this will give a RGB or RGBA pixel format (unsigned byte per component). IIRC slick uses this too. However getting the data out of a Buffered Image that I loaded with ImageIO is not so hard. You just need to create a image in the right format and then get the rasters. However this requires a bit more memory thrashing. There are some examples on the lwjgl wiki of how to do this.
hope this helps
Cheers
Thx deltOr,
i will try the texture approach. Maybe i'll later try to use glDrawPixels() just for fun... ;D
Cheers!