]> git.tdb.fi Git - libs/gl.git/commitdiff
Pull in sized depth component formats from ARB_depth_texture
authorMikko Rasa <tdb@tdb.fi>
Thu, 27 Oct 2016 22:02:40 +0000 (01:02 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 27 Oct 2016 22:08:07 +0000 (01:08 +0300)
extensions/arb_depth_texture.glext [new file with mode: 0644]
source/pixelformat.cpp
source/pixelformat.h
source/texture.cpp

diff --git a/extensions/arb_depth_texture.glext b/extensions/arb_depth_texture.glext
new file mode 100644 (file)
index 0000000..03a9725
--- /dev/null
@@ -0,0 +1 @@
+extension ARB_depth_texture
index 679c6467503e3d4d059668890b1eb2922eb54426..99f15307d1304bf41c36c80aa7af825fd41a7171 100644 (file)
@@ -96,6 +96,9 @@ 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;
        }
 }
@@ -147,11 +150,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 +198,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;
        }
index 7a562cc948408bccf0eaaba9982df73edc7307e7..8e3e6901e95d0e40c7357b3e2389429dabb14e8d 100644 (file)
@@ -4,6 +4,7 @@
 #include <msp/graphics/pixelformat.h>
 #include <msp/strings/lexicalcast.h>
 #include "gl.h"
+#include <msp/gl/extensions/arb_depth_texture.h>
 #include <msp/gl/extensions/arb_texture_float.h>
 #include <msp/gl/extensions/ext_bgra.h>
 #include <msp/gl/extensions/ext_texture_srgb.h>
@@ -17,6 +18,9 @@ enum PixelFormat
 {
        STENCIL_INDEX   = GL_STENCIL_INDEX,
        DEPTH_COMPONENT = GL_DEPTH_COMPONENT,
+       DEPTH_COMPONENT16 = GL_DEPTH_COMPONENT16,
+       DEPTH_COMPONENT24 = GL_DEPTH_COMPONENT24,
+       DEPTH_COMPONENT32 = GL_DEPTH_COMPONENT32,
        RGB             = GL_RGB,
        RGBA            = GL_RGBA,
        RGB8            = GL_RGB8,
index 004d78c2abc38d1b9bc383b361cefae647b8ac06..fd14458553417d2b5d2b0dc71d036e2434f9efbf 100644 (file)
@@ -78,7 +78,7 @@ Texture::~Texture()
 
 DataType Texture::get_alloc_type(PixelFormat fmt)
 {
-       return (fmt==DEPTH_COMPONENT ? UNSIGNED_SHORT : UNSIGNED_BYTE);
+       return (get_base_pixelformat(fmt)==DEPTH_COMPONENT ? UNSIGNED_SHORT : UNSIGNED_BYTE);
 }
 
 void Texture::update_parameter(int mask) const