def __init__(self): dl_hud_prepare = _make_dl_hud_prepare() dl_hud_restore = _make_dl_hud_restore() self.level_dl = get_displaylist() self.lives_dl = get_displaylist() self.health_outline = get_displaylist() self.health_level = get_displaylist() self.master_dl = get_displaylist() glNewList(self.master_dl, GL_COMPILE) glCallList(dl_hud_prepare) glCallList(self.level_dl) glCallList(self.lives_dl) glCallList(self.health_outline) glCallList(self.health_level) glCallList(dl_hud_restore) glEndList()
def _create_displaylist(self, scale=1): self.renderlist = util.get_displaylist() glNewList(self.renderlist, GL_COMPILE) if scale != 1: glPushMatrix() glScaled(scale, scale, scale) self.render() if scale != 1: glPopMatrix() glEndList()
def _make_dl_hud_restore(): dl_num = get_displaylist() glNewList(dl_num, GL_COMPILE) glEnable(GL_DEPTH_TEST) glDepthMask(GL_TRUE) glEnable(GL_LIGHTING) glPopMatrix() glMatrixMode(GL_PROJECTION) glPopMatrix() glMatrixMode(GL_MODELVIEW) glEndList() return dl_num
def _create_displaylist(self, scale=1): """Create the display list. Sub-classes *should* call this sometime during the initialization """ self.renderlist = util.get_displaylist() glNewList(self.renderlist, GL_COMPILE) if scale != 1: glPushMatrix() glScaled(scale, scale, scale) self.render() if scale != 1: glPopMatrix() glEndList()
def __init__(self): dl_hud_prepare = _make_dl_hud_prepare() dl_hud_restore = _make_dl_hud_restore() dl_static = _make_dl_hud_static() # create hud element display lists self.level_dl = get_displaylist() self.lives_dl = get_displaylist() self.shields_outline = get_displaylist() self.shields_level = get_displaylist() # Create master display list self.master_dl = get_displaylist() glNewList(self.master_dl, GL_COMPILE) glCallList(dl_hud_prepare) glCallList(dl_static) glCallList(self.level_dl) glCallList(self.lives_dl) glCallList(self.shields_outline) glCallList(self.shields_level) glCallList(dl_hud_restore) glEndList()
def _make_dl_hud_prepare(): dl_num = get_displaylist() glNewList(dl_num, GL_COMPILE) glMatrixMode(GL_PROJECTION) glPushMatrix() glLoadIdentity() glOrtho(0, 1, 0, 1, -1, 1) glMatrixMode(GL_MODELVIEW) glPushMatrix() glLoadIdentity() glDisable(GL_DEPTH_TEST) glDepthMask(GL_FALSE) glDisable(GL_LIGHTING) glEndList() return dl_num
def __init__(self, pos, vel, ttl, color): super(BulletEnt, self).__init__(None, 1) self.pos = numpy.array(pos, dtype=float) self.velocity = vel self.speed = numpy.linalg.norm(vel) self.ttl = ttl try: self.dl = bullet_dl[color] except KeyError: self.dl = util.get_displaylist() glNewList(self.dl, GL_COMPILE) glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color) glutSolidSphere(5, 5, 5) glEndList() bullet_dl[color] = self.dl
def _make_dl_hud_static(): """Returns a displaylist that draws static elements of the hud""" dl_num = get_displaylist() glNewList(dl_num, GL_COMPILE) #glColor3f(0.0,1.0,0.0) #glBegin(GL_LINE_LOOP) #glVertex2d(0.5,0.5) #glVertex2d(0.6,0.5) #glVertex2d(0.6,0.6) #glVertex2d(0.5,0.6) #glEnd() render_string(0.01, 0.975, "Level:") render_string(0.2, 0.975, "Lives:") render_string(0.4, 0.975, "Shields:") glEndList() return dl_num
def _make_dl_hud_restore(): """Makes a displaylist that restores the modelview and projection matrices """ dl_num = get_displaylist() glNewList(dl_num, GL_COMPILE) glEnable(GL_DEPTH_TEST) glDepthMask(GL_TRUE) glEnable(GL_LIGHTING) glPopMatrix() glMatrixMode(GL_PROJECTION) glPopMatrix() glMatrixMode(GL_MODELVIEW) glEndList() return dl_num
def _make_dl_hud_prepare(): """Makes a displaylist that prepares the projection and modelview matrices for drawing the hud""" dl_num = get_displaylist() glNewList(dl_num, GL_COMPILE) glMatrixMode(GL_PROJECTION) glPushMatrix() glLoadIdentity() glOrtho(0, 1, 0, 1, -1, 1) glMatrixMode(GL_MODELVIEW) glPushMatrix() glLoadIdentity() glDisable(GL_DEPTH_TEST) glDepthMask(GL_FALSE) glDisable(GL_LIGHTING) glEndList() return dl_num
def __init__(self, pos, vel, ttl, color): super(BulletEnt, self).__init__( None, 1 ) self.pos = numpy.array(pos, dtype=float) self.velocity = vel self.speed = numpy.linalg.norm(vel) # Total time self.ttl = ttl try: self.dl = bullet_dl[color] except KeyError: self.dl = util.get_displaylist() glNewList(self.dl, GL_COMPILE) glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color) glutSolidSphere(5, 5, 5) glEndList() bullet_dl[color] = self.dl