I'm using PyOpenGL and GLUT to draw a square that moves in a circle. I do not clear the screen after drawing squares, because I desire a trailing effect. For some reason, squares that have been drawn already will move when new ones are drawn.
Notice, the extra pixel in the stroke of the squares is not the issue. It is the fact that the trail of squares is not static.
Here is an example of the effect
I'm providing code that I think is relevant. First, the code that I use to initialize the window:
glutInit()
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
glutInitWindowSize(width, height)
Second, this piece of code is called once before every square being drawn.
glLoadIdentity()
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(0.0, width, 0.0, height, 0.0, 1.0)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
Third, the actual drawing of the square
def rect_fill(x, y, w, h):
glBegin(GL_QUADS)
glVertex2f(x, y)
glVertex2f(x + w, y)
glVertex2f(x + w, y + h)
glVertex2f(x, y + h)
glEnd()
def rect_stroke(x, y, w, h, lw):
lw = lw / 2
glBegin(GL_LINES)
glVertex2f(x - lw, y)
glVertex2f(x + w + lw, y)
glVertex2f(x + w, y - lw)
glVertex2f(x + w, y + h + lw)
glVertex2f(x + w + lw, y + h)
glVertex2f(x - lw, y + h)
glVertex2f(x, y + h + lw)
glVertex2f(x, y - lw)
glEnd()
I have been at this for a while, and haven't been able to find anyone with similar issues. Thank you for any help.