42 #include <ACG/GL/GLFormatInfo.hh> 52 std::map<GLenum, GLFormatInfo> GLFormatInfo::formatMap_;
54 GLFormatInfo::GLFormatInfo( GLenum _internalFormat )
55 : internalFormat_(_internalFormat), format_(GL_NONE), type_(GL_NONE),
56 channelCount_(0), bpp_(0), baseType_(UnsignedInt), normalized_(true)
64 if (formatMap_.empty())
66 registerFmt(GL_RED, GL_RED, GL_UNSIGNED_BYTE, 8, 0, 0, 0, UnsignedInt,
true);
67 registerFmt(GL_RG, GL_RG, GL_UNSIGNED_BYTE, 8, 8, 0, 0, UnsignedInt,
true);
68 registerFmt(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 8, 8, 8, 0, UnsignedInt,
true);
69 registerFmt(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 8, 8, 8, 8, UnsignedInt,
true);
71 registerFmt(GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 32, 0, 0, 0, UnsignedInt,
false);
72 registerFmt(GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 32, 0, 0, 0, UnsignedInt,
false);
73 registerFmt(GL_DEPTH_STENCIL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 24, 8, 0, 0, UnsignedInt,
false);
74 registerFmt(GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 24, 8, 0, 0, UnsignedInt,
false);
78 registerFmt(GL_R8, GL_RED, GL_UNSIGNED_BYTE, 8, 0, 0, 0, UnsignedInt,
true);
79 registerFmt(GL_R8_SNORM, GL_RED, GL_BYTE, 8, 0, 0, 0, SignedInt,
true);
80 registerFmt(GL_R8I, GL_RED_INTEGER, GL_BYTE, 8, 0, 0, 0, SignedInt,
false);
81 registerFmt(GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, 8, 0, 0, 0, UnsignedInt,
false);
83 registerFmt(GL_R16, GL_RED, GL_UNSIGNED_SHORT, 16, 0, 0, 0, UnsignedInt,
true);
84 registerFmt(GL_R16I, GL_RED_INTEGER, GL_SHORT, 16, 0, 0, 0, SignedInt,
false);
85 registerFmt(GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, 16, 0, 0, 0, UnsignedInt,
false);
86 registerFmt(GL_R16F, GL_RED, GL_HALF_FLOAT, 16, 0, 0, 0, FloatingPt,
false);
88 registerFmt(GL_R32I, GL_RED_INTEGER, GL_INT, 32, 0, 0, 0, SignedInt,
false);
89 registerFmt(GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, 32, 0, 0, 0, UnsignedInt,
false);
90 registerFmt(GL_R32F, GL_RED, GL_FLOAT, 32, 0, 0, 0, FloatingPt,
false);
93 registerFmt(GL_RG8, GL_RG, GL_UNSIGNED_BYTE, 8, 8, 0, 0, UnsignedInt,
true);
94 registerFmt(GL_RG8_SNORM, GL_RG, GL_BYTE, 8, 8, 0, 0, SignedInt,
true);
95 registerFmt(GL_RG8I, GL_RG_INTEGER, GL_BYTE, 8, 8, 0, 0, SignedInt,
false);
96 registerFmt(GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE, 8, 8, 0, 0, UnsignedInt,
false);
98 registerFmt(GL_RG16, GL_RG, GL_UNSIGNED_SHORT, 16, 16, 0, 0, UnsignedInt,
true);
99 registerFmt(GL_RG16I, GL_RG_INTEGER, GL_SHORT, 16, 16, 0, 0, SignedInt,
false);
100 registerFmt(GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, 16, 16, 0, 0, UnsignedInt,
false);
101 registerFmt(GL_RG16F, GL_RG, GL_HALF_FLOAT, 16, 16, 0, 0, FloatingPt,
false);
103 registerFmt(GL_RG32I, GL_RG_INTEGER, GL_INT, 32, 32, 0, 0, SignedInt,
false);
104 registerFmt(GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, 32, 32, 0, 0, UnsignedInt,
false);
105 registerFmt(GL_RG32F, GL_RG, GL_FLOAT, 32, 32, 0, 0, FloatingPt,
false);
109 registerFmt(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, 8, 8, 8, 0, UnsignedInt,
true);
110 registerFmt(GL_RGB8_SNORM, GL_RGB, GL_BYTE, 8, 8, 8, 0, SignedInt,
true);
111 registerFmt(GL_RGB16F, GL_RGB, GL_HALF_FLOAT, 16, 16, 16, 0, FloatingPt,
false);
112 registerFmt(GL_RGB32F, GL_RGB, GL_FLOAT, 32, 32, 32, 0, FloatingPt,
false);
115 registerFmt(GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, 8, 8, 8, 8, UnsignedInt,
true);
116 registerFmt(GL_RGBA8_SNORM, GL_RGBA, GL_BYTE, 8, 8, 8, 8, SignedInt,
true);
118 registerFmt(GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT, 16, 16, 16, 16, SignedInt,
false);
119 registerFmt(GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, 16, 16, 16, 16, UnsignedInt,
false);
120 registerFmt(GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 16, 16, 16, 16, FloatingPt,
false);
122 registerFmt(GL_RGBA32I, GL_RGBA_INTEGER, GL_INT, 32, 32, 32, 32, SignedInt,
false);
123 registerFmt(GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 32, 32, 32, 32, UnsignedInt,
false);
124 registerFmt(GL_RGBA32F, GL_RGBA, GL_FLOAT, 32, 32, 32, 32, FloatingPt,
false);
125 #endif // GL_VERSION_3_0 128 registerFmt(GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 24, 0, 0, 0, UnsignedInt,
false);
129 registerFmt(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 16, 0, 0, 0, UnsignedInt,
false);
130 #ifdef GL_ARB_depth_buffer_float 131 registerFmt(GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, 32, 0, 0, 0, FloatingPt,
false);
132 registerFmt(GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, 32, 8, -24, 0, FloatingPt,
false);
133 #endif // GL_ARB_depth_buffer_float 135 #ifdef GL_ARB_texture_stencil8 136 registerFmt(GL_STENCIL_INDEX8, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, 8, 0, 0, 0, UnsignedInt,
false);
137 #endif // GL_ARB_texture_stencil8 140 std::map<GLenum, GLFormatInfo>::iterator f = formatMap_.find(_internalFormat);
142 if (f != formatMap_.end())
147 std::cout <<
"GLFormatInfo: unknown internalFormat " << _internalFormat << std::endl;
151 GLFormatInfo::GLFormatInfo( GLenum _intfmt, GLenum _fmt, GLenum _type,
int _r,
int _g,
int _b,
int _a, BaseType _bt,
bool _nrm )
152 : internalFormat_(_intfmt), format_(_fmt), type_(_type),
153 channelCount_(0), bpp_(0), baseType_(_bt), normalized_(_nrm)
158 channelBits_[0] = std::max(_r, 0);
159 channelBits_[1] = std::max(_g, 0);
160 channelBits_[2] = std::max(_b, 0);
161 channelBits_[3] = std::max(_a, 0);
164 if (_r > 0) ++channelCount_;
165 if (_g > 0) ++channelCount_;
166 if (_b > 0) ++channelCount_;
167 if (_a > 0) ++channelCount_;
169 bpp_ = std::abs(_r) + std::abs(_g) + std::abs(_b) + std::abs(_a);
171 if (channelCount_ >= 1 && channelCount_ <= 4)
175 case GL_DEPTH_STENCIL: strcpy(sizedName_,
"GL_DEPTH_STENCIL");
break;
176 case GL_DEPTH_COMPONENT: strcpy(sizedName_,
"GL_DEPTH_COMPONENT");
break;
177 case GL_DEPTH_COMPONENT32: strcpy(sizedName_,
"GL_DEPTH_COMPONENT32");
break;
182 QString strfmt =
"GL_R";
184 if (channelCount_ > 1)
186 if (channelCount_ > 2)
188 if (channelCount_ > 3)
191 strfmt += QString (
"%1").arg(channelBits_[0]);
208 int len = std::min(strfmt.length(), 31);
210 for (
int i = 0; i < len; ++i)
211 sizedName_[i] = strfmt.at(i).toLatin1();
218 GLFormatInfo::GLFormatInfo()
219 : internalFormat_(GL_NONE), format_(GL_NONE), type_(GL_NONE),
220 channelCount_(0), bpp_(0), baseType_(UnsignedInt), normalized_(true)
229 GLFormatInfo::~GLFormatInfo()
233 void GLFormatInfo::registerFmt( GLenum _intfmt, GLenum _fmt, GLenum _type,
int _r,
int _g,
int _b,
int _a, BaseType _bt,
bool _nrm )
235 formatMap_[_intfmt] = GLFormatInfo(_intfmt, _fmt, _type, _r, _g, _b, _a, _bt, _nrm);
Namespace providing different geometric functions concerning angles.