mirror of
https://github.com/lubosz/overte.git
synced 2025-04-09 08:22:30 +02:00
Properly delete GL context and offscreen surfaces
This commit is contained in:
parent
171b9d8ecc
commit
cbbb2a7975
4 changed files with 20 additions and 9 deletions
|
@ -36,7 +36,15 @@ OffscreenGLCanvas::~OffscreenGLCanvas() {
|
|||
delete _logger;
|
||||
_logger = nullptr;
|
||||
}
|
||||
|
||||
_context->doneCurrent();
|
||||
delete _context;
|
||||
_context = nullptr;
|
||||
|
||||
_offscreenSurface->destroy();
|
||||
delete _offscreenSurface;
|
||||
_offscreenSurface = nullptr;
|
||||
|
||||
}
|
||||
|
||||
bool OffscreenGLCanvas::create(QOpenGLContext* sharedContext) {
|
||||
|
|
|
@ -34,8 +34,8 @@ public:
|
|||
|
||||
protected:
|
||||
std::once_flag _reportOnce;
|
||||
QOpenGLContext* _context;
|
||||
QOffscreenSurface* _offscreenSurface;
|
||||
QOpenGLContext* _context{ nullptr };
|
||||
QOffscreenSurface* _offscreenSurface{ nullptr };
|
||||
QOpenGLDebugLogger* _logger{ nullptr };
|
||||
};
|
||||
|
||||
|
|
|
@ -28,16 +28,17 @@ QOpenGLContext* QOpenGLContextWrapper::currentContext() {
|
|||
return QOpenGLContext::currentContext();
|
||||
}
|
||||
|
||||
|
||||
QOpenGLContextWrapper::QOpenGLContextWrapper() :
|
||||
_context(new QOpenGLContext)
|
||||
{
|
||||
}
|
||||
|
||||
_ownContext(true), _context(new QOpenGLContext) { }
|
||||
|
||||
QOpenGLContextWrapper::QOpenGLContextWrapper(QOpenGLContext* context) :
|
||||
_context(context)
|
||||
{
|
||||
_context(context) { }
|
||||
|
||||
QOpenGLContextWrapper::~QOpenGLContextWrapper() {
|
||||
if (_ownContext) {
|
||||
delete _context;
|
||||
_context = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void QOpenGLContextWrapper::setFormat(const QSurfaceFormat& format) {
|
||||
|
|
|
@ -23,6 +23,7 @@ class QOpenGLContextWrapper {
|
|||
public:
|
||||
QOpenGLContextWrapper();
|
||||
QOpenGLContextWrapper(QOpenGLContext* context);
|
||||
virtual ~QOpenGLContextWrapper();
|
||||
void setFormat(const QSurfaceFormat& format);
|
||||
bool create();
|
||||
void swapBuffers(QSurface* surface);
|
||||
|
@ -40,6 +41,7 @@ public:
|
|||
|
||||
|
||||
private:
|
||||
bool _ownContext { false };
|
||||
QOpenGLContext* _context { nullptr };
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue