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