]> git.tdb.fi Git - libs/gl.git/commitdiff
Add the ARB_texture_rg extension
authorMikko Rasa <tdb@tdb.fi>
Wed, 2 Nov 2016 20:57:10 +0000 (22:57 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 2 Nov 2016 20:57:10 +0000 (22:57 +0200)
extensions/arb_texture_rg.glext [new file with mode: 0644]
source/pixelformat.cpp
source/pixelformat.h

diff --git a/extensions/arb_texture_rg.glext b/extensions/arb_texture_rg.glext
new file mode 100644 (file)
index 0000000..567cea1
--- /dev/null
@@ -0,0 +1,2 @@
+extension ARB_texture_rg
+core_version gl 3.0
index 3fdf6942c63cc606c04babdf54316330878ec1f9..ac2b1ea73dfde7818fab470b45565e1c5f5e32a2 100644 (file)
@@ -14,6 +14,10 @@ void operator>>(const LexicalConverter &conv, PixelFormat &fmt)
                fmt = STENCIL_INDEX;
        else if(conv.get()=="DEPTH_COMPONENT")
                fmt = DEPTH_COMPONENT;
+       else if(conv.get()=="RED")
+               fmt = RED;
+       else if(conv.get()=="RG")
+               fmt = RG;
        else if(conv.get()=="RGB")
                fmt = RGB;
        else if(conv.get()=="RGBA")
@@ -76,6 +80,12 @@ PixelFormat get_base_pixelformat(PixelFormat pf)
 {
        switch(pf)
        {
+       case R8:
+       case R16F:
+       case R32F: return RED;
+       case RG8:
+       case RG16F:
+       case RG32F: return RG;
        case RGB8:
        case RGB16F:
        case RGB32F:
@@ -87,13 +97,9 @@ PixelFormat get_base_pixelformat(PixelFormat pf)
        case SRGB_ALPHA:
        case SRGB8_ALPHA8: return RGBA;
        case LUMINANCE8:
-       case LUMINANCE16F:
-       case LUMINANCE32F:
        case SLUMINANCE:
        case SLUMINANCE8: return LUMINANCE;
        case LUMINANCE_ALPHA8:
-       case LUMINANCE_ALPHA16F:
-       case LUMINANCE_ALPHA32F:
        case SLUMINANCE_ALPHA:
        case SLUMINANCE8_ALPHA8: return LUMINANCE_ALPHA;
        case DEPTH_COMPONENT16:
@@ -107,6 +113,8 @@ PixelFormat get_sized_pixelformat(PixelFormat pf)
 {
        switch(pf)
        {
+       case RED: return R8;
+       case RG: return RG8;
        case RGB: return RGB8;
        case RGBA: return RGBA8;
        case SRGB: return SRGB8;
@@ -146,9 +154,11 @@ unsigned get_component_count(PixelFormat pf)
        {
        case STENCIL_INDEX:
        case DEPTH_COMPONENT:
+       case RED:
        case LUMINANCE:
        case SLUMINANCE:
                return 1;
+       case RG:
        case LUMINANCE_ALPHA:
        case SLUMINANCE_ALPHA:
                return 2;
@@ -167,18 +177,18 @@ unsigned get_component_size(PixelFormat pf)
 {
        switch(pf)
        {
+       case R16F:
+       case RG16F:
        case RGB16F:
        case RGBA16F:
-       case LUMINANCE16F:
-       case LUMINANCE_ALPHA16F:
        case DEPTH_COMPONENT16:
                return 2;
        case DEPTH_COMPONENT24:
                return 3;
+       case R32F:
+       case RG32F:
        case RGB32F:
        case RGBA32F:
-       case LUMINANCE32F:
-       case LUMINANCE_ALPHA32F:
        case DEPTH_COMPONENT32:
                return 4;
        default:
@@ -195,14 +205,23 @@ void require_pixelformat(PixelFormat pf)
 {
        switch(pf)
        {
+       case RED:
+       case R8:
+       case RG:
+       case RG8:
+               { static Require _req(ARB_texture_rg); }
+               break;
+       case R16F:
+       case R32F:
+       case RG16F:
+       case RG32F:
+               { static Require _req(ARB_texture_rg); }
+               { static Require _req(ARB_texture_float); }
+               break;
        case RGB16F:
        case RGB32F:
        case RGBA16F:
        case RGBA32F:
-       case LUMINANCE16F:
-       case LUMINANCE32F:
-       case LUMINANCE_ALPHA16F:
-       case LUMINANCE_ALPHA32F:
                { static Require _req(ARB_texture_float); }
                break;
        case SRGB:
index b69ad499c59c6f77ad3ae737e9c257601544996a..17a90d365781095f650109457ec6673506522ac1 100644 (file)
@@ -6,6 +6,7 @@
 #include "gl.h"
 #include <msp/gl/extensions/arb_depth_texture.h>
 #include <msp/gl/extensions/arb_texture_float.h>
+#include <msp/gl/extensions/arb_texture_rg.h>
 #include <msp/gl/extensions/ext_bgra.h>
 #include <msp/gl/extensions/ext_texture_srgb.h>
 #include <msp/gl/extensions/msp_legacy_features.h>
@@ -21,8 +22,16 @@ enum PixelFormat
        DEPTH_COMPONENT16 = GL_DEPTH_COMPONENT16,
        DEPTH_COMPONENT24 = GL_DEPTH_COMPONENT24,
        DEPTH_COMPONENT32 = GL_DEPTH_COMPONENT32,
+       RED             = GL_RED,
+       RG              = GL_RG,
        RGB             = GL_RGB,
        RGBA            = GL_RGBA,
+       R8              = GL_R8,
+       R16F            = GL_R16F,
+       R32F            = GL_R32F,
+       RG8             = GL_RG8,
+       RG16F           = GL_RG16F,
+       RG32F           = GL_RG32F,
        RGB8            = GL_RGB8,
        RGB16F          = GL_RGB16F,
        RGB32F          = GL_RGB32F,
@@ -37,13 +46,8 @@ enum PixelFormat
        BGRA            = GL_BGRA,
        LUMINANCE       = GL_LUMINANCE,
        LUMINANCE8      = GL_LUMINANCE8,
-       // TODO Remove LUMINANCE(_ALPHA) float formats once ARB_texture_rg becomes supported
-       LUMINANCE16F    = GL_LUMINANCE16F_ARB,
-       LUMINANCE32F    = GL_LUMINANCE32F_ARB,
        LUMINANCE_ALPHA    = GL_LUMINANCE_ALPHA,
        LUMINANCE8_ALPHA8  = GL_LUMINANCE8_ALPHA8,
-       LUMINANCE_ALPHA16F = GL_LUMINANCE_ALPHA16F_ARB,
-       LUMINANCE_ALPHA32F = GL_LUMINANCE_ALPHA32F_ARB,
        SLUMINANCE         = GL_SLUMINANCE,
        SLUMINANCE8        = GL_SLUMINANCE8,
        SLUMINANCE_ALPHA   = GL_SLUMINANCE_ALPHA,