本文整理汇总了Python中pyglet.gl.glPopMatrix函数的典型用法代码示例。如果您正苦于以下问题:Python glPopMatrix函数的具体用法?Python glPopMatrix怎么用?Python glPopMatrix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glPopMatrix函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: chain
def chain(self):
gl.glPushMatrix()
p = self.position
r = self.rotation
gl.glMultMatrixf(
raw(
r[0][0],
r[1][0],
r[2][0],
0.0,
r[0][1],
r[1][1],
r[2][1],
0.0,
r[0][2],
r[1][2],
r[2][2],
0.0,
p[0],
p[1],
p[2],
1.0,
)
)
self.material.apply()
self.render()
self.material.unapply()
for c in self.children:
c.chain()
gl.glPopMatrix()
示例2: rotate
def rotate(self,ang,rx,ry,rz):
glPushMatrix()
glLoadIdentity()
glRotatef(ang,rx,ry,rz)
glMultMatrixf(self.matrix)
self.matrix=get_model_matrix()
glPopMatrix()
示例3: render
def render(self, geometry):
""" Add the sphere to the view.
:param scene: The view to render the model into
:type scene: pyglet_helper.objects.View
"""
# Renders a simple sphere with the #2 level of detail.
if self.radius == 0.0:
return
self.init_model(geometry)
coverage_levels = [30, 100, 500, 5000]
lod = self.lod_adjust(geometry, coverage_levels, self.pos, self.radius)
gl.glPushMatrix()
self.model_world_transform(geometry.gcf, self.scale).gl_mult()
self.color.gl_set(self.opacity)
if self.translucent:
# Spheres are convex, so we don't need to sort
gl.glEnable(gl.GL_CULL_FACE)
# Render the back half (inside)
gl.glCullFace(gl.GL_FRONT)
geometry.sphere_model[lod].gl_render()
# Render the front half (outside)
gl.glCullFace(gl.GL_BACK)
geometry.sphere_model[lod].gl_render()
else:
# Render a simple sphere.
geometry.sphere_model[lod].gl_render()
gl.glPopMatrix()
示例4: draw
def draw(self):
# set up projection
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glViewport(self.x, self.y, self.width, self.height)
gl.glOrtho(0, self.width, 0, self.height, self.near, self.far)
gl.glMatrixMode(gl.GL_MODELVIEW)
fx, fy = self._determine_focus()
w2 = self.width / 2
h2 = self.height / 2
x1, y1 = fx - w2, fy - h2
x2, y2 = fx + w2, fy + h2
gl.glPushMatrix()
gl.glTranslatef(self.width / 2 - fx, self.height / 2 - fy, 0)
for layer in self.layers:
if hasattr(layer, 'x'):
translate = layer.x or layer.y
else:
translate = False
if translate:
gl.glPushMatrix()
gl.glTranslatef(layer.x, layer.y, 0)
layer.draw()
if translate:
gl.glPopMatrix()
gl.glPopMatrix()
示例5: _layerProjectLocalToScreenUndo
def _layerProjectLocalToScreenUndo(self):
"""Undoes the _layerProjectLocalToScreen() operation."""
if self._scissorBox is None and self.localBounds is None:
return
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glPopMatrix()
gl.glMatrixMode(gl.GL_MODELVIEW)
示例6: render
def render(self, scene):
"""Add the cone to the scene.
:param scene: The view to render the model into
:type scene: pyglet_helper.objects.View
"""
if self.radius == 0:
return
self.init_model(scene)
coverage_levels = [10, 30, 90, 250, 450]
lod = self.lod_adjust(scene, coverage_levels, self.pos, self.radius)
length = self.axis.mag()
gl.glPushMatrix()
self.model_world_transform(scene.gcf, Vector([length, self.radius,
self.radius])).gl_mult()
self.color.gl_set(self.opacity)
if self.translucent:
gl.glEnable(gl.GL_CULL_FACE)
# Render the back half.
gl.glCullFace(gl.GL_FRONT)
scene.cone_model[lod].gl_render()
# Render the front half.
gl.glCullFace(gl.GL_BACK)
scene.cone_model[lod].gl_render()
else:
scene.cone_model[lod].gl_render()
gl.glPopMatrix()
示例7: draw_objects
def draw_objects(self):
'''called in the middle of ondraw after the buffer has been cleared'''
self.create_objects()
glPushMatrix()
if self.orthographic:
glTranslatef(0, 0, -3 * self.dist) # Move back
else:
glTranslatef(0, 0, -self.dist) # Move back
# Rotate according to trackball
glMultMatrixd(build_rotmatrix(self.basequat))
# Move origin to bottom left of platform
platformx0 = -self.build_dimensions[3] - self.parent.platform.width / 2
platformy0 = -self.build_dimensions[4] - self.parent.platform.depth / 2
glTranslatef(platformx0, platformy0, 0)
for obj in self.parent.objects:
if not obj.model \
or not obj.model.loaded \
or not obj.model.initialized:
continue
glPushMatrix()
glTranslatef(*(obj.offsets))
glTranslatef(*(obj.centeroffset))
glRotatef(obj.rot, 0.0, 0.0, 1.0)
glScalef(*obj.scale)
obj.model.display()
glPopMatrix()
glPopMatrix()
示例8: flush_labels
def flush_labels(self):
gl.glClear(gl.GL_DEPTH_BUFFER_BIT)
gl.glPushMatrix()
gl.glTranslatef(-self.game.camera_x * defs.WINDOW_SCALE[0],
-self.game.camera_y * defs.WINDOW_SCALE[1], 0)
for label, x, y, scale in self.labels:
if scale:
gl.glPushMatrix()
label.anchor_x = 'center'
label.anchor_y = 'center'
gl.glTranslatef(x * defs.WINDOW_SCALE[0],
y * defs.WINDOW_SCALE[1], 0)
gl.glScalef(*scale)
label.x = label.y = 0
label.draw()
gl.glPopMatrix()
else:
label.x = x * defs.WINDOW_SCALE[0]
label.y = y * defs.WINDOW_SCALE[1]
label.draw()
self.labels = []
gl.glColor3f(1, 1, 1)
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glPopMatrix()
# self.fps_label.draw()
self.game.score.draw()
示例9: on_draw
def on_draw(self):
pyglet.gl.glClearColor(0.2,0.2,0.8,1)
self.clear()
gl.glPushMatrix()
gl.glTranslatef(self.camera[0], self.camera[1], 0)
pyglet.gl.glColor4f(1,1,1,1)
for territory in self.landmass.land_terrs:
for tri in territory.triangles:
pyglet.gl.glColor4f(*territory.color)
pyglet.graphics.draw(
3, pyglet.gl.GL_TRIANGLES, ('v2f', tri)
)
for line in territory.lines:
pyglet.gl.glColor4f(*line.color)
self.draw_line(line.a.x, line.a.y, line.b.x, line.b.y)
for terr in self.landmass.sea_terrs:
for line in terr.lines:
pyglet.gl.glColor4f(*line.color)
self.draw_line(line.a.x, line.a.y, line.b.x, line.b.y)
if self.draw_capitals:
for terr in itertools.chain(self.landmass.land_terrs, self.landmass.sea_terrs):
pyglet.gl.glColor4f(1,1,1,1)
w = terr.label.content_width/2+2
h = terr.label.content_height/2
self.draw_rect(terr.x-w, terr.y-h, terr.x+w, terr.y+h)
pyglet.gl.glColor4f(1,1,1,1)
self.batch.draw()
gl.glPopMatrix()
示例10: draw_ents
def draw_ents(self, ents):
for ent in ents:
glPushMatrix()
glTranslatef(ent.body.position.x, ent.body.position.y, 0)
glRotatef(ent.body.angle * 180 / pi, 0, 0, 1)
ent.batch.draw()
glPopMatrix()
示例11: on_draw
def on_draw(self, dt=0):
env.dt = dt
if self.load_countdown == 0:
if self.music_countdown > 0:
self.music_countdown -= dt
if self.music_countdown <= 0:
music.new_song('The_Creature_Sneaks')
if self.mode == GUI:
gl.glLoadIdentity()
if env.scale_factor != 1.0:
gl.glPushMatrix()
env.scale()
gl.glClearColor(1,1,1,1)
self.clear()
gui.draw_card()
if gui.current_card == gui.START: self.start_game()
if gui.current_card == gui.QUIT: pyglet.app.exit()
if gui.current_card == gui.LOAD: self.load_game()
if env.scale_factor != 1.0:
gl.glPopMatrix()
elif self.load_countdown > 1:
self.draw_load_screen()
self.load_countdown -= 1
else:
self.init_resources()
self.init_gui()
self.load_countdown = 0
示例12: draw_axes
def draw_axes(self):
'draw x y z axis in r g b with text labels'
gl.glPushMatrix()
gl.glScalef( 1.1, 1.1, 1.1)
o = 0, 0, 0
x = 1, 0, 0
y = 0, 1, 0
z = 0, 0, 1
verts = numpy.array([ o, x, o, y, o, z], dtype=constants.DTYPE )
colors = numpy.array([ x, x, y, y, z, z], dtype=constants.DTYPE )
idxs = numpy.cast[constants.INTDTYPE]( numpy.mgrid[:6] )
self.drawlines( verts, colors, idxs)
def draw_axis_label( name, xyz):
'draw a single label'
gl.glPushMatrix()
gl.glTranslatef( xyz[0], xyz[1], xyz[2] )
gl.glScalef( .01, .01, .01 )
gl.glRotatef( 90, 0, 1, 0 )
gl.glRotatef( 90, 0, 0, 1 )
pyglet.text.Label(name).draw()
gl.glPopMatrix()
draw_axis_label( 'x', x)
draw_axis_label( 'y', y)
draw_axis_label( 'z', z)
gl.glPopMatrix()
示例13: draw
def draw(self):
if self.graph:
glPushMatrix()
glScalef(self.scale, self.scale, 1.0)
self.graph.draw()
glPopMatrix()
self.grid.batch.draw()
示例14: draw
def draw(self):
if self._dirty:
self._context = Context()
self._parts = []
self.free()
self.render()
self.build_vbo()
self._dirty = False
# set
gl.glEnable(self._texture.target)
gl.glBindTexture(self._texture.target, self._texture.id)
gl.glPushAttrib(gl.GL_COLOR_BUFFER_BIT)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glPushMatrix()
self.transform()
# cuadric.begin()
self._vertex_list.draw(gl.GL_TRIANGLES)
# cuadric.end()
# unset
gl.glPopMatrix()
gl.glPopAttrib()
gl.glDisable(self._texture.target)
示例15: display
def display(self, mode_2d=False):
with self.lock:
glPushMatrix()
glTranslatef(self.offset_x, self.offset_y, 0)
glEnableClientState(GL_VERTEX_ARRAY)
has_vbo = isinstance(self.vertex_buffer, VertexBufferObject)
if self.display_travels:
self._display_travels(has_vbo)
glEnable(GL_LIGHTING)
glEnableClientState(GL_NORMAL_ARRAY)
glEnableClientState(GL_COLOR_ARRAY)
glMaterialfv(GL_FRONT, GL_SPECULAR, vec(1, 1, 1, 1))
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, vec(0, 0, 0, 0))
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50)
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE)
self._display_movements(has_vbo)
glDisable(GL_LIGHTING)
glDisableClientState(GL_COLOR_ARRAY)
glDisableClientState(GL_VERTEX_ARRAY)
glDisableClientState(GL_NORMAL_ARRAY)
glPopMatrix()