god0fgod
2009-12-10 09:41:38 UTC
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?