<?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[Correct usage of QOpenGLContext??? [SOLVED]]]></title><description><![CDATA[<p dir="auto">Hi there everybody,</p>
<p dir="auto">I want to create a simple example for using a QOpenGLContext in QT5.<br />
I have found "this":<a href="http://www.youtube.com/watch?v=VxsS7u-vgc8" target="_blank" rel="noopener noreferrer nofollow ugc">http://www.youtube.com/watch?v=VxsS7u-vgc8</a> YouTube example and followed the steps exactly.<br />
One cannot see everything especially not the main function.</p>
<p dir="auto">I have written a simple class deriving from QWindow (as you can see in the video).</p>
<p dir="auto">@<br />
//header file<br />
class Window: public QWindow<br />
{<br />
private:<br />
QOpenGLContext *_glContext;<br />
public:<br />
Window(QScreen *screen=0);<br />
}@</p>
<p dir="auto">@<br />
//.cpp file</p>
<p dir="auto">Window::Window(QScreen *screen): QWindow(screen)<br />
{<br />
setSurfaceType(OpenGLSurface);</p>
<p dir="auto">QSurfaceFormat fmt;<br />
fmt.setMajorVersion(4);<br />
fmt.setMinorVersion(2);<br />
fmt.setProfile(QSurfaceFormat::CoreProfile); //whatever this is</p>
<p dir="auto">this-&gt;setFormat(fmt);</p>
<p dir="auto">create();</p>
<p dir="auto">resize(300, 300);</p>
<p dir="auto">_glContext = new QOpenGLContext();<br />
_glContext-&gt;setFormat(fmt);</p>
<p dir="auto">_glContext-&gt;create();</p>
<p dir="auto">if(!_glContext-&gt;isValid())<br />
qCritical()&lt;&lt;"The OpenGL context is invalid!"; //I allways get this message</p>
<p dir="auto">//now another test:<br />
//the next line prints: "Window format version is: 4.2" which is correct<br />
qDebug()&lt;&lt;"Window format version is: "&lt;&lt;this-&gt;format().majorVersion()&lt;&lt;"."&lt;&lt;this-&gt;format().minorVersion();<br />
//the next line prints: "Context format version is: 2.0" Which is ofcourse not correct! WTF?<br />
qDebug()&lt;&lt;"Context format version is: "&lt;&lt;_glContext-&gt;format().majorVersion()&lt;&lt;"."&lt;&lt;_glContext-&gt;format().minorVersion();<br />
}<br />
@</p>
<p dir="auto">As you can see, the format of the Window does not match the format of the context!!??!??<br />
Is this a bug or am i missing something?? Maybe i do it wrong in the main, already?</p>
<p dir="auto">@<br />
#include "window.h"<br />
int main(int argc, char *argv[])<br />
{<br />
QApplication a(argc, argv);</p>
<p dir="auto">a.setApplicationName("test");<br />
a.setApplicationVersion("0.1");</p>
<p dir="auto">Window w; //do i have to create a QScreen first to give it to the Window?<br />
w.show(); //A white window of size 300x300 appears<br />
}@</p>
<p dir="auto">I need to have a OpenGL 4.2 context!</p>
<p dir="auto">Any help would be nice!</p>
]]></description><link>https://forum.qt.io/topic/22383/correct-usage-of-qopenglcontext-solved</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 13:35:35 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/22383.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Dec 2012 12:34:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Correct usage of QOpenGLContext??? [SOLVED] on Sun, 26 Jan 2014 08:43:18 GMT]]></title><description><![CDATA[<p dir="auto">This my post is my own correct usage.Working perfectly.<br />
it is HOWTO using "QOpenGLFunctions_3_3_Core" class.<br />
There is no need Q_OBJECT macro.<br />
There is no need to define custom signal or slot.<br />
There is no need to define any connections.<br />
I put it as be reference:)</p>
<p dir="auto"><a href="http://qt-project.org/wiki/Using-QOpenGLFunctions-and-QOpenGLContext" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/wiki/Using-QOpenGLFunctions-and-QOpenGLContext</a></p>
]]></description><link>https://forum.qt.io/post/176072</link><guid isPermaLink="true">https://forum.qt.io/post/176072</guid><dc:creator><![CDATA[unixmania]]></dc:creator><pubDate>Sun, 26 Jan 2014 08:43:18 GMT</pubDate></item><item><title><![CDATA[Reply to Correct usage of QOpenGLContext??? [SOLVED] on Fri, 21 Dec 2012 14:00:37 GMT]]></title><description><![CDATA[<p dir="auto">OK. It's me again. I just builded an example with rendering part and i recognized that the created context is perfectly rendering and using shaders of version 3.3 !!!!! (didn't test any higher shader version, but i guess it would also work)</p>
<p dir="auto"><em>So maybe that is a bug??</em> The context format returns 2.1 right after creating it but it renders 3.3 shaders without any problem!<br />
In Windows the same code returns 4.2 and it is also rendering without problems!</p>
<p dir="auto">Merry X Mas and a happy end of the world (today the maya calendar ends! :D )</p>
]]></description><link>https://forum.qt.io/post/160352</link><guid isPermaLink="true">https://forum.qt.io/post/160352</guid><dc:creator><![CDATA[Seraph]]></dc:creator><pubDate>Fri, 21 Dec 2012 14:00:37 GMT</pubDate></item><item><title><![CDATA[Reply to Correct usage of QOpenGLContext??? [SOLVED] on Fri, 21 Dec 2012 12:07:52 GMT]]></title><description><![CDATA[<p dir="auto">Hi again. I did compile the framework in windows and Ubuntu 12.<br />
Now in windows i get a 4.2 context!<br />
But in Ubuntu it is still the same. But now i only get a 2.0 window format and a 2.1 context??? What is the right command to start the configure skript?</p>
<p dir="auto">I used:<br />
@./configure -prefix $PWD/qtbase -opensource -nomake tests -opengl desktop -developer-build@<br />
And then<br />
@make -j 4@</p>
<p dir="auto">???</p>
<p dir="auto">By the way, our graphics driver supports OpenGL 4.2! The context in our QT 4.8.4 version of our project returned 4.2 and was able to use at least Shaders of version 3.3</p>
]]></description><link>https://forum.qt.io/post/160345</link><guid isPermaLink="true">https://forum.qt.io/post/160345</guid><dc:creator><![CDATA[Seraph]]></dc:creator><pubDate>Fri, 21 Dec 2012 12:07:52 GMT</pubDate></item><item><title><![CDATA[Reply to Correct usage of QOpenGLContext??? [SOLVED] on Thu, 20 Dec 2012 18:21:43 GMT]]></title><description><![CDATA[<p dir="auto">Thanks ZapB. I voted for this ticket</p>
]]></description><link>https://forum.qt.io/post/160257</link><guid isPermaLink="true">https://forum.qt.io/post/160257</guid><dc:creator><![CDATA[Seraph]]></dc:creator><pubDate>Thu, 20 Dec 2012 18:21:43 GMT</pubDate></item><item><title><![CDATA[Reply to Correct usage of QOpenGLContext??? [SOLVED] on Thu, 20 Dec 2012 18:16:25 GMT]]></title><description><![CDATA[<p dir="auto">Ah in that case, have a read of this "post":<a href="http://qt-project.org/forums/viewthread/22821/#107114" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/forums/viewthread/22821/#107114</a> which explains the issue and solution. Please do vote on the linked bug report.</p>
]]></description><link>https://forum.qt.io/post/160256</link><guid isPermaLink="true">https://forum.qt.io/post/160256</guid><dc:creator><![CDATA[ZapB]]></dc:creator><pubDate>Thu, 20 Dec 2012 18:16:25 GMT</pubDate></item><item><title><![CDATA[Reply to Correct usage of QOpenGLContext??? [SOLVED] on Thu, 20 Dec 2012 18:11:37 GMT]]></title><description><![CDATA[<p dir="auto">Im working with Windows8 and i am using the released package (msvc2010)</p>
]]></description><link>https://forum.qt.io/post/160255</link><guid isPermaLink="true">https://forum.qt.io/post/160255</guid><dc:creator><![CDATA[Seraph]]></dc:creator><pubDate>Thu, 20 Dec 2012 18:11:37 GMT</pubDate></item><item><title><![CDATA[Reply to Correct usage of QOpenGLContext??? [SOLVED] on Thu, 20 Dec 2012 17:54:12 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">What platform are you on?</p>
<p dir="auto">Are you using self-compiled Qt or the released binary packages?</p>
]]></description><link>https://forum.qt.io/post/160251</link><guid isPermaLink="true">https://forum.qt.io/post/160251</guid><dc:creator><![CDATA[ZapB]]></dc:creator><pubDate>Thu, 20 Dec 2012 17:54:12 GMT</pubDate></item><item><title><![CDATA[Reply to Correct usage of QOpenGLContext??? [SOLVED] on Thu, 20 Dec 2012 13:10:21 GMT]]></title><description><![CDATA[<p dir="auto">I also found this "example":<a href="http://qt-project.org/doc/qt-5.0/qtgui/openglwindow.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5.0/qtgui/openglwindow.html</a>. It is one of the view QT5 examples delivered with the QT5.0.0 framework</p>
<p dir="auto">But this seems to be an example for OpenGL ES2. If i set the format version of the window to anything &gt;2.9 the whole example crashes!<br />
I wish i had the example from the youtube video as code! He used 3.3 by the way which is not working in my case, either.</p>
<p dir="auto">I mean can i somehow setup my QT project by telling it to use OpenGL desktop version?<br />
Or do I have to recompile the whole framework and setting the open gl module with configure?</p>
<p dir="auto">Does nobody know anything about that?</p>
]]></description><link>https://forum.qt.io/post/160195</link><guid isPermaLink="true">https://forum.qt.io/post/160195</guid><dc:creator><![CDATA[Seraph]]></dc:creator><pubDate>Thu, 20 Dec 2012 13:10:21 GMT</pubDate></item></channel></rss>