-//---------------------------------------------------------------------------
-// wxGLContext
-//---------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(wxGLContext,wxObject)
-
-wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, const wxPalette& WXUNUSED(palette) )
-{
- m_window = win;
- m_widget = win->m_wxwindow;
-
- wxGLCanvas *gc = (wxGLCanvas*) win;
- XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
-
- wxCHECK_RET( vi, _T("invalid visual for OpenGl") );
-
- m_glContext = glXCreateContext( GDK_DISPLAY(), vi, None, GL_TRUE );
-
- wxCHECK_RET( m_glContext, _T("Couldn't create OpenGl context") );
-}
-
-wxGLContext::wxGLContext(
- bool WXUNUSED(isRGB), wxWindow *win,
- const wxPalette& WXUNUSED(palette),
- const wxGLContext *other /* for sharing display lists */
-)
-{
- m_window = win;
- m_widget = win->m_wxwindow;
-
- wxGLCanvas *gc = (wxGLCanvas*) win;
- XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
-
- wxCHECK_RET( vi, _T("invalid visual for OpenGl") );
-
- m_glContext = glXCreateContext( GDK_DISPLAY(), vi,
- other ? other->m_glContext : None,
- GL_TRUE );
-
- if ( !m_glContext )
- {
- wxFAIL_MSG( _T("Couldn't create OpenGl context") );
- }
-}
-
-wxGLContext::~wxGLContext()
-{
- if (!m_glContext) return;
-
- if (m_glContext == glXGetCurrentContext())
- {
- glXMakeCurrent( GDK_DISPLAY(), None, NULL);
- }
-
- glXDestroyContext( GDK_DISPLAY(), m_glContext );
-}
-
-void wxGLContext::SwapBuffers()
-{
- if (m_glContext)
- {
- GdkWindow *window = GTK_PIZZA(m_widget)->bin_window;
- glXSwapBuffers( GDK_DISPLAY(), GDK_WINDOW_XWINDOW( window ) );
- }
-}
-
-void wxGLContext::SetCurrent()
-{
- if (m_glContext)
- {
- GdkWindow *window = GTK_PIZZA(m_widget)->bin_window;
- glXMakeCurrent( GDK_DISPLAY(), GDK_WINDOW_XWINDOW(window), m_glContext );
- }
-}
-
-void wxGLContext::SetColour(const wxChar *colour)
-{
- wxColour col = wxTheColourDatabase->Find(colour);
- if (col.Ok())
- {
- float r = (float)(col.Red()/256.0);
- float g = (float)(col.Green()/256.0);
- float b = (float)(col.Blue()/256.0);
- glColor3f( r, g, b);
- }
-}
-
-void wxGLContext::SetupPixelFormat()
-{
-}
-
-void wxGLContext::SetupPalette( const wxPalette& WXUNUSED(palette) )
-{
-}
-
-wxPalette wxGLContext::CreateDefaultPalette()
-{
- return wxNullPalette;
-}