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