summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2000-09-08 16:42:06 +0000
committerBrian Paul <[email protected]>2000-09-08 16:42:06 +0000
commit46dbaec56af26bbb76e275fb08febeded908fc41 (patch)
tree7cf3b1989e8dd4befca0d1d7a460e972cc94b613
parent2bf5d9470d3232763cb49b5589209940d4d5398d (diff)
Use OSMesaCreateContextExt() if using Mesa 3.5 or later
-rw-r--r--progs/demos/osdemo.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/progs/demos/osdemo.c b/progs/demos/osdemo.c
index 7411d4ad4e0..acb9d3ab01d 100644
--- a/progs/demos/osdemo.c
+++ b/progs/demos/osdemo.c
@@ -1,4 +1,4 @@
-/* $Id: osdemo.c,v 1.4 2000/03/28 16:59:39 rjfrank Exp $ */
+/* $Id: osdemo.c,v 1.5 2000/09/08 16:42:06 brianp Exp $ */
/*
* Demo of off-screen Mesa rendering
@@ -223,15 +223,38 @@ write_ppm(const char *filename, const GLubyte *buffer, int width, int height)
int main( int argc, char *argv[] )
{
+ void *buffer;
+
/* Create an RGBA-mode context */
+#if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305
+ /* specify Z, stencil, accum sizes */
+ OSMesaContext ctx = OSMesaCreateContextExt( GL_RGBA, 16, 0, 0, NULL );
+#else
OSMesaContext ctx = OSMesaCreateContext( GL_RGBA, NULL );
+#endif
+ if (!ctx) {
+ printf("OSMesaCreateContext failed!\n");
+ return 0;
+ }
/* Allocate the image buffer */
- void *buffer = malloc( WIDTH * HEIGHT * 4 );
+ buffer = malloc( WIDTH * HEIGHT * 4 );
+ if (!buffer) {
+ printf("Alloc image buffer failed!\n");
+ return 0;
+ }
/* Bind the buffer to the context and make it current */
OSMesaMakeCurrent( ctx, buffer, GL_UNSIGNED_BYTE, WIDTH, HEIGHT );
+ {
+ int z, s, a;
+ glGetIntegerv(GL_DEPTH_BITS, &z);
+ glGetIntegerv(GL_STENCIL_BITS, &s);
+ glGetIntegerv(GL_ACCUM_RED_BITS, &a);
+ printf("%d %d %d\n", z, s, a);
+ }
+
render_image();
if (argc>1) {