Added some comments describing the formats in the Canvas::Format enum.

--HG--
branch : Canvas-formats
This commit is contained in:
Alex Szpakowski
2014-05-14 01:38:33 -03:00
parent 4aeba24e94
commit 5658a2440b
2 changed files with 21 additions and 20 deletions
+9 -9
View File
@@ -1044,6 +1044,7 @@ bool Canvas::isMultiCanvasSupported()
}
bool Canvas::supportedFormats[] = {false};
bool Canvas::checkedFormats[] = {false};
bool Canvas::isFormatSupported(Canvas::Format format)
{
@@ -1065,12 +1066,11 @@ bool Canvas::isFormatSupported(Canvas::Format format)
supported = GLEE_VERSION_4_2 || GLEE_ARB_ES2_compatibility;
break;
case FORMAT_RG11B10F:
supported = GLEE_VERSION_3_0 || (GLEE_ARB_texture_float && GLEE_ARB_color_buffer_float
&& GLEE_EXT_packed_float);
supported = GLEE_VERSION_3_0 || (GLEE_ARB_texture_float && GLEE_EXT_packed_float);
break;
case FORMAT_RGBA16F:
case FORMAT_RGBA32F:
supported = GLEE_VERSION_3_0 || (GLEE_ARB_texture_float && GLEE_ARB_color_buffer_float);
supported = GLEE_VERSION_3_0 || GLEE_ARB_texture_float;
break;
case FORMAT_SRGB:
supported = GLEE_VERSION_3_0 || ((GLEE_ARB_framebuffer_sRGB || GLEE_EXT_framebuffer_sRGB)
@@ -1084,8 +1084,8 @@ bool Canvas::isFormatSupported(Canvas::Format format)
if (!supported)
return false;
if (supportedFormats[format])
return true;
if (checkedFormats[format])
return supportedFormats[format];
// Even though we might have the necessary OpenGL version or extension,
// drivers are still allowed to throw FRAMEBUFFER_UNSUPPORTED when attaching
@@ -1111,16 +1111,16 @@ bool Canvas::isFormatSupported(Canvas::Format format)
glTexImage2D(GL_TEXTURE_2D, 0, internalformat, 2, 2, 0, externalformat, textype, nullptr);
GLuint fbo = 0;
GLenum status = strategy->createFBO(fbo, texture);
supported = (strategy->createFBO(fbo, texture) == GL_FRAMEBUFFER_COMPLETE);
strategy->deleteFBO(fbo, 0, 0);
gl.deleteTexture(texture);
// Cache the result so we don't do this for every isFormatSupported call.
if (status == GL_FRAMEBUFFER_COMPLETE)
supportedFormats[format] = true;
checkedFormats[format] = true;
supportedFormats[format] = supported;
return status == GL_FRAMEBUFFER_COMPLETE;
return supported;
}
void Canvas::bindDefaultCanvas()
+12 -11
View File
@@ -43,17 +43,17 @@ public:
// Different Canvas render target formats.
enum Format
{
FORMAT_NORMAL,
FORMAT_HDR,
FORMAT_RGBA8,
FORMAT_RGBA4,
FORMAT_RGB5A1,
FORMAT_RGB565,
FORMAT_RGB10A2,
FORMAT_RG11B10F,
FORMAT_RGBA16F,
FORMAT_RGBA32F,
FORMAT_SRGB,
FORMAT_NORMAL, // Usually RGBA8 or a similar fallback. Always supported.
FORMAT_HDR, // Usually RGBA16F. Not always supported.
FORMAT_RGBA8, // RGBA with 8 bits per component.
FORMAT_RGBA4, // RGBA with 4 bits per component.
FORMAT_RGB5A1, // RGB with 5 bits per component, and A with 1 bit.
FORMAT_RGB565, // RGB with 5, 6, and 5 bits each, respectively.
FORMAT_RGB10A2, // RGB with 10 bits each, and A with 2 bits.
FORMAT_RG11B10F, // Floating point [0, +inf]. RG with 11 FP bits each, and B with 10 FP bits.
FORMAT_RGBA16F, // Floating point [-inf, +inf]. RGBA with 16 FP bits per component.
FORMAT_RGBA32F, // Floating point [-inf, +inf]. RGBA with 32 FP bits per component.
FORMAT_SRGB, // sRGB with 8 bits per component, plus 8 bit linear A.
FORMAT_MAX_ENUM
};
@@ -158,6 +158,7 @@ private:
void drawv(const Matrix &t, const Vertex *v);
static bool supportedFormats[FORMAT_MAX_ENUM];
static bool checkedFormats[FORMAT_MAX_ENUM];
static StringMap<Format, FORMAT_MAX_ENUM>::Entry formatEntries[];
static StringMap<Format, FORMAT_MAX_ENUM> formats;