PDA

View Full Version : QGLWidget renderText()



ToddAtWSU
26th June 2006, 17:59
I have a graph draw inside a QGLWidget and display grid lines and their values on the screen. I have x-values and y-values. Whenever I scroll the grid up and down the graph moves smoothly. But whenever I scroll the graph left or right, it slows up and lags whenever the text gets to the right edge of the screen. It speeds back up when the text is completely moved off the screen until the next number moves to the edge when it again slows up. Does anyone have any ideas why this does this? I am just using renderText() and it only slows up whenever text gets to the left side of the screen. Thanks again!

bits
26th June 2006, 20:13
Can we see your code related to renderText()?

ToddAtWSU
26th June 2006, 22:07
for( int i = 0 ; i < (xMax - xMin) / xStepSize ; i++ )
{
//point = some number discovered higher up
//xMin = the value of the first number to be printed next to the gridline
//xStepSize = the distance to the next grid line.
renderText( (xMin + i * xStepSize, 0.01, QString::number( point[i] ) );
}

I just run this through a for-loop while updating the int variable point. The numbers display in the correct place, its just the movement is jerky everytime a grid line/number approaches the right edge and only a portion of the text from renderText( ) displays. Hope this helps! Thanks!

bits
27th June 2006, 19:04
[QUOTE=ToddAtWSU]
for( int i = 0 ; i < (xMax - xMin) / xStepSize ; i++ )
{
renderText( (xMin + i * xStepSize, 0.01, QString::number( point[i] ) );
}

BTW, your renderText has mismatching brackets.

I have a doubt regarding your problem.
There are 2 signatures in renderText() available in Qt.

renderText ( int x, int y, const QString & str, const QFont & fnt = QFont(), int listBase = 2000 )
renderText ( double x, double y, double z, const QString & str, const QFont & fnt = QFont(), int listBase = 2000 )

It seems like you have been using the first signature ( the one with int x and int y)...
I feel that you intended to use the second signature because you are using 0.01 as your Y value.

But to your original problem of slow translation I can't find any good reason why your text slows your translations so much. It doesn't do the same with me. If you figure out a solution on your own, please post it.

ToddAtWSU
27th June 2006, 19:31
Thanks...I did not notice the first signature for renderText was using 2 ints. I just saw it only had an x and y coordinate so I used that since my z=0. But I will change that to see if it helps at all. If I do find a solution I will definately post it. But I might try to go another route and just create a QLabel and update it's text to match my grids. Thanks!

ToddAtWSU
5th July 2006, 19:53
I am still having problems with the text slowing up my moving of the graph. Has anyone else run into this problem? Thanks!

Rayven
19th July 2006, 22:39
Check the version of the Nvidia drivers being used. I had some trouble with using the newest drivers and OpenGL, and had to switch to the legacy drivers.

guilugi
21st July 2006, 11:44
Hello !

I have a problem with this method, on a Win32 system : my strings aren't displayed, and I grab this warning message :

warning : QGLContext::generateFontDisplayLists: Could not generate display lists for font 'Arial'

This message is always thrown, for any font I can specify...

Worse, the Qt example Sample Buffers that uses renderText(), works correctly... and I don't do anything specific
in my OpenGL code..
I have no problem at all with Linux / X11.

Any idea, or anyone experienced this ?

Thanks,
Guilugi.

ToddAtWSU
21st July 2006, 14:20
Thanks Rayven that worked!