50 #include <ACG/GL/GLFormatInfo.hh> 60 std::map<GLenum, GLFormatInfo> GLFormatInfo::formatMap_;
62 GLFormatInfo::GLFormatInfo( GLenum _internalFormat )
63 : internalFormat_(_internalFormat), format_(GL_NONE), type_(GL_NONE),
64 channelCount_(0), bpp_(0), baseType_(UnsignedInt), normalized_(true)
72 if (formatMap_.empty())
74 registerFmt(GL_RED, GL_RED, GL_UNSIGNED_BYTE, 8, 0, 0, 0, UnsignedInt,
true);
75 registerFmt(GL_RG, GL_RG, GL_UNSIGNED_BYTE, 8, 8, 0, 0, UnsignedInt,
true);
76 registerFmt(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 8, 8, 8, 0, UnsignedInt,
true);
77 registerFmt(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 8, 8, 8, 8, UnsignedInt,
true);
79 registerFmt(GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 32, 0, 0, 0, UnsignedInt,
false);
80 registerFmt(GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 32, 0, 0, 0, UnsignedInt,
false);
81 registerFmt(GL_DEPTH_STENCIL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 24, 8, 0, 0, UnsignedInt,
false);
82 registerFmt(GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 24, 8, 0, 0, UnsignedInt,
false);
86 registerFmt(GL_R8, GL_RED, GL_UNSIGNED_BYTE, 8, 0, 0, 0, UnsignedInt,
true);
87 registerFmt(GL_R8_SNORM, GL_RED, GL_BYTE, 8, 0, 0, 0, SignedInt,
true);
88 registerFmt(GL_R8I, GL_RED_INTEGER, GL_BYTE, 8, 0, 0, 0, SignedInt,
false);
89 registerFmt(GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, 8, 0, 0, 0, UnsignedInt,
false);
91 registerFmt(GL_R16, GL_RED, GL_UNSIGNED_SHORT, 16, 0, 0, 0, UnsignedInt,
true);
92 registerFmt(GL_R16I, GL_RED_INTEGER, GL_SHORT, 16, 0, 0, 0, SignedInt,
false);
93 registerFmt(GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, 16, 0, 0, 0, UnsignedInt,
false);
94 registerFmt(GL_R16F, GL_RED, GL_HALF_FLOAT, 16, 0, 0, 0, FloatingPt,
false);
96 registerFmt(GL_R32I, GL_RED_INTEGER, GL_INT, 32, 0, 0, 0, SignedInt,
false);
97 registerFmt(GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, 32, 0, 0, 0, UnsignedInt,
false);
98 registerFmt(GL_R32F, GL_RED, GL_FLOAT, 32, 0, 0, 0, FloatingPt,
false);
101 registerFmt(GL_RG8, GL_RG, GL_UNSIGNED_BYTE, 8, 8, 0, 0, UnsignedInt,
true);
102 registerFmt(GL_RG8_SNORM, GL_RG, GL_BYTE, 8, 8, 0, 0, SignedInt,
true);
103 registerFmt(GL_RG8I, GL_RG_INTEGER, GL_BYTE, 8, 8, 0, 0, SignedInt,
false);
104 registerFmt(GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE, 8, 8, 0, 0, UnsignedInt,
false);
106 registerFmt(GL_RG16, GL_RG, GL_UNSIGNED_SHORT, 16, 16, 0, 0, UnsignedInt,
true);
107 registerFmt(GL_RG16I, GL_RG_INTEGER, GL_SHORT, 16, 16, 0, 0, SignedInt,
false);
108 registerFmt(GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, 16, 16, 0, 0, UnsignedInt,
false);
109 registerFmt(GL_RG16F, GL_RG, GL_HALF_FLOAT, 16, 16, 0, 0, FloatingPt,
false);
111 registerFmt(GL_RG32I, GL_RG_INTEGER, GL_INT, 32, 32, 0, 0, SignedInt,
false);
112 registerFmt(GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, 32, 32, 0, 0, UnsignedInt,
false);
113 registerFmt(GL_RG32F, GL_RG, GL_FLOAT, 32, 32, 0, 0, FloatingPt,
false);
117 registerFmt(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, 8, 8, 8, 0, UnsignedInt,
true);
118 registerFmt(GL_RGB8_SNORM, GL_RGB, GL_BYTE, 8, 8, 8, 0, SignedInt,
true);
119 registerFmt(GL_RGB16F, GL_RGB, GL_HALF_FLOAT, 16, 16, 16, 0, FloatingPt,
false);
120 registerFmt(GL_RGB32F, GL_RGB, GL_FLOAT, 32, 32, 32, 0, FloatingPt,
false);
123 registerFmt(GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, 8, 8, 8, 8, UnsignedInt,
true);
124 registerFmt(GL_RGBA8_SNORM, GL_RGBA, GL_BYTE, 8, 8, 8, 8, SignedInt,
true);
126 registerFmt(GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT, 16, 16, 16, 16, SignedInt,
false);
127 registerFmt(GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, 16, 16, 16, 16, UnsignedInt,
false);
128 registerFmt(GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 16, 16, 16, 16, FloatingPt,
false);
130 registerFmt(GL_RGBA32I, GL_RGBA_INTEGER, GL_INT, 32, 32, 32, 32, SignedInt,
false);
131 registerFmt(GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, 32, 32, 32, 32, UnsignedInt,
false);
132 registerFmt(GL_RGBA32F, GL_RGBA, GL_FLOAT, 32, 32, 32, 32, FloatingPt,
false);
133 #endif // GL_VERSION_3_0 136 registerFmt(GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 24, 0, 0, 0, UnsignedInt,
false);
137 registerFmt(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 16, 0, 0, 0, UnsignedInt,
false);
138 #ifdef GL_ARB_depth_buffer_float 139 registerFmt(GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, 32, 0, 0, 0, FloatingPt,
false);
140 registerFmt(GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, 32, 8, -24, 0, FloatingPt,
false);
141 #endif // GL_ARB_depth_buffer_float 143 #ifdef GL_ARB_texture_stencil8 144 registerFmt(GL_STENCIL_INDEX8, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, 8, 0, 0, 0, UnsignedInt,
false);
145 #endif // GL_ARB_texture_stencil8 148 std::map<GLenum, GLFormatInfo>::iterator f = formatMap_.find(_internalFormat);
150 if (f != formatMap_.end())
155 std::cout <<
"GLFormatInfo: unknown internalFormat " << _internalFormat << std::endl;
159 GLFormatInfo::GLFormatInfo( GLenum _intfmt, GLenum _fmt, GLenum _type,
int _r,
int _g,
int _b,
int _a, BaseType _bt,
bool _nrm )
160 : internalFormat_(_intfmt), format_(_fmt), type_(_type),
161 channelCount_(0), bpp_(0), baseType_(_bt), normalized_(_nrm)
166 channelBits_[0] = std::max(_r, 0);
167 channelBits_[1] = std::max(_g, 0);
168 channelBits_[2] = std::max(_b, 0);
169 channelBits_[3] = std::max(_a, 0);
172 if (_r > 0) ++channelCount_;
173 if (_g > 0) ++channelCount_;
174 if (_b > 0) ++channelCount_;
175 if (_a > 0) ++channelCount_;
177 bpp_ = std::abs(_r) + std::abs(_g) + std::abs(_b) + std::abs(_a);
179 if (channelCount_ >= 1 && channelCount_ <= 4)
183 case GL_DEPTH_STENCIL: strcpy(sizedName_,
"GL_DEPTH_STENCIL");
break;
184 case GL_DEPTH_COMPONENT: strcpy(sizedName_,
"GL_DEPTH_COMPONENT");
break;
185 case GL_DEPTH_COMPONENT32: strcpy(sizedName_,
"GL_DEPTH_COMPONENT32");
break;
190 QString strfmt =
"GL_R";
192 if (channelCount_ > 1)
194 if (channelCount_ > 2)
196 if (channelCount_ > 3)
200 bitCount.sprintf(
"%i", channelBits_[0]);
219 int len = std::min(strfmt.length(), 31);
221 for (
int i = 0; i < len; ++i)
222 sizedName_[i] = strfmt.at(i).toLatin1();
229 GLFormatInfo::GLFormatInfo()
230 : internalFormat_(GL_NONE), format_(GL_NONE), type_(GL_NONE),
231 channelCount_(0), bpp_(0), baseType_(UnsignedInt), normalized_(true)
240 GLFormatInfo::~GLFormatInfo()
244 void GLFormatInfo::registerFmt( GLenum _intfmt, GLenum _fmt, GLenum _type,
int _r,
int _g,
int _b,
int _a, BaseType _bt,
bool _nrm )
246 formatMap_[_intfmt] = GLFormatInfo(_intfmt, _fmt, _type, _r, _g, _b, _a, _bt, _nrm);
Namespace providing different geometric functions concerning angles.