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