<?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[QOpenglWindow  PaintGL()  Native gl calls cause painter to disappear SOLVED]]></title><description><![CDATA[<p dir="auto">I've subclassed a QOpenglWindow, connected its update slot to its frameSwapped signal, and it merrily animates along.</p>
<p dir="auto">I'm able to use Qpainter on the window to render some nice animated text,  with glClear wiping the buffer each frame.</p>
<p dir="auto">However, when I add some more fancy gl calls,  the painter stuff gets wiped out.  Remove the other gl calls, it's back.  I've tried painting before and after the gl calls,  wrapping them in beginNativePanting() and endNativePainting(), to no avail.  Does anybody have any ideas?</p>
<p dir="auto">Thanks</p>
<p dir="auto">Here's my paintGL function,  minus some non-drawing animation stuff:<br />
@<br />
void PlaybackWindow::paintGL()<br />
{</p>
<pre><code>glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
                
                                                                           
                                                                           
//painter.beginNativePainting();                                           


m_program-&gt;bind();

QMatrix4x4 matrix;
matrix.setToIdentity();
matrix.perspective(60, 4.0/3.0, 0.1, 100.0);
matrix.lookAt(QVector3D(0.0,8.0,-20.0),QVector3D(0,0,0),QVector3D(0,1,0));
m_program-&gt;setUniformValue(m_matrixUniform, matrix);
</code></pre>
<p dir="auto">if(validbuffer &amp;&amp; pb1size &gt; 0)<br />
{<br />
glBindBuffer(GL_ARRAY_BUFFER,vertex_buffer_1);<br />
glEnableVertexAttribArray(m_posAttr);<br />
glVertexAttribPointer(m_posAttr,3 , GL_FLOAT, GL_FALSE, 0, 0);</p>
<pre><code>    glPointSize(4);
    glDrawArrays(GL_POINTS, 0, pb1size);
}


glDisableVertexAttribArray(m_posAttr);

m_program-&gt;release();
</code></pre>
<p dir="auto"><a href="//painter.endNativePainting" target="_blank" rel="noopener noreferrer nofollow ugc">//painter.endNativePainting</a>();</p>
<p dir="auto">QPainter painter;<br />
painter.begin(this);<br />
painter.setPen(Qt::white);<br />
painter.setFont(QFont("Arial", 30));<br />
painter.drawText(10,120,  QString::number(m_Engine-&gt;GetFrameNum()) );<br />
painter.end();<br />
}<br />
@</p>
]]></description><link>https://forum.qt.io/topic/50257/qopenglwindow-paintgl-native-gl-calls-cause-painter-to-disappear-solved</link><generator>RSS for Node</generator><lastBuildDate>Mon, 09 Nov 2026 16:59:44 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/50257.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 18 Jan 2015 04:04:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QOpenglWindow  PaintGL()  Native gl calls cause painter to disappear SOLVED on Sun, 18 Jan 2015 04:15:53 GMT]]></title><description><![CDATA[<p dir="auto">FIxed it by declaring</p>
<p dir="auto">glBindBuffer(GL_ARRAY_BUFFER,0);</p>
<p dir="auto">after releasing the program.</p>
]]></description><link>https://forum.qt.io/post/258024</link><guid isPermaLink="true">https://forum.qt.io/post/258024</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sun, 18 Jan 2015 04:15:53 GMT</pubDate></item></channel></rss>