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