summaryrefslogtreecommitdiff
path: root/glstate.cpp
diff options
context:
space:
mode:
authorJosé Fonseca <jose.r.fonseca@gmail.com>2011-05-24 09:49:23 +0100
committerJosé Fonseca <jose.r.fonseca@gmail.com>2011-05-24 09:50:09 +0100
commitc4c0be53e8151a61529822c1c11a99fad3f6ec20 (patch)
tree998bd27a8be2503aa7b58a4135faf12625f271ad /glstate.cpp
parent96404a790de7891a30bd4e3e668b436a735efde0 (diff)
Handle an arbitrary number of image channels.
Diffstat (limited to 'glstate.cpp')
-rw-r--r--glstate.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/glstate.cpp b/glstate.cpp
index 2fa4cb5..71aad7d 100644
--- a/glstate.cpp
+++ b/glstate.cpp
@@ -407,18 +407,17 @@ getDrawableBounds(GLint *width, GLint *height) {
Image::Image *
getDrawBufferImage(GLenum format) {
- GLint width, height;
-
- if (format != GL_RGBA) {
- // FIXME: this function can only handle 4-channel images
+ GLint channels = __gl_format_channels(format);
+ if (channels > 4) {
return NULL;
}
+ GLint width, height;
if (!getDrawableBounds(&width, &height)) {
return NULL;
}
- Image::Image *image = new Image::Image(width, height, true);
+ Image::Image *image = new Image::Image(width, height, channels, true);
if (!image) {
return NULL;
}
@@ -439,7 +438,7 @@ getDrawBufferImage(GLenum format) {
glPixelStorei(GL_PACK_SKIP_IMAGES, 0);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
- glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels);
+ glReadPixels(0, 0, width, height, format, GL_UNSIGNED_BYTE, image->pixels);
glPopClientAttrib();