]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/glcanvas.cpp
Applied patch [ 1196827 ] Fixes Assert with wxTreeCtrl::GetSelections on wxMSW
[wxWidgets.git] / src / gtk / glcanvas.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gtk/glcanvas.cpp
3 // Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWidgets and GTK
4 // Author: Robert Roebling
5 // Modified by:
6 // Created: 17/08/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "glcanvas.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #include "wx/setup.h"
20
21 #if wxUSE_GLCANVAS
22
23 #include "wx/glcanvas.h"
24
25 #include "wx/frame.h"
26 #include "wx/colour.h"
27 #include "wx/module.h"
28 #include "wx/app.h"
29
30 extern "C"
31 {
32 #include "gtk/gtk.h"
33 #include "gdk/gdk.h"
34 #include "gdk/gdkx.h"
35 }
36
37 #include "wx/gtk/win_gtk.h"
38
39 // DLL options compatibility check:
40 #include "wx/build.h"
41 WX_CHECK_BUILD_OPTIONS("wxGL")
42
43
44 //---------------------------------------------------------------------------
45 // static variables
46 //---------------------------------------------------------------------------
47 int wxGLCanvas::m_glxVersion = 0;
48
49 //---------------------------------------------------------------------------
50 // global data
51 //---------------------------------------------------------------------------
52
53 XVisualInfo *g_vi = (XVisualInfo*) NULL;
54 //-----------------------------------------------------------------------------
55 // idle system
56 //-----------------------------------------------------------------------------
57
58 extern void wxapp_install_idle_handler();
59 extern bool g_isIdle;
60
61 //---------------------------------------------------------------------------
62 // wxGLContext
63 //---------------------------------------------------------------------------
64
65 IMPLEMENT_CLASS(wxGLContext,wxObject)
66
67 wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, const wxPalette& WXUNUSED(palette) )
68 {
69 m_window = win;
70 m_widget = win->m_wxwindow;
71
72 wxGLCanvas *gc = (wxGLCanvas*) win;
73
74 if (wxGLCanvas::GetGLXVersion() >= 13)
75 {
76 // GLX >= 1.3
77 GLXFBConfig *fbc = gc->m_fbc;
78 wxCHECK_RET( fbc, _T("invalid GLXFBConfig for OpenGl") );
79 m_glContext = glXCreateNewContext( GDK_DISPLAY(), fbc[0], GLX_RGBA_TYPE, None, GL_TRUE );
80 }
81 else
82 {
83 // GLX <= 1.2
84 XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
85 wxCHECK_RET( vi, _T("invalid visual for OpenGl") );
86 m_glContext = glXCreateContext( GDK_DISPLAY(), vi, None, GL_TRUE );
87 }
88
89 wxCHECK_RET( m_glContext, _T("Couldn't create OpenGl context") );
90 }
91
92 wxGLContext::wxGLContext(
93 bool WXUNUSED(isRGB), wxWindow *win,
94 const wxPalette& WXUNUSED(palette),
95 const wxGLContext *other /* for sharing display lists */
96 )
97 {
98 m_window = win;
99 m_widget = win->m_wxwindow;
100
101 wxGLCanvas *gc = (wxGLCanvas*) win;
102
103 if (wxGLCanvas::GetGLXVersion() >= 13)
104 {
105 // GLX >= 1.3
106 GLXFBConfig *fbc = gc->m_fbc;
107 wxCHECK_RET( fbc, _T("invalid GLXFBConfig for OpenGl") );
108 m_glContext = glXCreateNewContext( GDK_DISPLAY(), fbc[0], GLX_RGBA_TYPE,
109 other ? other->m_glContext : None,
110 GL_TRUE );
111 }
112 else
113 {
114 // GLX <= 1.2
115 XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
116 wxCHECK_RET( vi, _T("invalid visual for OpenGl") );
117 m_glContext = glXCreateContext( GDK_DISPLAY(), vi,
118 other ? other->m_glContext : None,
119 GL_TRUE );
120 }
121
122 if ( !m_glContext )
123 {
124 wxFAIL_MSG( _T("Couldn't create OpenGl context") );
125 }
126 }
127
128 wxGLContext::~wxGLContext()
129 {
130 if (!m_glContext) return;
131
132 if (m_glContext == glXGetCurrentContext())
133 {
134 if (wxGLCanvas::GetGLXVersion() >= 13)
135 // GLX >= 1.3
136 glXMakeContextCurrent( GDK_DISPLAY(), None, None, NULL);
137 else
138 // GLX <= 1.2
139 glXMakeCurrent( GDK_DISPLAY(), None, NULL);
140 }
141
142 glXDestroyContext( GDK_DISPLAY(), m_glContext );
143 }
144
145 void wxGLContext::SwapBuffers()
146 {
147 if (m_glContext)
148 {
149 GdkWindow *window = GTK_PIZZA(m_widget)->bin_window;
150 glXSwapBuffers( GDK_DISPLAY(), GDK_WINDOW_XWINDOW( window ) );
151 }
152 }
153
154 void wxGLContext::SetCurrent()
155 {
156 if (m_glContext)
157 {
158 GdkWindow *window = GTK_PIZZA(m_widget)->bin_window;
159
160 if (wxGLCanvas::GetGLXVersion() >= 13)
161 // GLX >= 1.3
162 glXMakeContextCurrent( GDK_DISPLAY(), GDK_WINDOW_XWINDOW(window), GDK_WINDOW_XWINDOW(window), m_glContext );
163 else
164 // GLX <= 1.2
165 glXMakeCurrent( GDK_DISPLAY(), GDK_WINDOW_XWINDOW(window), m_glContext );
166 }
167 }
168
169 void wxGLContext::SetColour(const wxChar *colour)
170 {
171 wxColour col = wxTheColourDatabase->Find(colour);
172 if (col.Ok())
173 {
174 float r = (float)(col.Red()/256.0);
175 float g = (float)(col.Green()/256.0);
176 float b = (float)(col.Blue()/256.0);
177 glColor3f( r, g, b);
178 }
179 }
180
181 void wxGLContext::SetupPixelFormat()
182 {
183 }
184
185 void wxGLContext::SetupPalette( const wxPalette& WXUNUSED(palette) )
186 {
187 }
188
189 wxPalette wxGLContext::CreateDefaultPalette()
190 {
191 return wxNullPalette;
192 }
193
194 //-----------------------------------------------------------------------------
195 // "realize" from m_wxwindow
196 //-----------------------------------------------------------------------------
197
198 extern "C" {
199 static gint
200 gtk_glwindow_realized_callback( GtkWidget *WXUNUSED(widget), wxGLCanvas *win )
201 {
202 if ( !win->m_glContext )
203 {
204 wxGLContext *share = win->m_sharedContext;
205 if ( !share && win->m_sharedContextOf )
206 share = win->m_sharedContextOf->GetContext();
207
208 win->m_glContext = new wxGLContext( TRUE, win, wxNullPalette, share );
209 }
210
211 return FALSE;
212 }
213 }
214
215 //-----------------------------------------------------------------------------
216 // "map" from m_wxwindow
217 //-----------------------------------------------------------------------------
218
219 extern "C" {
220 static gint
221 gtk_glwindow_map_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win )
222 {
223 if (win->m_glContext/* && win->m_exposed*/)
224 {
225 wxPaintEvent event( win->GetId() );
226 event.SetEventObject( win );
227 win->GetEventHandler()->ProcessEvent( event );
228
229 win->m_exposed = FALSE;
230 win->GetUpdateRegion().Clear();
231 }
232
233 return FALSE;
234 }
235 }
236
237 //-----------------------------------------------------------------------------
238 // "expose_event" of m_wxwindow
239 //-----------------------------------------------------------------------------
240
241 extern "C" {
242 static void
243 gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxGLCanvas *win )
244 {
245 if (g_isIdle)
246 wxapp_install_idle_handler();
247
248 win->m_exposed = TRUE;
249
250 win->GetUpdateRegion().Union( gdk_event->area.x,
251 gdk_event->area.y,
252 gdk_event->area.width,
253 gdk_event->area.height );
254 }
255 }
256
257 //-----------------------------------------------------------------------------
258 // "draw" of m_wxwindow
259 //-----------------------------------------------------------------------------
260
261 #ifndef __WXGTK20__
262 extern "C" {
263 static void
264 gtk_glwindow_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxGLCanvas *win )
265 {
266 if (g_isIdle)
267 wxapp_install_idle_handler();
268
269 win->m_exposed = TRUE;
270
271 win->GetUpdateRegion().Union( rect->x, rect->y,
272 rect->width, rect->height );
273 }
274 }
275 #endif
276
277 //-----------------------------------------------------------------------------
278 // "size_allocate" of m_wxwindow
279 //-----------------------------------------------------------------------------
280
281 extern "C" {
282 static void
283 gtk_glcanvas_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxGLCanvas *win )
284 {
285 if (g_isIdle)
286 wxapp_install_idle_handler();
287
288 if (!win->m_hasVMT)
289 return;
290
291 wxSizeEvent event( wxSize(win->m_width,win->m_height), win->GetId() );
292 event.SetEventObject( win );
293 win->GetEventHandler()->ProcessEvent( event );
294 }
295 }
296
297 //---------------------------------------------------------------------------
298 // wxGlCanvas
299 //---------------------------------------------------------------------------
300
301 IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
302
303 BEGIN_EVENT_TABLE(wxGLCanvas, wxWindow)
304 EVT_SIZE(wxGLCanvas::OnSize)
305 END_EVENT_TABLE()
306
307 wxGLCanvas::wxGLCanvas( wxWindow *parent, wxWindowID id,
308 const wxPoint& pos, const wxSize& size,
309 long style, const wxString& name,
310 int *attribList,
311 const wxPalette& palette )
312 {
313 Create( parent, NULL, NULL, id, pos, size, style, name, attribList, palette );
314 }
315
316 wxGLCanvas::wxGLCanvas( wxWindow *parent,
317 const wxGLContext *shared,
318 wxWindowID id,
319 const wxPoint& pos, const wxSize& size,
320 long style, const wxString& name,
321 int *attribList,
322 const wxPalette& palette )
323 {
324 Create( parent, shared, NULL, id, pos, size, style, name, attribList, palette );
325 }
326
327 wxGLCanvas::wxGLCanvas( wxWindow *parent,
328 const wxGLCanvas *shared,
329 wxWindowID id,
330 const wxPoint& pos, const wxSize& size,
331 long style, const wxString& name,
332 int *attribList,
333 const wxPalette& palette )
334 {
335 Create( parent, NULL, shared, id, pos, size, style, name, attribList, palette );
336 }
337
338 bool wxGLCanvas::Create( wxWindow *parent,
339 const wxGLContext *shared,
340 const wxGLCanvas *shared_context_of,
341 wxWindowID id,
342 const wxPoint& pos, const wxSize& size,
343 long style, const wxString& name,
344 int *attribList,
345 const wxPalette& palette)
346 {
347 m_sharedContext = (wxGLContext*)shared; // const_cast
348 m_sharedContextOf = (wxGLCanvas*)shared_context_of; // const_cast
349 m_glContext = (wxGLContext*) NULL;
350
351 m_exposed = FALSE;
352 m_noExpose = TRUE;
353 m_nativeSizeEvent = TRUE;
354 m_fbc = NULL;
355 m_vi = NULL;
356
357 // to be sure the glx version is known
358 wxGLCanvas::QueryGLXVersion();
359
360 if (wxGLCanvas::GetGLXVersion() >= 13)
361 {
362 // GLX >= 1.3 uses a GLXFBConfig
363 GLXFBConfig * fbc = NULL;
364 if (wxTheApp->m_glFBCInfo != NULL)
365 {
366 fbc = (GLXFBConfig *) wxTheApp->m_glFBCInfo;
367 m_canFreeFBC = FALSE; // owned by wxTheApp - don't free upon destruction
368 }
369 else
370 {
371 fbc = (GLXFBConfig *) wxGLCanvas::ChooseGLFBC(attribList);
372 m_canFreeFBC = TRUE;
373 }
374 m_fbc = fbc; // save for later use
375 wxCHECK_MSG( m_fbc, FALSE, _T("required FBConfig couldn't be found") );
376 }
377
378 XVisualInfo *vi = NULL;
379 if (wxTheApp->m_glVisualInfo != NULL)
380 {
381 vi = (XVisualInfo *)wxTheApp->m_glVisualInfo;
382 m_canFreeVi = FALSE; // owned by wxTheApp - don't free upon destruction
383 }
384 else
385 {
386 if (wxGLCanvas::GetGLXVersion() >= 13)
387 // GLX >= 1.3
388 vi = glXGetVisualFromFBConfig(GDK_DISPLAY(), m_fbc[0]);
389 else
390 // GLX <= 1.2
391 vi = (XVisualInfo *) ChooseGLVisual(attribList);
392 m_canFreeVi = TRUE;
393 }
394 m_vi = vi; // save for later use
395
396 wxCHECK_MSG( m_vi, FALSE, _T("required visual couldn't be found") );
397 GdkVisual *visual = gdkx_visual_get( vi->visualid );
398 GdkColormap *colormap = gdk_colormap_new( visual, TRUE );
399
400 gtk_widget_push_colormap( colormap );
401 gtk_widget_push_visual( visual );
402
403 wxWindow::Create( parent, id, pos, size, style, name );
404
405 m_glWidget = m_wxwindow;
406
407 #ifdef __WXGTK20__
408 gtk_widget_set_double_buffered( m_glWidget, FALSE );
409 #endif
410
411 gtk_pizza_set_clear( GTK_PIZZA(m_wxwindow), FALSE );
412
413 gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize",
414 GTK_SIGNAL_FUNC(gtk_glwindow_realized_callback), (gpointer) this );
415
416 gtk_signal_connect( GTK_OBJECT(m_wxwindow), "map",
417 GTK_SIGNAL_FUNC(gtk_glwindow_map_callback), (gpointer) this );
418
419 gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
420 GTK_SIGNAL_FUNC(gtk_glwindow_expose_callback), (gpointer)this );
421
422 #ifndef __WXGTK20__
423 gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
424 GTK_SIGNAL_FUNC(gtk_glwindow_draw_callback), (gpointer)this );
425 #endif
426
427 gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
428 GTK_SIGNAL_FUNC(gtk_glcanvas_size_callback), (gpointer)this );
429
430 gtk_widget_pop_visual();
431 gtk_widget_pop_colormap();
432
433 // if our parent window is already visible, we had been realized before we
434 // connected to the "realize" signal and hence our m_glContext hasn't been
435 // initialized yet and we have to do it now
436 if (GTK_WIDGET_REALIZED(m_wxwindow))
437 gtk_glwindow_realized_callback( m_wxwindow, this );
438
439 if (GTK_WIDGET_MAPPED(m_wxwindow))
440 gtk_glwindow_map_callback( m_wxwindow, this );
441
442 return TRUE;
443 }
444
445 wxGLCanvas::~wxGLCanvas()
446 {
447 GLXFBConfig * fbc = (GLXFBConfig *) m_fbc;
448 if (fbc && m_canFreeFBC) XFree( fbc );
449
450 XVisualInfo *vi = (XVisualInfo *) m_vi;
451 if (vi && m_canFreeVi) XFree( vi );
452
453 delete m_glContext;
454 }
455
456 void* wxGLCanvas::ChooseGLVisual(int *attribList)
457 {
458 int data[512];
459 GetGLAttribListFromWX( attribList, data );
460 attribList = (int*) data;
461
462 Display *dpy = GDK_DISPLAY();
463
464 return glXChooseVisual( dpy, DefaultScreen(dpy), attribList );
465 }
466
467 void* wxGLCanvas::ChooseGLFBC(int *attribList)
468 {
469 int data[512];
470 GetGLAttribListFromWX( attribList, data );
471 attribList = (int*) data;
472
473 int returned;
474 return glXChooseFBConfig( GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()),
475 attribList, &returned );
476 }
477
478
479 void wxGLCanvas::GetGLAttribListFromWX(int *wx_attribList, int *gl_attribList )
480 {
481 if (!wx_attribList)
482 {
483 if (wxGLCanvas::GetGLXVersion() >= 13)
484 // leave GLX >= 1.3 choose the default attributes
485 gl_attribList[0] = 0;
486 else
487 {
488 int i = 0;
489 // default settings if attriblist = 0
490 gl_attribList[i++] = GLX_RGBA;
491 gl_attribList[i++] = GLX_DOUBLEBUFFER;
492 gl_attribList[i++] = GLX_DEPTH_SIZE; gl_attribList[i++] = 1;
493 gl_attribList[i++] = GLX_RED_SIZE; gl_attribList[i++] = 1;
494 gl_attribList[i++] = GLX_GREEN_SIZE; gl_attribList[i++] = 1;
495 gl_attribList[i++] = GLX_BLUE_SIZE; gl_attribList[i++] = 1;
496 gl_attribList[i++] = GLX_ALPHA_SIZE; gl_attribList[i++] = 0;
497 gl_attribList[i++] = None;
498 }
499 }
500 else
501 {
502 int arg=0, p=0;
503 while( (wx_attribList[arg]!=0) && (p<510) )
504 {
505 switch( wx_attribList[arg++] )
506 {
507 case WX_GL_RGBA:
508 if (wxGLCanvas::GetGLXVersion() <= 12)
509 // for GLX >= 1.3, GLX_RGBA is useless (setting this flags will crash on most opengl implm)
510 gl_attribList[p++] = GLX_RGBA;
511 break;
512 case WX_GL_BUFFER_SIZE:
513 gl_attribList[p++]=GLX_BUFFER_SIZE; gl_attribList[p++]=wx_attribList[arg++]; break;
514 case WX_GL_LEVEL:
515 gl_attribList[p++]=GLX_LEVEL; gl_attribList[p++]=wx_attribList[arg++]; break;
516 case WX_GL_DOUBLEBUFFER:
517 if (wxGLCanvas::GetGLXVersion() <= 12)
518 gl_attribList[p++] = GLX_DOUBLEBUFFER;
519 else
520 // for GLX >= 1.3, GLX_DOUBLEBUFFER format is different (1 <=> True)
521 // it seems this flag is useless for some hardware opengl implementation.
522 // but for Mesa 6.2.1, this flag is used so don't ignore it.
523 gl_attribList[p++] = GLX_DOUBLEBUFFER; gl_attribList[p++]=1;
524 break;
525 case WX_GL_STEREO: gl_attribList[p++] = GLX_STEREO; break;
526 case WX_GL_AUX_BUFFERS:
527 gl_attribList[p++]=GLX_AUX_BUFFERS; gl_attribList[p++]=wx_attribList[arg++]; break;
528 case WX_GL_MIN_RED:
529 gl_attribList[p++]=GLX_RED_SIZE; gl_attribList[p++]=wx_attribList[arg++]; break;
530 case WX_GL_MIN_GREEN:
531 gl_attribList[p++]=GLX_GREEN_SIZE; gl_attribList[p++]=wx_attribList[arg++]; break;
532 case WX_GL_MIN_BLUE:
533 gl_attribList[p++]=GLX_BLUE_SIZE; gl_attribList[p++]=wx_attribList[arg++]; break;
534 case WX_GL_MIN_ALPHA:
535 gl_attribList[p++]=GLX_ALPHA_SIZE; gl_attribList[p++]=wx_attribList[arg++]; break;
536 case WX_GL_DEPTH_SIZE:
537 gl_attribList[p++]=GLX_DEPTH_SIZE; gl_attribList[p++]=wx_attribList[arg++]; break;
538 case WX_GL_STENCIL_SIZE:
539 gl_attribList[p++]=GLX_STENCIL_SIZE; gl_attribList[p++]=wx_attribList[arg++]; break;
540 case WX_GL_MIN_ACCUM_RED:
541 gl_attribList[p++]=GLX_ACCUM_RED_SIZE; gl_attribList[p++]=wx_attribList[arg++]; break;
542 case WX_GL_MIN_ACCUM_GREEN:
543 gl_attribList[p++]=GLX_ACCUM_GREEN_SIZE; gl_attribList[p++]=wx_attribList[arg++]; break;
544 case WX_GL_MIN_ACCUM_BLUE:
545 gl_attribList[p++]=GLX_ACCUM_BLUE_SIZE; gl_attribList[p++]=wx_attribList[arg++]; break;
546 case WX_GL_MIN_ACCUM_ALPHA:
547 gl_attribList[p++]=GLX_ACCUM_ALPHA_SIZE; gl_attribList[p++]=wx_attribList[arg++]; break;
548 default:
549 break;
550 }
551 }
552 gl_attribList[p] = 0;
553 }
554 }
555
556 void wxGLCanvas::QueryGLXVersion()
557 {
558 if (m_glxVersion == 0)
559 {
560 // check the GLX version
561 int glxMajorVer, glxMinorVer;
562 bool ok = glXQueryVersion(GDK_DISPLAY(), &glxMajorVer, &glxMinorVer);
563 wxASSERT_MSG( ok, _T("GLX version not found") );
564 if (!ok)
565 m_glxVersion = 10; // 1.0 by default
566 else
567 m_glxVersion = glxMajorVer*10 + glxMinorVer;
568 }
569 }
570
571 int wxGLCanvas::GetGLXVersion()
572 {
573 wxASSERT_MSG( m_glxVersion>0, _T("GLX version has not been initialized with wxGLCanvas::QueryGLXVersion()") );
574 return m_glxVersion;
575 }
576
577
578 void wxGLCanvas::SwapBuffers()
579 {
580 if (m_glContext)
581 m_glContext->SwapBuffers();
582 }
583
584 void wxGLCanvas::OnSize(wxSizeEvent& WXUNUSED(event))
585 {
586 }
587
588 void wxGLCanvas::SetCurrent()
589 {
590 if (m_glContext)
591 m_glContext->SetCurrent();
592 }
593
594 void wxGLCanvas::SetColour( const wxChar *colour )
595 {
596 if (m_glContext)
597 m_glContext->SetColour( colour );
598 }
599
600 void wxGLCanvas::OnInternalIdle()
601 {
602 if (m_glContext && m_exposed)
603 {
604 wxPaintEvent event( GetId() );
605 event.SetEventObject( this );
606 GetEventHandler()->ProcessEvent( event );
607
608 m_exposed = FALSE;
609 GetUpdateRegion().Clear();
610 }
611
612 wxWindow::OnInternalIdle();
613 }
614
615
616
617 //---------------------------------------------------------------------------
618 // wxGLApp
619 //---------------------------------------------------------------------------
620
621 IMPLEMENT_CLASS(wxGLApp, wxApp)
622
623 wxGLApp::~wxGLApp()
624 {
625 if (m_glFBCInfo)
626 XFree(m_glFBCInfo);
627 if (m_glVisualInfo)
628 XFree(m_glVisualInfo);
629 }
630
631 bool wxGLApp::InitGLVisual(int *attribList)
632 {
633 wxGLCanvas::QueryGLXVersion();
634
635 if (wxGLCanvas::GetGLXVersion() >= 13)
636 {
637 // GLX >= 1.3
638 if (m_glFBCInfo)
639 XFree(m_glFBCInfo);
640 m_glFBCInfo = wxGLCanvas::ChooseGLFBC(attribList);
641
642 if (m_glFBCInfo)
643 {
644 if (m_glVisualInfo)
645 XFree(m_glVisualInfo);
646 m_glVisualInfo = glXGetVisualFromFBConfig(GDK_DISPLAY(), ((GLXFBConfig *)m_glFBCInfo)[0]);
647 }
648 return (m_glFBCInfo != NULL) && (m_glVisualInfo != NULL);
649 }
650 else
651 {
652 // GLX <= 1.2
653 if (m_glVisualInfo)
654 XFree(m_glVisualInfo);
655 m_glVisualInfo = wxGLCanvas::ChooseGLVisual(attribList);
656 return m_glVisualInfo != NULL;
657 }
658 }
659
660 #endif
661 // wxUSE_GLCANVAS
662