1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/glcanvas.h
3 // Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Windows
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GLCANVAS_H_
13 #define _WX_GLCANVAS_H_
15 #include "wx/palette.h"
16 #include "wx/scrolwin.h"
18 #include "wx/msw/wrapwin.h"
22 class WXDLLIMPEXP_GL wxGLCanvas
; /* forward reference */
24 class WXDLLIMPEXP_GL wxGLContext
: public wxObject
27 wxGLContext(wxGLCanvas
*win
, const wxGLContext
* other
=NULL
/* for sharing display lists */ );
28 virtual ~wxGLContext();
30 void SetCurrent(const wxGLCanvas
& win
) const;
31 inline HGLRC
GetGLRC() const { return m_glContext
; }
37 DECLARE_CLASS(wxGLContext
)
40 class WXDLLIMPEXP_GL wxGLCanvas
: public wxWindow
43 // This ctor is identical to the next, except for the fact that it
44 // doesn't create an implicit wxGLContext.
45 // The attribList parameter has been moved to avoid overload clashes.
46 wxGLCanvas(wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
48 const wxPoint
& pos
= wxDefaultPosition
,
49 const wxSize
& size
= wxDefaultSize
, long style
= 0,
50 const wxString
& name
= wxGLCanvasName
,
51 const wxPalette
& palette
= wxNullPalette
);
53 wxGLCanvas(wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
, long style
= 0,
56 const wxString
& name
= wxGLCanvasName
, int *attribList
= 0,
57 const wxPalette
& palette
= wxNullPalette
);
59 wxGLCanvas(wxWindow
*parent
,
60 const wxGLContext
*shared
,
61 wxWindowID id
= wxID_ANY
,
62 const wxPoint
& pos
= wxDefaultPosition
,
63 const wxSize
& size
= wxDefaultSize
,
65 const wxString
& name
= wxGLCanvasName
,
66 int *attribList
= (int *) NULL
,
67 const wxPalette
& palette
= wxNullPalette
);
69 wxGLCanvas(wxWindow
*parent
,
70 const wxGLCanvas
*shared
,
71 wxWindowID id
= wxID_ANY
,
72 const wxPoint
& pos
= wxDefaultPosition
,
73 const wxSize
& size
= wxDefaultSize
,
75 const wxString
& name
= wxGLCanvasName
,
77 const wxPalette
& palette
= wxNullPalette
);
79 virtual ~wxGLCanvas();
81 // Replaces wxWindow::Create functionality, since
82 // we need to use a different window class
83 bool Create(wxWindow
*parent
, wxWindowID id
,
84 const wxPoint
& pos
, const wxSize
& size
,
85 long style
, const wxString
& name
);
87 void SetCurrent(const wxGLContext
& RC
) const;
90 #ifdef __WXUNIVERSAL__
91 virtual bool SetCurrent(bool doit
) { return wxWindow::SetCurrent(doit
); };
94 void SetColour(const wxChar
*colour
);
98 void OnSize(wxSizeEvent
& event
);
100 void OnQueryNewPalette(wxQueryNewPaletteEvent
& event
);
102 void OnPaletteChanged(wxPaletteChangedEvent
& event
);
104 inline wxGLContext
* GetContext() const { return m_glContext
; }
106 inline WXHDC
GetHDC() const { return m_hDC
; }
108 void SetupPixelFormat(int *attribList
= (int *) NULL
);
110 void SetupPalette(const wxPalette
& palette
);
112 wxPalette
CreateDefaultPalette();
114 inline wxPalette
* GetPalette() const { return (wxPalette
*) &m_palette
; }
117 wxGLContext
* m_glContext
; // this is typedef-ed ptr, in fact
122 DECLARE_EVENT_TABLE()
123 DECLARE_CLASS(wxGLCanvas
)