summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/agl/glitz_agl_extension.c135
-rw-r--r--src/agl/glitz_agl_format.c40
-rw-r--r--src/agl/glitz_aglint.h10
3 files changed, 125 insertions, 60 deletions
diff --git a/src/agl/glitz_agl_extension.c b/src/agl/glitz_agl_extension.c
index 0456ee1..6fe2073 100644
--- a/src/agl/glitz_agl_extension.c
+++ b/src/agl/glitz_agl_extension.c
@@ -1,18 +1,19 @@
/*
* Copyright © 2004 David Reveman
+ * Copyright © 2008 Paolo Bonzini
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * David Reveman not be used in advertising or publicity pertaining to
+ * appear in supporting documentation, and that the name of the
+ * copyright holders not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior permission.
- * David Reveman makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
+ * The copyright holders make no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express or
* implied warranty.
*
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
@@ -21,6 +22,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: David Reveman <davidr@novell.com>
+ * Author: Paolo Bonzini <bonzini@gnu.org>
*/
#ifdef HAVE_CONFIG_H
@@ -41,51 +43,104 @@ static glitz_extension_map agl_extensions[] = {
{ 0.0, NULL, 0 }
};
+static int
+glitz_test_pbuffer_format (glitz_agl_thread_info_t *thread_info,
+ GLint *attrib)
+{
+ AGLContext ctx = NULL;
+ AGLPixelFormat pix = NULL;
+ AGLPbuffer pb = NULL;
+ int result;
+
+ result =
+ ((pix = aglChoosePixelFormat (NULL, 0, attrib)) != NULL
+ && (pb = glitz_agl_pbuffer_create (thread_info, 2, 2)) != NULL
+ && (ctx = aglCreateContext (pix, NULL)) != NULL
+ && aglSetPBuffer (ctx, pb, 0, 0,
+ aglGetVirtualScreen (ctx)) == AGL_NO_ERROR);
+
+ if (ctx != NULL)
+ aglDestroyContext (ctx);
+ if (pb != NULL)
+ aglDestroyPBuffer (pb);
+ if (pix != NULL)
+ aglDestroyPixelFormat (pix);
+ return result;
+}
+
+static GLint _default_attrib[] = {
+ AGL_RGBA,
+ AGL_NO_RECOVERY,
+ AGL_NONE
+};
+
+static GLint _db_attrib[] = {
+ AGL_RGBA,
+ AGL_DOUBLEBUFFER,
+ AGL_NO_RECOVERY,
+ AGL_NONE
+};
+
+static GLint _depth_attrib[] = {
+ AGL_RGBA,
+ AGL_NO_RECOVERY,
+ AGL_DEPTH_SIZE, 8,
+ AGL_STENCIL_SIZE, 8,
+ AGL_NONE
+};
+
+static GLint _ms_attrib[] = {
+ AGL_RGBA,
+ AGL_NO_RECOVERY,
+ AGL_SAMPLE_BUFFERS_ARB, 1,
+ AGL_SAMPLES_ARB, 2,
+ AGL_NONE
+};
+
glitz_status_t
glitz_agl_query_extensions (glitz_agl_thread_info_t *thread_info)
{
- GLint attrib[] = {
- AGL_RGBA,
- AGL_NO_RECOVERY,
- AGL_NONE
- };
- AGLPixelFormat pf;
AGLContext context;
+ AGLPixelFormat pf;
thread_info->agl_feature_mask = 0;
- pf = aglChoosePixelFormat (NULL, 0, attrib);
+ pf = aglChoosePixelFormat (NULL, 0, _default_attrib);
context = aglCreateContext (pf, NULL);
if (context) {
- const char *gl_extensions_string;
-
- aglSetCurrentContext (context);
-
- gl_extensions_string = (const char *) glGetString (GL_EXTENSIONS);
-
- thread_info->agl_feature_mask =
- glitz_extensions_query (0.0,
- gl_extensions_string,
- agl_extensions);
-
- if (thread_info->agl_feature_mask & GLITZ_AGL_FEATURE_MULTISAMPLE_MASK)
- {
- const char *vendor;
-
- vendor = glGetString (GL_VENDOR);
-
- if (vendor) {
-
- /* NVIDIA's driver seem to support multisample with pbuffers */
- if (!strncmp ("NVIDIA", vendor, 6))
- thread_info->agl_feature_mask |=
- GLITZ_AGL_FEATURE_PBUFFER_MULTISAMPLE_MASK;
- }
- }
-
- aglSetCurrentContext (NULL);
- aglDestroyContext (context);
+ const char *gl_extensions_string;
+
+ aglSetCurrentContext (context);
+
+ gl_extensions_string = (const char *) glGetString (GL_EXTENSIONS);
+
+ thread_info->agl_feature_mask =
+ glitz_extensions_query (0.0,
+ gl_extensions_string,
+ agl_extensions);
+
+ aglSetCurrentContext (NULL);
+ aglDestroyContext (context);
+
+ if (glitz_test_pbuffer_format (thread_info, _db_attrib))
+ {
+ thread_info->agl_feature_mask |=
+ GLITZ_AGL_FEATURE_PBUFFER_DOUBLEBUFFER_MASK;
+ }
+
+ if (glitz_test_pbuffer_format (thread_info, _depth_attrib))
+ {
+ thread_info->agl_feature_mask |=
+ GLITZ_AGL_FEATURE_PBUFFER_DEPTH_STENCIL_MASK;
+ }
+
+ if ((thread_info->agl_feature_mask & GLITZ_AGL_FEATURE_MULTISAMPLE_MASK)
+ && glitz_test_pbuffer_format (thread_info, _ms_attrib))
+ {
+ thread_info->agl_feature_mask |=
+ GLITZ_AGL_FEATURE_PBUFFER_MULTISAMPLE_MASK;
+ }
}
aglDestroyPixelFormat (pf);
diff --git a/src/agl/glitz_agl_format.c b/src/agl/glitz_agl_format.c
index 80795b9..0375490 100644
--- a/src/agl/glitz_agl_format.c
+++ b/src/agl/glitz_agl_format.c
@@ -275,22 +275,30 @@ glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info)
} else
format.d.samples = 1;
- if (thread_info->agl_feature_mask & GLITZ_AGL_FEATURE_PBUFFER_MASK) {
- if (format.d.color.red_size && format.d.color.green_size &&
- format.d.color.blue_size && format.d.color.alpha_size &&
- format.d.doublebuffer == 0 && format.d.stencil_size == 0 &&
- format.d.depth_size == 0) {
-
- if (thread_info->agl_feature_mask &
- GLITZ_AGL_FEATURE_PBUFFER_MULTISAMPLE_MASK)
- format.types |= GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
- else if (format.d.samples == 1)
- format.types |= GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
- else
- format.types &= ~GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
- } else
- format.types &= ~GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
- } else
+ format.types |= GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
+ if ((thread_info->agl_feature_mask &
+ GLITZ_AGL_FEATURE_PBUFFER_MASK) == 0)
+ format.types &= ~GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
+
+ else if (format.d.color.red_size == 0 ||
+ format.d.color.green_size == 0 ||
+ format.d.color.blue_size == 0 ||
+ format.d.color.alpha_size == 0)
+ format.types &= ~GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
+
+ else if ((thread_info->agl_feature_mask &
+ GLITZ_AGL_FEATURE_PBUFFER_DOUBLEBUFFER_MASK) == 0
+ && format.d.doublebuffer)
+ format.types &= ~GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
+
+ else if ((thread_info->agl_feature_mask &
+ GLITZ_AGL_FEATURE_PBUFFER_MULTISAMPLE_MASK) == 0
+ && format.d.samples > 1)
+ format.types &= ~GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
+
+ else if ((thread_info->agl_feature_mask &
+ GLITZ_AGL_FEATURE_PBUFFER_DEPTH_STENCIL_MASK) == 0
+ && (format.d.depth_size > 0 || format.d.stencil_size > 0))
format.types &= ~GLITZ_DRAWABLE_TYPE_PBUFFER_MASK;
if (format.d.color.red_size ||
diff --git a/src/agl/glitz_aglint.h b/src/agl/glitz_aglint.h
index 998bc09..f9fc389 100644
--- a/src/agl/glitz_aglint.h
+++ b/src/agl/glitz_aglint.h
@@ -35,10 +35,12 @@
#include <Carbon/Carbon.h>
#include <AGL/agl.h>
-#define GLITZ_AGL_FEATURE_PBUFFER_MASK (1L << 0)
-#define GLITZ_AGL_FEATURE_MULTISAMPLE_MASK (1L << 1)
-#define GLITZ_AGL_FEATURE_PBUFFER_MULTISAMPLE_MASK (1L << 2)
-#define GLITZ_AGL_FEATURE_TEXTURE_RECTANGLE_MASK (1L << 3)
+#define GLITZ_AGL_FEATURE_PBUFFER_MASK (1L << 0)
+#define GLITZ_AGL_FEATURE_MULTISAMPLE_MASK (1L << 1)
+#define GLITZ_AGL_FEATURE_PBUFFER_MULTISAMPLE_MASK (1L << 2)
+#define GLITZ_AGL_FEATURE_PBUFFER_DOUBLEBUFFER_MASK (1L << 3)
+#define GLITZ_AGL_FEATURE_PBUFFER_DEPTH_STENCIL_MASK (1L << 4)
+#define GLITZ_AGL_FEATURE_TEXTURE_RECTANGLE_MASK (1L << 5)
typedef struct _glitz_agl_drawable glitz_agl_drawable_t;