24.09., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

gltextureformattraits.cpp 10.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
/**********************************************************************
*                                                                    *
* cgt - CAMP Graphics Toolbox, Copyright (C) 2012-2015               *
*     Chair for Computer Aided Medical Procedures                    *
*     Technische Universitaet Muenchen, Germany.                     *
*     <http://campar.in.tum.de/>                                     *
*                                                                    *
* forked from tgt - Tiny Graphics Toolbox, Copyright (C) 2006-2011   *
*     Visualization and Computer Graphics Group, Department of       *
*     Computer Science, University of Muenster, Germany.             *
*     <http://viscg.uni-muenster.de>                                 *
*                                                                    *
* This file is part of the cgt library. This library is free         *
* software; you can redistribute it and/or modify it under the terms *
* of the GNU Lesser General Public License version 2.1 as published  *
* by the Free Software Foundation.                                   *
*                                                                    *
* This library is distributed in the hope that it will be useful,    *
* but WITHOUT ANY WARRANTY; without even the implied warranty of     *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the       *
* GNU Lesser General Public License for more details.                *
*                                                                    *
* You should have received a copy of the GNU Lesser General Public   *
* License in the file "LICENSE.txt" along with this library.         *
* If not, see <http://www.gnu.org/licenses/>.                        *
*                                                                    *
**********************************************************************/

#include "gltextureformattraits.h"

