I'm trying to draw some objects in Pyglet using the same Vertex List and 
transforming; unfortunately, I can't get the shape to appear on my screen. 
Why can't I see it? Is this a good way to draw the same shape in different 
places with different colors?

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


class PointySide:
    neither = 0
    left = 1
    right = 2
    both = 3


v_lists = {}
def getVList(psTup):
    if psTup in v_lists:
        return v_lists[psTup];
    vs = (0,0,3,0)
    for i,v in enumerate(psTup):
        if v & PointySide.right:
            vs = vs + (4,i*4+2)
        vs = vs + (3,i*4+4)
    
    for i,v in enumerate(psTup[::-1]): # in reverse now
        vs = vs + (0,i*4)
        print v
        if v & PointySide.left:
            vs = vs + (1,i*4+2)
    
    v_lists[psTup] = vs
    return vs


# Direct OpenGL commands to this window.
window = pyglet.window.Window()


t = (PointySide.both,PointySide.left)
l = getVList(t)
pointsnum = len(l)/2
vertex_list = pyglet.graphics.vertex_list(pointsnum,
    ('v2i/static',l),
    ('c3b/static',(255,0,0) * pointsnum) # * repeats a tuple, because python
)


@window.event
def on_draw():
    glClear(GL_COLOR_BUFFER_BIT)
    glLoadIdentity()
    glPushMatrix()
    glTranslatef(-10,-60,0)
    #glScalef(2,2,1)
     # # #
    pyglet.graphics.draw_indexed(4, pyglet.gl.GL_TRIANGLES,
    [0, 1, 2, 0, 2, 3],
    ('v2i', (100, 100,
             150, 100,
             150, 150,
             100, 150))
    )


    vertex_list.draw(GL_POLYGON);
    glPopMatrix()
    


pyglet.app.run()



-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to