[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Pygame and OpenGL




Well, I created a simple OpenGL app just for testing my ideas, and it
works just fine. The following code Works For Me(tm):

import sys
import pygame
from pygame.locals import *
from OpenGL.GL import *
 
def draw ():
    glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
 
    glMatrixMode (GL_PROJECTION)
    glLoadIdentity ()
    glOrtho ( 0, 640, 0, 480, -1, 1 )
 
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
 
    glColor3f ( 255.0, 0.0, 0.0 )
 
    glBegin (GL_TRIANGLES)
    glVertex2i (200, 100)
    glVertex2i (320, 300)
    glVertex2i (440, 100)
    glEnd ();
 
    pygame.display.flip ()

pygame.init()
pygame.display.set_mode ( (640, 480), OPENGL | DOUBLEBUF)
 
while 1:
    event = pygame.event.wait ()
 
    if event.type == QUIT:
        sys.exit ( 0 )
 
    draw ()


Ugly code, but works. Paints a red triangle in the screen. So interfacing
with Python works as I hoped it would do. I'm very impressed.

-- 
         Real stupidity beats artificial intelligence every time.
                                              -- Terry Pratchett, Hogfather

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org