Hi, (having used c++ and java before) I've so far ran a few simple
pyglet programs successfully, more or less copied from the
documentation.  Prefering to stick to OOP and not to use decorators I
wrote a program with the main window sub-classed, with one 'shape'
class and one 'bag' (for the shapes) class.  The trivial program is
below.  It runs without errors but I only get a blank black screen.
I'm assuming I've missed something obvious but haven't for the life of
me been able to figure out what that is.  Please point me in the right
direction.  I'm on linux.

pawel.

#!/usr/bin/python


import pyglet
import pyglet.graphics
from pyglet.gl import *

class Shape:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.verts = (0, 0,  x, 0,  x, y,  0, y)

    x = 0
    y = 0
    cols = (0, 125, 255,  0, 125, 125,  0, 125, 125,  0, 125, 255)
    verts = ()

    def draw(self):
        glLoadIdentity();
        vertex_list = pyglet.graphics.vertex_list(4,
            ('v2i', self.verts),
            ('c3i', self.cols) )
        vertex_list.draw(pyglet.gl.GL_POLYGON)
        print 'x, y = ', self.x, self.y
        print 'verts, cols = ', self.verts, self.cols

class Bag:
    shapes = []

    def __init__(self):
        pass

    def add(self, sh):
        self.shapes.append(sh)

    def draw(self):
        for i in range(len(self.shapes)):
            self.shapes[i].draw()


class myWindow(pyglet.window.Window):

    def on_draw(self):
        self.clear()
        glClear(GL_COLOR_BUFFER_BIT)
        glMatrixMode(GL_MODELVIEW)
        bag.draw()


win = myWindow()
bag = Bag()

k = Shape(10, 70)
bag.add(k)

l = Shape(65, 15)
bag.add(l)

pyglet.app.run()

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to