]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/pixelformat.cpp
Remove support for array size specialization from the engine as well
[libs/gl.git] / source / core / pixelformat.cpp
index cfbf8112e2278477dec5ae8d0d79928f59371a0d..81379ef07062831a85fed2ee8fa1f925f34b450a 100644 (file)
@@ -1,5 +1,3 @@
-#include <msp/gl/extensions/arb_texture_float.h>
-#include <msp/io/print.h>
 #include <msp/strings/format.h>
 #include "pixelformat.h"
 
@@ -81,19 +79,7 @@ void operator>>(const LexicalConverter &conv, PixelFormat &fmt)
        else if(conv.get()=="DEPTH_COMPONENT32F")
                fmt = DEPTH_COMPONENT32F;
        else
-       {
-               if(conv.get()=="SRGB")
-                       fmt = SRGB8;
-               else if(conv.get()=="SRGB_ALPHA")
-                       fmt = SRGB8_ALPHA8;
-               else
-               {
-                       PixelComponents comp;
-                       conv >> comp;
-                       fmt = make_pixelformat(comp, (comp==DEPTH_COMPONENT ? FLOAT : UNSIGNED_BYTE));
-               }
-               IO::print(IO::cerr, "Warning: deprecated conversion of '%s' to PixelFormat\n", conv.get());
-       }
+               throw lexical_error(format("conversion of '%s' to PixelFormat", conv.get()));
 }
 
 PixelComponents components_from_graphics(Graphics::PixelFormat pf)
@@ -112,10 +98,10 @@ PixelComponents components_from_graphics(Graphics::PixelFormat pf)
        }
 }
 
-PixelFormat pixelformat_from_image(const Graphics::Image &image)
+PixelFormat pixelformat_from_image(const Graphics::Image &image, bool srgb)
 {
        PixelComponents comp = components_from_graphics(image.get_format());
-       return make_pixelformat(comp, UNSIGNED_BYTE);
+       return make_pixelformat(comp, UNSIGNED_BYTE, srgb);
 }
 
 PixelFormat make_pixelformat(PixelComponents comp, DataType type, bool srgb)
@@ -124,97 +110,5 @@ PixelFormat make_pixelformat(PixelComponents comp, DataType type, bool srgb)
        return static_cast<PixelFormat>(comp | get_type_size(type)<<8 | (type&0x300)<<4 | normalized*0x4000 | srgb*0x8000);
 }
 
-void require_pixelformat(PixelFormat pf)
-{
-       /* TODO These checks are only accurate for textures.  On OpenGL ES some
-       formats are allowed for render buffers earlier than textures.  In particular
-       it's possible to create a 16-bit depth renderbuffer on OpenGL ES 2.0 but
-       depth textures are only available with 3.0 or the OES_depth_texture
-       extension.*/
-       switch(pf)
-       {
-       case RGB8:
-       case RGBA8:
-               { static Require _req(OES_required_internalformat); }
-               break;
-       case R8:
-       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:
-               { static Require _req(ARB_texture_float); }
-               break;
-       case SRGB8:
-       case SRGB8_ALPHA8:
-               { static Require _req(EXT_texture_sRGB); }
-               break;
-       case DEPTH_COMPONENT16:
-       case DEPTH_COMPONENT24:
-       case DEPTH_COMPONENT32:
-               { static Require _req(ARB_depth_texture); }
-               { static Require _req(OES_required_internalformat); }
-               break;
-       case DEPTH_COMPONENT32F:
-               { static Require _req(ARB_depth_buffer_float); }
-               break;
-       case STENCIL_INDEX8:
-               { static Require _req(OES_texture_stencil8); }
-               break;
-       default:
-               throw invalid_argument("require_pixelformat");
-       }
-}
-
-GLenum get_gl_components(PixelComponents comp)
-{
-       switch(comp)
-       {
-       case RED: return GL_RED;
-       case RG: return GL_RG;
-       case RGB: return GL_RGB;
-       case RGBA: return GL_RGBA;
-       case DEPTH_COMPONENT: return GL_DEPTH_COMPONENT;
-       case STENCIL_INDEX: return GL_STENCIL_INDEX;
-       default: throw invalid_argument("get_gl_components");
-       }
-}
-
-GLenum get_gl_pixelformat(PixelFormat pf)
-{
-       switch(pf)
-       {
-       case R8: return GL_R8;
-       case R16F: return GL_R16F;
-       case R32F: return GL_R32F;
-       case RG8: return GL_RG8;
-       case RG16F: return GL_RG16F;
-       case RG32F: return GL_RG32F;
-       case RGB8: return GL_RGB8;
-       case RGB16F: return GL_RGB16F;
-       case RGB32F: return GL_RGB32F;
-       case RGBA8: return GL_RGBA8;
-       case RGBA16F: return GL_RGBA16F;
-       case RGBA32F: return GL_RGBA32F;
-       case SRGB8: return GL_SRGB8;
-       case SRGB8_ALPHA8: return GL_SRGB8_ALPHA8;
-       case DEPTH_COMPONENT16: return GL_DEPTH_COMPONENT16;
-       case DEPTH_COMPONENT24: return GL_DEPTH_COMPONENT24;
-       case DEPTH_COMPONENT32: return GL_DEPTH_COMPONENT32;
-       case DEPTH_COMPONENT32F: return GL_DEPTH_COMPONENT32F;
-       case STENCIL_INDEX8: return GL_STENCIL_INDEX8;
-       default: throw invalid_argument("get_gl_pixelformat");
-       }
-}
-
 } // namespace GL
 } // namespace Msp