1 Attachment(s)
Dynamic Data Display with OpenGL
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?
Re: Dynamic Data Display with OpenGL
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.
Code:
this->wiggleData=(float**) new float [10000];
This should be:
Code:
wiggleData = new (float*)[10000];
Re: Dynamic Data Display with OpenGL
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!
Re: Dynamic Data Display with OpenGL
Quote:
Originally Posted by showhand
I must delete all the arrys and recreate them void losing the EMS memory.
No, you don't --- you just waste time. Look:
Code:
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?
Quote:
Originally Posted by showhand
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().