DevIL texture quality issue?

Started by sir_wojciech, January 12, 2006, 18:10:48

Previous topic - Next topic


I have the same problem (at least I think so) as 1 thread on this forum, but still after reading it I couldn't solve the problem.
This is the texture viewed in lets say Paint Shop Pro:

And this is the same texture but viewed in my application:

As you see there's a mayor difference.
My loading code:
package game;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import org.lwjgl.devil.IL;
import org.lwjgl.devil.ILU;
import org.lwjgl.opengl.GL11;

public class TextureLoader
    public static int load(String path)
        int pixelFormat = 0;
        IntBuffer image = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
        IL.ilConvertImage(IL.ilGetInteger(IL.IL_IMAGE_FORMAT), IL.IL_BYTE);
        ByteBuffer scratch = ByteBuffer.allocateDirect(IL.ilGetInteger(IL.IL_IMAGE_WIDTH) * IL.ilGetInteger(IL.IL_IMAGE_HEIGHT) * 4);
        IL.ilCopyPixels(0, 0, 0, IL.ilGetInteger(IL.IL_IMAGE_WIDTH), IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 1, IL.ilGetInteger(IL.IL_IMAGE_FORMAT), IL.IL_BYTE, scratch);
        IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0));
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        if(IL.ilGetInteger(IL.IL_IMAGE_FORMAT) == IL.IL_RGB)
            pixelFormat = GL11.GL_RGB;
        else if(IL.ilGetInteger(IL.IL_IMAGE_FORMAT) == IL.IL_RGBA)
            pixelFormat = GL11.GL_RGBA;
        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, pixelFormat, IL.ilGetInteger(IL.IL_IMAGE_WIDTH),
                IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 0, pixelFormat, GL11.GL_UNSIGNED_BYTE, scratch);
        return buf.get(0);

Any solution?

Thanks in advance!

Fool Running

That looks like 16 bit color.
What are you passing into the PixelFormat constructor that you are giving to the Display.create() method?
Its also possible that your video card automatically compreses(sp) the texture in OpenGL and turns it into 16 bit color format because of this.

EDIT: Its also possible (if you are running in a window) that your current desktop bpp is set to 16 bit and Paint Shop Pro dithers the image. If you need to use 16bpp try turning dithering "on" in OpenGL. That should help a little.  :P
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D


Nah, it's almost 100% that my app is set to 32 bpp (and desktop :D). Don't know actually about the Graphics Card changing anything, though all games opengl and nonopengl work properly.

My PixelFormat looks like:
new PixelFormat(8, 24, 0, samples);

BTW. How can you set dithering in OpenGL?

Thanks anyways :)


If you set dithering with

than it doesn't work (change).

Fool Running

QuoteIf you set dithering with

than it doesn't work (change).
That's what I meant. Too bad it doesn't work. :?
I'm almost positive that what you are seeing is the result of 16bit color (or some other loss of color data)...

What about the image file? Is it possible that you are losing color data in your image format (i.e. By using JPEG images or something)?
Although I've never seen JPEG mess with an image that badly :lol:

EDIT: Someone else can chime in here  :D
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D


It's defenetly because the texture or display is 16 bit.

Go to your Display Properties and make sure that the texture preferences is set to high quality in OpenGL.


Ok. I made some tests and it came out that the problem was caused by the ATI Catalyst drivers (had 5.13). When I updated them to the newest 6.1 version everything looked and worked fine.