]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/glcanvas.h
show the function in which the assert failure occured if the compiler supports it
[wxWidgets.git] / include / wx / msw / glcanvas.h
CommitLineData
8b089c5e 1/////////////////////////////////////////////////////////////////////////////
86e5d706 2// Name: wx/msw/glcanvas.h
77ffb593 3// Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Windows
8b089c5e
JS
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
8b089c5e
JS
10/////////////////////////////////////////////////////////////////////////////
11
db4c39a9
VZ
12#ifndef _WX_GLCANVAS_H_
13#define _WX_GLCANVAS_H_
14
2b5f62a0
VZ
15#include "wx/palette.h"
16#include "wx/scrolwin.h"
8b089c5e
JS
17
18#include <windows.h>
2b5f62a0 19#include "wx/msw/winundef.h"
8b089c5e 20
86e5d706 21#include <GL/gl.h>
8b089c5e
JS
22
23//---------------------------------------------------------------------------
24// Constants for attriblist
25//---------------------------------------------------------------------------
26
f48d169c
UN
27// The generic GL implementation doesn't support most of these options,
28// such as stereo, auxiliary buffers, alpha channel, and accum buffer.
29// Other implementations may actually support them.
30
8b089c5e
JS
31enum
32{
0b3fcc0a
DS
33 WX_GL_RGBA=1, /* use true color palette */
34 WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */
35 WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */
36 WX_GL_DOUBLEBUFFER, /* use doublebuffer */
37 WX_GL_STEREO, /* use stereoscopic display */
38 WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */
39 WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
40 WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
41 WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */
42 WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */
43 WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
44 WX_GL_STENCIL_SIZE, /* bits for stencil buffer */
45 WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
46 WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
47 WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
48 WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
8b089c5e
JS
49};
50
eac90854 51class WXDLLIMPEXP_GL wxGLCanvas; /* forward reference */
8b089c5e 52
eac90854 53class WXDLLIMPEXP_GL wxGLContext: public wxObject
8b089c5e
JS
54{
55public:
0b3fcc0a 56 wxGLContext(bool isRGB, wxGLCanvas *win, const wxPalette& palette = wxNullPalette);
8b089c5e 57
0b3fcc0a
DS
58 wxGLContext( bool isRGB, wxGLCanvas *win,
59 const wxPalette& WXUNUSED(palette),
60 const wxGLContext *other /* for sharing display lists */ );
8b089c5e 61
0b3fcc0a 62 ~wxGLContext();
8b089c5e 63
0b3fcc0a
DS
64
65 void SetCurrent();
66
67 void SetColour(const wxChar *colour);
68
69 void SwapBuffers();
70
71
72 inline wxWindow* GetWindow() const { return m_window; }
73
74 inline WXHDC GetHDC() const { return m_hDC; }
75
76 inline HGLRC GetGLRC() const { return m_glContext; }
8b089c5e
JS
77
78public:
0b3fcc0a
DS
79 HGLRC m_glContext;
80 WXHDC m_hDC;
81 wxWindow* m_window;
8b089c5e
JS
82};
83
eac90854 84class WXDLLIMPEXP_GL wxGLCanvas: public wxWindow
8b089c5e 85{
0b3fcc0a
DS
86 DECLARE_CLASS(wxGLCanvas)
87public:
88 wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
89 const wxPoint& pos = wxDefaultPosition,
8b089c5e 90 const wxSize& size = wxDefaultSize, long style = 0,
0b3fcc0a
DS
91 const wxString& name = wxGLCanvasName, int *attribList = 0,
92 const wxPalette& palette = wxNullPalette);
93
94 wxGLCanvas(wxWindow *parent,
a0573e8e 95 const wxGLContext *shared,
0b3fcc0a
DS
96 wxWindowID id = wxID_ANY,
97 const wxPoint& pos = wxDefaultPosition,
98 const wxSize& size = wxDefaultSize,
99 long style = 0,
100 const wxString& name = wxGLCanvasName,
101 int *attribList = (int *) NULL,
102 const wxPalette& palette = wxNullPalette);
103
104 wxGLCanvas(wxWindow *parent,
a0573e8e 105 const wxGLCanvas *shared,
0b3fcc0a
DS
106 wxWindowID id = wxID_ANY,
107 const wxPoint& pos = wxDefaultPosition,
108 const wxSize& size = wxDefaultSize,
109 long style = 0,
110 const wxString& name = wxGLCanvasName,
111 int *attribList = 0,
112 const wxPalette& palette = wxNullPalette);
113
114 ~wxGLCanvas();
115
116 // Replaces wxWindow::Create functionality, since
117 // we need to use a different window class
118 bool Create(wxWindow *parent, wxWindowID id,
119 const wxPoint& pos, const wxSize& size,
120 long style, const wxString& name);
121
122 void SetCurrent();
123
124#ifdef __WXUNIVERSAL__
125 virtual bool SetCurrent(bool doit) { return wxWindow::SetCurrent(doit); };
126#endif
127
128 void SetColour(const wxChar *colour);
8b089c5e 129
0b3fcc0a 130 void SwapBuffers();
8b089c5e 131
0b3fcc0a 132 void OnSize(wxSizeEvent& event);
8b089c5e 133
0b3fcc0a 134 void OnQueryNewPalette(wxQueryNewPaletteEvent& event);
8b089c5e 135
0b3fcc0a 136 void OnPaletteChanged(wxPaletteChangedEvent& event);
8a39593e 137
0b3fcc0a 138 inline wxGLContext* GetContext() const { return m_glContext; }
8b089c5e 139
0b3fcc0a 140 inline WXHDC GetHDC() const { return m_hDC; }
8b089c5e 141
0b3fcc0a 142 void SetupPixelFormat(int *attribList = (int *) NULL);
8b089c5e 143
0b3fcc0a 144 void SetupPalette(const wxPalette& palette);
8b089c5e 145
0b3fcc0a 146 wxPalette CreateDefaultPalette();
8b089c5e 147
0b3fcc0a 148 inline wxPalette* GetPalette() const { return (wxPalette *) &m_palette; }
8b089c5e
JS
149
150protected:
151 wxGLContext* m_glContext; // this is typedef-ed ptr, in fact
152 wxPalette m_palette;
153 WXHDC m_hDC;
154
a3081354 155 DECLARE_EVENT_TABLE()
8b089c5e
JS
156};
157
8b089c5e
JS
158#endif
159 // _WX_GLCANVAS_H_
160