]> git.saurik.com Git - wxWidgets.git/blobdiff - src/x11/glcanvas.cpp
Committed forgotten files
[wxWidgets.git] / src / x11 / glcanvas.cpp
index 6a6869fc0f4848b279a9d44bd5e1afeb8e8ce102..11eda0cfe559905dcbebb2674d497e0abc155741 100644 (file)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        glcanvas.cpp
-// Purpose:     wxGLCanvas, for using OpenGL with wxWindows
+// Purpose:     wxGLCanvas, for using OpenGL with wxWidgets
 //              Uses the GLX extension.
 // Author:      Julian Smart and Wolfram Gloger
 // Modified by:
 // Licence:    wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "glcanvas.h"
-#endif
-
 #include "wx/setup.h"
 
 #if wxUSE_GLCANVAS
 #endif
 #include "wx/x11/private.h"
 
+// DLL options compatibility check:
+#include "wx/build.h"
+WX_CHECK_BUILD_OPTIONS("wxGL")
+
 static inline WXWindow wxGetClientAreaWindow(wxWindow* win)
 {
 #ifdef __WXMOTIF__
@@ -69,12 +69,12 @@ wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win,
     wxGLCanvas *gc = (wxGLCanvas*) win;
     XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
     
-    wxCHECK_RET( vi, "invalid visual for OpenGl" );
+    wxCHECK_RET( vi, wxT("invalid visual for OpenGL") );
     
     m_glContext = glXCreateContext( (Display *)wxGetDisplay(), vi,
                                     None, GL_TRUE);
   
-    wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
+    wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGL context") );
 }
 
 wxGLContext::wxGLContext( 
@@ -89,7 +89,7 @@ wxGLContext::wxGLContext(
     wxGLCanvas *gc = (wxGLCanvas*) win;
     XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
     
-    wxCHECK_RET( vi, "invalid visual for OpenGl" );
+    wxCHECK_RET( vi, wxT("invalid visual for OpenGL") );
     
     if( other != 0 )
         m_glContext = glXCreateContext( (Display *)wxGetDisplay(), vi, 
@@ -98,7 +98,7 @@ wxGLContext::wxGLContext(
         m_glContext = glXCreateContext( (Display *)wxGetDisplay(), vi,
                                         None, GL_TRUE );
     
-    wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
+    wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGL context") );
 }
 
 wxGLContext::~wxGLContext()
@@ -128,34 +128,38 @@ void wxGLContext::SetCurrent()
     { 
         Display* display = (Display*) wxGetDisplay();
         glXMakeCurrent(display, (Window) wxGetClientAreaWindow(m_window), 
-                       m_glContext );;
+                       m_glContext );
     }
 }
 
-void wxGLContext::SetColour(const char *colour)
+void wxGLContext::SetColour(const wxChar *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 {
+    wxColour the_colour = wxTheColourDatabase->Find(colour);
+    if(the_colour.Ok())
+    {
+        GLboolean b;
+        glGetBooleanv(GL_RGBA_MODE, &b);
+        if(b)
+        {
+            glColor3ub(the_colour.Red(),
+                    the_colour.Green(),
+                    the_colour.Blue());
+        }
+        else
+        {
 #ifdef __WXMOTIF__
-            the_colour->AllocColour(m_window->GetXDisplay());
+            the_colour.AllocColour(m_window->GetXDisplay());
 #else
-            the_colour->CalcPixel(wxTheApp->GetMainColormap(wxGetDisplay()));
+            the_colour.CalcPixel(wxTheApp->GetMainColormap(wxGetDisplay()));
 #endif
-           GLint pix = (GLint)the_colour->GetPixel();
-           if(pix == -1)
+            GLint pix = (GLint)the_colour.GetPixel();
+            if(pix == -1)
             {
-                wxLogError("wxGLCanvas: cannot allocate color\n");
-               return;
+                wxLogError(wxT("wxGLCanvas: cannot allocate color\n"));
+                return;
             }
-           glIndexi(pix);
-       }
+            glIndexi(pix);
+        }
     }
 }
 
@@ -251,7 +255,7 @@ bool wxGLCanvas::Create( wxWindow *parent,
 
     // Check for the presence of the GLX extension
     if(!glXQueryExtension(display, NULL, NULL)) {
-       wxLogDebug("wxGLCanvas: GLX extension is missing\n");
+       wxLogDebug(wxT("wxGLCanvas: GLX extension is missing\n"));
        return FALSE;
     }
 
@@ -346,7 +350,7 @@ bool wxGLCanvas::Create( wxWindow *parent,
 
     m_vi = vi;  // safe for later use
     
-    wxCHECK_MSG( m_vi, FALSE, "required visual couldn't be found" );
+    wxCHECK_MSG( m_vi, FALSE, wxT("required visual couldn't be found") );
 
     // Create the GLX context and make it current
 
@@ -391,7 +395,7 @@ void wxGLCanvas::SetCurrent()
     // if(glx_cx) glXMakeCurrent(display, (Window) GetClientAreaWindow(), glx_cx);
 }
 
-void wxGLCanvas::SetColour(const char *col)
+void wxGLCanvas::SetColour(const wxChar *col)
 {
     if( m_glContext ) m_glContext->SetColour(col);
 }