]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/glcanvas.h
Adding SetFocus to wxABI_VERSION.
[wxWidgets.git] / include / wx / mac / carbon / glcanvas.h
CommitLineData
8cf73271 1/////////////////////////////////////////////////////////////////////////////
b73e73f9 2// Name: wx/mac/carbon/glcanvas.h
77ffb593 3// Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Macintosh
8cf73271
SC
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
8cf73271
SC
10/////////////////////////////////////////////////////////////////////////////
11
db4c39a9
VZ
12#ifndef _WX_GLCANVAS_H_
13#define _WX_GLCANVAS_H_
14
b73e73f9 15#include "wx/defs.h"
8cf73271
SC
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
8cf73271
SC
31class WXDLLEXPORT wxGLCanvas; /* forward reference */
32
33class WXDLLEXPORT wxGLContext: public wxObject
34{
35public:
b73e73f9 36 wxGLContext(AGLPixelFormat fmt, wxGLCanvas *win,
8cf73271
SC
37 const wxPalette& WXUNUSED(palette),
38 const wxGLContext *other /* for sharing display lists */
39 );
d3c7fc99 40 virtual ~wxGLContext();
8cf73271
SC
41
42 void SetCurrent();
43 void Update(); // must be called after window drag/grows/zoom or clut change
44 void SetColour(const wxChar *colour);
45 void SwapBuffers();
46
47
48 inline wxWindow* GetWindow() const { return m_window; }
49 inline AGLDrawable GetDrawable() const { return m_drawable; }
50
51public:
52 AGLContext m_glContext;
53 AGLDrawable m_drawable;
54 wxWindow* m_window;
55};
56
57class WXDLLEXPORT wxGLCanvas: public wxWindow
58{
59 DECLARE_CLASS(wxGLCanvas)
60 public:
b73e73f9 61 wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
8cf73271
SC
62 const wxSize& size = wxDefaultSize, long style = 0,
63 const wxString& name = wxT("GLCanvas") , int *attribList = 0, const wxPalette& palette = wxNullPalette);
a0573e8e 64 wxGLCanvas( wxWindow *parent, const wxGLContext *shared,
b73e73f9
WS
65 wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
66 const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("GLCanvas"),
8cf73271
SC
67 int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette );
68
b73e73f9
WS
69 wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id = wxID_ANY,
70 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0,
8cf73271
SC
71 const wxString& name = wxT("GLCanvas"), int *attribList = 0, const wxPalette& palette = wxNullPalette );
72
d3c7fc99 73 virtual ~wxGLCanvas();
8cf73271
SC
74
75 bool Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id,
76 const wxPoint& pos, const wxSize& size, long style, const wxString& name,
77 int *attribList, const wxPalette& palette);
78
79 void SetCurrent();
80 void SetColour(const wxChar *colour);
81 void SwapBuffers();
82 void UpdateContext();
83 void SetViewport();
b73e73f9
WS
84 virtual bool Show(bool show = true) ;
85
8cf73271
SC
86 // Unlike some other platforms, this must get called if you override it.
87 // It sets the viewport correctly and update the context.
88 // You shouldn't call glViewport yourself either (use SetViewport if you must reset it.)
89 void OnSize(wxSizeEvent& event);
8cf73271 90
b73e73f9
WS
91 virtual void MacSuperChangedPosition() ;
92 virtual void MacTopLevelWindowChangedPosition() ;
93 virtual void MacVisibilityChanged() ;
94
95 void MacUpdateView() ;
8cf73271
SC
96
97 inline wxGLContext* GetContext() const { return m_glContext; }
98
99protected:
100 wxGLContext* m_glContext;
b73e73f9 101 bool m_macCanvasIsShown ;
8cf73271
SC
102DECLARE_EVENT_TABLE()
103};
104
105#endif // wxUSE_GLCANVAS
106#endif // _WX_GLCANVAS_H_