Improve wxGLCanvas to be more type safe and better support modern OpenGL

Add wxGLAttribsBase, wxGLAttributes and wxGLContextAttrs replacing the old
untyped "int attributes[]".

Don't use global object for creating OpenGL > 3.0 contexts.

Closes #16909.
This commit is contained in:
Manuel Martin
2016-02-23 00:30:49 +01:00
committed by Vadim Zeitlin
parent fb5ff50eda
commit bdc95f5766
17 changed files with 2964 additions and 1089 deletions

View File

@@ -24,7 +24,9 @@
class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase
{
public:
wxGLContext(wxGLCanvas *win, const wxGLContext* other = NULL);
wxGLContext(wxGLCanvas *win,
const wxGLContext *other = NULL,
const wxGLContextAttrs *ctxAttrs = NULL);
virtual ~wxGLContext();
virtual bool SetCurrent(const wxGLCanvas& win) const;
@@ -46,6 +48,16 @@ class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase
{
public:
wxEXPLICIT // avoid implicitly converting a wxWindow* to wxGLCanvas
wxGLCanvas(wxWindow *parent,
const wxGLAttributes& dispAttrs,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxGLCanvasName,
const wxPalette& palette = wxNullPalette);
wxEXPLICIT
wxGLCanvas(wxWindow *parent,
wxWindowID id = wxID_ANY,
const int *attribList = NULL,
@@ -55,6 +67,15 @@ public:
const wxString& name = wxGLCanvasName,
const wxPalette& palette = wxNullPalette);
bool Create(wxWindow *parent,
const wxGLAttributes& dispAttrs,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxGLCanvasName,
const wxPalette& palette = wxNullPalette);
bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
@@ -76,9 +97,12 @@ public:
// get the HDC used for OpenGL rendering
HDC GetHDC() const { return m_hDC; }
// try to find pixel format matching the given attributes list for the
// specified HDC, return 0 on error, otherwise pfd is filled in with the
// information from attribList if non-NULL
// Try to find pixel format matching the given attributes list for the
// specified HDC, return 0 on error, otherwise ppfd is filled in with the
// information from dispAttrs
static int FindMatchingPixelFormat(const wxGLAttributes& dispAttrs,
PIXELFORMATDESCRIPTOR* ppfd = NULL);
// Same as FindMatchingPixelFormat
static int ChooseMatchingPixelFormat(HDC hdc, const int *attribList,
PIXELFORMATDESCRIPTOR *pfd = NULL);