From: Mikko Rasa Date: Wed, 2 Nov 2016 20:57:10 +0000 (+0200) Subject: Add the ARB_texture_rg extension X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b1c758a602262afad23e28ab68d62021a5b1257e;p=libs%2Fgl.git Add the ARB_texture_rg extension --- diff --git a/extensions/arb_texture_rg.glext b/extensions/arb_texture_rg.glext new file mode 100644 index 00000000..567cea12 --- /dev/null +++ b/extensions/arb_texture_rg.glext @@ -0,0 +1,2 @@ +extension ARB_texture_rg +core_version gl 3.0 diff --git a/source/pixelformat.cpp b/source/pixelformat.cpp index 3fdf6942..ac2b1ea7 100644 --- a/source/pixelformat.cpp +++ b/source/pixelformat.cpp @@ -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: diff --git a/source/pixelformat.h b/source/pixelformat.h index b69ad499..17a90d36 100644 --- a/source/pixelformat.h +++ b/source/pixelformat.h @@ -6,6 +6,7 @@ #include "gl.h" #include #include +#include #include #include #include @@ -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,