Qt-interest Archive, August 2006
QPainter slow on QGLWidget
Message 1 in thread
Hi, I have modified the overpainting example to overpaint some text
Here is the code I added in paintEvent()
//<<<<<<<<<<<<
QString text = "Here <b>is</b> some <em>text</em>.";
text += text;
text += text;
text += text;
text += text;
text += text;
QFont font("Courier");
font.setPixelSize(24);
QTextDocument document;
document.setHtml(text);
document.setDefaultFont(font);
document.setPageSize(QSize(width(),height()));
QAbstractTextDocumentLayout *layout = document.documentLayout();
QAbstractTextDocumentLayout::PaintContext ctx;
ctx.palette.setColor(QPalette::Text,Qt::white);
ctx.clip = event->rect();
layout->draw(&painter,ctx);
//>>>>>>>>>>>>
Unfortunately, this makes the program render very slow (on my laptop
with a GeForce 1400go, that is quite a good openGL card). In comparison,
I have put the same render code in the paintEvent of a custom QWidget
(not QGLWidget) and it renders much faster.
I am hesitating between 3 explanations, in order of plausability:
- I have missed something and it is my fault, if you know what, please
point it to me
- It is normal: it is inherently slow to render so many glyphs. This
seems doubtful, as the card can eat millions of polygons/fragments per
seconds.
- There is a bug in the implementation ;-). That sounds possible: if I
increase the number of bubbles to 125 initially, it renders very slow
too. I ams *sure* I can render 125 such bubbles very fast in pure OpenGL.
I am quite surprised as Arthur is selled as a nice framework to benefit
from the OpenGL acceleration?!?!
Note also that painting such a QTextDocument in a QImage is also very
slow. Only painting in a QWidget seems fast.
--
[ signature omitted ]
Message 2 in thread
Xavier Décoret wrote:
> Note also that painting such a QTextDocument in a QImage is also very
> slow. Only painting in a QWidget seems fast.
Win* or X11?
Andre'
--
[ signature omitted ]
Message 3 in thread
André Pönitz a écrit :
> Xavier Décoret wrote:
>
>> Note also that painting such a QTextDocument in a QImage is also very
>> slow. Only painting in a QWidget seems fast.
>>
>
> Win* or X11?
>
>
I observed the problem on both. And it is not a driver problem, my other
GL apps and GL code in the same app work blazzing fast.
> Andre'
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>
>
--
[ signature omitted ]
Message 4 in thread
Xavier Décoret wrote:
> André Pönitz a écrit :
> > Xavier Décoret wrote:
> >
> >> Note also that painting such a QTextDocument in a QImage
> >> is also very slow. Only painting in a QWidget seems fast.
> >
> > Win* or X11?
>
> I observed the problem on both. And it is not a driver problem, my other
> GL apps and GL code in the same app work blazzing fast.
Some time ago (4.0.x or even 4.1.0) there was a lot of context
related copying going on in each invoked painter call
in the QtOpenGL implementation. That decreased performance
considerably.
I seem to remember being told that this had been acted upon
but my memory is known for failing, and all I know for sure
is that I haven't checked it lately...
Andre'
--
[ signature omitted ]