]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/glcanvas.h
use memcpy() instead of wxTmemcpy() as the latter is defined in wx/wxcrt.h which...
[wxWidgets.git] / include / wx / msw / glcanvas.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/msw/glcanvas.h
3// Purpose: wxGLCanvas, for using OpenGL with wxWidgets 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#ifndef _WX_GLCANVAS_H_
13#define _WX_GLCANVAS_H_
14
15#include "wx/palette.h"
16
17#include "wx/msw/wrapwin.h"
18
19#include <GL/gl.h>
20
21// ----------------------------------------------------------------------------
22// wxGLContext: OpenGL rendering context
23// ----------------------------------------------------------------------------
24
25class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase
26{
27public:
28 wxGLContext(wxGLCanvas *win, const wxGLContext* other = NULL);
29 virtual ~wxGLContext();
30
31 virtual bool SetCurrent(const wxGLCanvas& win) const;
32
33 HGLRC GetGLRC() const { return m_glContext; }
34
35protected:
36 HGLRC m_glContext;
37
38private:
39 DECLARE_CLASS(wxGLContext)
40};
41
42// ----------------------------------------------------------------------------
43// wxGLCanvas: OpenGL output window
44// ----------------------------------------------------------------------------
45
46class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase
47{
48public:
49 wxEXPLICIT // avoid implicitly converting a wxWindow* to wxGLCanvas
50 wxGLCanvas(wxWindow *parent,
51 wxWindowID id = wxID_ANY,
52 const int *attribList = NULL,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize,
55 long style = 0,
56 const wxString& name = wxGLCanvasName,
57 const wxPalette& palette = wxNullPalette);
58
59 bool Create(wxWindow *parent,
60 wxWindowID id = wxID_ANY,
61 const wxPoint& pos = wxDefaultPosition,
62 const wxSize& size = wxDefaultSize,
63 long style = 0,
64 const wxString& name = wxGLCanvasName,
65 const int *attribList = NULL,
66 const wxPalette& palette = wxNullPalette);
67
68 virtual ~wxGLCanvas();
69
70 // implement wxGLCanvasBase methods
71 virtual bool SwapBuffers();
72
73
74 // MSW-specific helpers
75 // --------------------
76
77 // get the HDC used for OpenGL rendering
78 HDC GetHDC() const { return m_hDC; }
79
80 // try to find pixel format matching the given attributes list for the
81 // specified HDC, return 0 on error, otherwise pfd is filled in with the
82 // information from attribList if non-NULL
83 static int ChooseMatchingPixelFormat(HDC hdc, const int *attribList,
84 PIXELFORMATDESCRIPTOR *pfd = NULL);
85
86#if wxUSE_PALETTE
87 // palette stuff
88 bool SetupPalette(const wxPalette& palette);
89 virtual wxPalette CreateDefaultPalette();
90 void OnQueryNewPalette(wxQueryNewPaletteEvent& event);
91 void OnPaletteChanged(wxPaletteChangedEvent& event);
92#endif // wxUSE_PALETTE
93
94 // deprecated methods using the implicit wxGLContext, associate the context
95 // explicitly with the window instead
96#if WXWIN_COMPATIBILITY_2_8
97 wxDEPRECATED(
98 wxGLCanvas(wxWindow *parent,
99 wxWindowID id = wxID_ANY,
100 const wxPoint& pos = wxDefaultPosition,
101 const wxSize& size = wxDefaultSize,
102 long style = 0,
103 const wxString& name = wxGLCanvasName,
104 const int *attribList = NULL,
105 const wxPalette& palette = wxNullPalette)
106 );
107
108 wxDEPRECATED(
109 wxGLCanvas(wxWindow *parent,
110 const wxGLContext *shared,
111 wxWindowID id = wxID_ANY,
112 const wxPoint& pos = wxDefaultPosition,
113 const wxSize& size = wxDefaultSize,
114 long style = 0,
115 const wxString& name = wxGLCanvasName,
116 const int *attribList = NULL,
117 const wxPalette& palette = wxNullPalette)
118 );
119
120 wxDEPRECATED(
121 wxGLCanvas(wxWindow *parent,
122 const wxGLCanvas *shared,
123 wxWindowID id = wxID_ANY,
124 const wxPoint& pos = wxDefaultPosition,
125 const wxSize& size = wxDefaultSize,
126 long style = 0,
127 const wxString& name = wxGLCanvasName,
128 const int *attribList = NULL,
129 const wxPalette& palette = wxNullPalette)
130 );
131#endif // WXWIN_COMPATIBILITY_2_8
132
133protected:
134 // common part of all ctors
135 void Init();
136
137 // set up the pixel format using the given attributes and palette
138 bool DoSetup(const int *attribList);
139
140
141 // HDC for this window, we keep it all the time
142 HDC m_hDC;
143
144private:
145 DECLARE_EVENT_TABLE()
146 DECLARE_CLASS(wxGLCanvas)
147};
148
149#endif // _WX_GLCANVAS_H_
150