# pygame double buffering [closed]

I am trying to use double buffering in pygame. What I'm trying to do is display a red then green screen, and switch from one to the other. Unfortunately, all I have is a black screen. I looked through many sites, but have been unable to find a solution. Any help would be appreciated.

import pygame, sys
from pygame.locals import *

RED = (255, 0, 0)
GREEN = ( 0, 255, 0)
bob = 1

pygame.init()
#DISPLAYSURF = pygame.display.set_mode((500, 400), 0, 32)
DISPLAYSURF = pygame.display.set_mode((1920, 1080), pygame.OPENGL | pygame.DOUBLEBUF | pygame.HWSURFACE | pygame.FULLSCREEN)
glClear(GL_COLOR_BUFFER_BIT)
glMatrixMode(GL_MODELVIEW)
running = True
while running:

if bob==1:
#pygame.draw.rect(DISPLAYSURF, RED, (0, 0, 1920, 1080))
#pygame.display.flip()
glColor3f(1.0, 0.0, 0.0)
glVertex2f(-1.0, 1.0)
glVertex2f(-1.0, -1.0)
glVertex2f(1.0, -1.0)
glVertex2f(1.0, 1.0)
glEnd()
pygame.display.flip()
bob = 0

else:
#pygame.draw.rect(DISPLAYSURF, GREEN, (0, 0, 1920, 1080))
#pygame.display.flip()
glColor3f(0.0, 1.0, 0.0)
glVertex2f(-1.0, 1.0)
glVertex2f(-1.0, -1.0)
glVertex2f(1.0, -1.0)
glVertex2f(1.0, 1.0)
glEnd()
pygame.display.flip()
bob = 1

for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == KEYDOWN:
if event.key == K_ESCAPE:
running = False

pygame.quit()
sys.exit()


I'm using Python 2.7 and my code need to be os independent.

Thanks for your help.

## closed as off-topic by Josh♦Aug 1 '14 at 15:04

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Questions about debugging a problem in your project must present a concise selection of code and context so as to allow a reader to diagnose the issue without needing to read all of your code or to engage in extensive back-and-forth dialog. For more information, see this meta thread." – Josh
If this question can be reworded to fit the rules in the help center, please edit the question.

• Ok, I got it, but it seems that I can't answer my quetion yet. I had to use pyopengl calls to draw on the surface. But now, the problem is that it doesn't seem to flip on vsync... the question is why? – BaldDude Jul 3 '13 at 15:59
• Your indentation is messed up. – monkey Jul 20 '13 at 4:13
• Does it work if you take off "FULLSCREEN"? – jsbueno Jul 15 '14 at 1:08
• The project went in another direction. I no longer use Pygame, so I did not keep up with this question. – BaldDude Jul 15 '14 at 11:58