fixed color linearity, and tweaked for VR
[vrfileman] / src / texture.cc
index 95d34e3..f332efa 100644 (file)
@@ -110,6 +110,14 @@ void Texture::set_filtering(unsigned int min_filt, unsigned int mag_filt)
        glTexParameteri(target, GL_TEXTURE_MAG_FILTER, mag_filt);
 }
 
+void Texture::set_anisotropy(int aniso)
+{
+       if(GLEW_EXT_texture_filter_anisotropic) {
+               glBindTexture(target, id);
+               glTexParameteri(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso);
+       }
+}
+
 unsigned int Texture::get_format() const
 {
        return texfmt;
@@ -345,14 +353,17 @@ static int glfmt_from_ifmt(unsigned int ifmt)
        switch(ifmt) {
        case GL_LUMINANCE16F:
        case GL_LUMINANCE32F:
+       case GL_SLUMINANCE:
                return GL_LUMINANCE;
 
        case GL_RGB16F:
        case GL_RGB32F:
+       case GL_SRGB:
                return GL_RGB;
 
        case GL_RGBA16F:
        case GL_RGBA32F:
+       case GL_SRGB_ALPHA:
                return GL_RGBA;
 
        default:
@@ -385,17 +396,23 @@ static int glifmt_from_imgfmt(Image::Format fmt)
 {
        switch(fmt) {
        case Image::FMT_GREY:
-               return GL_LUMINANCE;
+               return GLEW_EXT_texture_sRGB ? GL_SLUMINANCE : GL_LUMINANCE;
+
        case Image::FMT_GREY_FLOAT:
                return GL_LUMINANCE16F;
+
        case Image::FMT_RGB:
-               return GL_RGB;
+               return GLEW_EXT_texture_sRGB ? GL_SRGB : GL_RGB;
+
        case Image::FMT_RGB_FLOAT:
                return GL_RGB16F;
+
        case Image::FMT_RGBA:
-               return GL_RGBA;
+               return GLEW_EXT_texture_sRGB ? GL_SRGB_ALPHA : GL_RGBA;
+
        case Image::FMT_RGBA_FLOAT:
                return GL_RGBA16F;
+
        default:
                break;
        }
@@ -406,14 +423,17 @@ static Image::Format imgfmt_from_glifmt(unsigned int ifmt)
 {
        switch(ifmt) {
        case GL_LUMINANCE:
+       case GL_SLUMINANCE:
                return Image::FMT_GREY;
        case GL_LUMINANCE16F:
                return Image::FMT_GREY_FLOAT;
        case GL_RGB:
+       case GL_SRGB:
                return Image::FMT_RGB;
        case GL_RGB16F:
                return Image::FMT_RGB_FLOAT;
        case GL_RGBA:
+       case GL_SRGB_ALPHA:
                return Image::FMT_RGBA;
        case GL_RGBA16F:
                return Image::FMT_RGBA_FLOAT;