]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pixelformat.cpp
Prefer sized internal formats when possible
[libs/gl.git] / source / pixelformat.cpp
index 679c6467503e3d4d059668890b1eb2922eb54426..3fdf6942c63cc606c04babdf54316330878ec1f9 100644 (file)
@@ -96,6 +96,30 @@ PixelFormat get_base_pixelformat(PixelFormat pf)
        case LUMINANCE_ALPHA32F:
        case SLUMINANCE_ALPHA:
        case SLUMINANCE8_ALPHA8: return LUMINANCE_ALPHA;
+       case DEPTH_COMPONENT16:
+       case DEPTH_COMPONENT24:
+       case DEPTH_COMPONENT32: return DEPTH_COMPONENT;
+       default: return pf;
+       }
+}
+
+PixelFormat get_sized_pixelformat(PixelFormat pf)
+{
+       switch(pf)
+       {
+       case RGB: return RGB8;
+       case RGBA: return RGBA8;
+       case SRGB: return SRGB8;
+       case SRGB_ALPHA: return SRGB8_ALPHA8;
+       case LUMINANCE: return LUMINANCE8;
+       case SLUMINANCE: return SLUMINANCE8;
+       case LUMINANCE_ALPHA: return LUMINANCE8_ALPHA8;
+       case SLUMINANCE_ALPHA: return SLUMINANCE8_ALPHA8;
+       case DEPTH_COMPONENT:
+               if(get_gl_api()==OPENGL_ES2)
+                       return DEPTH_COMPONENT16;
+               else
+                       return DEPTH_COMPONENT32;
        default: return pf;
        }
 }
@@ -147,11 +171,15 @@ unsigned get_component_size(PixelFormat pf)
        case RGBA16F:
        case LUMINANCE16F:
        case LUMINANCE_ALPHA16F:
+       case DEPTH_COMPONENT16:
                return 2;
+       case DEPTH_COMPONENT24:
+               return 3;
        case RGB32F:
        case RGBA32F:
        case LUMINANCE32F:
        case LUMINANCE_ALPHA32F:
+       case DEPTH_COMPONENT32:
                return 4;
        default:
                return 1;
@@ -191,6 +219,12 @@ void require_pixelformat(PixelFormat pf)
        case BGRA:
                { static Require _req(EXT_bgra); }
                break;
+       case DEPTH_COMPONENT:
+       case DEPTH_COMPONENT16:
+       case DEPTH_COMPONENT24:
+       case DEPTH_COMPONENT32:
+               { static Require _req(ARB_depth_texture); }
+               break;
        default:
                break;
        }