]> git.cworth.org Git - apitrace/blobdiff - glstate.cpp
Make windows build user friendlier.
[apitrace] / glstate.cpp
index 2fa4cb5577e08879d9b333379c6b537aec1aa5bf..59d28c967336fc3c044a700e5224f94dfe9bb58a 100644 (file)
 extern "C" {
 #endif
 
-typedef int CGSConnectionID;
-typedef int CGSWindowID;
-typedef int CGSSurfaceID;
-
-CGLError CGLGetSurface(CGLContextObj, CGSConnectionID*, CGSWindowID*, CGSSurfaceID*);
 OSStatus CGSGetSurfaceBounds(CGSConnectionID, CGWindowID, CGSSurfaceID, CGRect *);
 
 #ifdef __cplusplus
@@ -407,18 +402,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 +433,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();