Question

How can i load a PNG file that has 64 bit depth color in openGL? I have tried SOIL and SDL but he texture that it is displaying is white. For 32 bit depth works perfectly (only that if my PNG contains gradient it isn't displayed smoothly and the colors are washed out a little) -> something isn't working properly. I have tried on numeroues forums but nothing seems to fix my problem. Here is the function i use with SOIL:

    bool LoadGLTextures()                                  
    {
        texture = SOIL_load_OGL_texture 
    (
    "mountain.png",
    SOIL_LOAD_AUTO,
    SOIL_CREATE_NEW_ID,
    SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
    );


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    return true;
  }

when i draw the texture i use :

    glBindTexture(GL_TEXTURE_2D, texture);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    //Code for drawing quad with texture (glTexCoord and  glVertex)

I have my png file in my project directory.

Was it helpful?

Solution

There's 64-bit PNG files?? Let's see:

  1. The stb_image library used by SOIL does not support 64-bit PNG: http://nothings.org/stb_image.c
  2. SDL uses libpng, which should support everything.
  3. Make sure the texture is using GL_RGBA16.

I suggest trying to manually create a 64-bit texture, to make sure that your OpenGL implementation supports GL_RGBA16. Ex: Create a simple gradient of red, in memory, then load that as a texture. Then once you have that working, try loading the texture with SDL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top