- Support wxGLContext::SetCurrent. - Pass GL canvas attributes via ParseAttribList to handle defaults. - Remove OpenGL not implemented message. - Prevent QGLWidget from changing OpenGL state before we paint. - Set Qt::StrongFocus for wxQtGLWidget to allow keyboard input. - Use QtCanPaintWithoutActivePainter to fix wxPaintDCImpl assert when using wxGLCanvas.
92 lines
3 KiB
C++
92 lines
3 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: include/wx/qt/glcanvas.cpp
|
|
// Author: Sean D'Epagnier
|
|
// Copyright: (c) Sean D'Epagnier 2014
|
|
// Licence: wxWindows licence
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _WX_GLCANVAS_H_
|
|
#define _WX_GLCANVAS_H_
|
|
|
|
#include <GL/gl.h>
|
|
|
|
class QGLWidget;
|
|
class QGLContext;
|
|
class QGLFormat;
|
|
|
|
class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase
|
|
{
|
|
public:
|
|
wxGLContext(wxGLCanvas *win,
|
|
const wxGLContext *other = nullptr,
|
|
const wxGLContextAttrs *ctxAttrs = nullptr);
|
|
/// virtual ~wxGLContext();
|
|
|
|
virtual bool SetCurrent(const wxGLCanvas& win) const override;
|
|
|
|
private:
|
|
QGLContext* m_glContext = nullptr;
|
|
|
|
wxDECLARE_CLASS(wxGLContext);
|
|
};
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// wxGLCanvas: OpenGL output window
|
|
// ----------------------------------------------------------------------------
|
|
|
|
class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase
|
|
{
|
|
public:
|
|
wxGLCanvas() = default;
|
|
|
|
explicit // 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);
|
|
|
|
explicit
|
|
wxGLCanvas(wxWindow *parent,
|
|
wxWindowID id = wxID_ANY,
|
|
const int *attribList = nullptr,
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
const wxSize& size = wxDefaultSize,
|
|
long style = 0,
|
|
const wxString& name = wxGLCanvasName,
|
|
const wxPalette& palette = wxNullPalette);
|
|
|
|
~wxGLCanvas();
|
|
|
|
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,
|
|
const wxSize& size = wxDefaultSize,
|
|
long style = 0,
|
|
const wxString& name = wxGLCanvasName,
|
|
const int *attribList = nullptr,
|
|
const wxPalette& palette = wxNullPalette);
|
|
|
|
virtual bool SwapBuffers() override;
|
|
|
|
virtual bool QtCanPaintWithoutActivePainter() const override;
|
|
|
|
static bool ConvertWXAttrsToQtGL(const wxGLAttributes &glattrs, const wxGLContextAttrs ctxAttrs, QGLFormat &format);
|
|
|
|
private:
|
|
wxDECLARE_CLASS(wxGLCanvas);
|
|
};
|
|
|
|
#endif // _WX_GLCANVAS_H_
|