]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/glcanvas.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/glcanvas.h
3 // Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Macintosh
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GLCANVAS_H_
13 #define _WX_GLCANVAS_H_
19 #include "wx/palette.h"
20 #include "wx/scrolwin.h"
24 # include <OpenGL/gl.h>
31 //---------------------------------------------------------------------------
32 // Constants for attriblist
33 //---------------------------------------------------------------------------
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) */
55 class WXDLLEXPORT wxGLCanvas
; /* forward reference */
57 class WXDLLEXPORT wxGLContext
: public wxObject
60 wxGLContext(AGLPixelFormat fmt
, wxGLCanvas
*win
,
61 const wxPalette
& WXUNUSED(palette
),
62 const wxGLContext
*other
/* for sharing display lists */
67 void Update(); // must be called after window drag/grows/zoom or clut change
68 void SetColour(const wxChar
*colour
);
72 inline wxWindow
* GetWindow() const { return m_window
; }
73 inline AGLDrawable
GetDrawable() const { return m_drawable
; }
76 AGLContext m_glContext
;
77 AGLDrawable m_drawable
;
81 class WXDLLEXPORT wxGLCanvas
: public wxWindow
83 DECLARE_CLASS(wxGLCanvas
)
85 wxGLCanvas(wxWindow
*parent
, wxWindowID id
= wxID_ANY
, 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
= wxID_ANY
, 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
);
93 wxGLCanvas( wxWindow
*parent
, const wxGLCanvas
*shared
, wxWindowID id
= wxID_ANY
,
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
);
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
);
104 void SetColour(const wxChar
*colour
);
106 void UpdateContext();
108 virtual bool Show(bool show
= true) ;
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
);
115 virtual void MacSuperChangedPosition() ;
116 virtual void MacTopLevelWindowChangedPosition() ;
117 virtual void MacVisibilityChanged() ;
119 void MacUpdateView() ;
121 inline wxGLContext
* GetContext() const { return m_glContext
; }
124 wxGLContext
* m_glContext
;
125 bool m_macCanvasIsShown
;
126 DECLARE_EVENT_TABLE()
129 #endif // wxUSE_GLCANVAS
130 #endif // _WX_GLCANVAS_H_