Hi everyone,
I'm running into difficulties when using an opengl window in pygame.
For reasons I don't catch, sometimes, when I draw quads with pyopengl, I
have to call pygame.display.flip to actually display anything, and
sometimes, I don't, resulting in a blinking horrific mess when I draw
multiple quads overlapping themselves.
I really don't know when it happen but it does in one project, not in
one another. Can't tell the difference...
I'm using flags OPENGL | DOUBLEBUF | HWSURFACE for my pygame window
Here's what I execute at the beginning of my drawing state :
def clear():
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
And here's my function to draw quads :
def drawtexturedquad(imgid, pos, proj=True, siz=(1, 1), r=1.0, g=1.0,
b=1.0, alpha=1.0):
if proj:
glMatrixMode(GL_MODELVIEW)
else:
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glPushMatrix()
glEnable(GL_TEXTURE_2D)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glTranslated(-1, -1, 0)
glTranslated(pos[0], pos[1], 0)
glScalef(siz[0], siz[1], 1)
glColor4f(r, g, b, alpha)
glBindTexture(GL_TEXTURE_2D, imgid)
glBegin(GL_QUADS)
glTexCoord2f(0.0, 1.0)
glVertex2f(-1.0, 1.0)
glTexCoord2f(1.0, 1.0)
glVertex2f(1.0, 1.0)
glTexCoord2f(1.0, 0.0)
glVertex2f(1.0, -1.0)
glTexCoord2f(0.0, 0.0)
glVertex2f(-1.0, -1.0)
glEnd()
glPopMatrix()
glFlush()