]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/glcanvas/msw/myglcanvas.h
Added missing files to listing
[wxWidgets.git] / wxPython / contrib / glcanvas / msw / myglcanvas.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
22 #undef wxUSE_GLCANVAS
23 #define wxUSE_GLCANVAS 1
24 #if wxUSE_GLCANVAS
25
26 #include <wx/palette.h>
27 #include <wx/scrolwin.h>
28
29 #include <windows.h>
30
31 #include "gl/gl.h"
32
33 //---------------------------------------------------------------------------
34 // Constants for attriblist
35 //---------------------------------------------------------------------------
36
37 // The generic GL implementation doesn't support most of these options,
38 // such as stereo, auxiliary buffers, alpha channel, and accum buffer.
39 // Other implementations may actually support them.
40
41 enum
42 {
43 WX_GL_RGBA=1, /* use true color palette */
44 WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */
45 WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */
46 WX_GL_DOUBLEBUFFER, /* use doublebuffer */
47 WX_GL_STEREO, /* use stereoscopic display */
48 WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */
49 WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
50 WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
51 WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */
52 WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */
53 WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
54 WX_GL_STENCIL_SIZE, /* bits for stencil buffer */
55 WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
56 WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
57 WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
58 WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
59 };
60
61 class wxGLCanvas; /* forward reference */
62
63 class wxGLContext: public wxObject
64 {
65 public:
66 wxGLContext(bool isRGB, wxGLCanvas *win, const wxPalette& palette = wxNullPalette);
67 wxGLContext(
68 bool isRGB, wxGLCanvas *win,
69 const wxPalette& WXUNUSED(palette),
70 const wxGLContext *other /* for sharing display lists */
71 );
72 ~wxGLContext();
73
74 void SetCurrent();
75 void SetColour(const char *colour);
76 void SwapBuffers();
77
78
79 inline wxWindow* GetWindow() const { return m_window; }
80 inline WXHDC GetHDC() const { return m_hDC; }
81 inline HGLRC GetGLRC() const { return m_glContext; }
82
83 public:
84 HGLRC m_glContext;
85 WXHDC m_hDC;
86 wxWindow* m_window;
87 };
88
89 class wxGLCanvas: public wxScrolledWindow
90 {
91 DECLARE_CLASS(wxGLCanvas)
92 public:
93 wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
94 const wxSize& size = wxDefaultSize, long style = 0,
95 const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette);
96 wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
97 wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
98 const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "GLCanvas",
99 int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette );
100
101 wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, wxWindowID id = -1,
102 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0,
103 const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette );
104
105 ~wxGLCanvas();
106
107 // Replaces wxWindow::Create functionality, since we need to use a different window class
108 bool Create(wxWindow *parent, wxWindowID id,
109 const wxPoint& pos, const wxSize& size, long style, const wxString& name);
110
111 void SetCurrent();
112 void SetColour(const char *colour);
113 void SwapBuffers();
114
115 void OnSize(wxSizeEvent& event);
116
117 void OnQueryNewPalette(wxQueryNewPaletteEvent& event);
118 void OnPaletteChanged(wxPaletteChangedEvent& event);
119
120 inline wxGLContext* GetContext() const { return m_glContext; }
121
122 inline WXHDC GetHDC() const { return m_hDC; }
123 void SetupPixelFormat(int *attribList = (int*) NULL);
124 void SetupPalette(const wxPalette& palette);
125 wxPalette CreateDefaultPalette();
126
127 inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
128
129 protected:
130 wxGLContext* m_glContext; // this is typedef-ed ptr, in fact
131 wxPalette m_palette;
132 WXHDC m_hDC;
133
134 DECLARE_EVENT_TABLE()
135 };
136
137 #endif
138 // wxUSE_GLCANVAS
139 #endif
140 // _WX_GLCANVAS_H_
141