Re: [AD] SF.net SVN: alleg:[11750] allegro/branches/4.9/src/x |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Sat February 28 2009, you wrote:
> Revision: 11750
> http://alleg.svn.sourceforge.net/alleg/?rev=11750&view=rev
> Author: mmimica
> Date: 2009-02-28 21:47:45 +0000 (Sat, 28 Feb 2009)
>
> Log Message:
> -----------
> * The GLX context creation wasn't fully using the FBConfig path.
> * Added OpenGL 3 support to GLX. Untested.
/me thinks somehting is wrong:
moose@xxxxxxxxxx$ ./ex_prim
Assert failed at line 215 of
/home/moose/.projects/allegro.git/src/display_new.c
Aborted
allegro.log seems to say its picking "Visual 21" which has this to say for
itself: display_settings INFO: Single Buffer requirement not met.
I'm not sure how its picking a format that its already rejected. And why does
it seem to be wanting a SINGLEBUFFER display by default to begin with?
(ex_prim doesn't seem to request any specific display flags).
Many examples are now Asserting, or just plain drawing wrong. ex_opengl draws
a solid green display. ex_glext seems to be unaffected, but ex_bitmap is
asserting and ex_expose and ex_scale are segfaulting.
> Modified Paths:
> --------------
> allegro/branches/4.9/src/x/xdisplay.c
> allegro/branches/4.9/src/x/xglx.h
> allegro/branches/4.9/src/x/xglx_config.c
>
> Modified: allegro/branches/4.9/src/x/xdisplay.c
> ===================================================================
> --- allegro/branches/4.9/src/x/xdisplay.c 2009-02-28 19:51:02 UTC (rev
> 11749) +++ allegro/branches/4.9/src/x/xdisplay.c 2009-02-28 21:47:45 UTC
> (rev 11750) @@ -307,7 +307,14 @@
> */
> _al_cond_wait(&system->mapped, &system->lock);
>
> - _al_xglx_config_create_context(d);
> + if (!_al_xglx_config_create_context(d)) {
> + TRACE("xdisplay: Failed to create a context.\n");
> + _AL_FREE(d);
> + _AL_FREE(ogl);
> + _al_mutex_unlock(&system->lock);
> + /* FIXME: make it a clean exit */
> + return NULL;
> + }
>
> if (display->flags & ALLEGRO_FULLSCREEN) {
> _al_xglx_fullscreen_to_display(system, d);
> @@ -327,8 +334,26 @@
> _al_ogl_manage_extensions(display);
> _al_ogl_set_extensions(ogl->extension_api);
>
> - setup_gl(display);
> + if (display->ogl_extras->ogl_info.version < 1.2) {
> + ALLEGRO_EXTRA_DISPLAY_SETTINGS *eds =
> _al_get_new_display_settings(); + if (eds->required &
> (1<<ALLEGRO_COMPATIBLE_DISPLAY)) {
> + TRACE("Allegro requires at least OpenGL version 1.2 to work.");
> + _AL_FREE(d);
> + _AL_FREE(ogl);
> + _al_mutex_unlock(&system->lock);
> + /* FIXME: make it a clean exit */
> + return NULL;
> + }
> + display->extra_settings.settings[ALLEGRO_COMPATIBLE_DISPLAY] = 0;
> + }
> + else if (display->ogl_extras->ogl_info.version > 2.1) {
> + /* We don't have OpenGL3 a driver. */
> + display->extra_settings.settings[ALLEGRO_COMPATIBLE_DISPLAY] = 0;
> + }
>
> + if (display->extra_settings.settings[ALLEGRO_COMPATIBLE_DISPLAY])
> + setup_gl(display);
> +
> d->invisible_cursor = None; /* Will be created on demand. */
> d->current_cursor = None; /* Initially, we use the root cursor. */
> d->cursor_hidden = false;
> @@ -399,10 +424,16 @@
> glx->context = NULL;
> }
>
> - if (glx->xvinfo) {
> + if (glx->fbc) {
> + free(glx->fbc);
> + glx->fbc = NULL;
> XFree(glx->xvinfo);
> glx->xvinfo = NULL;
> }
> + else if (glx->xvinfo) {
> + free(glx->xvinfo);
> + glx->xvinfo = NULL;
> + }
>
> _al_vector_free(&d->bitmaps);
> _al_event_source_free(&d->es);
>
> Modified: allegro/branches/4.9/src/x/xglx.h
> ===================================================================
> --- allegro/branches/4.9/src/x/xglx.h 2009-02-28 19:51:02 UTC (rev 11749)
> +++ allegro/branches/4.9/src/x/xglx.h 2009-02-28 21:47:45 UTC (rev 11750)
> @@ -144,4 +144,4 @@
>
> /* glx_config */
> void _al_xglx_config_select_visual(ALLEGRO_DISPLAY_XGLX *glx);
> -void _al_xglx_config_create_context(ALLEGRO_DISPLAY_XGLX *glx);
> +bool _al_xglx_config_create_context(ALLEGRO_DISPLAY_XGLX *glx);
>
> Modified: allegro/branches/4.9/src/x/xglx_config.c
> ===================================================================
> --- allegro/branches/4.9/src/x/xglx_config.c 2009-02-28 19:51:02 UTC (rev
> 11749) +++ allegro/branches/4.9/src/x/xglx_config.c 2009-02-28 21:47:45 UTC
> (rev 11750) @@ -232,9 +232,10 @@
> free(eds_list[j]);
> eds_list[j] = NULL;
> continue;
> - }
> + }
> eds_list[j]->index = i;
> - eds_list[j]->info = glXGetVisualFromFBConfig(system->gfxdisplay,
> fbconfig[i]); + eds_list[j]->info = malloc(sizeof(GLXFBConfig));
> + memcpy(eds_list[j]->info, &fbconfig[i], sizeof(GLXFBConfig));
> j++;
> }
>
> @@ -348,7 +349,7 @@
> eds_list = malloc(num_visuals * sizeof(*eds_list));
> memset(eds_list, 0, num_visuals * sizeof(*eds_list));
>
> - TRACE(PREFIX_I "get_visuals_new: %i formats.\n", num_visuals);
> + TRACE(PREFIX_I "get_visuals_old: %i formats.\n", num_visuals);
>
> for (j = i = 0; i < num_visuals; i++) {
> TRACE("-- \n");
> @@ -372,11 +373,11 @@
> j++;
> }
>
> - TRACE(PREFIX_I "get_visuals_new(): %i visuals are good enough.\n", j);
> + TRACE(PREFIX_I "get_visuals_old(): %i visuals are good enough.\n", j);
> *count = j;
> + XFree(xv);
> if (j == 0) {
> free(eds_list);
> - XFree(xv);
> return NULL;
> }
> return eds_list;
> @@ -386,13 +387,19 @@
> void _al_xglx_config_select_visual(ALLEGRO_DISPLAY_XGLX *glx)
> {
> ALLEGRO_EXTRA_DISPLAY_SETTINGS **eds = NULL;
> + ALLEGRO_SYSTEM_XGLX *system = (void *)al_system_driver();
> int eds_count = 0;
> int i;
> + bool using_fbc;
>
> if (glx->glx_version >= 130)
> eds = get_visuals_new(&eds_count, glx);
> - if (!eds)
> + if (!eds) {
> eds = get_visuals_old(&eds_count);
> + using_fbc = false;
> + }
> + else
> + using_fbc = true;
>
> if (!eds) {
> TRACE(PREFIX_E "_al_xglx_config_select_visual(): Failed to get any
> visual info.\n"); @@ -405,19 +412,49 @@
> #ifdef DEBUGMODE
> display_pixel_format(eds[0]);
> #endif
> - glx->xvinfo = eds[0]->info;
> + if (using_fbc) {
> + glx->fbc = eds[0]->info;
> + glx->xvinfo = glXGetVisualFromFBConfig(system->gfxdisplay,
> *glx->fbc); + }
> + else
> + glx->xvinfo = eds[0]->info;
> memcpy(&glx->display.extra_settings, eds[0],
> sizeof(ALLEGRO_EXTRA_DISPLAY_SETTINGS));
>
> for (i = 0; i < eds_count; i++) {
> - if (glx->xvinfo != eds[i]->info)
> - XFree(eds[i]->info);
> + if (i != 0)
> + free(eds[i]->info);
> free(eds[i]);
> }
> free(eds);
> }
>
> -void _al_xglx_config_create_context(ALLEGRO_DISPLAY_XGLX *glx)
> +static GLXContext create_context_new(int ver, Display *dpy, GLXFBConfig
> fb, + GLXContext ctx, int fc, int major, int minor)
> {
> + typedef GLXContext (*GCCA_PROC) (Display*, GLXFBConfig, GLXContext,
> Bool, const int*); + GCCA_PROC _xglx_glXCreateContextAttribsARB;
> + if (ver >= 140) {
> + /* GLX 1.4 should have this */
> + _xglx_glXCreateContextAttribsARB = glXCreateContextAttribsARB;
> + }
> + else {
> + /* Load the extension manually. */
> + _xglx_glXCreateContextAttribsARB =
> + (GCCA_PROC)glXGetProcAddress((const
> GLubyte*)"glXCreateContextAttribsARB"); + if
> (!_xglx_glXCreateContextAttribsARB) {
> + TRACE("GLX_ARB_create_context not supported and needed for OpenGL
> 3\n"); + return NULL;
> + }
> + }
> + int attrib[] = {GLX_CONTEXT_MAJOR_VERSION_ARB, major,
> + GLX_CONTEXT_MINOR_VERSION_ARB, minor,
> + GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, fc,
> + 0};
> + return _xglx_glXCreateContextAttribsARB(dpy, fb, ctx, True, attrib);
> +}
> +
> +bool _al_xglx_config_create_context(ALLEGRO_DISPLAY_XGLX *glx)
> +{
> ALLEGRO_SYSTEM_XGLX *system = (void *)al_system_driver();
> ALLEGRO_DISPLAY *disp = (void*)glx;
> GLXContext existing_ctx = NULL;
> @@ -432,10 +469,18 @@
>
> if (glx->fbc) {
> /* Create a GLX context from FBC. */
> - glx->context = glXCreateNewContext(system->gfxdisplay, glx->fbc[0],
> - GLX_RGBA_TYPE, existing_ctx, True);
> + if (disp->flags & ALLEGRO_OPENGL_3_0) {
> + int fc = disp->flags & ALLEGRO_OPENGL_FORWARD_COMPATIBLE;
> + glx->context = create_context_new(glx->glx_version,
> system->gfxdisplay, + *glx->fbc, existing_ctx,
> fc, 3, 0);
> + }
> + else {
> + glx->context = glXCreateNewContext(system->gfxdisplay, *glx->fbc,
> + GLX_RGBA_TYPE, existing_ctx, True);
> + }
> +
> /* Create a GLX subwindow inside our window. */
> - glx->glxwindow = glXCreateWindow(system->gfxdisplay, glx->fbc[0],
> + glx->glxwindow = glXCreateWindow(system->gfxdisplay, *glx->fbc,
> glx->window, 0);
> }
> else {
> @@ -445,7 +490,12 @@
> glx->glxwindow = glx->window;
> }
>
> + if (!glx->context || !glx->glxwindow) {
> + return false;
> + }
> +
> disp->ogl_extras->is_shared = true;
>
> TRACE("xglx_config: Got GLX context.\n");
> + return true;
> }
>
>
> This was sent by the SourceForge.net collaborative development platform,
> the world's largest Open Source development site.
>
> ---------------------------------------------------------------------------
>--- Open Source Business Conference (OSBC), March 24-25, 2009, San
> Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing
> the Enterprise -Strategies to boost innovation and cut costs with open
> source participation -Receive a $600 discount off the registration fee with
> the source code: SFAD http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Alleg-commits mailing list
> Alleg-commits@xxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/alleg-commits
--
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx