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