Bonjour,
Je n'arrive pas à rafraîchir correctement mon image entre chaque affichage. L'ancienne image reste et la nouvelle se superpose. Je me suis pourtant inspiré de ce tutorial.

Voici le code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
 
import pygame
 
from OpenGL.GL import *
from OpenGL.GLU import *
from pygame.locals import *
 
def initializeDisplay(w, h):
	pygame.display.set_mode((w,h), pygame.OPENGL|pygame.DOUBLEBUF)
 
	glClearColor(0.0, 0.0, 0.0, 1.0)
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
 
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0, w, 0, h);
	glMatrixMode(GL_MODELVIEW);
 
	glEnable(GL_TEXTURE_2D)
	glEnable(GL_BLEND)
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
 
def handleEvents():
	eventlist = pygame.event.get()
	for event in eventlist:
		if event.type == QUIT or event.type == KEYDOWN and event.key == K_ESCAPE:
			return True
 
def main():
 
	pygame.init()
	initializeDisplay(800, 600)
	done = False
	fff = 10
	while not done:
		glPushMatrix()
		glLoadIdentity()
		fff += 1
		glColor4f(1.0,1.0,1.0,1.0)
		glBegin(GL_TRIANGLES)
		glVertex2i(10 + fff, 400)
		glVertex2i(400 + fff, 400)
		glVertex2i(400 + fff, 200)
		glEnd()
		pygame.display.flip()
		done = handleEvents()
   		glPushMatrix()
main()
J'ai essayé de mettre un glLoadIdentity au début du while, de l'entourer de glPush/PopMatrix, mais les images se superposent toujours.
Il doit me manquer un truc tout bête mais quoi?

Merci