Thanks Bruce,
I had amended another program, reducing it down to what seemed
minimally required though, as you say, there is likely some redundancy
left.  And optimisations can come after I have _something_ working.

The examples in pyglet tend to use decorators - that I want to avoid.
I can get my own such programs working no problem but prefer sub-
classing.

Thanks again but I'm really wanting to know what is wrong with my
code.
pawel.


On Oct 27, 6:11 am, Bruce Smith <[email protected]> wrote:
> It doesn't work for me either (on Mac OS 10.5), and I can't see why not --
> probably some trivial
> error in the code, or conceivably a pyglet bug in the specific combination
> of features you're using
> (though I doubt it). (There are several useless or redundant statements, a
> mutable class global
> (Bag.shapes), not clearing the depth buffer (except with self.clear() which
> I think does that), etc,
> but those don't seem to be the cause. )
>
> But I would suggest just starting with a known working, simple example --
> there are many
> available, including in pyglet's own examples directory -- and modifying
> that, to get going.
> (This would also get you going with a better way of using pyglet features,
> e.g. using a
> pyglet Batch rather than your own less efficient Bag class.)
>
> - Bruce Smith
>
>
>
> On Sun, Oct 25, 2009 at 2:04 AM, Pawel <[email protected]> wrote:
>
> > 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()- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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