diff --git a/include/wx/gtk/glcanvas.h b/include/wx/gtk/glcanvas.h index b69bcf9f46..ca356c5870 100644 --- a/include/wx/gtk/glcanvas.h +++ b/include/wx/gtk/glcanvas.h @@ -29,6 +29,8 @@ class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasImpl { typedef wxGLCanvasImpl BaseType; public: + wxGLCanvas() = default; + wxGLCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs, wxWindowID id = wxID_ANY, diff --git a/include/wx/msw/glcanvas.h b/include/wx/msw/glcanvas.h index 241d223d8d..1666aa5494 100644 --- a/include/wx/msw/glcanvas.h +++ b/include/wx/msw/glcanvas.h @@ -47,6 +47,8 @@ private: class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase { public: + wxGLCanvas() = default; + explicit // avoid implicitly converting a wxWindow* to wxGLCanvas wxGLCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs, @@ -115,9 +117,6 @@ public: #endif // wxUSE_PALETTE protected: - // common part of all ctors - void Init(); - // the real window creation function, Create() may reuse it twice as we may // need to create an OpenGL window to query the available extensions and // then potentially delete and recreate it with another pixel format @@ -133,7 +132,7 @@ protected: // HDC for this window, we keep it all the time - HDC m_hDC; + HDC m_hDC = nullptr; private: wxDECLARE_EVENT_TABLE(); diff --git a/include/wx/osx/glcanvas.h b/include/wx/osx/glcanvas.h index 1971c82b07..2aa6cb0fcd 100644 --- a/include/wx/osx/glcanvas.h +++ b/include/wx/osx/glcanvas.h @@ -60,6 +60,8 @@ private: class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase { public: + wxGLCanvas() = default; + wxGLCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs, wxWindowID id = wxID_ANY, @@ -126,7 +128,7 @@ protected: long style, const wxString& name); - WXGLPixelFormat m_glFormat; + WXGLPixelFormat m_glFormat = nullptr; wxGLAttributes m_GLAttrs; wxDECLARE_EVENT_TABLE(); diff --git a/include/wx/qt/glcanvas.h b/include/wx/qt/glcanvas.h index 2fd3409e8d..1cf84efba8 100644 --- a/include/wx/qt/glcanvas.h +++ b/include/wx/qt/glcanvas.h @@ -34,6 +34,8 @@ public: class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase { public: + wxGLCanvas() = default; + explicit // avoid implicitly converting a wxWindow* to wxGLCanvas wxGLCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs, diff --git a/include/wx/x11/glcanvas.h b/include/wx/x11/glcanvas.h index baf89b67ed..fdad407d90 100644 --- a/include/wx/x11/glcanvas.h +++ b/include/wx/x11/glcanvas.h @@ -17,6 +17,8 @@ class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasX11 { public: + wxGLCanvas() = default; + wxGLCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs, wxWindowID id = wxID_ANY, diff --git a/interface/wx/glcanvas.h b/interface/wx/glcanvas.h index 711e631ebe..0b0e1f7bd7 100644 --- a/interface/wx/glcanvas.h +++ b/interface/wx/glcanvas.h @@ -785,6 +785,15 @@ enum class wxGLCanvas : public wxWindow { public: + /** + Default constructor not creating the window. + + Create() must be used to actually create it later. + + @since 3.3.0 + */ + wxGLCanvas(); + /** Creates a window with the given parameters. Notice that you need to create and use a wxGLContext to output to this window. diff --git a/src/msw/glcanvas.cpp b/src/msw/glcanvas.cpp index c66537b00e..bbe8331c6d 100644 --- a/src/msw/glcanvas.cpp +++ b/src/msw/glcanvas.cpp @@ -641,11 +641,6 @@ wxEND_EVENT_TABLE() // wxGLCanvas construction // ---------------------------------------------------------------------------- -void wxGLCanvas::Init() -{ - m_hDC = nullptr; -} - wxGLCanvas::wxGLCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs, wxWindowID id, @@ -655,8 +650,6 @@ wxGLCanvas::wxGLCanvas(wxWindow *parent, const wxString& name, const wxPalette& palette) { - Init(); - (void)Create(parent, dispAttrs, id, pos, size, style, name, palette); } @@ -669,8 +662,6 @@ wxGLCanvas::wxGLCanvas(wxWindow *parent, const wxString& name, const wxPalette& palette) { - Init(); - (void)Create(parent, id, pos, size, style, name, attribList, palette); } diff --git a/src/osx/glcanvas_osx.cpp b/src/osx/glcanvas_osx.cpp index 72cfc89af4..5fdfac4df0 100644 --- a/src/osx/glcanvas_osx.cpp +++ b/src/osx/glcanvas_osx.cpp @@ -465,7 +465,6 @@ bool wxGLCanvas::Create(wxWindow *parent, const wxString& name, const wxPalette& WXUNUSED(palette)) { - m_glFormat = nullptr; // Don't allow an empty list if ( !dispAttrs.GetGLAttrs() ) {