]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/glcanvas.h
Added WXDLLEXPORT symbol for DynLib classes
[wxWidgets.git] / include / wx / gtk / 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_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
39 WX_GL_DOUBLEBUFFER, /* use doublebuffer */
40 WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
41 WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
42 WX_GL_MIN_BLUE /* use blue buffer with most bits (> MIN_BLUE bits) */
43 /* these are enough constants for now, the remaining will be added later */
44 };
45
46 //---------------------------------------------------------------------------
47 // classes
48 //---------------------------------------------------------------------------
49
50 class WXDLLEXPORT wxGLContext;
51 class WXDLLEXPORT wxGLCanvas;
52
53 //---------------------------------------------------------------------------
54 // wxGLContext
55 //---------------------------------------------------------------------------
56
57
58 class WXDLLEXPORT wxGLContext: public wxObject
59 {
60 public:
61 wxGLContext( bool isRGB, wxWindow *win, const wxPalette& palette = wxNullPalette );
62 wxGLContext(
63 bool WXUNUSED(isRGB), wxWindow *win,
64 const wxPalette& WXUNUSED(palette),
65 const wxGLContext *other /* for sharing display lists */
66 );
67 ~wxGLContext();
68
69 void SetCurrent();
70 void SetColour(const char *colour);
71 void SwapBuffers();
72
73 void SetupPixelFormat();
74 void SetupPalette(const wxPalette& palette);
75 wxPalette CreateDefaultPalette();
76
77 inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
78 inline wxWindow* GetWindow() const { return m_window; }
79 inline GtkWidget* GetWidget() const { return m_widget; }
80 inline GLXContext GetContext() const { return m_glContext; }
81
82 public:
83 GLXContext m_glContext;
84
85 GtkWidget *m_widget;
86 wxPalette m_palette;
87 wxWindow* m_window;
88
89 private:
90 DECLARE_CLASS(wxGLContext)
91 };
92
93 //---------------------------------------------------------------------------
94 // wxGLContext
95 //---------------------------------------------------------------------------
96
97 class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow
98 {
99 public:
100 inline wxGLCanvas() {
101 m_glContext = (wxGLContext*) NULL;
102 m_sharedContext = (wxGLContext*) NULL;
103 m_glWidget = (GtkWidget*) NULL;
104 m_vi = (void*) NULL;
105 m_exposed = FALSE;
106 }
107 wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
108 const wxPoint& pos = wxDefaultPosition,
109 const wxSize& size = wxDefaultSize,
110 long style = 0, const wxString& name = "GLCanvas",
111 int *attribList = (int*) NULL,
112 const wxPalette& palette = wxNullPalette );
113 wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
114 wxWindowID id = -1,
115 const wxPoint& pos = wxDefaultPosition,
116 const wxSize& size = wxDefaultSize,
117 long style = 0, const wxString& name = "GLCanvas",
118 int *attribList = (int*) NULL,
119 const wxPalette& palette = wxNullPalette );
120 wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL,
121 wxWindowID id = -1,
122 const wxPoint& pos = wxDefaultPosition,
123 const wxSize& size = wxDefaultSize,
124 long style = 0, const wxString& name = "GLCanvas",
125 int *attribList = (int*) NULL,
126 const wxPalette& palette = wxNullPalette );
127
128 bool Create( wxWindow *parent,
129 const wxGLContext *shared = (wxGLContext*)NULL,
130 const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL,
131 wxWindowID id = -1,
132 const wxPoint& pos = wxDefaultPosition,
133 const wxSize& size = wxDefaultSize,
134 long style = 0, const wxString& name = "GLCanvas",
135 int *attribList = (int*) NULL,
136 const wxPalette& palette = wxNullPalette );
137
138 ~wxGLCanvas();
139
140 void SetCurrent();
141 void SetColour(const char *colour);
142 void SwapBuffers();
143
144 void OnSize(wxSizeEvent& event);
145
146 void OnInternalIdle();
147
148 inline wxGLContext* GetContext() const { return m_glContext; }
149
150 // implementation
151
152 wxGLContext *m_glContext,
153 *m_sharedContext;
154 wxGLCanvas *m_sharedContextOf;
155 void *m_vi;
156 GtkWidget *m_glWidget;
157 bool m_exposed;
158
159 private:
160 DECLARE_EVENT_TABLE()
161 DECLARE_CLASS(wxGLCanvas)
162 };
163
164 #endif
165 // wxUSE_GLCANVAS
166
167 #endif
168 // _WX_GLCANVAS_H_
169