]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/glcanvas.h
build fixes
[wxWidgets.git] / include / wx / msw / glcanvas.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/glcanvas.h
3 // Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Windows
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GLCANVAS_H_
13 #define _WX_GLCANVAS_H_
14
15 #include "wx/palette.h"
16
17 #include "wx/msw/wrapwin.h"
18
19 #include <GL/gl.h>
20
21 // ----------------------------------------------------------------------------
22 // wxGLContext: OpenGL rendering context
23 // ----------------------------------------------------------------------------
24
25 class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase
26 {
27 public:
28 wxGLContext(wxGLCanvas *win, const wxGLContext* other = NULL);
29 virtual ~wxGLContext();
30
31 virtual void SetCurrent(const wxGLCanvas& win) const;
32
33 HGLRC GetGLRC() const { return m_glContext; }
34
35 protected:
36 HGLRC m_glContext;
37
38 private:
39 DECLARE_CLASS(wxGLContext)
40 };
41
42 // ----------------------------------------------------------------------------
43 // wxGLCanvas: OpenGL output window
44 // ----------------------------------------------------------------------------
45
46 class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase
47 {
48 public:
49 wxGLCanvas(wxWindow *parent,
50 wxWindowID id = wxID_ANY,
51 const int *attribList = NULL,
52 const wxPoint& pos = wxDefaultPosition,
53 const wxSize& size = wxDefaultSize,
54 long style = 0,
55 const wxString& name = wxGLCanvasName,
56 const wxPalette& palette = wxNullPalette);
57
58 bool Create(wxWindow *parent,
59 wxWindowID id = wxID_ANY,
60 const wxPoint& pos = wxDefaultPosition,
61 const wxSize& size = wxDefaultSize,
62 long style = 0,
63 const wxString& name = wxGLCanvasName,
64 const int *attribList = NULL,
65 const wxPalette& palette = wxNullPalette);
66
67 virtual ~wxGLCanvas();
68
69 // implement wxGLCanvasBase methods
70 virtual void SwapBuffers();
71
72
73 // MSW-specific helpers
74 // --------------------
75
76 // get the HDC used for OpenGL rendering
77 HDC GetHDC() const { return m_hDC; }
78
79 // try to find pixel format matching the given attributes list for the
80 // specified HDC, return 0 on error, otherwise pfd is filled in with the
81 // information from attribList if non-NULL
82 static int ChooseMatchingPixelFormat(HDC hdc, const int *attribList,
83 PIXELFORMATDESCRIPTOR *pfd = NULL);
84
85 #if wxUSE_PALETTE
86 // palette stuff
87 bool SetupPalette(const wxPalette& palette);
88 virtual wxPalette CreateDefaultPalette();
89 void OnQueryNewPalette(wxQueryNewPaletteEvent& event);
90 void OnPaletteChanged(wxPaletteChangedEvent& event);
91 #endif // wxUSE_PALETTE
92
93 // deprecated methods using the implicit wxGLContext, associate the context
94 // explicitly with the window instead
95 #if WXWIN_COMPATIBILITY_2_8
96 wxDEPRECATED(
97 wxGLCanvas(wxWindow *parent,
98 wxWindowID id = wxID_ANY,
99 const wxPoint& pos = wxDefaultPosition,
100 const wxSize& size = wxDefaultSize,
101 long style = 0,
102 const wxString& name = wxGLCanvasName,
103 const int *attribList = NULL,
104 const wxPalette& palette = wxNullPalette)
105 );
106
107 wxDEPRECATED(
108 wxGLCanvas(wxWindow *parent,
109 const wxGLContext *shared,
110 wxWindowID id = wxID_ANY,
111 const wxPoint& pos = wxDefaultPosition,
112 const wxSize& size = wxDefaultSize,
113 long style = 0,
114 const wxString& name = wxGLCanvasName,
115 const int *attribList = NULL,
116 const wxPalette& palette = wxNullPalette)
117 );
118
119 wxDEPRECATED(
120 wxGLCanvas(wxWindow *parent,
121 const wxGLCanvas *shared,
122 wxWindowID id = wxID_ANY,
123 const wxPoint& pos = wxDefaultPosition,
124 const wxSize& size = wxDefaultSize,
125 long style = 0,
126 const wxString& name = wxGLCanvasName,
127 const int *attribList = NULL,
128 const wxPalette& palette = wxNullPalette)
129 );
130 #endif // WXWIN_COMPATIBILITY_2_8
131
132 protected:
133 // common part of all ctors
134 void Init();
135
136 // set up the pixel format using the given attributes and palette
137 bool DoSetup(const int *attribList);
138
139
140 // HDC for this window, we keep it all the time
141 HDC m_hDC;
142
143 private:
144 DECLARE_EVENT_TABLE()
145 DECLARE_CLASS(wxGLCanvas)
146 };
147
148 #endif // _WX_GLCANVAS_H_
149