Display.update() very slow

Started by Kyjak, October 16, 2006, 20:48:15

Previous topic - Next topic

Kyjak

When running even a very simple program the Display.update() command is very slow. The part that is causeing the slowdown is SwapBuffers(). Is it possible that lwjgl is use software calls to flip the buffers rather than just using pointer shifting or native array copying?
When drawing a sphere made of 10000 polys about 10 ms is spent drawing the sphere while 35 ms is spent flipping the buffers. When only drawing 1 traingle almost 0 time is spent drawing the triangle while 35 ms is still spent on flipping the buffers. Even when nothing is drawn it still takes 35 ms to flip the buffers.
Any sugestions for fixing this?

ndhb

Maybe you could post some code. We have no problem hitting 1000+ fps with a full screen drawn. Are you absolutely positive your Graphics driver isn't Vsync your output?

Kyjak

Here is the code.
public void draw()
{
	GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
	GL11.glLoadIdentity();

	pos += 1f; 
	GL11.glColor3f(0.75f, 0.75f, 0.75f);
	GL11.glTranslatef(0.0f, 0.0f, -20.0f);
	GL11.glRotatef(pos, 1.0f, 1.0f, 1.0f);
	
	GL11.glCallList(listID); // Draws sphere

	//GL11.glFlush();
	Display.update();
}

When the Display.update() is replaced by the glFlush() the frame rate goes much higher (of course you don't get to see anything so its not that useful). I just finished a similar program using jogl and it has the same slowdown. I'm thinking it has to do with my hardware. I'm running this on an older laptop (windows me, 900mhz, integrated graphics) and thats where the problem is coming from. The odd thing though is that for other games, the fps is just fine. The problem isn't a vsync issue. The time it takes for the Display.update() is perportional to the number of pixels in the window. With a small window I can get a much higher fps. Something gives me the feeling this is not the kind of problem that is going to get fixed except by changing computers so I think I'll just try that.

aldacron

Add a Thread.yield() at the bottom of your main loop, or of the draw method, and see what happens. If all you are doing is drawing a single sphere, your problem may actually be that you're running too fast.

Kyjak

No that didn't do anything. Display.update() is blocking isn't it? I could put it in another thread but I don't think that I'm going to do that now. For now I think I'll just use jogl because I can make the window smaller and it will run faster. It's probably some strange problem between openGL and my dated graphics card.

Kyjak

I ran the program on another computer and the fps was 100x faster so it clearly is just a problem with my laptop.