Commit fa10de61 authored by Laszlo Agocs's avatar Laszlo Agocs

gl: fix fallbackSurface ownership in examples

parent 989c155b
......@@ -166,6 +166,7 @@ protected:
#ifndef QT_NO_OPENGL
QOpenGLContext *m_context = nullptr;
QOffscreenSurface *m_fallbackSurface = nullptr;
#endif
};
......@@ -247,12 +248,14 @@ void Window::init()
if (!m_context->create())
qFatal("Failed to get OpenGL context");
m_fallbackSurface = new QOffscreenSurface;
m_fallbackSurface->setFormat(m_context->format());
m_fallbackSurface->create();
QRhiGles2InitParams params;
params.context = m_context;
params.window = this;
params.fallbackSurface = new QOffscreenSurface;
params.fallbackSurface->setFormat(m_context->format());
params.fallbackSurface->create();
params.fallbackSurface = m_fallbackSurface;
m_r = QRhi::create(QRhi::OpenGLES2, &params);
}
#endif
......@@ -327,6 +330,8 @@ void Window::releaseResources()
#ifndef QT_NO_OPENGL
delete m_context;
m_context = nullptr;
delete m_fallbackSurface;
m_fallbackSurface = nullptr;
#endif
}
......
......@@ -65,6 +65,7 @@ private:
void releaseResources() override;
QOpenGLContext *ctx = nullptr;
QOffscreenSurface *fallbackSurface = nullptr;
};
void GlWindow::init()
......@@ -73,12 +74,14 @@ void GlWindow::init()
if (!ctx->create())
qFatal("Failed to get OpenGL context");
fallbackSurface = new QOffscreenSurface;
fallbackSurface->setFormat(ctx->format());
fallbackSurface->create();
QRhiGles2InitParams params;
params.context = ctx;
params.window = this;
params.fallbackSurface = new QOffscreenSurface;
params.fallbackSurface->setFormat(ctx->format());
params.fallbackSurface->create();
params.fallbackSurface = fallbackSurface;
m_r = QRhi::create(QRhi::OpenGLES2, &params);
ExampleWindow::init();
......@@ -89,6 +92,8 @@ void GlWindow::releaseResources()
ExampleWindow::releaseResources();
delete ctx;
ctx = nullptr;
delete fallbackSurface;
fallbackSurface = nullptr;
}
int main(int argc, char **argv)
......
make rp dep in ps less invasive (rethink how QRhiRenderPass is handled)
gl: offscreensurface ownership not taken (fix examples)
figure out what's up with instance step rate
mtl: buffer logic is borked
mtl: fix Dynamic for non-uniform buffers
......@@ -42,6 +41,7 @@ bytecode (fxc/dxc) for d3d?
bytecode for metal?
+++ done
gl: offscreensurface ownership not taken (fix examples)
d3d: why rtv/dsv in rp -> should be in rtD
new "minimal" example
cubemap face as target
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment