diff --git a/src/Fl_Gl_Choice.H b/src/Fl_Gl_Choice.H index 790c6372d..65a855c9a 100644 --- a/src/Fl_Gl_Choice.H +++ b/src/Fl_Gl_Choice.H @@ -64,9 +64,6 @@ typedef NSOpenGLContext* FLOpenGLContextPtr; #else # include # define GLContext GLXContext -# if ! defined(GLX_VERSION_1_3) -# typedef void *GLXFBConfig; -# endif #endif // Describes crap needed to create a GLContext. @@ -83,7 +80,6 @@ public: #else XVisualInfo *vis; // the visual to use Colormap colormap; // a colormap for that visual - GLXFBConfig best_fb; #endif // Return one of these structures for a given gl mode. // The second argument is a glX attribute list, and is used if mode is diff --git a/src/Fl_Gl_Choice.cxx b/src/Fl_Gl_Choice.cxx index 071a1a790..fb19b0e68 100644 --- a/src/Fl_Gl_Choice.cxx +++ b/src/Fl_Gl_Choice.cxx @@ -33,63 +33,6 @@ void fl_save_dc(HWND, HDC); extern void gl_texture_reset(); #endif -#if defined(USE_X11) -static XVisualInfo *gl3_getvisual(const int *blist, GLXFBConfig *pbestFB) -{ - int glx_major, glx_minor; - - // FBConfigs were added in GLX version 1.3. - if ( !glXQueryVersion( fl_display, &glx_major, &glx_minor ) || - ( ( glx_major == 1 ) && ( glx_minor < 3 ) ) || ( glx_major < 1 ) ) - { - //printf("Invalid GLX version"); - return NULL; - } - - //printf( "Getting matching framebuffer configs\n" ); - int fbcount; - GLXFBConfig* fbc = glXChooseFBConfig(fl_display, DefaultScreen(fl_display), blist, &fbcount); - if (!fbc) - { - //printf( "Failed to retrieve a framebuffer config\n" ); - return NULL; - } - //printf( "Found %d matching FB configs.\n", fbcount ); - - // Pick the FB config/visual with the most samples per pixel - int best_fbc = -1, worst_fbc = -1, best_num_samp = -1, worst_num_samp = 999; - - int i; - for (i=0; i visualid, samp_buf, samples );*/ - if ( best_fbc < 0 || (samp_buf && samples > best_num_samp) ) - best_fbc = i, best_num_samp = samples; - if ( worst_fbc < 0 || !samp_buf || samples < worst_num_samp ) - worst_fbc = i, worst_num_samp = samples; - } - XFree( vi ); - } - - GLXFBConfig bestFbc = fbc[ best_fbc ]; - - // Be sure to free the FBConfig list allocated by glXChooseFBConfig() - XFree( fbc ); - - // Get a visual - XVisualInfo *vi = glXGetVisualFromFBConfig( fl_display, bestFbc ); - *pbestFB = bestFbc; - return vi; -} -#endif - static Fl_Gl_Choice *first; // this assumes one of the two arguments is zero: @@ -153,19 +96,12 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) { } fl_open_display(); - XVisualInfo *visp = NULL; - GLXFBConfig best_fb = NULL; - if (m & FL_OPENGL3) { - visp = gl3_getvisual((const int *)blist, &best_fb); - } + XVisualInfo *visp = glXChooseVisual(fl_display, fl_screen, (int *)blist); if (!visp) { - visp = glXChooseVisual(fl_display, fl_screen, (int *)blist); - if (!visp) { -# if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample) +# if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample) if (m&FL_MULTISAMPLE) return find(m&~FL_MULTISAMPLE,0); -# endif - return 0; - } +# endif + return 0; } #elif defined(__APPLE_QUARTZ__) @@ -256,7 +192,6 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) { #if defined(USE_X11) g->vis = visp; - g->best_fb = best_fb; if (/*MaxCmapsOfScreen(ScreenOfDisplay(fl_display,fl_screen))==1 && */ visp->visualid == fl_visual->visualid && @@ -317,38 +252,8 @@ static int ctxErrorHandler( Display *dpy, XErrorEvent *ev ) GLContext fl_create_gl_context(Fl_Window *window, const Fl_Gl_Choice* g) { GLContext shared_ctx = 0; if (context_list && nContext) shared_ctx = context_list[0]; - - typedef GLContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLContext, Bool, const int*); - - // It is not necessary to create or make current to a context before calling glXGetProcAddressARB - static glXCreateContextAttribsARBProc glXCreateContextAttribsARB = - (glXCreateContextAttribsARBProc)glXGetProcAddressARB((const GLubyte *)"glXCreateContextAttribsARB"); - - GLContext ctx = 0; - - // Check for the GLX_ARB_create_context extension string and the function. - // If either is not present, use GLX 1.3 context creation method. - const char *glxExts = glXQueryExtensionsString(fl_display, fl_screen); - if (g->best_fb && strstr(glxExts, "GLX_ARB_create_context") && glXCreateContextAttribsARB ) { - int context_attribs[] = - { - GLX_CONTEXT_MAJOR_VERSION_ARB, 3, - GLX_CONTEXT_MINOR_VERSION_ARB, 2, - //GLX_CONTEXT_FLAGS_ARB , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, - //GLX_CONTEXT_PROFILE_MASK_ARB , GLX_CONTEXT_CORE_PROFILE_BIT_ARB , - None - }; - ctxErrorOccurred = false; - XErrorHandler oldHandler = XSetErrorHandler(&ctxErrorHandler); - ctx = glXCreateContextAttribsARB( fl_display, g->best_fb, shared_ctx, True, context_attribs ); - // Sync to ensure any errors generated are processed. - XSync( fl_display, False ); - if (ctxErrorOccurred) ctx = 0; - XSetErrorHandler(oldHandler); - } - if (!ctx) { // use OpenGL 1-style context creation - ctx = glXCreateContext(fl_display, g->vis, shared_ctx, true); - } + + GLContext ctx = glXCreateContext(fl_display, g->vis, shared_ctx, true); if (ctx) add_context(ctx); //glXMakeCurrent(fl_display, fl_xid(window), ctx);printf("%s\n", glGetString(GL_VERSION));