PDA

View Full Version : OpenGL app at full speed? Can you do it?



mattropolis
18th October 2007, 01:46
I was looking at the Qt library of OpenGL samples, but see that I think they have the same problem that wxWidgets does. Basically, all OpenGL updates need to be triggered by a timer event. For example:
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(rotateOneStep()));
timer->start(20);

The rotateOneStep function then calls update/paint on the OpenGL context. The problem I have is that I want to run at the max FPS I can get. Usually, one does this in the WinMain or other message pump loop:
while()
{
processmessage();
dispatchmessage();
drawscene();
}

Is there a way to do this in Qt?
Thanks in advance,

high_flyer
18th October 2007, 11:54
all OpenGL updates need to be triggered by a timer event.
What makes you think that?
You can call your update function in any way you choose.

I am not sure what is the problem you are trying to describe.
you can call the update function that will update your opengl context be it with a timer or any other means as fast as the system time resolution.
If what ever you are drawing is beyond just filling the screen with one color (and usually you will have a scene that is larger then few pixels), the drawing will be slower then your update call rate, even on the fastest hardware.

The example you gave used a trigger for updating - based on the changes done in the scene, and not to have contentious "video" in max speed...
For example, a frame rate of 500 fps will mean an update every 2ms, which is no problem on the systems side, the question is if the graphic card can do your scene in 2 ms.

So, to your question, yes, there is a way to do it in Qt - but it has nothing to do with Qt.
You can do it with a thread that will loop and only call your update function, for example.
The speed will be determined only by the time it takes for your update function to return.