PDA

View Full Version : Bug in QGraphicsPixmapItem with QGLWidget



spud
16th February 2009, 13:19
I've noticed that my application freezes when I add a pixmap larger than 1024x1024 to a QGraphicsView with an opengl viewport.

Could anyone test the following example(on Windows) and see if they have the same problem:

#include <QtGui>
#include <QGLWidget>

int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QGraphicsView w;
w.setScene(new QGraphicsScene);
w.setViewport(new QGLWidget);
w.scene()->addPixmap(QPixmap(":/trolltech/styles/commonstyle/images/networkdrive-128.png").scaled(1025,1025));
w.show();
return app.exec();
}
My specs:
Intel P4
WindowsXP
Qt 4.4.3 open source
ATI Radeon X1650
Video driver: ati2dvag.dll V. 6.14.0010.6764 (English)

EDIT:
Just tried it on an AMD Phenom with a NVIDEO GeForce 8400 and it worked. So I'd be greatful if someone could test it with an ATI card.

talk2amulya
16th February 2009, 13:31
it works fine on my system..i used a 443 * 450 png image..so i guess problem is smwhere else

spud
16th February 2009, 15:04
Thanks for taking the time!
Just to clarify, you did scale the pixmap to 1025x1025 before adding it to the scene, right?
Could you please tell me what video card you have, and if it is a ATI Radeon, which driver?

I am trying to find out with which video cards this bug appears, or if there is just something wrong with my system.

talk2amulya
16th February 2009, 15:32
yes i used ur code as it was..just changed the image..i m also using windows XP and i have an intel Q35

spud
17th February 2009, 09:18
I'd be really grateful i some one would test the code with an ATI card.

Bjoern
26th February 2009, 10:29
Check the maximum supported texture size of your GFX card / OpenGL Implementation.
Subclass the QGLWidget and add this code where you have a valid OpenGL context (e.g. inside initializeGL() ):


GLuint maxsize;
glGetIntegerv( GL_MAX_TEXTURE_SIZE, &maxsize);

And check / output the value of maxsize after this

I'm pretty sure you're hitting a limit of your GL Implementation there, even though I'd expect the new ATI Cards to have a limit of 8192 or more ...

Also double check your OpenGL (correct dll used ?), or maybe try another driver version - had many problems with corrupted/buggy implementations with ATI, that's one reason why I'm using NVidia...

hope this helps,
regards,
Bjoern

h123
26th February 2009, 12:46
hi spud,
i tested code with linux and ati card with 2025x2025 image, it works file.

i have one question here, if we comment the w.setViewport(new QGLWidget)line; then also this example works fine, so what is the use of QGLWidget here ?

thank you

Bjoern
26th February 2009, 13:05
what is the use of QGLWidget here ?
With an OpenGL based widget you have graphics hardware accelerated rendering, w/o its using a system dependent engine, which lacks performance in some cases.
In this small example you could end up with anything with no problems at all, I'd bet :p

Did you run the example with the
w.setViewport(new QGLWidget) in place ?
And please post your driver version and hardware used, as this may help finding a working driver (afaik ATI is using the same codebase on Linux and Windows, as NVidia does) :cool:

run glxinfo and find lines OpenGL version string and OpenGL renderer string for this.

spud
26th February 2009, 13:37
Thanks to both of you!
I can't check the texture size limit until I get home from work, but I have manipulated 2048x2048 textures on that graphic card in the past. Anyway the QOpenGLPaintEnginge checks for max texture size and scales the pixmap otherwise.
From qt\src\opengl\qpaintengine_opengl.cpp:


glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_tex_size);


const int sz = d->max_texture_size;
if (pm.width() > sz || pm.height() > sz) {
...
const QPixmap scaled = sub.scaled(sz, sz, Qt::KeepAspectRatio);


I'm suspecting it is a bug in the ATI driver. I'll see if I get around to debugging it tonight.
If i remember correctly it was the call to glPopattrib() in
bool QOpenGLPaintEngine::end() that freezes the application.

h123
27th February 2009, 05:31
Hi Bjoern,
i tested code with and without w.setViewport(new QGLWidget), and it worked fine with 2025x2025.

> run glxinfo and find lines OpenGL version string and OpenGL renderer string for this.
server glx version string: 1.2
client glx version string: 1.2
OpenGL version string: 2.0.5079 WinXP Release
glu version: 1.3

cenos and winnt with xming.

thank you.