blind compilation fix: include wx/window.h
[wxWidgets.git] / include / wx / cocoa / glcanvas.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/glcanvas.h
3 // Purpose: wxGLCanvas class
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2004/09/29
7 // RCS-ID: $Id$
8 // Copyright: (c) 2004 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_COCOA_GLCANVAS_H__
13 #define _WX_COCOA_GLCANVAS_H__
14
15 #include "wx/window.h"
16
17 // #include "wx/cocoa/NSOpenGLView.h"
18 // Include gl.h from the OpenGL framework
19 #include <OpenGL/gl.h>
20
21 class WXDLLIMPEXP_GL wxGLCanvas;
22 DECLARE_WXCOCOA_OBJC_CLASS(NSOpenGLContext);
23 //DECLARE_WXCOCOA_OBJC_CLASS(NSOpenGLView);
24
25 // ========================================================================
26 // wxGLContext
27 // ========================================================================
28 class WXDLLIMPEXP_GL wxGLContext: public wxObject
29 {
30 public:
31 wxGLContext(bool isRGB, wxGLCanvas *win, const wxPalette& palette = wxNullPalette);
32
33 wxGLContext( bool isRGB, wxGLCanvas *win,
34 const wxPalette& WXUNUSED(palette),
35 const wxGLContext *other /* for sharing display lists */ );
36
37 virtual ~wxGLContext();
38
39
40 void SetCurrent();
41
42 void SetColour(const wxChar *colour);
43
44 void SwapBuffers();
45
46
47 inline wxWindow* GetWindow() const
48 { return m_window; }
49
50 inline WX_NSOpenGLContext GetNSOpenGLContext() const
51 { return m_cocoaNSOpenGLContext; }
52
53 public:
54 WX_NSOpenGLContext m_cocoaNSOpenGLContext;
55 wxWindow* m_window;
56 };
57
58
59
60 // ========================================================================
61 // wxGLCanvas
62 // ========================================================================
63 class WXDLLIMPEXP_GL wxGLCanvas: public wxWindow// , protected wxCocoaNSOpenGLView
64 {
65 DECLARE_DYNAMIC_CLASS(wxGLCanvas)
66 DECLARE_EVENT_TABLE()
67 // WX_DECLARE_COCOA_OWNER(NSOpenGLView,NSView,NSView)
68 // ------------------------------------------------------------------------
69 // initialization
70 // ------------------------------------------------------------------------
71 public:
72 wxGLCanvas()
73 : m_glContext(NULL)
74 { }
75 wxGLCanvas(wxWindow *parent, wxWindowID winid = wxID_ANY,
76 const wxPoint& pos = wxDefaultPosition,
77 const wxSize& size = wxDefaultSize,
78 long style = 0, const wxString& name = wxGLCanvasName,
79 int *attribList = NULL, const wxPalette& palette = wxNullPalette);
80
81 wxGLCanvas(wxWindow *parent,
82 const wxGLContext *shared = NULL,
83 wxWindowID winid = wxID_ANY,
84 const wxPoint& pos = wxDefaultPosition,
85 const wxSize& size = wxDefaultSize,
86 long style = 0, const wxString& name = wxGLCanvasName,
87 int *attribList = NULL, const wxPalette& palette = wxNullPalette);
88
89 wxGLCanvas(wxWindow *parent,
90 const wxGLCanvas *shared = NULL,
91 wxWindowID winid = wxID_ANY,
92 const wxPoint& pos = wxDefaultPosition,
93 const wxSize& size = wxDefaultSize,
94 long style = 0, const wxString& name = wxGLCanvasName,
95 int *attribList = NULL, const wxPalette& palette = wxNullPalette);
96
97 bool Create(wxWindow *parent, wxWindowID winid,
98 const wxPoint& pos = wxDefaultPosition,
99 const wxSize& size = wxDefaultSize,
100 long style = 0, const wxString& name = wxGLCanvasName);
101 virtual ~wxGLCanvas();
102
103 // ------------------------------------------------------------------------
104 // Cocoa callbacks
105 // ------------------------------------------------------------------------
106 protected:
107 // NSOpenGLView cannot be enabled/disabled
108 virtual void CocoaSetEnabled(bool enable) { }
109 // ------------------------------------------------------------------------
110 // Implementation
111 // ------------------------------------------------------------------------
112 public:
113 void SetCurrent();
114 void SwapBuffers();
115
116 void OnSize(wxSizeEvent& event)
117 {}
118 inline wxGLContext* GetContext() const
119 { return m_glContext; }
120 protected:
121 wxGLContext *m_glContext;
122 wxPalette m_palette;
123 };
124
125 #endif //ndef _WX_COCOA_GLCANVAS_H__