def build_display_list(self): if not self.lit: opengl.glDisable(opengl.GL_LIGHTING) opengl.glColor4f(*self._color) opengl.glScalef(self._size, -self._size, 1.0) w, h = self._font.get_print_size(self._text) if self.center_x == 0: opengl.glTranslatef(-w / 2.0, 0.0, 0.0) elif self.center_x == 1: opengl.glTranslatef(-w, 0.0, 0.0) if self.center_y == 0: opengl.glTranslatef(0.0, -h / 2.0, 0.0) elif self.center_y == 1: opengl.glTranslatef(0.0, -h, 0.0) if self._auto_flip: opengl.glEnable(opengl.GL_CULL_FACE) self._font.draw(self._text, 0.0, 0.0, 0.0, 1) opengl.glTranslatef(w, 0.0, 0.0) opengl.glScalef(-1.0, 1.0, 1.0) self._font.draw(self._text, 0.0, 0.0, 0.0, 1) opengl.glDisable(opengl.GL_CULL_FACE) else: self._font.draw(self._text, 0.0, 0.0, 0.0) opengl.glEnable(opengl.GL_BLEND) # Font.draw calls glDisable(GL_BLEND) if not self.lit: opengl.glEnable(opengl.GL_LIGHTING)
def activated(self): f1 = self.amplitude * (math.cos(self.angle) + 1.0) f2 = 1.0 - 2.0 * f1 opengl.glMatrixMode(opengl.GL_TEXTURE) opengl.glLoadIdentity() # Needed, because activated() may be called several time without inactivated being called opengl.glTranslatef(f1, f1, 0.0) opengl.glScalef(f2, f2, 1.0) opengl.glMatrixMode(opengl.GL_MODELVIEW)