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