GLint active_texture = GL_TEXTURE0;
glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
- snprintf(label, sizeof label, "%s, %s, %s, %d level",
- enumToString(active_texture), enumToString(target), enumToString(format), level);
+ snprintf(label, sizeof label, "%s, %s, level = %d",
+ enumToString(active_texture), enumToString(target), level);
json.beginMember(label);
json.writeNumberMember("__height__", height);
json.writeNumberMember("__depth__", depth);
+ json.writeStringMember("__format__", enumToString(format));
+
// Hardcoded for now, but we could chose types more adequate to the
// texture internal format
json.writeStringMember("__type__", "uint8");
#else
+#if !TRACE_EGL
Display *display;
Drawable drawable;
Window root;
*width = w;
*height = h;
+#else
+ return false;
+#endif
#endif
}
-static GLint
+static GLenum
getTextureLevelFormat(GLint texture, GLint level)
{
GLenum target;
}
+static GLenum
+getRenderbufferFormat(GLint renderbuffer)
+{
+ GLint bound_renderbuffer = 0;
+ glGetIntegerv(GL_RENDERBUFFER_BINDING, &bound_renderbuffer);
+ glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
+
+ GLint format = GL_NONE;
+ glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_INTERNAL_FORMAT, &format);
+
+ glBindRenderbuffer(GL_RENDERBUFFER, bound_renderbuffer);
+
+ return format;
+}
+
+
static bool
getFramebufferAttachmentSize(GLenum target, GLenum attachment, GLint *width, GLint *height)
{
}
if (object_type == GL_RENDERBUFFER) {
- GLint format = GL_NONE;
- glGetRenderbufferParameteriv(object_name, GL_RENDERBUFFER_INTERNAL_FORMAT,
- &format);
- return format;
+ return getRenderbufferFormat(object_name);
} else if (object_type == GL_TEXTURE) {
GLint texture_level = 0;
glGetFramebufferAttachmentParameteriv(target, attachment,
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL,
&texture_level);
-
- GLint format = getTextureLevelFormat(object_name, texture_level);
- return format;
+ return getTextureLevelFormat(object_name, texture_level);
} else {
std::cerr << "warning: unexpected GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = " << object_type << "\n";
return GL_NONE;
image::Image *
-getDrawBufferImage(GLenum format) {
+getDrawBufferImage() {
+ GLenum format = GL_RGB;
GLint channels = __gl_format_channels(format);
if (channels > 4) {
return NULL;
* Dump the image of the currently bound read buffer.
*/
static inline void
-dumpReadBufferImage(JSONWriter &json, GLint width, GLint height, GLenum format)
+dumpReadBufferImage(JSONWriter &json, GLint width, GLint height, GLenum format,
+ GLint internalFormat = GL_NONE)
{
GLint channels = __gl_format_channels(format);
json.writeNumberMember("__height__", height);
json.writeNumberMember("__depth__", 1);
+ json.writeStringMember("__format__", enumToString(internalFormat));
+
// Hardcoded for now, but we could chose types more adequate to the
// texture internal format
json.writeStringMember("__type__", "uint8");
glGetIntegerv(GL_READ_BUFFER, &read_buffer);
GLint alpha_bits = 0;
+#if 0
+ // XXX: Ignore alpha until we are able to match the traced visual
glGetIntegerv(GL_ALPHA_BITS, &alpha_bits);
+#endif
GLenum format = alpha_bits ? GL_RGBA : GL_RGB;
json.beginMember(enumToString(draw_buffer));
dumpReadBufferImage(json, width, height, format);
json.endMember();
}
}
+
+
/**
* Dump the specified framebuffer attachment.
*
}
GLint internalFormat = getFramebufferAttachmentFormat(target, attachment);
- std::stringstream ss;
- ss << enumToString(attachment);
- if (internalFormat != GL_NONE) {
- ss << ", ";
- ss << enumToString(internalFormat);
- }
- json.beginMember(ss.str());
- dumpReadBufferImage(json, width, height, format);
+ json.beginMember(enumToString(attachment));
+ dumpReadBufferImage(json, width, height, format, internalFormat);
json.endMember();
}