]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/glcanvas.h
move wxMSLU_xxx redefinitions of xxx() Windows functions to wx/msw/wrapwin.h as we...
[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:
b7ea712c 56 wxGLContext(wxGLCanvas *win, const wxGLContext* other=NULL /* for sharing display lists */ );
d3c7fc99 57 virtual ~wxGLContext();
8b089c5e 58
adfb405a 59 void SetCurrent(const wxGLCanvas& win) const;
0b3fcc0a 60 inline HGLRC GetGLRC() const { return m_glContext; }
8b089c5e 61
b7ea712c
RR
62protected:
63 HGLRC m_glContext;
64
65private:
66 DECLARE_CLASS(wxGLContext)
8b089c5e
JS
67};
68
eac90854 69class WXDLLIMPEXP_GL wxGLCanvas: public wxWindow
8b089c5e 70{
0b3fcc0a 71public:
b7ea712c
RR
72 // This ctor is identical to the next, except for the fact that it
73 // doesn't create an implicit wxGLContext.
74 // The attribList parameter has been moved to avoid overload clashes.
75 wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
76 int* attribList = 0,
77 const wxPoint& pos = wxDefaultPosition,
78 const wxSize& size = wxDefaultSize, long style = 0,
79 const wxString& name = wxGLCanvasName,
80 const wxPalette& palette = wxNullPalette);
81
0b3fcc0a
DS
82 wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
83 const wxPoint& pos = wxDefaultPosition,
8b089c5e 84 const wxSize& size = wxDefaultSize, long style = 0,
0b3fcc0a
DS
85 const wxString& name = wxGLCanvasName, int *attribList = 0,
86 const wxPalette& palette = wxNullPalette);
87
88 wxGLCanvas(wxWindow *parent,
a0573e8e 89 const wxGLContext *shared,
0b3fcc0a
DS
90 wxWindowID id = wxID_ANY,
91 const wxPoint& pos = wxDefaultPosition,
92 const wxSize& size = wxDefaultSize,
93 long style = 0,
94 const wxString& name = wxGLCanvasName,
95 int *attribList = (int *) NULL,
96 const wxPalette& palette = wxNullPalette);
97
98 wxGLCanvas(wxWindow *parent,
a0573e8e 99 const wxGLCanvas *shared,
0b3fcc0a
DS
100 wxWindowID id = wxID_ANY,
101 const wxPoint& pos = wxDefaultPosition,
102 const wxSize& size = wxDefaultSize,
103 long style = 0,
104 const wxString& name = wxGLCanvasName,
105 int *attribList = 0,
106 const wxPalette& palette = wxNullPalette);
107
d3c7fc99 108 virtual ~wxGLCanvas();
0b3fcc0a
DS
109
110 // Replaces wxWindow::Create functionality, since
111 // we need to use a different window class
112 bool Create(wxWindow *parent, wxWindowID id,
113 const wxPoint& pos, const wxSize& size,
114 long style, const wxString& name);
115
b7ea712c 116 void SetCurrent(const wxGLContext& RC) const;
0b3fcc0a
DS
117 void SetCurrent();
118
119#ifdef __WXUNIVERSAL__
120 virtual bool SetCurrent(bool doit) { return wxWindow::SetCurrent(doit); };
121#endif
122
123 void SetColour(const wxChar *colour);
8b089c5e 124
0b3fcc0a 125 void SwapBuffers();
8b089c5e 126
0b3fcc0a 127 void OnSize(wxSizeEvent& event);
8b089c5e 128
0b3fcc0a 129 void OnQueryNewPalette(wxQueryNewPaletteEvent& event);
8b089c5e 130
0b3fcc0a 131 void OnPaletteChanged(wxPaletteChangedEvent& event);
8a39593e 132
0b3fcc0a 133 inline wxGLContext* GetContext() const { return m_glContext; }
8b089c5e 134
0b3fcc0a 135 inline WXHDC GetHDC() const { return m_hDC; }
8b089c5e 136
0b3fcc0a 137 void SetupPixelFormat(int *attribList = (int *) NULL);
8b089c5e 138
0b3fcc0a 139 void SetupPalette(const wxPalette& palette);
8b089c5e 140
0b3fcc0a 141 wxPalette CreateDefaultPalette();
8b089c5e 142
0b3fcc0a 143 inline wxPalette* GetPalette() const { return (wxPalette *) &m_palette; }
8b089c5e
JS
144
145protected:
146 wxGLContext* m_glContext; // this is typedef-ed ptr, in fact
147 wxPalette m_palette;
148 WXHDC m_hDC;
149
b7ea712c 150private:
a3081354 151 DECLARE_EVENT_TABLE()
b7ea712c 152 DECLARE_CLASS(wxGLCanvas)
8b089c5e
JS
153};
154
8b089c5e
JS
155#endif
156 // _WX_GLCANVAS_H_
157