namespace cgt {

#define defFormat(INTERNAL_FORMAT, BPP, CHANNELS, PIXEL_FORMAT, PIXEL_DATA_TYPE, GLSL_FORMAT_QUALIFIER) \
    if(internalFormat == INTERNAL_FORMAT) { return GLTextureFormatTraits(INTERNAL_FORMAT, #INTERNAL_FORMAT, BPP, CHANNELS, PIXEL_FORMAT, PIXEL_DATA_TYPE, GLSL_FORMAT_QUALIFIER); }

GLTextureFormatTraits GLTextureFormatTraits::get(GLint internalFormat) 
{

        defFormat(GL_DEPTH_COMPONENT         ,   1,   1, GL_DEPTH_COMPONENT, GL_FLOAT         , "**UNKNOWN**")
        defFormat(GL_R8                      ,   1,   1, GL_RED            , GL_UNSIGNED_BYTE , "r8")
        defFormat(GL_R8_SNORM                ,   1,   1, GL_RED            , GL_BYTE          , "r8_snorm")
        defFormat(GL_R8I                     ,   1,   1, GL_RED_INTEGER    , GL_BYTE          , "r8i")
        defFormat(GL_R8UI                    ,   1,   1, GL_RED_INTEGER    , GL_UNSIGNED_BYTE , "r8ui")
        defFormat(GL_R3_G3_B2                ,   1,   3, GL_RGB            , GL_FLOAT         , "**UNKNOWN**")
        defFormat(GL_RGBA2                   ,   1,   4, GL_RGB            , GL_UNSIGNED_BYTE , "**UNKNOWN**")
        //                                   , bpp, chn, pixel_format      , pixel_data_type, "**UNKNOWN**");
        defFormat(GL_DEPTH_COMPONENT16       ,   2,   1, GL_DEPTH_COMPONENT, GL_FLOAT         , "**UNKNOWN**")
        defFormat(GL_R16                     ,   2,   1, GL_RED            , GL_UNSIGNED_SHORT, "r16")
        defFormat(GL_R16_SNORM               ,   2,   1, GL_RED            , GL_SHORT         , "r16_snorm")
        defFormat(GL_R16F                    ,   2,   1, GL_RED            , GL_FLOAT         , "r16f")
        defFormat(GL_R16I                    ,   2,   1, GL_RED_INTEGER    , GL_SHORT         , "r16i")
        defFormat(GL_R16UI                   ,   2,   1, GL_RED_INTEGER    , GL_UNSIGNED_SHORT, "r16ui")
        defFormat(GL_DEPTH_STENCIL           ,   2,   1, GL_RG             , GL_FLOAT         , "**UNKNOWN**")
        defFormat(GL_RG8                     ,   2,   2, GL_RG             , GL_UNSIGNED_BYTE , "rg8")
        defFormat(GL_RG8_SNORM               ,   2,   2, GL_RG             , GL_BYTE          , "rg8_snorm")
        defFormat(GL_RG8I                    ,   2,   2, GL_RG_INTEGER     , GL_BYTE          , "rg8i")
        defFormat(GL_RG8UI                   ,   2,   2, GL_RG_INTEGER     , GL_UNSIGNED_BYTE , "rg8ui")
        defFormat(GL_RGB4                    ,   2,   3, GL_RGB            , GL_UNSIGNED_BYTE , "**UNKNOWN**")
        defFormat(GL_RGB5                    ,   2,   3, GL_RGB            , GL_FLOAT         , "**UNKNOWN**")
        defFormat(GL_RGBA4                   ,   2,   4, GL_RGBA           , GL_UNSIGNED_BYTE , "**UNKNOWN**")
        defFormat(GL_RGB5_A1                 ,   2,   4, GL_RGBA           , GL_FLOAT         , "**UNKNOWN**")
        //                                   , bpp, chn, pixel_format      , pixel_data_type, "**UNKNOWN**");
        defFormat(GL_DEPTH_COMPONENT24       ,   3,   1, GL_DEPTH_COMPONENT, GL_FLOAT         , "**UNKNOWN**")
        defFormat(GL_RGB8                    ,   3,   3, GL_RGB            , GL_UNSIGNED_BYTE , "**UNKNOWN**")
        defFormat(GL_RGB8_SNORM              ,   3,   3, GL_RGB            , GL_BYTE          , "**UNKNOWN**")
        defFormat(GL_SRGB8                   ,   3,   3, GL_RGB            , GL_UNSIGNED_BYTE , "**UNKNOWN**")
        defFormat(GL_RGB8I                   ,   3,   3, GL_RGB_INTEGER    , GL_BYTE          , "**UNKNOWN**")
        defFormat(GL_RGB8UI                  ,   3,   3, GL_RGB_INTEGER    , GL_UNSIGNED_BYTE , "**UNKNOWN**")
        //                                   , bpp, chn, pixel_format      , pixel_data_type, "**UNKNOWN**");
        defFormat(GL_DEPTH_COMPONENT32       ,   4,   1, GL_DEPTH_COMPONENT, GL_FLOAT         , "**UNKNOWN**")
        defFormat(GL_DEPTH_COMPONENT32F      ,   4,   1, GL_DEPTH_COMPONENT, GL_FLOAT         , "**UNKNOWN**")
        defFormat(GL_R32F                    ,   4,   1, GL_RED            , GL_FLOAT         , "r32f")
        defFormat(GL_R32I                    ,   4,   1, GL_RED_INTEGER    , GL_INT           , "r32i")
        defFormat(GL_R32UI                   ,   4,   1, GL_RED_INTEGER    , GL_UNSIGNED_INT  , "r32ui")
        defFormat(GL_RG16                    ,   4,   2, GL_RG             , GL_UNSIGNED_SHORT, "rg16")
        defFormat(GL_RG16_SNORM              ,   4,   2, GL_RG             , GL_SHORT         , "rg16_snorm")
        defFormat(GL_RG16F                   ,   4,   2, GL_RG             , GL_FLOAT         , "rg16f")
        defFormat(GL_RG16I                   ,   4,   2, GL_RG_INTEGER     , GL_SHORT         , "rg16i")
        defFormat(GL_RG16UI                  ,   4,   2, GL_RG_INTEGER     , GL_UNSIGNED_SHORT, "rg16ui")
        defFormat(GL_RGB10                   ,   4,   3, GL_RGB            , GL_FLOAT         , "**UNKNOWN**")
        defFormat(GL_R11F_G11F_B10F          ,   4,   3, GL_RGB            , GL_FLOAT         , "r11f_g11f_b10f")
        defFormat(GL_RGB9_E5                 ,   4,   3, GL_RGB            , GL_FLOAT         , "**UNKNOWN**")
        defFormat(GL_RGBA8                   ,   4,   4, GL_RGBA           , GL_UNSIGNED_BYTE , "rgba8")
        defFormat(GL_RGBA8_SNORM             ,   4,   4, GL_RGBA           , GL_BYTE          , "rgba8_snorm")
        defFormat(GL_RGB10_A2                ,   4,   4, GL_RGBA           , GL_FLOAT         , "rgb10_a2")
        defFormat(GL_RGB10_A2UI              ,   4,   4, GL_RGBA_INTEGER   , GL_FLOAT         , "rgb10_a2ui")
        defFormat(GL_SRGB8_ALPHA8            ,   4,   4, GL_RGBA           , GL_UNSIGNED_BYTE , "**UNKNOWN**")
        defFormat(GL_RGBA8I                  ,   4,   4, GL_RGBA_INTEGER   , GL_BYTE          , "rgba8i")
        defFormat(GL_RGBA8UI                 ,   4,   4, GL_RGBA_INTEGER   , GL_UNSIGNED_BYTE , "rgba8ui")
        //                                   , bpp, chn, pixel_format      , pixel_data_type, "**UNKNOWN**");
        defFormat(GL_RGB12                   ,   5,   3, GL_RGB            , GL_FLOAT         , "**UNKNOWN**")
        //                                   , bpp, chn, pixel_format      , pixel_data_type, "**UNKNOWN**");
        defFormat(GL_RGB16                   ,   6,   3, GL_RGB            , GL_UNSIGNED_SHORT, "**UNKNOWN**")
        defFormat(GL_RGB16_SNORM             ,   6,   3, GL_RGB            , GL_SHORT         , "**UNKNOWN**")
        defFormat(GL_RGB16F                  ,   6,   3, GL_RGB            , GL_FLOAT         , "**UNKNOWN**")
        defFormat(GL_RGB16I                  ,   6,   3, GL_RGB_INTEGER    , GL_SHORT         , "**UNKNOWN**")
        defFormat(GL_RGB16UI                 ,   6,   3, GL_RGB_INTEGER    , GL_UNSIGNED_SHORT, "**UNKNOWN**")
        defFormat(GL_RGBA12                  ,   6,   4, GL_RGBA           , GL_FLOAT         , "**UNKNOWN**")
        //                                   , bpp, chn, pixel_format      , pixel_data_type, "**UNKNOWN**");
        defFormat(GL_RG32F                   ,   8,   2, GL_RG             , GL_FLOAT         , "rg32f")
        defFormat(GL_RG32I                   ,   8,   2, GL_RG_INTEGER     , GL_INT           , "rg32i")
        defFormat(GL_RG32UI                  ,   8,   2, GL_RG_INTEGER     , GL_UNSIGNED_INT  , "rg32ui")
        defFormat(GL_RGBA16                  ,   8,   4, GL_RGBA           , GL_FLOAT         , "rgba16")
        defFormat(GL_RGBA16_SNORM            ,   8,   4, GL_RGBA           , GL_SHORT         , "rgba16_snorm")
        defFormat(GL_RGBA16F                 ,   8,   4, GL_RGBA           , GL_FLOAT         , "rgba16f")
        defFormat(GL_RGBA16I                 ,   8,   4, GL_RGBA_INTEGER   , GL_SHORT         , "rgba16i")
        defFormat(GL_RGBA16UI                ,   8,   4, GL_RGBA_INTEGER   , GL_UNSIGNED_SHORT, "rgba16ui")
        //                                   , bpp, chn, pixel_format      , pixel_data_type, "**UNKNOWN**");
        defFormat(GL_RGB32F                  ,  12,   3, GL_RGB            , GL_FLOAT         , "**UNKNOWN**")
        defFormat(GL_RGB32I                  ,  12,   3, GL_RGB_INTEGER    , GL_INT           , "**UNKNOWN**")
        defFormat(GL_RGB32UI                 ,  12,   3, GL_RGB_INTEGER    , GL_UNSIGNED_INT  , "**UNKNOWN**")
        //                                   , bpp, chn, pixel_format      , pixel_data_type, "**UNKNOWN**");
        defFormat(GL_RGBA32F                 ,  16,   4, GL_RGBA           , GL_FLOAT         , "rgba32f")
        defFormat(GL_RGBA32I                 ,  16,   4, GL_RGBA_INTEGER   , GL_INT           , "rgba32i")
        defFormat(GL_RGBA32UI                ,  16,   4, GL_RGBA_INTEGER   , GL_UNSIGNED_INT  , "rgba32ui")
        
        // default case:
        return GLTextureFormatTraits(internalFormat);
}

#undef defFormat

}; // namspace cgt