]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/glcanvas.h
corrected conditional include
[wxWidgets.git] / include / wx / gtk1 / glcanvas.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: glcanvas.h
3 // Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWindows and GTK
4 // Author: Robert Roebling
5 // Modified by:
6 // Created: 17/8/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma interface "glcanvas.h"
14 #endif
15
16 #ifndef _WX_GLCANVAS_H_
17 #define _WX_GLCANVAS_H_
18
19 #include <wx/defs.h>
20
21 #if wxUSE_GLCANVAS
22
23 #include <wx/scrolwin.h>
24
25 extern "C" {
26 #include "GL/gl.h"
27 #include "GL/glx.h"
28 #include "GL/glu.h"
29 }
30
31 //---------------------------------------------------------------------------
32 // Constants for attriblist
33 //---------------------------------------------------------------------------
34
35 enum
36 {
37 WX_GL_RGBA=1, /* use true color palette */
38 WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */
39 WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */
40 WX_GL_DOUBLEBUFFER, /* use doublebuffer */
41 WX_GL_STEREO, /* use stereoscopic display */
42 WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */
43 WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
44 WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
45 WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */
46 WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */
47 WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
48 WX_GL_STENCIL_SIZE, /* bits for stencil buffer */
49 WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
50 WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
51 WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
52 WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
53 };
54
55 //---------------------------------------------------------------------------
56 // classes
57 //---------------------------------------------------------------------------
58
59 class WXDLLEXPORT wxGLContext;
60 class WXDLLEXPORT wxGLCanvas;
61
62 //---------------------------------------------------------------------------
63 // wxGLContext
64 //---------------------------------------------------------------------------
65
66
67 class WXDLLEXPORT wxGLContext: public wxObject
68 {
69 public:
70 wxGLContext( bool isRGB, wxWindow *win, const wxPalette& palette = wxNullPalette );
71 wxGLContext(
72 bool WXUNUSED(isRGB), wxWindow *win,
73 const wxPalette& WXUNUSED(palette),
74 const wxGLContext *other /* for sharing display lists */
75 );
76 ~wxGLContext();
77
78 void SetCurrent();
79 void SetColour(const char *colour);
80 void SwapBuffers();
81
82 void SetupPixelFormat();
83 void SetupPalette(const wxPalette& palette);
84 wxPalette CreateDefaultPalette();
85
86 inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
87 inline wxWindow* GetWindow() const { return m_window; }
88 inline GtkWidget* GetWidget() const { return m_widget; }
89 inline GLXContext GetContext() const { return m_glContext; }
90
91 public:
92 GLXContext m_glContext;
93
94 GtkWidget *m_widget;
95 wxPalette m_palette;
96 wxWindow* m_window;
97
98 private:
99 DECLARE_CLASS(wxGLContext)
100 };
101
102 //---------------------------------------------------------------------------
103 // wxGLContext
104 //---------------------------------------------------------------------------
105
106 class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow
107 {
108 public:
109 inline wxGLCanvas() {
110 m_glContext = (wxGLContext*) NULL;
111 m_sharedContext = (wxGLContext*) NULL;
112 m_glWidget = (GtkWidget*) NULL;
113 m_vi = (void*) NULL;
114 m_exposed = FALSE;
115 }
116 wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
117 const wxPoint& pos = wxDefaultPosition,
118 const wxSize& size = wxDefaultSize,
119 long style = 0, const wxString& name = "GLCanvas",
120 int *attribList = (int*) NULL,
121 const wxPalette& palette = wxNullPalette );
122 wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
123 wxWindowID id = -1,
124 const wxPoint& pos = wxDefaultPosition,
125 const wxSize& size = wxDefaultSize,
126 long style = 0, const wxString& name = "GLCanvas",
127 int *attribList = (int*) NULL,
128 const wxPalette& palette = wxNullPalette );
129 wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL,
130 wxWindowID id = -1,
131 const wxPoint& pos = wxDefaultPosition,
132 const wxSize& size = wxDefaultSize,
133 long style = 0, const wxString& name = "GLCanvas",
134 int *attribList = (int*) NULL,
135 const wxPalette& palette = wxNullPalette );
136
137 bool Create( wxWindow *parent,
138 const wxGLContext *shared = (wxGLContext*)NULL,
139 const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL,
140 wxWindowID id = -1,
141 const wxPoint& pos = wxDefaultPosition,
142 const wxSize& size = wxDefaultSize,
143 long style = 0, const wxString& name = "GLCanvas",
144 int *attribList = (int*) NULL,
145 const wxPalette& palette = wxNullPalette );
146
147 ~wxGLCanvas();
148
149 void SetCurrent();
150 void SetColour(const char *colour);
151 void SwapBuffers();
152
153 void OnSize(wxSizeEvent& event);
154
155 void OnInternalIdle();
156
157 inline wxGLContext* GetContext() const { return m_glContext; }
158
159 // implementation
160
161 wxGLContext *m_glContext,
162 *m_sharedContext;
163 wxGLCanvas *m_sharedContextOf;
164 void *m_vi;
165 GtkWidget *m_glWidget;
166 bool m_exposed;
167
168 private:
169 DECLARE_EVENT_TABLE()
170 DECLARE_CLASS(wxGLCanvas)
171 };
172
173 #endif
174 // wxUSE_GLCANVAS
175
176 #endif
177 // _WX_GLCANVAS_H_
178