<?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[QPainter draws text quads counterclockwise and other primitives clockwise.  Bug or intentional?]]></title><description><![CDATA[<p dir="auto">Using Qt 5.6.0 on Windows 10.</p>
<p dir="auto">QPainter draws the quads for text bitmaps \counterclockwise, while primitives like ellipses and the quads for QPixmap draw clockwise.  Result found on QOpenGLWidget.</p>
<p dir="auto"><strong>Is this intentional?</strong></p>
<p dir="auto">Ex: I want to draw a 3D scene and then try to draw a framerate counter on top of it with QPainter's text functionality.</p>
<p dir="auto"><strong>Justification:</strong></p>
<ul>
<li>According to <a href="https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCullFace.xml" target="_blank" rel="noopener noreferrer nofollow ugc">glCullFace</a>, OpenGL face culling defaults to culling the back face, so front faces are shown but back faces are not.</li>
<li>According to <a href="https://www.khronos.org/opengles/sdk/docs/man/xhtml/glFrontFace.xml" target="_blank" rel="noopener noreferrer nofollow ugc">glFrontFace</a>, OpenGL defines a "front face" as counterclockwise polygons.</li>
<li>Therefore, if face culling is enabled in an OpenGL-running widget, it will default to culling clockwise (back face) polygons and anything that uses them.</li>
</ul>
<p dir="auto"><strong>Demonstration code:</strong><br />
See the example “2D Painting Example” in Qt Creator (I’m running Qt 5.6.0).  This example uses a QPainter object to draw text and rotating elipses on a QOpenGLWidget.</p>
<ul>
<li>Add override of initializeGL() to GLwidget.</li>
<li>In source file, add function:</li>
</ul>
<pre><code>#include &lt;qopenglfunctions_2_1.h&gt;
void GLWidget::initializeGL()
{
    QOpenGLFunctions_2_1 *f = QOpenGLContext::currentContext()-&gt;versionFunctions&lt;QOpenGLFunctions_2_1&gt;();
    f-&gt;glEnable(GL_CULL_FACE);
    //f-&gt;glCullFace(GL_FRONT);      // uncomment to cull the text and show the rotating elipses
}
</code></pre>
<ul>
<li>Run the program.  The text "Qt" draws but the elipses don't.  Uncomment glCullFace(GL_FRONT) to reverse the effect and show the elipses but not the text.</li>
<li>Now try drawing a pixmap after culling is turned on.  The following won’t draw if culling is turned on and it is culling back faces (clockwise polygons).</li>
</ul>
<pre><code>void GLWidget::paintGL()
{
    QPixmap p(myImageFilePath);
    QPainter painter(this);
    painter.drawPixmap(0, 0, p.scaled(this-&gt;size());
}
</code></pre>
<ul>
<li>To draw a QPixmap when back faces are being culled, you have to do this:</li>
</ul>
<pre><code>void GLWidget::paintGL()
{
    QPixmap p(myImageFilePath);
    QOpenGLFunctions_2_1 *f = QOpenGLContext::currentContext()-&gt;versionFunctions&lt;QOpenGLFunctions_2_1&gt;();
    GLBoolean faceCullingIsOn;
    
    // save current culling state
    f-&gt;glGetBooleanv(GL_CULL_FACE, &amp;faceCullingIsOn);
    f-&gt;glDisable(GL_CULL_FACE);
    QPainter painter(this);
    painter.drawPixmap(0, 0, p.scaled(this-&gt;size());
    if (faceCullingIsOn == GL_TRUE)
    {
        // turn it back on
        f-&gt;glEnable(GL_CULL_FACE);
    }
}
</code></pre>
<p dir="auto"><strong>Bug or intentional?</strong>  This isn't a show-stopper for me but it did cause some grief.</p>
]]></description><link>https://forum.qt.io/topic/71814/qpainter-draws-text-quads-counterclockwise-and-other-primitives-clockwise-bug-or-intentional</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 21:54:48 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/71814.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 01 Oct 2016 02:12:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QPainter draws text quads counterclockwise and other primitives clockwise.  Bug or intentional? on Sun, 02 Oct 2016 20:57:57 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">No, you send a mail to the mailing list address. Everybody subscribed will receive it.</p>
]]></description><link>https://forum.qt.io/post/351475</link><guid isPermaLink="true">https://forum.qt.io/post/351475</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 02 Oct 2016 20:57:57 GMT</pubDate></item><item><title><![CDATA[Reply to QPainter draws text quads counterclockwise and other primitives clockwise.  Bug or intentional? on Sun, 02 Oct 2016 20:46:55 GMT]]></title><description><![CDATA[<p dir="auto">@Wieland I just subscribed, but it is a mailing list and not a regular forum, so I don't know the usual practice.  In a forum you create a thread, but for a mailing list to I just send an email to everyone on the list?</p>
]]></description><link>https://forum.qt.io/post/351473</link><guid isPermaLink="true">https://forum.qt.io/post/351473</guid><dc:creator><![CDATA[amdreallyfast]]></dc:creator><pubDate>Sun, 02 Oct 2016 20:46:55 GMT</pubDate></item><item><title><![CDATA[Reply to QPainter draws text quads counterclockwise and other primitives clockwise.  Bug or intentional? on Sun, 02 Oct 2016 20:32:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/amdreallyfast">@<bdi>amdreallyfast</bdi></a> Sorry, I posted the wrong link. "Interest" is the right one: <a href="http://lists.qt-project.org/mailman/listinfo/interest" target="_blank" rel="noopener noreferrer nofollow ugc">http://lists.qt-project.org/mailman/listinfo/interest</a></p>
]]></description><link>https://forum.qt.io/post/351471</link><guid isPermaLink="true">https://forum.qt.io/post/351471</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sun, 02 Oct 2016 20:32:53 GMT</pubDate></item><item><title><![CDATA[Reply to QPainter draws text quads counterclockwise and other primitives clockwise.  Bug or intentional? on Sun, 02 Oct 2016 20:29:18 GMT]]></title><description><![CDATA[<p dir="auto">@Wieland Sorry for the late reply.  Where are the framework developers?  Would they be under the Interest or Development lists?</p>
]]></description><link>https://forum.qt.io/post/351470</link><guid isPermaLink="true">https://forum.qt.io/post/351470</guid><dc:creator><![CDATA[amdreallyfast]]></dc:creator><pubDate>Sun, 02 Oct 2016 20:29:18 GMT</pubDate></item><item><title><![CDATA[Reply to QPainter draws text quads counterclockwise and other primitives clockwise.  Bug or intentional? on Sat, 01 Oct 2016 11:03:03 GMT]]></title><description><![CDATA[<p dir="auto">Hi! Please ask this the framework developers on the mailing list (<a href="http://lists.qt-project.org/mailman/listinfo" target="_blank" rel="noopener noreferrer nofollow ugc">http://lists.qt-project.org/mailman/listinfo</a>). This forum is more user oriented thus it's unlikely that the right people will find your question here :-)</p>
]]></description><link>https://forum.qt.io/post/351280</link><guid isPermaLink="true">https://forum.qt.io/post/351280</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sat, 01 Oct 2016 11:03:03 GMT</pubDate></item></channel></rss>