X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b5f62a0b2db198609b45dec622a018dae37008e..1978421a6d8b81c1f8a961da4b8ddf544fec7b1b:/src/x11/glcanvas.cpp diff --git a/src/x11/glcanvas.cpp b/src/x11/glcanvas.cpp index cac1674d9f..9fc512eb43 100644 --- a/src/x11/glcanvas.cpp +++ b/src/x11/glcanvas.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: glcanvas.cpp -// Purpose: wxGLCanvas, for using OpenGL with wxWindows 2.0 for Motif. +// Purpose: wxGLCanvas, for using OpenGL with wxWindows // Uses the GLX extension. // Author: Julian Smart and Wolfram Gloger // Modified by: @@ -10,7 +10,7 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "glcanvas.h" #endif @@ -26,11 +26,24 @@ #ifdef __VMS # pragma message disable nosimpint #endif -#include +#include #ifdef __VMS # pragma message enable nosimpint #endif -#include "wx/motif/private.h" +#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__ + return win->GetClientXWindow(); +#else + return win->GetClientAreaWindow(); +#endif +} #ifdef OLD_MESA // workaround for bug in Mesa's glx.c @@ -109,7 +122,7 @@ void wxGLContext::SwapBuffers() if (m_glContext) { Display* display = (Display*) wxGetDisplay(); - glXSwapBuffers(display, (Window) m_window->GetClientAreaWindow()); + glXSwapBuffers(display, (Window) wxGetClientAreaWindow(m_window)); } } @@ -118,7 +131,7 @@ void wxGLContext::SetCurrent() if (m_glContext) { Display* display = (Display*) wxGetDisplay(); - glXMakeCurrent(display, (Window) m_window->GetClientAreaWindow(), + glXMakeCurrent(display, (Window) wxGetClientAreaWindow(m_window), m_glContext );; } } @@ -134,7 +147,11 @@ void wxGLContext::SetColour(const char *colour) the_colour->Green(), the_colour->Blue()); } else { +#ifdef __WXMOTIF__ + the_colour->AllocColour(m_window->GetXDisplay()); +#else the_colour->CalcPixel(wxTheApp->GetMainColormap(wxGetDisplay())); +#endif GLint pix = (GLint)the_colour->GetPixel(); if(pix == -1) { @@ -295,7 +312,7 @@ bool wxGLCanvas::Create( wxWindow *parent, } else { // By default, we use the visual of xwindow // NI: is this really senseful ? opengl in e.g. color index mode ? - XGetWindowAttributes(display, (Window) GetClientAreaWindow(), &xwa); + XGetWindowAttributes(display, (Window)wxGetClientAreaWindow(this), &xwa); vi_templ.visualid = XVisualIDFromVisual(xwa.visual); vi = XGetVisualInfo(display, VisualIDMask, &vi_templ, &n); if(!vi) return FALSE;