[Xquartz-changes] [177] AppleSGLX/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu Feb 19 15:09:20 PST 2009
Revision: 177
http://trac.macosforge.org/projects/xquartz/changeset/177
Author: gstaplin at apple.com
Date: 2009-02-19 15:09:20 -0800 (Thu, 19 Feb 2009)
Log Message:
-----------
Simplify the glXQueryDrawable path and extend it to support windows.
Redesign the private interface for the pbuffer querying, and make it
use the get_max_size() for the LARGEST_PBUFFER attribute.
Tested with ./builds/pbuffer and ./builds/pbuffer_destroy. The
latter still generates an XError message, as it should (to indicate
correct behavior).
Modified Paths:
--------------
AppleSGLX/trunk/apple_glx_pbuffer.c
AppleSGLX/trunk/apple_glx_pbuffer.h
AppleSGLX/trunk/glx_pbuffer.c
Modified: AppleSGLX/trunk/apple_glx_pbuffer.c
===================================================================
--- AppleSGLX/trunk/apple_glx_pbuffer.c 2009-02-19 22:39:03 UTC (rev 176)
+++ AppleSGLX/trunk/apple_glx_pbuffer.c 2009-02-19 23:09:20 UTC (rev 177)
@@ -36,7 +36,7 @@
struct apple_glx_pbuffer {
GLXPbuffer xid; /* our pixmap */
int width, height;
- XID fbconfig_id;
+ GLint fbconfigID;
CGLPBufferObj buffer_obj;
struct apple_glx_pbuffer *previous, *next;
};
@@ -95,7 +95,7 @@
struct apple_glx_pbuffer *pbuf;
Window root;
int screen;
- __GLcontextModes *mode = (__GLcontextModes *)config;
+ __GLcontextModes *modes = (__GLcontextModes *)config;
pbuf = malloc(sizeof(*pbuf));
@@ -109,9 +109,9 @@
pbuf->previous = NULL;
pbuf->next = NULL;
- /*TODO perhaps use GL_RGB if the config specifies a 0 alpha. */
err = apple_cgl.create_pbuffer(width, height, GL_TEXTURE_RECTANGLE_EXT,
- GL_RGBA, 0, &pbuf->buffer_obj);
+ (modes->alphaBits > 0) ? GL_RGBA : GL_RGB,
+ 0, &pbuf->buffer_obj);
if(kCGLNoError != err) {
free(pbuf);
@@ -138,8 +138,7 @@
return true;
}
- printf("mode->fbconfigID %d\n", mode->fbconfigID);
- pbuf->fbconfig_id = mode->fbconfigID;
+ pbuf->fbconfigID = modes->fbconfigID;
*result = pbuf->xid;
@@ -204,41 +203,8 @@
return false;
}
-bool apple_glx_pbuffer_get_width(GLXDrawable d, int *width) {
- struct apple_glx_pbuffer *pbuf;
-
- if(find_pbuffer(d, &pbuf)) {
- *width = pbuf->width;
- return true;
- }
-
- return false;
-}
-
-bool apple_glx_pbuffer_get_height(GLXDrawable d, int *height) {
- struct apple_glx_pbuffer *pbuf;
-
- if(find_pbuffer(d, &pbuf)) {
- *height = pbuf->height;
- return true;
- }
-
- return false;
-}
-
-bool apple_glx_pbuffer_get_fbconfig_id(GLXDrawable d, XID *id) {
- struct apple_glx_pbuffer *pbuf;
-
- if(find_pbuffer(d, &pbuf)) {
- *id = pbuf->fbconfig_id;
- return true;
- }
-
- return false;
-}
-
/* Return true if an error occurred. */
-bool apple_glx_pbuffer_get_max_size(int *widthresult, int *heightresult) {
+static bool get_max_size(int *widthresult, int *heightresult) {
CGLContextObj oldcontext;
GLint ar[2];
@@ -299,6 +265,8 @@
apple_cgl.destroy_context(newcontext);
apple_cgl.destroy_pixel_format(pfobj);
} else {
+ /* We have a valid context. */
+
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, ar);
}
@@ -307,3 +275,46 @@
return false;
}
+
+bool apple_glx_pbuffer_query(GLXPbuffer p, int attr, unsigned int *value) {
+ bool result = false;
+ struct apple_glx_pbuffer *pbuf;
+
+ if(find_pbuffer(p, &pbuf)) {
+ switch(attr) {
+ case GLX_WIDTH:
+ *value = pbuf->width;
+ result = true;
+ break;
+
+ case GLX_HEIGHT:
+ *value = pbuf->height;
+ result = true;
+ break;
+
+ case GLX_PRESERVED_CONTENTS:
+ *value = true;
+ result = true;
+ break;
+
+ case GLX_LARGEST_PBUFFER: {
+ int width, height;
+ if(get_max_size(&width, &height)) {
+ fprintf(stderr, "internal error: "
+ "unable to find the largest pbuffer!\n");
+ } else {
+ *value = width;
+ result = true;
+ }
+ }
+ break;
+
+ case GLX_FBCONFIG_ID:
+ *value = pbuf->fbconfigID;
+ result = true;
+ break;
+ }
+ }
+
+ return result;
+}
Modified: AppleSGLX/trunk/apple_glx_pbuffer.h
===================================================================
--- AppleSGLX/trunk/apple_glx_pbuffer.h 2009-02-19 22:39:03 UTC (rev 176)
+++ AppleSGLX/trunk/apple_glx_pbuffer.h 2009-02-19 23:09:20 UTC (rev 177)
@@ -42,6 +42,10 @@
/* Returns true if the drawable has a valid pbuffer object result. */
bool apple_glx_pbuffer_get(GLXDrawable d, CGLPBufferObj *result);
+/* Returns true if the pbuffer was valid and the attribute. */
+bool apple_glx_pbuffer_query(GLXDrawable d, int attribute,
+ unsigned int *value);
+
/* These return true if the drawable is a valid Pbuffer: */
bool apple_glx_pbuffer_get_width(GLXDrawable d, int *width);
bool apple_glx_pbuffer_get_height(GLXDrawable d, int *height);
Modified: AppleSGLX/trunk/glx_pbuffer.c
===================================================================
--- AppleSGLX/trunk/glx_pbuffer.c 2009-02-19 22:39:03 UTC (rev 176)
+++ AppleSGLX/trunk/glx_pbuffer.c 2009-02-19 23:09:20 UTC (rev 177)
@@ -649,54 +649,31 @@
glXQueryDrawable(Display *dpy, GLXDrawable drawable,
int attribute, unsigned int *value) {
GLXContext gc = __glXGetCurrentContext();
+ Window root;
+ int x, y;
+ unsigned int width, height, bd, depth;
xError error;
if(apple_glx_pixmap_query(drawable, attribute, value))
return; /*done*/
- switch(attribute) {
- case GLX_WIDTH: {
- int width;
+ if(apple_glx_pbuffer_query(drawable, attribute, value))
+ return; /*done*/
- if(apple_glx_pbuffer_get_width(drawable, &width)) {
- *value = (unsigned int)width;
+ if(XGetGeometry(dpy, drawable, &root, &x, &y, &width, &height, &bd, &depth)) {
+ switch(attribute) {
+ case GLX_WIDTH:
+ *value = width;
return;
- }
- }
- break;
- case GLX_HEIGHT: {
- int height;
-
- if(apple_glx_pbuffer_get_height(drawable, &height)) {
- *value = (unsigned int)height;
+ case GLX_HEIGHT:
+ *value = height;
return;
}
+ /*FALL THROUGH*/
}
- break;
-
- case GLX_PRESERVED_CONTENTS:
- *value = true;
- return;
- break;
-
- case GLX_FBCONFIG_ID: {
- XID id;
-
- if(apple_glx_pbuffer_get_fbconfig_id(drawable, &id)) {
- *value = id;
- return;
- }
- }
- break;
-
- default:
- fprintf(stderr, "%s invalid attribute: %d\n", __func__, attribute);
- abort();
- }
-
-
+
LockDisplay(dpy);
error.errorCode = GLXBadDrawable;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/xquartz-changes/attachments/20090219/14ee499c/attachment-0001.html>
More information about the Xquartz-changes
mailing list