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

Re: [pygame] Using PyOpenGL for 2D graphics



Richard Jones wrote:
[snip other stuff not relevant to me teasing Richard]
But fundamentally, GFX* is just using a GL context, and pygame and pyglet both provide one of
those.

Quick, untested translation of Simon's example to pyglet:


 1  from pyglet import window, image
 2  from gfx import gl
3 4 w = window.Window(800, 600)
w is window here...
 5  gl.init((800,600))       # I assume this is just setting up a projection :)
6 7 im = image.load('ball.png')
 8  texture_id = im.texture.id
 9  w,h = im.width, im.height
and, whoops, you reassigned it to the width here :D
Good thing this isn't *tested* code or I'd be wondering about you, Richard ;)
10  while not w.has_exit:
11      w.dispatch_events()
12      gl.draw_quad((0,0),((0,0),(0,h),(w,h),(w,0)), texture_id=texture_id)
13      w.flip()
I was confused as to how you were flipping an integer... 2s complement? :D
-Luke