};
+/**
+ * Choose the glReadPixels/glGetTexImage format appropriate for the given
+ * internalFormat.
+ */
static GLenum
getFormat(GLenum internalFormat)
{
json.beginMember(label);
- GLenum format = getFormat(desc.internalFormat);;
+ GLenum format = getFormat(desc.internalFormat);
if (context.ES && format == GL_DEPTH_COMPONENT) {
format = GL_RED;
}
- GLuint channels = _gl_format_channels(format);;
+ GLuint channels = _gl_format_channels(format);
image::Image *image = new image::Image(desc.width, desc.height*desc.depth, channels, true);
* In the case of a color attachment, it assumes it is already bound for read.
*/
static void
-dumpFramebufferAttachment(JSONWriter &json, Context &context, GLenum target, GLenum attachment, GLenum format)
+dumpFramebufferAttachment(JSONWriter &json, Context &context, GLenum target, GLenum attachment, GLenum format = GL_NONE)
{
ImageDesc desc;
if (!getFramebufferAttachmentDesc(context, target, attachment, desc)) {
assert(desc.samples == 0);
+ if (format == GL_NONE) {
+ assert(desc.internalFormat != GL_NONE);
+ format = getFormat(desc.internalFormat);
+ }
+
json.beginMember(enumToString(attachment));
dumpReadBufferImage(json, desc.width, desc.height, format, desc.internalFormat);
json.endMember();
std::cerr << "warning: unexpected GL_DRAW_BUFFER" << i << " = " << draw_buffer << "\n";
attachment = GL_COLOR_ATTACHMENT0;
}
- GLint alpha_size = 0;
- glGetFramebufferAttachmentParameteriv(target, attachment,
- GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
- &alpha_size);
- GLenum format = alpha_size ? GL_RGBA : GL_RGB;
- dumpFramebufferAttachment(json, context, target, attachment, format);
+ dumpFramebufferAttachment(json, context, target, attachment);
}
}