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