<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[OpenGL context and testing with catch2]]></title><description><![CDATA[<p dir="auto">I'am trying to test my class that uses QOpenGLTexture but it cannot use QOpenGLTexture becouse there is no OpenGL context. I tried this:</p>
<pre><code>
// gui app
    char *dummyArgv[] = {"dummy program name", NULL};
    int dummyArgc = sizeof(dummyArgv) / sizeof(char*) - 1;
    QGuiApplication app(dummyArgc, dummyArgv);

// try 1 
    const auto screens = QGuiApplication::screens();
    REQUIRE(screens.size() &gt; 0);
    QOpenGLContext context;
    context.setScreen(screens[0]);
    REQUIRE(context.create());
    REQUIRE(context.isValid());

// try 2
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/window.qml")));

// try 3
    QQuickView *view = new QQuickView;
    view-&gt;setSource(QUrl(QStringLiteral("qrc:/rect.qml")));
    view-&gt;show();

</code></pre>
<p dir="auto">but I get</p>
<pre><code>Requires a valid current OpenGL context.
Texture has not been created
</code></pre>
<p dir="auto">all the time.<br />
Is there a valid way to create a OpenGL context for QOpenGL-classes without running event loop?</p>
]]></description><link>https://forum.qt.io/topic/92456/opengl-context-and-testing-with-catch2</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Nov 2026 19:05:46 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/92456.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 10 Jul 2018 09:03:25 GMT</pubDate><ttl>60</ttl></channel></rss>