]> git.tdb.fi Git - libs/gl.git/commitdiff
Move internal format management to the Texture base class
authorMikko Rasa <tdb@tdb.fi>
Thu, 3 Nov 2016 08:08:29 +0000 (10:08 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 3 Nov 2016 08:08:29 +0000 (10:08 +0200)
source/texture.cpp
source/texture.h
source/texture1d.cpp
source/texture1d.h
source/texture2d.cpp
source/texture2d.h
source/texture3d.cpp
source/texture3d.h
source/texturecube.cpp
source/texturecube.h

index 581ec705690d556320bc412577a7ad8e5f4d0adb..21fc7a6ae9bb41711cf079795e752196c4a2e014 100644 (file)
@@ -52,6 +52,7 @@ void operator>>(const LexicalConverter &c, TextureWrap &tw)
 Texture::Texture(GLenum t, ResourceManager *m):
        id(0),
        target(t),
+       ifmt(RGB),
        min_filter(NEAREST_MIPMAP_LINEAR),
        mag_filter(LINEAR),
        wrap_s(REPEAT),
@@ -84,6 +85,15 @@ DataType Texture::get_alloc_type(PixelFormat fmt)
        return (get_base_pixelformat(fmt)==DEPTH_COMPONENT ? UNSIGNED_SHORT : UNSIGNED_BYTE);
 }
 
+void Texture::set_internal_format(PixelFormat fmt)
+{
+       if(MSP_sized_internal_formats)
+               fmt = get_sized_pixelformat(fmt);
+
+       require_pixelformat(fmt);
+       ifmt = fmt;
+}
+
 void Texture::update_parameter(int mask) const
 {
        if(!ARB_direct_state_access && TexUnit::current().get_texture()!=this)
index f1a51767f577771477289c582375ab2170c98c11..1b80e950f08d93e54debd3bdc8b14ae4c7f458ac 100644 (file)
@@ -109,6 +109,7 @@ protected:
 
        unsigned id;
        GLenum target;
+       PixelFormat ifmt;
        TextureFilter min_filter;
        TextureFilter mag_filter;
        float max_anisotropy;
@@ -128,6 +129,7 @@ public:
 
 protected:
        static DataType get_alloc_type(PixelFormat);
+       void set_internal_format(PixelFormat);
 
        void update_parameter(int) const;
        void set_parameter_i(GLenum, int) const;
index 32053e83fa9bd8ad9231720c79defa3474229415..6affe8999a2414ae61b950c8f3c232a9269e4af1 100644 (file)
@@ -13,7 +13,6 @@ namespace GL {
 
 Texture1D::Texture1D():
        Texture(GL_TEXTURE_1D),
-       ifmt(RGB),
        width(0),
        allocated(0)
 {
@@ -27,11 +26,7 @@ void Texture1D::storage(PixelFormat fmt, unsigned wd)
        if(wd==0)
                throw invalid_argument("Texture1D::storage");
 
-       if(MSP_sized_internal_formats)
-               fmt = get_sized_pixelformat(fmt);
-       require_pixelformat(fmt);
-
-       ifmt = fmt;
+       set_internal_format(fmt);
        width = wd;
 }
 
index d75167b1f3215b2402c25c0825f47fa8886c2ed3..5e6f254977f877a20565e131412bb333f6248ab4 100644 (file)
@@ -22,7 +22,6 @@ public:
        };
 
 private:
-       PixelFormat ifmt;
        unsigned width;
        unsigned allocated;
 
index 8ecebdfb6e1748132bf39a14040f5bae8704aa33..75b84ec7bbe5747c17ee47b137ba56df33e9101e 100644 (file)
@@ -36,7 +36,6 @@ public:
 
 Texture2D::Texture2D(ResourceManager *m):
        Texture(GL_TEXTURE_2D, m),
-       ifmt(RGB),
        width(0),
        height(0),
        allocated(0)
@@ -54,11 +53,7 @@ void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht)
        if(wd==0 || ht==0)
                throw invalid_argument("Texture2D::storage");
 
-       if(MSP_sized_internal_formats)
-               fmt = get_sized_pixelformat(fmt);
-       require_pixelformat(fmt);
-
-       ifmt = fmt;
+       set_internal_format(fmt);
        width = wd;
        height = ht;
 }
index 9647ad3ed55c688a86c156dd11e3daacba687b9d..1f8b5f7ea557e94abcded7d8f7fd423b7fea7cdd 100644 (file)
@@ -31,7 +31,6 @@ public:
 private:
        class AsyncLoader;
 
-       PixelFormat ifmt;
        unsigned width;
        unsigned height;
        unsigned allocated;
index f64f548ad926ef5901f43a775f8da3e3b6427e25..680880a820be1507ba81fb0c252eafdcd98677ad 100644 (file)
@@ -16,7 +16,6 @@ namespace GL {
 
 Texture3D::Texture3D(GLenum t):
        Texture(t),
-       ifmt(RGB),
        width(0),
        height(0),
        depth(0),
@@ -25,7 +24,6 @@ Texture3D::Texture3D(GLenum t):
 
 Texture3D::Texture3D():
        Texture(GL_TEXTURE_3D),
-       ifmt(RGB),
        width(0),
        height(0),
        depth(0),
@@ -41,11 +39,7 @@ void Texture3D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp)
        if(wd==0 || ht==0 || dp==0)
                throw invalid_argument("Texture3D::storage");
 
-       if(MSP_sized_internal_formats)
-               fmt = get_sized_pixelformat(fmt);
-       require_pixelformat(fmt);
-
-       ifmt = fmt;
+       set_internal_format(fmt);
        width = wd;
        height = ht;
        depth = dp;
index 57f3a6f8589e9d1ea9c986785b477524880b0a76..cf336e52b0227fb859d2125cb686f07d70db46b3 100644 (file)
@@ -27,7 +27,6 @@ public:
        };
 
 private:
-       PixelFormat ifmt;
        unsigned width;
        unsigned height;
        unsigned depth;
index 833ef28f0ebd78add08ccfae4c8555df87dff288..19c3bf074b9a3557adf7668c4752f22bda3bcb8c 100644 (file)
@@ -45,7 +45,6 @@ unsigned TextureCube::orientations[12] =
 
 TextureCube::TextureCube():
        Texture(GL_TEXTURE_CUBE_MAP),
-       ifmt(RGB),
        size(0),
        allocated(0)
 {
@@ -59,11 +58,7 @@ void TextureCube::storage(PixelFormat fmt, unsigned sz)
        if(sz==0)
                throw invalid_argument("TextureCube::storage");
 
-       if(MSP_sized_internal_formats)
-               fmt = get_sized_pixelformat(fmt);
-       require_pixelformat(fmt);
-
-       ifmt = fmt;
+       set_internal_format(fmt);
        size = sz;
 }
 
index 9ce216fdd1db1e79e164769f9d6017984de15f46..ea1c8296190ade9703121238771c9277baba3d04 100644 (file)
@@ -49,7 +49,6 @@ public:
        };
 
 private:
-       PixelFormat ifmt;
        unsigned size;
        unsigned allocated;