]> git.saurik.com Git - wxWidgets.git/blame - include/wx/glcanvas.h
correct the signature of the overriden Reparent()
[wxWidgets.git] / include / wx / glcanvas.h
CommitLineData
99d80019
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/glcanvas.h
3// Purpose: wxGLCanvas base header
4// Author: Julian Smart
5// Modified by:
6// Created:
7// Copyright: (c) Julian Smart
8// RCS-ID: $Id$
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
8b089c5e
JS
12#ifndef _WX_GLCANVAS_H_BASE_
13#define _WX_GLCANVAS_H_BASE_
14
a3081354
VZ
15#include "wx/defs.h"
16
17#if wxUSE_GLCANVAS
18
dc3065a5
VZ
19#include "wx/app.h"
20#include "wx/palette.h"
21#include "wx/window.h"
0643d43c 22
b5dbe15d
VS
23class WXDLLIMPEXP_FWD_GL wxGLCanvas;
24class WXDLLIMPEXP_FWD_GL wxGLContext;
dc3065a5
VZ
25
26// ----------------------------------------------------------------------------
27// Constants for attributes list
28// ----------------------------------------------------------------------------
0643d43c 29
4aa59c3d
VZ
30// Notice that not all implementation support options such as stereo, auxiliary
31// buffers, alpha channel, and accumulator buffer, use IsDisplaySupported() to
32// check for individual attributes support.
0643d43c
VZ
33enum
34{
4aa59c3d
VZ
35 WX_GL_RGBA = 1, // use true color palette (on if no attrs specified)
36 WX_GL_BUFFER_SIZE, // bits for buffer if not WX_GL_RGBA
37 WX_GL_LEVEL, // 0 for main buffer, >0 for overlay, <0 for underlay
38 WX_GL_DOUBLEBUFFER, // use double buffering (on if no attrs specified)
39 WX_GL_STEREO, // use stereoscopic display
40 WX_GL_AUX_BUFFERS, // number of auxiliary buffers
41 WX_GL_MIN_RED, // use red buffer with most bits (> MIN_RED bits)
42 WX_GL_MIN_GREEN, // use green buffer with most bits (> MIN_GREEN bits)
43 WX_GL_MIN_BLUE, // use blue buffer with most bits (> MIN_BLUE bits)
44 WX_GL_MIN_ALPHA, // use alpha buffer with most bits (> MIN_ALPHA bits)
45 WX_GL_DEPTH_SIZE, // bits for Z-buffer (0,16,32)
46 WX_GL_STENCIL_SIZE, // bits for stencil buffer
47 WX_GL_MIN_ACCUM_RED, // use red accum buffer with most bits (> MIN_ACCUM_RED bits)
48 WX_GL_MIN_ACCUM_GREEN, // use green buffer with most bits (> MIN_ACCUM_GREEN bits)
49 WX_GL_MIN_ACCUM_BLUE, // use blue buffer with most bits (> MIN_ACCUM_BLUE bits)
50 WX_GL_MIN_ACCUM_ALPHA // use alpha buffer with most bits (> MIN_ACCUM_ALPHA bits)
0643d43c
VZ
51};
52
2b5f62a0
VZ
53#define wxGLCanvasName _T("GLCanvas")
54
dc3065a5
VZ
55// ----------------------------------------------------------------------------
56// wxGLContextBase: OpenGL rendering context
57// ----------------------------------------------------------------------------
58
59class WXDLLIMPEXP_GL wxGLContextBase : public wxObject
60{
61public:
62 /*
63 The derived class should provide a ctor with this signature:
64
65 wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
66 */
67
68 // set this context as the current one
5ec69e96 69 virtual bool SetCurrent(const wxGLCanvas& win) const = 0;
dc3065a5
VZ
70};
71
72// ----------------------------------------------------------------------------
73// wxGLCanvasBase: window which can be used for OpenGL rendering
74// ----------------------------------------------------------------------------
75
76class WXDLLIMPEXP_GL wxGLCanvasBase : public wxWindow
77{
78public:
79 // default ctor doesn't initialize the window, use Create() later
15b239c0 80 wxGLCanvasBase();
dc3065a5
VZ
81
82 virtual ~wxGLCanvasBase();
83
84
85 /*
86 The derived class should provide a ctor with this signature:
87
88 wxGLCanvas(wxWindow *parent,
89 wxWindowID id = wxID_ANY,
90 int* attribList = 0,
91 const wxPoint& pos = wxDefaultPosition,
92 const wxSize& size = wxDefaultSize,
93 long style = 0,
94 const wxString& name = wxGLCanvasName,
95 const wxPalette& palette = wxNullPalette);
96 */
97
98 // operations
99 // ----------
100
101 // set the given context associated with this window as the current one
5ec69e96 102 bool SetCurrent(const wxGLContext& context) const;
dc3065a5
VZ
103
104 // flush the back buffer (if we have it)
5ec69e96 105 virtual bool SwapBuffers() = 0;
dc3065a5
VZ
106
107
108 // accessors
109 // ---------
110
3f20f7d8
VZ
111 // check if the given attributes are supported without creating a canvas
112 static bool IsDisplaySupported(const int *attribList);
113
dc3065a5
VZ
114 const wxPalette *GetPalette() const { return &m_palette; }
115
116 // miscellaneous helper functions
117 // ------------------------------
118
119 // call glcolor() for the colour with the given name, return false if
120 // colour not found
35f1f4f7 121 bool SetColour(const wxString& colour);
dc3065a5
VZ
122
123
124
125 // deprecated methods using the implicit wxGLContext
126#if WXWIN_COMPATIBILITY_2_8
127 wxDEPRECATED( wxGLContext* GetContext() const );
128
129 wxDEPRECATED( void SetCurrent() );
130
131 wxDEPRECATED( void OnSize(wxSizeEvent& event) );
132#endif // WXWIN_COMPATIBILITY_2_8
133
134#ifdef __WXUNIVERSAL__
135 // resolve the conflict with wxWindowUniv::SetCurrent()
136 virtual bool SetCurrent(bool doit) { return wxWindow::SetCurrent(doit); };
137#endif
138
139protected:
140 // override this to implement SetColour() in GL_INDEX_MODE
141 // (currently only implemented in wxX11 and wxMotif ports)
142 virtual int GetColourIndex(const wxColour& WXUNUSED(col)) { return -1; }
143
144 // create default palette if we're not using RGBA mode
145 // (not supported in most ports)
146 virtual wxPalette CreateDefaultPalette() { return wxNullPalette; }
147
148
149 wxPalette m_palette;
150
151#if WXWIN_COMPATIBILITY_2_8
152 wxGLContext *m_glContext;
153#endif // WXWIN_COMPATIBILITY_2_8
154};
155
498ace9e
VZ
156// ----------------------------------------------------------------------------
157// wxGLApp: a special wxApp subclass for OpenGL applications which must be used
158// to select a visual compatible with the given attributes
159// ----------------------------------------------------------------------------
160
161class WXDLLIMPEXP_GL wxGLAppBase : public wxApp
162{
163public:
164 wxGLAppBase() : wxApp() { }
165
166 // use this in the constructor of the user-derived wxGLApp class to
167 // determine if an OpenGL rendering context with these attributes
168 // is available - returns true if so, false if not.
169 virtual bool InitGLVisual(const int *attribList) = 0;
170};
171
8b089c5e 172#if defined(__WXMSW__)
dc3065a5
VZ
173 #include "wx/msw/glcanvas.h"
174#elif defined(__WXMOTIF__) || defined(__WXX11__)
175 #include "wx/x11/glcanvas.h"
1be7a35c 176#elif defined(__WXGTK20__)
dc3065a5 177 #include "wx/gtk/glcanvas.h"
1be7a35c 178#elif defined(__WXGTK__)
dc3065a5 179 #include "wx/gtk1/glcanvas.h"
8b089c5e 180#elif defined(__WXMAC__)
dc3065a5 181 #include "wx/mac/glcanvas.h"
bd2af428 182#elif defined(__WXCOCOA__)
dc3065a5 183 #include "wx/cocoa/glcanvas.h"
2e35565a 184#else
dc3065a5 185 #error "wxGLCanvas not supported in this wxWidgets port"
8b089c5e
JS
186#endif
187
498ace9e
VZ
188// wxMac and wxMSW don't need anything extra in wxGLAppBase, so declare it here
189#ifndef wxGL_APP_DEFINED
190
191class WXDLLIMPEXP_GL wxGLApp : public wxGLAppBase
a3081354
VZ
192{
193public:
498ace9e 194 wxGLApp() : wxGLAppBase() { }
a3081354 195
498ace9e 196 virtual bool InitGLVisual(const int *attribList);
a3081354
VZ
197
198private:
199 DECLARE_DYNAMIC_CLASS(wxGLApp)
200};
201
498ace9e
VZ
202#endif // !wxGL_APP_DEFINED
203
dc3065a5
VZ
204#endif // wxUSE_GLCANVAS
205
206#endif // _WX_GLCANVAS_H_BASE_