]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/glcanvas.h
1. fixed bug with MDI child frames changign state when parent frame was
[wxWidgets.git] / include / wx / msw / glcanvas.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: glcanvas.h
3 // Purpose: wxGLCanvas, for using OpenGL with wxWindows 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 #ifdef __GNUG__
13 #pragma interface "glcanvas.h"
14 #endif
15
16 #ifndef _WX_GLCANVAS_H_
17 #define _WX_GLCANVAS_H_
18
19 #include <wx/setup.h>
20
21 #if wxUSE_GLCANVAS
22
23 #include <wx/scrolwin.h>
24
25 #include <windows.h>
26
27 #include "gl/gl.h"
28
29 //---------------------------------------------------------------------------
30 // Constants for attriblist
31 //---------------------------------------------------------------------------
32
33 enum
34 {
35 WX_GL_RGBA=1, /* use true color palette */
36 WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
37 WX_GL_DOUBLEBUFFER, /* use doublebuffer */
38 WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
39 WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
40 WX_GL_MIN_BLUE /* use blue buffer with most bits (> MIN_BLUE bits) */
41 /* these are enough constants for now, the remaining will be added later */
42 };
43
44 class WXDLLEXPORT wxGLCanvas; /* forward reference */
45
46 class WXDLLEXPORT wxGLContext: public wxObject
47 {
48 public:
49 wxGLContext(bool isRGB, wxGLCanvas *win, const wxPalette& palette = wxNullPalette);
50 wxGLContext(
51 bool isRGB, wxGLCanvas *win,
52 const wxPalette& WXUNUSED(palette),
53 const wxGLContext *other /* for sharing display lists */
54 );
55 ~wxGLContext();
56
57 void SetCurrent();
58 void SetColour(const char *colour);
59 void SwapBuffers();
60
61
62 inline wxWindow* GetWindow() const { return m_window; }
63 inline WXHDC GetHDC() const { return m_hDC; }
64 inline HGLRC GetGLRC() const { return m_glContext; }
65
66 public:
67 HGLRC m_glContext;
68 WXHDC m_hDC;
69 wxWindow* m_window;
70 };
71
72 class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow
73 {
74 DECLARE_CLASS(wxGLCanvas)
75 public:
76 wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
77 const wxSize& size = wxDefaultSize, long style = 0,
78 const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette);
79 wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
80 wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
81 const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "GLCanvas",
82 int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette );
83
84 wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, wxWindowID id = -1,
85 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0,
86 const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette );
87
88 ~wxGLCanvas();
89
90 // Replaces wxWindow::Create functionality, since we need to use a different window class
91 bool Create(wxWindow *parent, wxWindowID id,
92 const wxPoint& pos, const wxSize& size, long style, const wxString& name);
93
94 void SetCurrent();
95 void SetColour(const char *colour);
96 void SwapBuffers();
97
98 void OnSize(wxSizeEvent& event);
99
100 void OnQueryNewPalette(wxQueryNewPaletteEvent& event);
101 void OnPaletteChanged(wxPaletteChangedEvent& event);
102
103 inline wxGLContext* GetContext() const { return m_glContext; }
104
105 inline WXHDC GetHDC() const { return m_hDC; }
106 void SetupPixelFormat();
107 void SetupPalette(const wxPalette& palette);
108 wxPalette CreateDefaultPalette();
109
110 inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
111
112 protected:
113 wxGLContext* m_glContext; // this is typedef-ed ptr, in fact
114 wxPalette m_palette;
115 WXHDC m_hDC;
116
117 DECLARE_EVENT_TABLE()
118 };
119
120 #ifdef __cplusplus
121 extern "C" {
122 #endif
123
124 /* Give extensions proper function names. */
125
126 /* N.B. - this is not completely implemented as yet */
127
128 /* EXT_vertex_array */
129 void glArrayElementEXT(GLint i);
130 void glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
131 void glDrawArraysEXT(GLenum mode, GLint first, GLsizei count);
132 void glEdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *pointer);
133 void glGetPointervEXT(GLenum pname, GLvoid* *params);
134 void glIndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
135 void glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
136 void glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
137 void glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
138
139 /* EXT_color_subtable */
140 void glColorSubtableEXT(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *table);
141
142 /* EXT_color_table */
143 void glColorTableEXT(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
144 void glCopyColorTableEXT(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
145 void glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid *table);
146 void glGetColorTableParamaterfvEXT(GLenum target, GLenum pname, GLfloat *params);
147 void glGetColorTavleParameterivEXT(GLenum target, GLenum pname, GLint *params);
148
149 /* SGI_compiled_vertex_array */
150 void glLockArraysSGI(GLint first, GLsizei count);
151 void glUnlockArraysSGI();
152
153 /* SGI_cull_vertex */
154 void glCullParameterdvSGI(GLenum pname, GLdouble* params);
155 void glCullParameterfvSGI(GLenum pname, GLfloat* params);
156
157 /* SGI_index_func */
158 void glIndexFuncSGI(GLenum func, GLclampf ref);
159
160 /* SGI_index_material */
161 void glIndexMaterialSGI(GLenum face, GLenum mode);
162
163 /* WIN_swap_hint */
164 void glAddSwapHintRectWin(GLint x, GLint y, GLsizei width, GLsizei height);
165
166 #ifdef __cplusplus
167 }
168 #endif
169
170 #endif
171 // wxUSE_GLCANVAS
172 #endif
173 // _WX_GLCANVAS_H_
174