LWJGL Forum

Programming => OpenGL => Topic started by: CodeBunny on April 25, 2011, 11:59:32

Title: Display.update becomes very slow
Post by: CodeBunny on April 25, 2011, 11:59:32
Ordinarily, calling Display.update() on my system takes 0.6-0.9 milliseconds. However, occasionally it starts spiking up, sometimes taking as much as 60 milliseconds. The weird thing is, my actual rendering is taking a fairly constant time, usually on the order of 8 milliseconds, so basically all the slowdown is coming from Display.update().

So... does anyone know what could cause this? Some preliminary testing seems to show that it is related to what I've been rendering - if I don't add any of the enemies in my game, it doesn't seem to occur. However, I'm stuck after that.
Title: Re: Display.update becomes very slow
Post by: CodeBunny on April 26, 2011, 11:39:30
Apparently it takes even longer than 60 ms. I've had it going on 200 milliseconds to update the Display.

Has this ever happened before, to anyone?
Title: Re: Display.update becomes very slow
Post by: Fool Running on April 26, 2011, 12:44:33
The time to render is, I'm assuming, the time it takes your code to call the OpenGL methods? If that is the case then there is something you should know:
Calling OpenGL methods just puts the calls into a queue of sorts in the display driver that the GPU reads from to know what to do next. Display.update() waits until the GPU has finished with the queue. What this means is that the problem is actually, indeed, in what you are rendering. For some reason (I guess when the enemies come on screen), the GPU sometimes has trouble with it.

If you're using shaders, I would check the ones on the enemies to make sure there isn't some code that might cause some problems. Otherwise, make sure that the enemies don't set some state that you forget to turn off for the other rendering that might cause it to slow down.

Hope that helps. ;D