[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Using PyOpenGL for 2D graphics



I've been told pyglet (http://pyglet.org/) is approaching a stable
release. AFAIK, Pyglet works without pygame.

If you're after brain dead simple 2D OpenGL functions only, try gfx.gl
in the GFX package. (http://cheeseshop.python.org/pypi/GFX).

Dumb GFX example:

 1 import pygame
 2 from pygame.locals import *
 3 from gfx import gl
 4
 5 pygame.init()
 6 flags =  OPENGL|DOUBLEBUF|HWSURFACE
 7 pygame.display.set_mode((800,600), flags)
 8 gl.init((800,600))
 9 image = pygame.image.load('ball.png')
10 texture_id = gl.load_texture(pygame.image.tostring(image, 'RGBA'),
image.get_size())
11 running = True
12 w,h = image.get_size()
13 while running:
14     if QUIT in (i.type for i in pygame.event.get()):
15         running = False
16     gl.draw_quad((0,0),((0,0),(0,h),(w,h),(w,0)), texture_id=texture_id)
17     pygame.display.flip()
18

--
   :: Simon Wittber
   :: http://www.linkedin.com/in/simonwittber
   :: phone: +61.4.0135.0685
   :: jabber/msn: simonwittber@xxxxxxxxx