diff options
author | David Reveman <davidr@novell.com> | 2004-05-01 20:36:34 +0000 |
---|---|---|
committer | David Reveman <davidr@novell.com> | 2004-05-01 20:36:34 +0000 |
commit | 6734c7137843ae690c47ce830e5bfe543520db9c (patch) | |
tree | 79862e59daae69600508a6f182f2c40215235a6b | |
parent | 25b7beb7f2794a6953e44dcb828bdb9d220a606d (diff) |
Initialization fixes
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | src/glitz_agl_format.c | 29 | ||||
-rw-r--r-- | src/glitz_format.c | 18 | ||||
-rw-r--r-- | src/glitz_glx_extension.c | 19 | ||||
-rw-r--r-- | src/glitz_glx_format.c | 71 | ||||
-rw-r--r-- | src/glitz_glx_info.c | 102 |
6 files changed, 147 insertions, 110 deletions
@@ -1,3 +1,21 @@ +2004-05-01 David Reveman <c99drn@cs.umu.se> + + * src/glitz_agl_format.c (glitz_agl_query_formats): Cleaned up + creation of fake offscreen formats. + + * src/glitz_glx_info.c (glitz_glx_thread_info_get): Do + proc address lookup. + (glitz_glx_screen_info_get): Handle errors better. + (glitz_glx_create_root_context): Better root context creation. + + * src/glitz_glx_format.c: Cleaned up creation of fake offscreen + formats. + + * src/glitz_glx_extension.c (glitz_glx_query_extensions): Pbuffer + multi-sampling supported on Quadro cards. + + * src/glitz_format.c: Fixed indentation. + 2004-04-30 David Reveman <c99drn@cs.umu.se> * configure.in: Bump version to 0.1.1. diff --git a/src/glitz_agl_format.c b/src/glitz_agl_format.c index ff90ec8..04b5d63 100644 --- a/src/glitz_agl_format.c +++ b/src/glitz_agl_format.c @@ -259,7 +259,6 @@ glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info) glitz_format_t format; AGLPixelFormat pixel_format; int i = 0; - glitz_bool_t offscreen_argb32_format = 0; for (i = 0; *(pixel_format_attrib_map[i].attrib); i++) { GLint value; @@ -275,7 +274,7 @@ glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info) } aglDescribePixelFormat (pixel_format, AGL_DOUBLEBUFFER, &value); - format.doublebuffer = (value) ? 1: 0; + format.doublebuffer = (value)? 1: 0; /* We don't support single buffering in MacOS X */ if (!format.doublebuffer) { @@ -306,7 +305,7 @@ glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info) if (thread_info->feature_mask & GLITZ_FEATURE_MULTISAMPLE_MASK) { aglDescribePixelFormat (pixel_format, AGL_SAMPLE_BUFFERS_ARB, &value); - format.multisample.supported = (value) ? 1: 0; + format.multisample.supported = (value)? 1: 0; aglDescribePixelFormat (pixel_format, AGL_SAMPLES_ARB, &value); format.multisample.samples = (unsigned short) value; @@ -320,11 +319,6 @@ glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info) format.multisample.samples = 0; } - if (format.drawable.offscreen && - format.alpha_size && - format.red_size && format.green_size && format.blue_size) - offscreen_argb32_format = 1; - _glitz_add_format (thread_info, &format); if (format.alpha_size && @@ -342,20 +336,25 @@ glitz_agl_query_formats (glitz_agl_thread_info_t *thread_info) qsort (thread_info->formats, thread_info->n_formats, sizeof (glitz_format_t), _glitz_agl_format_compare); - - /* Adding fake offscreen formats if no real argb32 offscreen formats exist. - Surfaces created with these formats can only be used with draw/read - pixel functions and as source in composite functions. */ - if (!offscreen_argb32_format) { + + if (!glitz_format_find_standard (thread_info->formats, + thread_info->n_formats, + GLITZ_FORMAT_OPTION_OFFSCREEN_MASK, + GLITZ_STANDARD_ARGB32)) { + + thread_info->feature_mask &= ~GLITZ_FEATURE_OFFSCREEN_DRAWING_MASK; + + /* Adding fake offscreen formats. Surfaces created with these format can + only be used with draw/read pixel functions and as source in composite + functions. */ memset (&format, 0, sizeof (glitz_format_t)); format.drawable.offscreen = 1; format.alpha_size = format.red_size = format.green_size = format.blue_size = 8; - format.id = 0; _glitz_add_format (thread_info, &format); format.alpha_size = 0; _glitz_add_format (thread_info, &format); - format.alpha_size = 8; + format.alpha_size = 8; format.red_size = format.green_size = format.blue_size = 0; _glitz_add_format (thread_info, &format); } diff --git a/src/glitz_format.c b/src/glitz_format.c index 9fe1556..faecb2a 100644 --- a/src/glitz_format.c +++ b/src/glitz_format.c @@ -35,10 +35,10 @@ glitz_format_t * glitz_format_find (glitz_format_t *formats, - int n_formats, - unsigned long mask, - const glitz_format_t *templ, - int count) + int n_formats, + unsigned long mask, + const glitz_format_t *templ, + int count) { for (; n_formats; n_formats--, formats++) { if (mask & GLITZ_FORMAT_ID_MASK) @@ -119,8 +119,8 @@ glitz_format_find (glitz_format_t *formats, static void _glitz_format_add_options (unsigned long options, - glitz_format_t *format, - unsigned long *mask) + glitz_format_t *format, + unsigned long *mask) { if (options & GLITZ_FORMAT_OPTION_DOUBLEBUFFER_MASK) { format->doublebuffer = 1; @@ -155,9 +155,9 @@ _glitz_format_add_options (unsigned long options, glitz_format_t * glitz_format_find_standard (glitz_format_t *formats, - int n_formats, - unsigned long options, - glitz_format_name_t format_name) + int n_formats, + unsigned long options, + glitz_format_name_t format_name) { glitz_format_t templ; unsigned long mask = GLITZ_FORMAT_RED_SIZE_MASK | diff --git a/src/glitz_glx_extension.c b/src/glitz_glx_extension.c index 83db743..4ce9d5f 100644 --- a/src/glitz_glx_extension.c +++ b/src/glitz_glx_extension.c @@ -78,16 +78,11 @@ _glitz_glx_extension_query_gl (void) void glitz_glx_query_extensions (glitz_glx_screen_info_t *screen_info) { - screen_info->glx_feature_mask = 0; - screen_info->glx_feature_mask |= _glitz_glx_extension_query_client_glx (screen_info->display_info->display); screen_info->glx_feature_mask |= _glitz_glx_extension_query_gl (); - screen_info->feature_mask = 0; - screen_info->texture_mask = GLITZ_TEXTURE_TARGET_2D_MASK; - if (_glitz_glx_proc_address.get_fbconfigs && _glitz_glx_proc_address.get_fbconfig_attrib && _glitz_glx_proc_address.get_visual_from_fbconfig && @@ -101,10 +96,16 @@ glitz_glx_query_extensions (glitz_glx_screen_info_t *screen_info) screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK) { screen_info->feature_mask |= GLITZ_FEATURE_MULTISAMPLE_MASK; - - /* All geforce cards seems to support multisample with pbuffers */ - if (!strncmp ("GeForce", (char *) glGetString (GL_RENDERER), 7)) - screen_info->feature_mask |= GLITZ_FEATURE_OFFSCREEN_MULTISAMPLE_MASK; + char *renderer = (char *) glGetString (GL_RENDERER); + if (renderer) { + + /* All geforce and quadro cards seems to support multisample with + pbuffers */ + if (!strncmp ("GeForce", renderer, 7)) + screen_info->feature_mask |= GLITZ_FEATURE_OFFSCREEN_MULTISAMPLE_MASK; + else if (!strncmp ("Quadro", renderer, 6)) + screen_info->feature_mask |= GLITZ_FEATURE_OFFSCREEN_MULTISAMPLE_MASK; + } } if (screen_info->glx_feature_mask & GLITZ_GLX_FEATURE_TEXTURE_NPOT_MASK) { diff --git a/src/glitz_glx_format.c b/src/glitz_glx_format.c index 0438e73..7209144 100644 --- a/src/glitz_glx_format.c +++ b/src/glitz_glx_format.c @@ -185,21 +185,6 @@ glitz_glx_query_formats_glx12 (glitz_glx_screen_info_t *screen_info) qsort (screen_info->formats, screen_info->n_formats, sizeof (glitz_format_t), _glitz_glx_format_compare); - - /* Adding fake offscreen formats as no real offscreen formats exists. - Surfaces created with this format can only be used with draw/read - pixel functions and as source in composite functions. */ - memset (&format, 0, sizeof (glitz_format_t)); - format.drawable.offscreen = 1; - format.alpha_size = format.red_size = format.green_size = - format.blue_size = 8; - format.id = 0; - _glitz_add_format (screen_info, &format); - format.alpha_size = 0; - _glitz_add_format (screen_info, &format); - format.alpha_size = 8; - format.red_size = format.green_size = format.blue_size = 0; - _glitz_add_format (screen_info, &format); if (visuals) XFree (visuals); @@ -212,7 +197,6 @@ glitz_glx_query_formats_glx13 (glitz_glx_screen_info_t *screen_info) glitz_format_t format; GLXFBConfig *fbconfigs; int i, num_configs; - glitz_bool_t offscreen_argb32_format = 0; display = screen_info->display_info->display; @@ -273,13 +257,13 @@ glitz_glx_query_formats_glx13 (glitz_glx_screen_info_t *screen_info) format.stencil_size = (unsigned short) value; _glitz_glx_proc_address.get_fbconfig_attrib (display, fbconfigs[i], GLX_DOUBLEBUFFER, &value); - format.doublebuffer = (value) ? 1: 0; + format.doublebuffer = (value)? 1: 0; if (screen_info->feature_mask & GLITZ_FEATURE_MULTISAMPLE_MASK) { _glitz_glx_proc_address.get_fbconfig_attrib (display, fbconfigs[i], GLX_SAMPLE_BUFFERS_ARB, &value); - format.multisample.supported = (value) ? 1: 0; + format.multisample.supported = (value)? 1: 0; _glitz_glx_proc_address.get_fbconfig_attrib (display, fbconfigs[i], GLX_SAMPLES_ARB, &value); format.multisample.samples = (unsigned short) value; @@ -288,11 +272,6 @@ glitz_glx_query_formats_glx13 (glitz_glx_screen_info_t *screen_info) format.multisample.samples = 0; } - if (format.drawable.offscreen && - format.alpha_size && - format.red_size && format.green_size && format.blue_size) - offscreen_argb32_format = 1; - _glitz_add_format (screen_info, &format); if (format.alpha_size && @@ -310,24 +289,6 @@ glitz_glx_query_formats_glx13 (glitz_glx_screen_info_t *screen_info) qsort (screen_info->formats, screen_info->n_formats, sizeof (glitz_format_t), _glitz_glx_format_compare); - - /* Adding fake offscreen formats if no real argb32 offscreen formats exist. - Surfaces created with these format can only be used with draw/read - pixel functions and as source in composite functions. */ - if (!offscreen_argb32_format) { - screen_info->feature_mask &= ~GLITZ_FEATURE_OFFSCREEN_DRAWING_MASK; - memset (&format, 0, sizeof (glitz_format_t)); - format.drawable.offscreen = 1; - format.alpha_size = format.red_size = format.green_size = - format.blue_size = 8; - format.id = 0; - _glitz_add_format (screen_info, &format); - format.alpha_size = 0; - _glitz_add_format (screen_info, &format); - format.alpha_size = 8; - format.red_size = format.green_size = format.blue_size = 0; - _glitz_add_format (screen_info, &format); - } if (fbconfigs) XFree (fbconfigs); @@ -335,6 +296,28 @@ glitz_glx_query_formats_glx13 (glitz_glx_screen_info_t *screen_info) return 0; } +static void +glitz_glx_use_fake_offscreen_formats (glitz_glx_screen_info_t *screen_info) +{ + glitz_format_t format; + + screen_info->feature_mask &= ~GLITZ_FEATURE_OFFSCREEN_DRAWING_MASK; + + /* Adding fake offscreen formats. Surfaces created with these format can + only be used with draw/read pixel functions and as source in composite + functions. */ + memset (&format, 0, sizeof (glitz_format_t)); + format.drawable.offscreen = 1; + format.alpha_size = format.red_size = format.green_size = + format.blue_size = 8; + _glitz_add_format (screen_info, &format); + format.alpha_size = 0; + _glitz_add_format (screen_info, &format); + format.alpha_size = 8; + format.red_size = format.green_size = format.blue_size = 0; + _glitz_add_format (screen_info, &format); +} + void glitz_glx_query_formats (glitz_glx_screen_info_t *screen_info) { @@ -346,6 +329,12 @@ glitz_glx_query_formats (glitz_glx_screen_info_t *screen_info) if (status) glitz_glx_query_formats_glx12 (screen_info); + if (!glitz_format_find_standard (screen_info->formats, + screen_info->n_formats, + GLITZ_FORMAT_OPTION_OFFSCREEN_MASK, + GLITZ_STANDARD_ARGB32)) + glitz_glx_use_fake_offscreen_formats (screen_info); + _glitz_move_out_ids (screen_info); } diff --git a/src/glitz_glx_info.c b/src/glitz_glx_info.c index 8a738bb..5453e30 100644 --- a/src/glitz_glx_info.c +++ b/src/glitz_glx_info.c @@ -172,7 +172,8 @@ glitz_glx_thread_info_get (void) malloc (sizeof (glitz_glx_thread_info_t)); info->displays = NULL; info->n_displays = 0; - glitz_glx_proc_address_lookup (); + if (!_glitz_glx_proc_address.supported) + glitz_glx_proc_address_lookup (); xthread_key_create (&info_tsd, NULL); xthread_set_specific (info_tsd, info); tsd_initialized = 1; @@ -196,6 +197,9 @@ static glitz_glx_thread_info_t thread_info = { glitz_glx_thread_info_t * glitz_glx_thread_info_get (void) { + if (!_glitz_glx_proc_address.supported) + glitz_glx_proc_address_lookup (); + return &thread_info; } @@ -235,33 +239,57 @@ glitz_glx_create_root_context (glitz_glx_screen_info_t *screen_info) { XVisualInfo *vinfo; XSetWindowAttributes win_attrib; - int attrib[] = { - GLX_RGBA, - 0 + int attrib_single[] = { + GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + None }; + int attrib_double[] = { + GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, + None + }; int screen = screen_info->screen; Display *display = screen_info->display_info->display; - - vinfo = glXChooseVisual (display, screen, attrib); + + vinfo = glXChooseVisual (display, screen, attrib_single); if (!vinfo) - return; + vinfo = glXChooseVisual (display, screen, attrib_double); - win_attrib.colormap = - XCreateColormap (display, - RootWindow (display, screen), - vinfo->visual, AllocNone); - screen_info->root_drawable = - XCreateWindow (display, - RootWindow (display, screen), - -2, -2, 1, 1, 0, vinfo->depth, CopyFromParent, - vinfo->visual, CWColormap, &win_attrib); - - screen_info->root_context.context = - glXCreateContext (display, vinfo, NULL, 1); + if (vinfo) { + win_attrib.background_pixel = 0; + win_attrib.border_pixel = 0; + win_attrib.event_mask = StructureNotifyMask | ExposureMask; + win_attrib.colormap = XCreateColormap (display, + RootWindow (display, screen), + vinfo->visual, AllocNone); + + screen_info->root_drawable = + XCreateWindow (display, RootWindow (display, screen), + 0, 0, 100, 100, 0, vinfo->depth, InputOutput, + vinfo->visual, + CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, + &win_attrib); + + screen_info->root_context.context = + glXCreateContext (display, vinfo, NULL, 1); + + screen_info->root_context.id = vinfo->visualid; + + XFree (vinfo); + } else { + screen_info->root_drawable = None; + screen_info->root_context.context = NULL; + screen_info->root_context.id = 0; + } screen_info->root_context.fbconfig = (XID) 0; - screen_info->root_context.id = vinfo->visualid; - + memcpy (&screen_info->root_context.gl, &_glitz_gl_proc_address, sizeof (glitz_gl_proc_address_list_t)); @@ -269,12 +297,8 @@ glitz_glx_create_root_context (glitz_glx_screen_info_t *screen_info) memset (&screen_info->root_context.glx, 0, sizeof (glitz_glx_proc_address_list_t)); - if (_glitz_glx_proc_address.supported) { - screen_info->root_context.gl.supported = - screen_info->root_context.glx.supported = 1; - } - - XFree (vinfo); + screen_info->root_context.gl.supported = + screen_info->root_context.glx.supported = 1; } glitz_glx_screen_info_t * @@ -313,22 +337,28 @@ glitz_glx_screen_info_get (Display *display, glitz_glx_create_root_context (screen_info); - glXMakeCurrent (screen_info->display_info->display, - screen_info->root_drawable, - screen_info->root_context.context); - glPixelStorei (GL_PACK_ALIGNMENT, 4); - glPixelStorei (GL_UNPACK_ALIGNMENT, 4); + screen_info->glx_feature_mask = 0; + screen_info->feature_mask = 0; + screen_info->texture_mask = GLITZ_TEXTURE_TARGET_2D_MASK; - glitz_glx_query_extensions (screen_info); - glitz_glx_query_formats (screen_info); + if (screen_info->root_context.context && + glXMakeCurrent (screen_info->display_info->display, + screen_info->root_drawable, + screen_info->root_context.context)) { + + glPixelStorei (GL_PACK_ALIGNMENT, 4); + glPixelStorei (GL_UNPACK_ALIGNMENT, 4); - if (screen_info->root_context.gl.supported) glitz_glx_context_proc_address_lookup (&screen_info->root_context); + + glitz_glx_query_extensions (screen_info); + glitz_glx_query_formats (screen_info); + } screen_info->context_stack = malloc (sizeof (glitz_glx_context_info_t)); screen_info->context_stack_size = 1; screen_info->context_stack->surface = NULL; screen_info->context_stack->constraint = GLITZ_CN_NONE; - + return screen_info; } |