Revision
227
Author
gstaplin@apple.com
Date
2009-02-21 21:19:26 -0800 (Sat, 21 Feb 2009)

Log Message

Add a test program that according to the CGL documentation
provides the maximum size of a Pbuffer.  This is used for
getting a value for the xserver's hw/xquartz/GL/indirect.c

We may at some point want to create a context, and probe
at runtime, but I'm not sure what will be involved with 
doing that in the X server.

Added Paths

Diff

Added: AppleSGLX/trunk/apple_GL_pbuffer_max.c (0 => 227)


--- AppleSGLX/trunk/apple_GL_pbuffer_max.c	                        (rev 0)
+++ AppleSGLX/trunk/apple_GL_pbuffer_max.c	2009-02-22 05:19:26 UTC (rev 227)
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <OpenGL/OpenGL.h>
+
+int main() {
+	CGLPixelFormatAttribute attribs[] = {
+                kCGLPFAAccelerated,
+                kCGLPFADoubleBuffer,
+                kCGLPFAColorSize, 24,
+		0
+	};	
+	
+	CGLPixelFormatObj pixobj;
+	GLint npix;
+	CGLError err;
+	CGLContextObj context;
+	GLint maxview[2];
+
+	err = CGLChoosePixelFormat(attribs, &pixobj, &npix);
+
+	if(err != kCGLNoError) {
+		fprintf(stderr, "choose pixel format error!\n");
+		return EXIT_FAILURE;
+	}
+
+	err = CGLCreateContext(pixobj, NULL, &context);
+	
+	if(err != kCGLNoError) {
+		fprintf(stderr, "create context error!\n");
+		return EXIT_FAILURE;
+	}
+
+	CGLSetCurrentContext(context);
+
+	maxview[0] = 0;
+	maxview[1] = 0;
+	glGetIntegerv(GL_MAX_VIEWPORT_DIMS, maxview);
+
+	printf("max pbuffer width %d heigth %d\n", maxview[0], maxview[1]);
+
+	return EXIT_SUCCESS;
+}