]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/glcanvas.h
first impl (needs extending)
[wxWidgets.git] / include / wx / mac / glcanvas.h
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 #include <gl.h>
27 #include <agl.h>
28
29 //---------------------------------------------------------------------------
30 // Constants for attriblist
31 //---------------------------------------------------------------------------
32
33 enum
34 {
35 WX_GL_RGBA=1, /* use true color palette */
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 doublebuffer */
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 blue 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 blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
51 };
52
53 class WXDLLEXPORT wxGLCanvas; /* forward reference */
54
55 class WXDLLEXPORT wxGLContext: public wxObject
56 {
57 public:
58 wxGLContext(AGLPixelFormat fmt, wxGLCanvas *win,
59 const wxPalette& WXUNUSED(palette),
60 const wxGLContext *other /* for sharing display lists */
61 );
62 ~wxGLContext();
63
64 void SetCurrent();
65 void Update(); // must be called after window drag/grows/zoom or clut change
66 void SetColour(const char *colour);
67 void SwapBuffers();
68
69
70 inline wxWindow* GetWindow() const { return m_window; }
71 inline AGLDrawable GetDrawable() const { return m_drawable; }
72
73 public:
74 AGLContext m_glContext;
75 AGLDrawable m_drawable;
76 wxWindow* m_window;
77 };
78
79 class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow
80 {
81 DECLARE_CLASS(wxGLCanvas)
82 public:
83 wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
84 const wxSize& size = wxDefaultSize, long style = 0,
85 const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette);
86 wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
87 wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
88 const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "GLCanvas",
89 int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette );
90
91 wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, wxWindowID id = -1,
92 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0,
93 const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette );
94
95 ~wxGLCanvas();
96
97 bool Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id,
98 const wxPoint& pos, const wxSize& size, long style, const wxString& name,
99 int *attribList, const wxPalette& palette);
100
101 void SetCurrent();
102 void SetColour(const char *colour);
103 void SwapBuffers();
104 void UpdateContext();
105 void SetViewport();
106
107 // Unlike some other platforms, this must get called if you override it.
108 // It sets the viewport correctly and update the context.
109 // You shouldn't call glViewport yourself either (use SetViewport if you must reset it.)
110 void OnSize(wxSizeEvent& event);
111
112 inline wxGLContext* GetContext() const { return m_glContext; }
113
114 protected:
115 wxGLContext* m_glContext;
116
117 DECLARE_EVENT_TABLE()
118 };
119
120 #endif // wxUSE_GLCANVAS
121 #endif // _WX_GLCANVAS_H_