-/*
- * GLContext implementation
- */
-
-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, "invalid visual for OpenGl" );
-
- m_glContext = glXCreateContext( (Display *)wxGetDisplay(), vi,
- None, GL_TRUE);
-
- wxCHECK_RET( m_glContext, "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, "invalid visual for OpenGl" );
-
- if( other != 0 )
- m_glContext = glXCreateContext( (Display *)wxGetDisplay(), vi,
- other->m_glContext, GL_TRUE );
- else
- m_glContext = glXCreateContext( (Display *)wxGetDisplay(), vi,
- None, GL_TRUE );
-
- wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
-}
-
-wxGLContext::~wxGLContext()
-{
- if (!m_glContext) return;
-
- if (m_glContext == glXGetCurrentContext())
- {
- glXMakeCurrent( (Display*) wxGetDisplay(), None, NULL);
- }
-
- glXDestroyContext( (Display*) wxGetDisplay(), m_glContext );
-}
-
-void wxGLContext::SwapBuffers()
-{
- if (m_glContext)
- {
- Display* display = (Display*) wxGetDisplay();
- glXSwapBuffers(display, (Window) m_window->GetClientAreaWindow());
- }
-}
-
-void wxGLContext::SetCurrent()
-{
- if (m_glContext)
- {
- Display* display = (Display*) wxGetDisplay();
- glXMakeCurrent(display, (Window) m_window->GetClientAreaWindow(),
- m_glContext );;
- }
-}
-
-void wxGLContext::SetColour(const char *colour)
-{
- wxColour *the_colour = wxTheColourDatabase->FindColour(colour);
- if(the_colour) {
- GLboolean b;
- glGetBooleanv(GL_RGBA_MODE, &b);
- if(b) {
- glColor3ub(the_colour->Red(),
- the_colour->Green(),
- the_colour->Blue());
- } else {
- the_colour->CalcPixel(wxTheApp->GetMainColormap(wxGetDisplay()));
- GLint pix = (GLint)the_colour->GetPixel();
- if(pix == -1)
- {
- wxLogError("wxGLCanvas: cannot allocate color\n");
- return;
- }
- glIndexi(pix);
- }
- }
-}
-
-void wxGLContext::SetupPixelFormat()
-{
-}
-
-void wxGLContext::SetupPalette( const wxPalette& WXUNUSED(palette) )
-{
-}
-
-wxPalette wxGLContext::CreateDefaultPalette()
-{
- return wxNullPalette;
-}
-
-
-