]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/glcanvas.h
split wxchar.h into several smaller headers
[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 17
0643d43c 18#include "wx/msw/wrapwin.h"
8b089c5e 19
86e5d706 20#include <GL/gl.h>
8b089c5e 21
eac90854 22class WXDLLIMPEXP_GL wxGLCanvas; /* forward reference */
8b089c5e 23
eac90854 24class WXDLLIMPEXP_GL wxGLContext: public wxObject
8b089c5e
JS
25{
26public:
b7ea712c 27 wxGLContext(wxGLCanvas *win, const wxGLContext* other=NULL /* for sharing display lists */ );
d3c7fc99 28 virtual ~wxGLContext();
8b089c5e 29
adfb405a 30 void SetCurrent(const wxGLCanvas& win) const;
0b3fcc0a 31 inline HGLRC GetGLRC() const { return m_glContext; }
8b089c5e 32
b7ea712c
RR
33protected:
34 HGLRC m_glContext;
35
36private:
37 DECLARE_CLASS(wxGLContext)
8b089c5e
JS
38};
39
eac90854 40class WXDLLIMPEXP_GL wxGLCanvas: public wxWindow
8b089c5e 41{
0b3fcc0a 42public:
b7ea712c
RR
43 // This ctor is identical to the next, except for the fact that it
44 // doesn't create an implicit wxGLContext.
45 // The attribList parameter has been moved to avoid overload clashes.
46 wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
47 int* attribList = 0,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize, long style = 0,
50 const wxString& name = wxGLCanvasName,
51 const wxPalette& palette = wxNullPalette);
52
0b3fcc0a
DS
53 wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
54 const wxPoint& pos = wxDefaultPosition,
8b089c5e 55 const wxSize& size = wxDefaultSize, long style = 0,
0b3fcc0a
DS
56 const wxString& name = wxGLCanvasName, int *attribList = 0,
57 const wxPalette& palette = wxNullPalette);
58
59 wxGLCanvas(wxWindow *parent,
a0573e8e 60 const wxGLContext *shared,
0b3fcc0a
DS
61 wxWindowID id = wxID_ANY,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
64 long style = 0,
65 const wxString& name = wxGLCanvasName,
66 int *attribList = (int *) NULL,
67 const wxPalette& palette = wxNullPalette);
68
69 wxGLCanvas(wxWindow *parent,
a0573e8e 70 const wxGLCanvas *shared,
0b3fcc0a
DS
71 wxWindowID id = wxID_ANY,
72 const wxPoint& pos = wxDefaultPosition,
73 const wxSize& size = wxDefaultSize,
74 long style = 0,
75 const wxString& name = wxGLCanvasName,
76 int *attribList = 0,
77 const wxPalette& palette = wxNullPalette);
78
d3c7fc99 79 virtual ~wxGLCanvas();
0b3fcc0a
DS
80
81 // Replaces wxWindow::Create functionality, since
82 // we need to use a different window class
83 bool Create(wxWindow *parent, wxWindowID id,
84 const wxPoint& pos, const wxSize& size,
85 long style, const wxString& name);
86
b7ea712c 87 void SetCurrent(const wxGLContext& RC) const;
0b3fcc0a
DS
88 void SetCurrent();
89
90#ifdef __WXUNIVERSAL__
91 virtual bool SetCurrent(bool doit) { return wxWindow::SetCurrent(doit); };
92#endif
93
94 void SetColour(const wxChar *colour);
8b089c5e 95
0b3fcc0a 96 void SwapBuffers();
8b089c5e 97
0b3fcc0a 98 void OnSize(wxSizeEvent& event);
8b089c5e 99
0b3fcc0a 100 void OnQueryNewPalette(wxQueryNewPaletteEvent& event);
8b089c5e 101
0b3fcc0a 102 void OnPaletteChanged(wxPaletteChangedEvent& event);
8a39593e 103
0b3fcc0a 104 inline wxGLContext* GetContext() const { return m_glContext; }
8b089c5e 105
0b3fcc0a 106 inline WXHDC GetHDC() const { return m_hDC; }
8b089c5e 107
0b3fcc0a 108 void SetupPixelFormat(int *attribList = (int *) NULL);
8b089c5e 109
0b3fcc0a 110 void SetupPalette(const wxPalette& palette);
8b089c5e 111
0b3fcc0a 112 wxPalette CreateDefaultPalette();
8b089c5e 113
0b3fcc0a 114 inline wxPalette* GetPalette() const { return (wxPalette *) &m_palette; }
8b089c5e
JS
115
116protected:
117 wxGLContext* m_glContext; // this is typedef-ed ptr, in fact
118 wxPalette m_palette;
119 WXHDC m_hDC;
120
b7ea712c 121private:
a3081354 122 DECLARE_EVENT_TABLE()
b7ea712c 123 DECLARE_CLASS(wxGLCanvas)
8b089c5e
JS
124};
125
8b089c5e
JS
126#endif
127 // _WX_GLCANVAS_H_
128