[Qt-interest] Best way to draw pixels (raw data) in QGLWidget from large array ?
Hannu Shemeikka
hps at shemeikka.org
Fri Apr 9 10:26:51 CEST 2010
Hi,
I have a GUI application with 3 threads. 1 for sending data to hardware,
1 for receiving data from hardware and 1 is the main GUI thread.
The receiving thread, let's call it thread A, receives data from custom
hardware but in this testing setup it's a for-loop which generates data
to large uchar array. The array size is [5000][96]. This generated data
for testing purposes is all '0' since qrand() took too much CPU power.
This array is one image. I need to display as many images per second as
possible on display.
Currently, I use QTimer to fire every 30ms my slot that creates QImage
from that uchar array
CODE
bufImage = new
QImage((uchar*)acData,COLUMNS,ROWS,QImage::Format_Indexed8);)
CODE
in thread A and send it to main thread using signals and slots. This
QImage is then displayed in my custom QGLWidget class in its
paintEvent(QPaintEvent *event) with QPainter drawImage.
Performance is..well..not so good. With [5000][96] array and 33 fps my
CPU usage varies from 0 to 34% and this is when my app is just playing
still. The strange part is, that sometimes I get only 0-3% usage for
about a minute, then it goes to 33% and returns to 0% when I change
window size.
Now, what would be the best way to get this raw data to be displayed in
my custom QGLWidget ? At first, I had normal QWidget but the performance
was even worse.
My system:
Qt 4.6.2
Ubuntu 9.10 64-bit
Intel Q9550
Nvidia 8800GTS
Thanks,
Hannu Shemeikka
More information about the Qt-interest-old
mailing list