PDA

View Full Version : Dynamic Data Display with OpenGL



showhand
13th March 2006, 13:50
Hi, all
I want to draw series wiggle lines with OpenGL in Qt4. As we all know, the doubleBuffer is 'on' by default in Qt4. So I think the QGLWidget will be the fittest to me. But the effect is not good and the screen is flicker.
My method is refresh the the whole GL scene when the data is changed which is generated by a functin of rand. Please looked at the attachment which are some code. Is anyone would help me or have some other good idear?

jacek
13th March 2006, 15:05
Why do you delete all those arrays and create them again every 40 ms (in A::advanceData())? Can't you just fill them with new data?

Recreating the display list might also have some impact on performance. You redraw your widget 25 times per second, so probably that display list is used only once --- try to draw directly.


this->wiggleData=(float**) new float [10000];
This should be:
wiggleData = new (float*)[10000];

showhand
14th March 2006, 00:50
advanceData() is the slot with a 'timer' and it will be called per 40 ms. I must delete all the arrys and recreate them void losing the EMS memory. And could you tell me your method about the directly draw. Thanks a lot!

jacek
14th March 2006, 01:17
I must delete all the arrys and recreate them void losing the EMS memory.
No, you don't --- you just waste time. Look:
if(movieData)
{
for(int i=0;i<traceNum;i++)
delete []movieData[i];
delete []movieData;
}
movieData=(float**) new float [XNum];
for(int i=0;i<XNum;i++)
{
movieData[i]=new float[YNum];
for(int j=0;j<YNum;j++)
{
movieData[i][j]=0.0;
}
}
Each time this code is run, you delete all of the arrays just to create new ones of the same size. Can't you reuse them?


And could you tell me your method about the directly draw.
Just remove the code related to display lists and invoke A::movieWiggle() from A::paintGL().