LWJGL
May 20, 2012, 23:04:10 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: DevIL texture quality issue?  (Read 5118 times)
sir_wojciech
Newbie
*
Posts: 38


« on: January 12, 2006, 10:10:48 »

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:
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.ilGenImages(image);
        IL.ilBindImage(image.get(0));
        IL.ilLoadImage(path);
        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.glGenTextures(buf);
        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!
Logged
Fool Running
Nerdus Imperius
*****
Posts: 647


« Reply #1 on: January 12, 2006, 12:32:22 »

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.  Tongue
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
sir_wojciech
Newbie
*
Posts: 38


« Reply #2 on: January 12, 2006, 13:32:56 »

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

My PixelFormat looks like:
Code:

new PixelFormat(8, 24, 0, samples);


BTW. How can you set dithering in OpenGL?

Thanks anyways Smiley
Logged
sir_wojciech
Newbie
*
Posts: 38


« Reply #3 on: January 12, 2006, 13:36:47 »

If you set dithering with
Code:
GL11.glEnable(GL11.GL_DITHER);

than it doesn't work (change).
Logged
Fool Running
Nerdus Imperius
*****
Posts: 647


« Reply #4 on: January 13, 2006, 07:59:21 »

Quote
If you set dithering with
Code:
GL11.glEnable(GL11.GL_DITHER);

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  Cheesy
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
tomb
Talks Too Much
***
Posts: 147


« Reply #5 on: January 14, 2006, 04:39:27 »

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.
Logged
sir_wojciech
Newbie
*
Posts: 38


« Reply #6 on: January 22, 2006, 02:04:04 »

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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!