Question:
How do I fix this problem with OpenGL where the frame-rate degrades over time?
god0fgod
2009-12-10 09:41:38 UTC
I'm using OpenGL for a 2D game. A mini-game uses a lot of lines because it's a 360˚ snake game. At first the game runs wonderfully at 60fps. This only lasts a few seconds before the fps starts to go down. After a few minutes it's about 15fps. It doesn't seem to be a memory leak.

I use:

def draw_line(surface,a,b,c,w):
offset = surface.get_offset()
glDisable(GL_LINE_SMOOTH)
glDisable(GL_TEXTURE_2D) #Diable textures temporarily.
glColor4fv(c) #Set Colour
glLineWidth(w) #Set width
glBegin(GL_LINES) #Begin the line
glVertex2i(a[0] + offset[0],a[1] + offset[1]) #Point A
glVertex2i(b[0] + offset[0],b[1] + offset[1]) #Point B
glEnd()
glEnable(GL_TEXTURE_2D)
glEnable(GL_LINE_SMOOTH)
def draw_lines(surface,coordinates,c,w):
offset = surface.get_offset()
glDisable(GL_TEXTURE_2D) #Diable textures temporarily.
glColor4fv(c) #Set Colour
glLineWidth(w) #Set width
glBegin(GL_LINE_STRIP) #Begin the line
for c in coordinates: #Loop though the coordinates and add them as vertices.
glVertex2i(c[0] + offset[0],c[1] + offset[1])
glEnd()
glEnable(GL_TEXTURE_2D)

I use glClear(GL_COLOR_BUFFER_BIT) before the next frame is put together. The depth testing is disabled.

Even when the snake is kept the same length so the number of lines rendered is steady, the game slows down.
This is with python but OpenGL should work the same regardless of language, right?
Three answers:
?
2009-12-10 09:48:26 UTC
Im not the expert but as far as I know you need to make a double buffer or back buffer.

The frame is rendered in the buffer first then copied to screen.
Pfo
2009-12-10 13:03:14 UTC
The fact that you're using Python shouldn't matter. This game looks pretty simple, so it's not obvious that their would be a bottleneck anywhere.



Are you using fixed time step? It's possible that some update processing is causing a runaway gap between renderings which accumulates over time, slowing the rendering.
stringer
2016-10-30 04:28:39 UTC
ive heard some people talk bout how they have been getting freezes interior the comparable place all of the time with that game, inspite of a sparkling reproduction. yet each so often, thats because of the fact those are signs and indicators of pink ring of dying. so in the journey that your on your 360 lots, identity say relax, then attempt returned day after at present.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...