]> git.saurik.com Git - wxWidgets.git/blob - utils/glcanvas/win/glcanvas.h
Added GLCanvas library (Win only at present).
[wxWidgets.git] / utils / glcanvas / win / 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/scrolwin.h>
20
21 #include "gl/gl.h"
22
23 class wxGLContext: public wxObject
24 {
25 public:
26 wxGLContext(bool isRGB, wxWindow *win, const wxPalette& palette = wxNullPalette);
27 ~wxGLContext();
28
29 void SetCurrent();
30 void SetColour(const char *colour);
31 void SwapBuffers();
32
33 void SetupPixelFormat();
34 void SetupPalette(const wxPalette& palette);
35 wxPalette CreateDefaultPalette();
36
37 inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
38 inline wxWindow* GetWindow() const { return m_window; }
39 inline WXHDC GetHDC() const { return m_hDC; }
40 inline HGLRC GetGLRC() const { return m_glContext; }
41
42 public:
43 HGLRC m_glContext;
44 WXHDC m_hDC;
45 wxPalette m_palette;
46 wxWindow* m_window;
47 };
48
49 class wxGLCanvas: public wxScrolledWindow
50 {
51 DECLARE_CLASS(wxGLCanvas)
52 public:
53 wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize, long style = 0,
55 const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette);
56 ~wxGLCanvas();
57
58 void SetCurrent();
59 void SetColour(const char *colour);
60 void SwapBuffers();
61
62 void OnSize(wxSizeEvent& event);
63
64 void OnQueryNewPalette(wxQueryNewPaletteEvent& event);
65 void OnPaletteChanged(wxPaletteChangedEvent& event);
66
67 inline wxGLContext* GetContext() const { return m_glContext; }
68
69 protected:
70 wxGLContext* m_glContext; // this is typedef-ed ptr, in fact
71
72 DECLARE_EVENT_TABLE()
73 };
74
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78
79 /* Give extensions proper function names. */
80
81 /* N.B. - this is not completely implemented as yet */
82
83 /* EXT_vertex_array */
84 void glArrayElementEXT(GLint i);
85 void glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
86 void glDrawArraysEXT(GLenum mode, GLint first, GLsizei count);
87 void glEdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *pointer);
88 void glGetPointervEXT(GLenum pname, GLvoid* *params);
89 void glIndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
90 void glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
91 void glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
92 void glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
93
94 /* EXT_color_subtable */
95 void glColorSubtableEXT(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *table);
96
97 /* EXT_color_table */
98 void glColorTableEXT(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
99 void glCopyColorTableEXT(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
100 void glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid *table);
101 void glGetColorTableParamaterfvEXT(GLenum target, GLenum pname, GLfloat *params);
102 void glGetColorTavleParameterivEXT(GLenum target, GLenum pname, GLint *params);
103
104 /* SGI_compiled_vertex_array */
105 void glLockArraysSGI(GLint first, GLsizei count);
106 void glUnlockArraysSGI();
107
108 /* SGI_cull_vertex */
109 void glCullParameterdvSGI(GLenum pname, GLdouble* params);
110 void glCullParameterfvSGI(GLenum pname, GLfloat* params);
111
112 /* SGI_index_func */
113 void glIndexFuncSGI(GLenum func, GLclampf ref);
114
115 /* SGI_index_material */
116 void glIndexMaterialSGI(GLenum face, GLenum mode);
117
118 /* WIN_swap_hint */
119 void glAddSwapHintRectWin(GLint x, GLint y, GLsizei width, GLsizei height);
120
121 #ifdef __cplusplus
122 }
123 #endif
124
125 #endif