1 /////////////////////////////////////////////////////////////////////////////// 2 // Name: wx/unix/glx11.h 3 // Purpose: class common for all X11-based wxGLCanvas implementations 4 // Author: Vadim Zeitlin 5 // Created: 2007-04-15 6 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org> 7 // Licence: wxWindows licence 8 /////////////////////////////////////////////////////////////////////////////// 9 10 #ifndef _WX_UNIX_GLX11_H_ 11 #define _WX_UNIX_GLX11_H_ 12 13 #include <GL/gl.h> 14 15 typedef struct __GLXcontextRec* GLXContext; 16 typedef struct __GLXFBConfigRec* GLXFBConfig; 17 18 // ---------------------------------------------------------------------------- 19 // wxGLContext 20 // ---------------------------------------------------------------------------- 21 22 class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase 23 { 24 public: 25 wxGLContext(wxGLCanvas *win, 26 const wxGLContext *other = NULL, 27 const wxGLContextAttrs *ctxAttrs = NULL); 28 virtual ~wxGLContext(); 29 30 virtual bool SetCurrent(const wxGLCanvas& win) const wxOVERRIDE; 31 32 private: 33 GLXContext m_glContext; 34 35 wxDECLARE_CLASS(wxGLContext); 36 }; 37 38 // ---------------------------------------------------------------------------- 39 // wxGLCanvasX11 40 // ---------------------------------------------------------------------------- 41 42 class WXDLLIMPEXP_GL wxGLCanvasX11 : public wxGLCanvasBase 43 { 44 public: 45 // initialization and dtor 46 // ----------------------- 47 48 // default ctor doesn't do anything, InitVisual() must be called 49 wxGLCanvasX11(); 50 51 // initializes GLXFBConfig and XVisualInfo corresponding to the given attributes 52 bool InitVisual(const wxGLAttributes& dispAttrs); 53 54 // frees XVisualInfo info 55 virtual ~wxGLCanvasX11(); 56 57 58 // implement wxGLCanvasBase methods 59 // -------------------------------- 60 61 virtual bool SwapBuffers() wxOVERRIDE; 62 63 64 // X11-specific methods 65 // -------------------- 66 67 // return GLX version: 13 means 1.3 &c 68 static int GetGLXVersion(); 69 70 // return true if multisample extension is available 71 static bool IsGLXMultiSampleAvailable(); 72 73 // get the X11 handle of this window 74 virtual unsigned long GetXWindow() const = 0; 75 76 77 // GLX-specific methods 78 // -------------------- 79 80 // override some wxWindow methods 81 // ------------------------------ 82 83 // return true only if the window is realized: OpenGL context can't be 84 // created until we are 85 virtual bool IsShownOnScreen() const wxOVERRIDE; 86 87 88 // implementation only from now on 89 // ------------------------------- 90 91 // get the GLXFBConfig/XVisualInfo we use GetGLXFBConfig()92 GLXFBConfig *GetGLXFBConfig() const { return m_fbc; } GetXVisualInfo()93 void* GetXVisualInfo() const { return m_vi; } 94 95 // initialize the global default GL visual, return false if matching visual 96 // not found 97 static bool InitDefaultVisualInfo(const int *attribList); 98 99 private: 100 GLXFBConfig *m_fbc; 101 void* m_vi; 102 }; 103 104 // ---------------------------------------------------------------------------- 105 // wxGLApp 106 // ---------------------------------------------------------------------------- 107 108 // this is used in wx/glcanvas.h, prevent it from defining a generic wxGLApp 109 #define wxGL_APP_DEFINED 110 111 class WXDLLIMPEXP_GL wxGLApp : public wxGLAppBase 112 { 113 public: 114 virtual bool InitGLVisual(const int *attribList) wxOVERRIDE; 115 116 // This method is not currently used by the library itself, but remains for 117 // backwards compatibility and also because wxGTK has it we could start 118 // using it for the same purpose in wxX11 too some day. 119 virtual void* GetXVisualInfo() wxOVERRIDE; 120 121 // and override this wxApp method to clean up 122 virtual int OnExit() wxOVERRIDE; 123 124 private: 125 wxDECLARE_DYNAMIC_CLASS(wxGLApp); 126 }; 127 128 #endif // _WX_UNIX_GLX11_H_ 129 130