]>
Commit | Line | Data |
---|---|---|
0a67a93b SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: glcanvas.h | |
3 | // Purpose: wxGLCanvas, for using OpenGL with wxWindows under Macintosh | |
a31a5f85 | 4 | // Author: Stefan Csomor |
0a67a93b | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
0a67a93b | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
e40298d5 | 9 | // Licence: wxWindows licence |
0a67a93b SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12028905 | 12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
c107c21e | 13 | # pragma interface "glcanvas.h" |
0a67a93b SC |
14 | #endif |
15 | ||
16 | #ifndef _WX_GLCANVAS_H_ | |
17 | #define _WX_GLCANVAS_H_ | |
18 | ||
19 | #include "wx/setup.h" | |
20 | ||
21 | #if wxUSE_GLCANVAS | |
22 | ||
23 | #include "wx/palette.h" | |
24 | #include "wx/scrolwin.h" | |
cba5db5f | 25 | #include "wx/app.h" |
0a67a93b | 26 | |
c107c21e GD |
27 | #ifdef __DARWIN__ |
28 | # include <OpenGL/gl.h> | |
29 | # include <AGL/agl.h> | |
30 | #else | |
31 | # include <gl.h> | |
32 | # include <agl.h> | |
33 | #endif | |
0a67a93b SC |
34 | |
35 | //--------------------------------------------------------------------------- | |
36 | // Constants for attriblist | |
37 | //--------------------------------------------------------------------------- | |
38 | ||
39 | enum | |
40 | { | |
41 | WX_GL_RGBA=1, /* use true color palette */ | |
42 | WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */ | |
43 | WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */ | |
44 | WX_GL_DOUBLEBUFFER, /* use doublebuffer */ | |
45 | WX_GL_STEREO, /* use stereoscopic display */ | |
46 | WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */ | |
47 | WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */ | |
48 | WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */ | |
49 | WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */ | |
50 | WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */ | |
51 | WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */ | |
52 | WX_GL_STENCIL_SIZE, /* bits for stencil buffer */ | |
53 | WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */ | |
54 | WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */ | |
55 | WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */ | |
56 | WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */ | |
57 | }; | |
58 | ||
59 | class WXDLLEXPORT wxGLCanvas; /* forward reference */ | |
60 | ||
61 | class WXDLLEXPORT wxGLContext: public wxObject | |
62 | { | |
63 | public: | |
64 | wxGLContext(AGLPixelFormat fmt, wxGLCanvas *win, | |
65 | const wxPalette& WXUNUSED(palette), | |
66 | const wxGLContext *other /* for sharing display lists */ | |
67 | ); | |
68 | ~wxGLContext(); | |
69 | ||
70 | void SetCurrent(); | |
71 | void Update(); // must be called after window drag/grows/zoom or clut change | |
c4e41ce3 | 72 | void SetColour(const wxChar *colour); |
0a67a93b SC |
73 | void SwapBuffers(); |
74 | ||
75 | ||
76 | inline wxWindow* GetWindow() const { return m_window; } | |
77 | inline AGLDrawable GetDrawable() const { return m_drawable; } | |
78 | ||
79 | public: | |
80 | AGLContext m_glContext; | |
81 | AGLDrawable m_drawable; | |
82 | wxWindow* m_window; | |
83 | }; | |
84 | ||
4660d7e5 | 85 | class WXDLLEXPORT wxGLCanvas: public wxWindow |
0a67a93b SC |
86 | { |
87 | DECLARE_CLASS(wxGLCanvas) | |
88 | public: | |
89 | wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, | |
90 | const wxSize& size = wxDefaultSize, long style = 0, | |
c4e41ce3 | 91 | const wxString& name = wxT("GLCanvas") , int *attribList = 0, const wxPalette& palette = wxNullPalette); |
0a67a93b SC |
92 | wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL, |
93 | wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, | |
c4e41ce3 | 94 | const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("GLCanvas"), |
e40298d5 | 95 | int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette ); |
0a67a93b SC |
96 | |
97 | wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, wxWindowID id = -1, | |
98 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, | |
c4e41ce3 | 99 | const wxString& name = wxT("GLCanvas"), int *attribList = 0, const wxPalette& palette = wxNullPalette ); |
0a67a93b SC |
100 | |
101 | ~wxGLCanvas(); | |
102 | ||
103 | bool Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id, | |
104 | const wxPoint& pos, const wxSize& size, long style, const wxString& name, | |
e40298d5 | 105 | int *attribList, const wxPalette& palette); |
0a67a93b SC |
106 | |
107 | void SetCurrent(); | |
c4e41ce3 | 108 | void SetColour(const wxChar *colour); |
0a67a93b SC |
109 | void SwapBuffers(); |
110 | void UpdateContext(); | |
111 | void SetViewport(); | |
ab89a5b5 | 112 | virtual bool Show(bool show = TRUE) ; |
0a67a93b SC |
113 | |
114 | // Unlike some other platforms, this must get called if you override it. | |
115 | // It sets the viewport correctly and update the context. | |
116 | // You shouldn't call glViewport yourself either (use SetViewport if you must reset it.) | |
117 | void OnSize(wxSizeEvent& event); | |
fce5f505 | 118 | |
e40298d5 JS |
119 | virtual void MacSuperChangedPosition() ; |
120 | virtual void MacTopLevelWindowChangedPosition() ; | |
ab89a5b5 SC |
121 | virtual void MacSuperShown( bool show ) ; |
122 | ||
e40298d5 | 123 | void MacUpdateView() ; |
0a67a93b SC |
124 | |
125 | inline wxGLContext* GetContext() const { return m_glContext; } | |
126 | ||
127 | protected: | |
128 | wxGLContext* m_glContext; | |
ab89a5b5 | 129 | bool m_macCanvasIsShown ; |
0a67a93b SC |
130 | DECLARE_EVENT_TABLE() |
131 | }; | |
132 | ||
133 | #endif // wxUSE_GLCANVAS | |
134 | #endif // _WX_GLCANVAS_H_ |