]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/glcanvas.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWidgets and GTK
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GLCANVAS_H_
13 #define _WX_GLCANVAS_H_
15 #include "wx/scrolwin.h"
24 //---------------------------------------------------------------------------
25 // Constants for attriblist
26 //---------------------------------------------------------------------------
30 WX_GL_RGBA
=1, /* use true color palette */
31 WX_GL_BUFFER_SIZE
, /* bits for buffer if not WX_GL_RGBA */
32 WX_GL_LEVEL
, /* 0 for main buffer, >0 for overlay, <0 for underlay */
33 WX_GL_DOUBLEBUFFER
, /* use doublebuffer */
34 WX_GL_STEREO
, /* use stereoscopic display */
35 WX_GL_AUX_BUFFERS
, /* number of auxiliary buffers */
36 WX_GL_MIN_RED
, /* use red buffer with most bits (> MIN_RED bits) */
37 WX_GL_MIN_GREEN
, /* use green buffer with most bits (> MIN_GREEN bits) */
38 WX_GL_MIN_BLUE
, /* use blue buffer with most bits (> MIN_BLUE bits) */
39 WX_GL_MIN_ALPHA
, /* use blue buffer with most bits (> MIN_ALPHA bits) */
40 WX_GL_DEPTH_SIZE
, /* bits for Z-buffer (0,16,32) */
41 WX_GL_STENCIL_SIZE
, /* bits for stencil buffer */
42 WX_GL_MIN_ACCUM_RED
, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
43 WX_GL_MIN_ACCUM_GREEN
, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
44 WX_GL_MIN_ACCUM_BLUE
, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
45 WX_GL_MIN_ACCUM_ALPHA
/* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
48 //---------------------------------------------------------------------------
50 //---------------------------------------------------------------------------
52 class WXDLLEXPORT wxGLContext
;
53 class WXDLLEXPORT wxGLCanvas
;
55 //---------------------------------------------------------------------------
57 //---------------------------------------------------------------------------
60 class WXDLLEXPORT wxGLContext
: public wxObject
63 wxGLContext(wxWindow
* win
, const wxGLContext
* other
=NULL
/* for sharing display lists */);
64 virtual ~wxGLContext();
67 // The win wxGLCanvas needs not necessarily be the same as the wxGLCanvas with which this context was created!
68 void SetCurrent(const wxGLCanvas
& win
) const;
72 GLXContext m_glContext
;
75 DECLARE_CLASS(wxGLContext
)
78 //---------------------------------------------------------------------------
80 //---------------------------------------------------------------------------
82 class WXDLLEXPORT wxGLCanvas
: public wxWindow
85 // This ctor is identical to the next, except for the fact that it
86 // doesn't create an implicit wxGLContext.
87 // The attribList parameter has been moved to avoid overload clashes.
88 wxGLCanvas( wxWindow
*parent
, wxWindowID id
= -1,
89 int *attribList
= (int*) NULL
,
90 const wxPoint
& pos
= wxDefaultPosition
,
91 const wxSize
& size
= wxDefaultSize
,
92 long style
= 0, const wxString
& name
= wxGLCanvasName
,
93 const wxPalette
& palette
= wxNullPalette
);
95 wxGLCanvas( wxWindow
*parent
, wxWindowID id
= -1,
96 const wxPoint
& pos
= wxDefaultPosition
,
97 const wxSize
& size
= wxDefaultSize
,
98 long style
= 0, const wxString
& name
= wxGLCanvasName
,
99 int *attribList
= (int*) NULL
,
100 const wxPalette
& palette
= wxNullPalette
);
102 wxGLCanvas( wxWindow
*parent
, const wxGLContext
*shared
,
104 const wxPoint
& pos
= wxDefaultPosition
,
105 const wxSize
& size
= wxDefaultSize
,
106 long style
= 0, const wxString
& name
= wxGLCanvasName
,
107 int *attribList
= (int*) NULL
,
108 const wxPalette
& palette
= wxNullPalette
);
110 wxGLCanvas( wxWindow
*parent
, const wxGLCanvas
*shared
,
112 const wxPoint
& pos
= wxDefaultPosition
,
113 const wxSize
& size
= wxDefaultSize
,
114 long style
= 0, const wxString
& name
= wxGLCanvasName
,
115 int *attribList
= (int*) NULL
,
116 const wxPalette
& palette
= wxNullPalette
);
118 bool Create( wxWindow
*parent
,
119 const wxGLContext
*shared
= (wxGLContext
*)NULL
,
120 const wxGLCanvas
*shared_context_of
= (wxGLCanvas
*)NULL
,
122 const wxPoint
& pos
= wxDefaultPosition
,
123 const wxSize
& size
= wxDefaultSize
,
125 const wxString
& name
= wxGLCanvasName
,
126 int *attribList
= (int*) NULL
,
127 const wxPalette
& palette
= wxNullPalette
);
129 virtual ~wxGLCanvas();
131 void SetCurrent(const wxGLContext
& RC
) const;
133 void SetColour(const wxChar
*colour
);
136 void OnSize(wxSizeEvent
& event
);
138 void OnInternalIdle();
140 inline wxGLContext
* GetContext() const { return m_glContext
; }
144 wxGLContext
*m_glContext
,
146 wxGLCanvas
*m_sharedContextOf
;
147 const bool m_createImplicitContext
;
148 void *m_vi
; // actually an XVisualInfo*
152 GtkWidget
*m_glWidget
;
155 // returns an XVisualInfo* based on desired GL attributes;
156 // returns NULL if an appropriate visual is not found. The
157 // caller is reponsible for using XFree() to deallocate
158 // the returned structure.
159 static void* ChooseGLVisual(int *attribList
);
160 static void* ChooseGLFBC(int *attribList
);
161 static void GetGLAttribListFromWX(int *wx_attribList
, int *gl_attribList
);
163 static void QueryGLXVersion();
164 static int GetGLXVersion();
165 static int m_glxVersion
;
168 DECLARE_EVENT_TABLE()
169 DECLARE_CLASS(wxGLCanvas
)