|
mot
|
 |
« on: April 25, 2008, 02:12:53 » |
|
I'm looking for a replacement for DevIL to be able to switch to LWJGL 2.0 sometime... and I don't want to use the default Java libraries to be still able to strip the Windows JRE to the bare essentials.
It should be able to load JPEG and PNG or TGA with alpha channel and write at least one popular format (BMP, TGA, whatever). A pure Java portable implementation would be preferred over speed. Any suggestions?
I really need to load JPEG because some textures compress very well using JPEG and switching to a lossless format would make them way too big.
Custom image formats are not the best solution for me either, I like being able to do a "Slices" export from Photoshop and get the resulting PNG/JPEG files into the game without an additional conversion step.
Any suggestions are welcome, thanks!
|
|
|
|
|
Logged
|
|
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #2 on: May 15, 2008, 12:34:23 » |
|
I'm also having problems with the texture loading. Using this loader works: http://www.cokeandcode.com/info/showsrc/showsrc.php?src=../spaceinvaders104/org/newdawn/spaceinvaders/lwjgl/TextureLoader.javaBut this filters textures just with GL_Linear. I tryed to build mipmaps: GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, 3, texture.getImageWidth(), texture.getImageHeight(), GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, textureBuffer); but all i get is: java.lang.IllegalArgumentException: Number of remaining buffer elements is 196608, must be at least 262144 at org.lwjgl.BufferChecks.throwBufferSizeException(BufferChecks.java:130) Anybody got an idea how to fix this?
|
|
|
|
|
Logged
|
|
|
|
bobjob
Prolific Timewaster
   
Posts: 335
LWJGL: WOW SO GOOD
|
 |
« Reply #3 on: May 15, 2008, 14:53:54 » |
|
some ideas: (Im sure u tried some of these already, but ill try help the best i can)
what image format are you using? .jpg? if so then it could be a problem with the GL11.GL_RGBA change it to GL11.GL_RGB
have you changed the textureBuffer at all, is it back to its first position. does it need to be fliped.
double check that the numbers from getImageWidth, and getImageHieght are not actually bigger than the image you are using.
and make sure that the image is the power of 2.
|
|
|
|
|
Logged
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #4 on: May 16, 2008, 00:04:43 » |
|
You're right, it was the RGB thing, didn't see this one  Additionally, i needed to change the order in which 2 things were done.
|
|
|
|
|
Logged
|
|
|
|
|
mot
|
 |
« Reply #5 on: May 22, 2008, 05:13:08 » |
|
Someone mentioned it was possible to use DevIL from 1.1.4 with 2.0b1, so I tried it. And it works!
First I was getting library version mismatch errors when initializing OpenAL but solved it by shuffling the initialization code so that AL.create() is called BEFORE IL.create().
And 2.0b1 works fine for me without any additional modifications required.
|
|
|
|
|
Logged
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #6 on: May 26, 2008, 02:33:28 » |
|
I now ran into the next Problem, i can't get transparency to work. This Texture:  i load with: ... if (bufferedImage.getColorModel().hasAlpha()) { srcPixelFormat = GL11.GL_RGBA; System.out.println("loaded tex with alpha"); } else { srcPixelFormat = GL11.GL_RGB; System.out.println("loaded tex without alpha"); }
// convert that image into a byte buffer of texture data ByteBuffer textureBuffer = convertImageData(bufferedImage, texture);
// produce a texture from the byte buffer GL11.glTexImage2D(target, 0, dstPixelFormat, get2Fold(bufferedImage.getWidth()), get2Fold(bufferedImage.getHeight()), 0, srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer);
if (target == GL11.GL_TEXTURE_2D) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST); GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, 3, texture.getImageWidth(), texture.getImageHeight(), srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer); } ...
which tells me the texture has alpha. then i render with: tex.bind(); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND);
But it renders the texture with the transparent regions in black, not transparent. What could be wrong?
|
|
|
|
|
Logged
|
|
|
|
bobjob
Prolific Timewaster
   
Posts: 335
LWJGL: WOW SO GOOD
|
 |
« Reply #7 on: May 26, 2008, 02:51:40 » |
|
GL11.glAlphaFunc(GL11.GL_GREATER,0.1f); // sets aplha function GL11.glEnable(GL11.GL_ALPHA_TEST); // allows alpha channels or transperancy
|
|
|
|
|
Logged
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #8 on: May 26, 2008, 03:00:14 » |
|
I tried this before, unfortunately it does not change anything.
|
|
|
|
|
Logged
|
|
|
|
Orangy Tang
Talks Too Much
  
Posts: 199
|
 |
« Reply #9 on: May 26, 2008, 03:13:02 » |
|
Are you sure that both src and dest pixel formats are being set to RGBA?
Also, have you made sure to generate a texture id/object and have it currently bound (glBindTexture) before making your glTexImage2D calls?
Double also, I think you only need one of glTexImage2D / gluBuild2DMipmaps. glTexImage2D just uploads raw pixel data, gluBuild2DMipmaps resizes to power-of-two then uploads the texture and it's mipmaps. For now I'd get it working with one or the other first.
|
|
|
|
|
Logged
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #10 on: May 26, 2008, 03:31:13 » |
|
Are you sure that both src and dest pixel formats are being set to RGBA?
Also, have you made sure to generate a texture id/object and have it currently bound (glBindTexture) before making your glTexImage2D calls?
Double also, I think you only need one of glTexImage2D / gluBuild2DMipmaps. glTexImage2D just uploads raw pixel data, gluBuild2DMipmaps resizes to power-of-two then uploads the texture and it's mipmaps. For now I'd get it working with one or the other first.
yes, both of them are RGBA. yes, it is bound. you're right, gluBuild2DMipmaps is enough, i deleted the glTexImage2D statement, with no resulting changes. i have no idea whats wrong 
|
|
|
|
|
Logged
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #11 on: May 26, 2008, 04:47:21 » |
|
If i load the Image, the bufferedImage i get is from type TYPE_BYTE_BINARY, which has no alpha according to the documentation. However, bufferedImage.getColorModel().hasAlpha() returns true. Should i convert to something like TYPE_4BYTE_ABGR?
|
|
|
|
|
Logged
|
|
|
|
Rainer
Regular nerd
 
Posts: 71
|
 |
« Reply #12 on: May 26, 2008, 06:42:22 » |
|
found the error, really dumb one of course... GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, 3, texture.getImageWidth(), texture.getImageHeight(), srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer); changed to GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, 3, texture.getImageWidth(), texture.getImageHeight(), srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer); 
|
|
|
|
|
Logged
|
|
|
|
|