0

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.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Andrew
  • 1,109
  • 1
  • 15
  • 27

1 Answers1

2

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.

Moby Disk
  • 3,761
  • 1
  • 19
  • 38
  • Thanks for the advice. The SDL which uses libpng worked with GL_RGBA16. The only error i get now is that the SDL_GetError(); specifies that i use sRGB and it is not the correct color format. The image is still being displayed with higher quality then before but it is upside down even if i specified from coordinates to be drawn normal. Still an improvement. Thanks again. – Andrew Jan 28 '14 at 20:38