Hey guys,

I'm trying to use the 2d drawing primitives written by Flávio to
render in the 2d portion of a 3d game.  Here's the code I'm trying to
call:
-->8--- snippy snippy -->8---

from pyglet.gl import *
from primitives import Circle, Line

CENTER = (150, 150)

class HUD:
    def __init__(self, center=CENTER):
        self.reticle = Reticle(center)
        self.active = True

    def draw(self):
        if self.active:
            self.reticle.draw()

class Reticle:
    def __init__(self, position=CENTER, color=(0, 1, 0, 1)):
        self.color = color
        self.position = position
        self.parts = []

        self.lines = [
            ((position[0], position[1]-4), (position[0], position[1]-12)),
            ((position[0], position[1]+4), (position[0], position[1]+12)),
            ((position[0]-4, position[1]), (position[0]-12, position[1])),
            ((position[0]+4, position[1]), (position[0]+12, position[1])),
        ]

        self.parts.append(
            Circle(self.position[0], self.position[1], width=10, stroke=0.5,
               style=GLU_LINE, color=self.color))

        for line in self.lines:
            print line
            self.parts.append(
                Line(a=line[0], b=line[1], stroke=1, color=self.color))

    def draw(self):
        for part in self.parts:
            part.render()

if __name__ == '__main__':
    from pyglet import window

    win = window.Window()

    hud = HUD((200, 200))

    while not win.has_exit:
        win.dispatch_events()
        win.clear()

        hud.draw()

        win.flip()


This works fine if I call it directly, but doesn't seem to display at
all when I call it in my game between these two methods (which is
similar to the stuff in the Turret Command demo):

    def mode2d(self):
        glLoadIdentity()
        glPushAttrib(GL_ENABLE_BIT)
        glEnable(GL_TEXTURE_2D)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        glDisable(GL_LIGHTING)
        glDisable(GL_DEPTH_TEST)
        glMatrixMode(GL_PROJECTION)
        glPushMatrix()
        glLoadIdentity()
        glOrtho(0, 1024, 0, 768, -1, 1)
        glMatrixMode(GL_MODELVIEW)

    def end_mode2d(self):
        glMatrixMode(GL_PROJECTION)
        glPopMatrix()
        glMatrixMode(GL_MODELVIEW)
        glPopAttrib()

Any idea what I'm doing wrong?  Everything else seems to be displaying
fine (the 3d world, the blits into the 2d part, etc).

Thanks,
--Patrick.

--~--~---------~--~----~------------~-------~--~----~
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