]> git.saurik.com Git - wxWidgets.git/blame - include/wx/unix/glx11.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / unix / glx11.h
CommitLineData
498ace9e
VZ
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
498ace9e
VZ
6// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
7// Licence: wxWindows licence
8///////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_UNIX_GLX11_H_
11#define _WX_UNIX_GLX11_H_
12
13#include <GL/glx.h>
14
15// ----------------------------------------------------------------------------
16// wxGLContext
17// ----------------------------------------------------------------------------
18
5a83f42b 19class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase
498ace9e
VZ
20{
21public:
22 wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
23 virtual ~wxGLContext();
24
5ec69e96 25 virtual bool SetCurrent(const wxGLCanvas& win) const;
498ace9e
VZ
26
27private:
28 // attach context to the drawable or unset it (if NULL)
5ec69e96 29 static bool MakeCurrent(GLXDrawable drawable, GLXContext context);
498ace9e
VZ
30
31 GLXContext m_glContext;
32
33 DECLARE_CLASS(wxGLContext)
34};
35
36// ----------------------------------------------------------------------------
37// wxGLCanvasX11
38// ----------------------------------------------------------------------------
39
5a83f42b 40class WXDLLIMPEXP_GL wxGLCanvasX11 : public wxGLCanvasBase
498ace9e
VZ
41{
42public:
43 // initialization and dtor
44 // -----------------------
45
46 // default ctor doesn't do anything, InitVisual() must be called
47 wxGLCanvasX11();
48
49 // initializes the XVisualInfo corresponding to the given attributes
50 bool InitVisual(const int *attribList);
51
52 // frees XVisualInfo info
53 virtual ~wxGLCanvasX11();
54
55
56 // implement wxGLCanvasBase methods
57 // --------------------------------
58
5ec69e96 59 virtual bool SwapBuffers();
498ace9e
VZ
60
61
62 // X11-specific methods
63 // --------------------
64
65 // return GLX version: 13 means 1.3 &c
66 static int GetGLXVersion();
67
c39d2e0a
VZ
68 // return true if multisample extension is available
69 static bool IsGLXMultiSampleAvailable();
70
498ace9e
VZ
71 // get the X11 handle of this window
72 virtual Window GetXWindow() const = 0;
73
74
75 // override some wxWindow methods
76 // ------------------------------
77
78 // return true only if the window is realized: OpenGL context can't be
79 // created until we are
80 virtual bool IsShownOnScreen() const;
81
82
83 // implementation only from now on
84 // -------------------------------
85
86 // get the GLXFBConfig/XVisualInfo we use
87 GLXFBConfig *GetGLXFBConfig() const { return m_fbc; }
88 XVisualInfo *GetXVisualInfo() const { return m_vi; }
89
90 // initialize the global default GL visual, return false if matching visual
91 // not found
92 static bool InitDefaultVisualInfo(const int *attribList);
93
94 // get the default GL X11 visual (may be NULL, shouldn't be freed by caller)
95 static XVisualInfo *GetDefaultXVisualInfo() { return ms_glVisualInfo; }
96
97 // free the global GL visual, called by wxGLApp
98 static void FreeDefaultVisualInfo();
99
3f20f7d8
VZ
100 // initializes XVisualInfo (in any case) and, if supported, GLXFBConfig
101 //
102 // returns false if XVisualInfo couldn't be initialized, otherwise caller
103 // is responsible for freeing the pointers
104 static bool InitXVisualInfo(const int *attribList,
105 GLXFBConfig **pFBC, XVisualInfo **pXVisual);
106
498ace9e
VZ
107private:
108 // fills in glattrs with attributes defined by wxattrs which must be
109 // 0-terminated if it is non-NULL
110 //
111 // n is the max size of glattrs, false is returned if we overflow it, it
112 // should be at least 16 to accommodate the default attributes
113 static bool ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n);
114
498ace9e
VZ
115
116 // this is only used if it's supported i.e. if GL >= 1.3
117 GLXFBConfig *m_fbc;
118
119 // used for all GL versions, obtained from GLXFBConfig for GL >= 1.3
120 XVisualInfo *m_vi;
121
122 // the global/default versions of the above
123 static GLXFBConfig *ms_glFBCInfo;
124 static XVisualInfo *ms_glVisualInfo;
125};
126
127// ----------------------------------------------------------------------------
128// wxGLApp
129// ----------------------------------------------------------------------------
130
131// this is used in wx/glcanvas.h, prevent it from defining a generic wxGLApp
132#define wxGL_APP_DEFINED
133
5a83f42b 134class WXDLLIMPEXP_GL wxGLApp : public wxGLAppBase
498ace9e
VZ
135{
136public:
1c269771 137 wxGLApp() : wxGLAppBase() { }
498ace9e
VZ
138
139 // implement wxGLAppBase method
140 virtual bool InitGLVisual(const int *attribList)
141 {
142 return wxGLCanvasX11::InitDefaultVisualInfo(attribList);
143 }
144
145 // and implement this wxGTK::wxApp method too
146 virtual void *GetXVisualInfo()
147 {
148 return wxGLCanvasX11::GetDefaultXVisualInfo();
149 }
150
151 // and override this wxApp method to clean up
152 virtual int OnExit()
153 {
154 wxGLCanvasX11::FreeDefaultVisualInfo();
155
156 return wxGLAppBase::OnExit();
157 }
158
159private:
047b6c71 160 DECLARE_DYNAMIC_CLASS(wxGLApp)
498ace9e
VZ
161};
162
163#endif // _WX_UNIX_GLX11_H_
164