本文整理汇总了Python中pyglet.gl.glPushMatrix函数的典型用法代码示例。如果您正苦于以下问题:Python glPushMatrix函数的具体用法?Python glPushMatrix怎么用?Python glPushMatrix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glPushMatrix函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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()
开发者ID:manishjakhodecdn,项目名称:skyseam,代码行数:30,代码来源:viewer.py
示例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()
开发者ID:fos,项目名称:fos-legacy,代码行数:7,代码来源:camera.py
示例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()
开发者ID:encukou,项目名称:pyglet_helper,代码行数:33,代码来源:sphere.py
示例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()
开发者ID:bitcraft,项目名称:pyglet,代码行数:29,代码来源:view.py
示例5: _layerProjectLocalToScreen
def _layerProjectLocalToScreen(self):
"""Maps self.coordLocal to self.coordScreen within OpenGL."""
if self._scissorBox is None and self.localBounds is None:
return
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glPushMatrix()
gl.glLoadIdentity()
# gluOrtho2D declares the render space for the corners of the window.
# So, we want to set it up in such a way that our layer renders in
# the right place. In other words, determine window corners that
# map cl -> cs. All clipping, etc is already handled by the coordsLocal
# getter.
cs = self.coordsScreen
cl = self.coordsLocal
sw = self.scene.width
sh = self.scene.height
# Determine the window width and height. We want a local-sized chunk
# of this to correspond to a screen-sized chunk of the screen. That is,
# cl[2] / ww == cs[2] / sw
ww = cl[2] * sw / cs[2]
wh = cl[3] * sh / cs[3]
# cs[0] / sw = (x - nx) / ww
nx = cl[0] - cs[0] * ww / sw
ny = cl[1] - cs[1] * wh / sh
gl.gluOrtho2D(nx, nx+ww, ny, ny+wh)
gl.glMatrixMode(gl.GL_MODELVIEW)
开发者ID:wwoods,项目名称:pyglet_piss,代码行数:28,代码来源:layer.py
示例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()
开发者ID:encukou,项目名称:pyglet_helper,代码行数:33,代码来源:cone.py
示例7: 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()
开发者ID:noonat,项目名称:deathbeam,代码行数:26,代码来源:draw.py
示例8: 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()
开发者ID:pavlog,项目名称:Printrun,代码行数:27,代码来源:actors.py
示例9: on
def on(self):
gl.glPushMatrix()
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glPushAttrib(gl.GL_LIGHTING_BIT)
gl.glEnable(gl.GL_LIGHTING)
for l in self:
l.on()
开发者ID:Knio,项目名称:miru,代码行数:7,代码来源:camera.py
示例10: 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()
开发者ID:faustreg,项目名称:Printrun,代码行数:30,代码来源:gcview.py
示例11: 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()
开发者ID:tartley,项目名称:sole-scion,代码行数:7,代码来源:renderer.py
示例12: 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()
开发者ID:irskep,项目名称:Incontinents,代码行数:28,代码来源:demo.py
示例13: 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
开发者ID:irskep,项目名称:Gluball,代码行数:29,代码来源:gluball.py
示例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)
开发者ID:1414648814,项目名称:cocos,代码行数:27,代码来源:draw.py
示例15: draw_world_items
def draw_world_items(self, glyphs):
'''
Draw all passed glyphs
'''
shader = None
for position, orientation, glyph in glyphs:
gl.glPushMatrix()
gl.glTranslatef(*position)
if orientation and orientation != Orientation.Identity:
gl.glMultMatrixf(orientation.matrix)
if glyph.shader is not shader:
shader = glyph.shader
shader.use()
gl_wrap.glBindVertexArray(glyph.vao)
gl.glDrawElements(
gl.GL_TRIANGLES,
len(glyph.glindices),
glyph.index_type,
glyph.glindices
)
gl.glPopMatrix()
gl_wrap.glBindVertexArray(0)
Shader.unuse()
开发者ID:tartley,项目名称:gloopy,代码行数:30,代码来源:render.py
示例16: paint
def paint(self, peg):
batch = self.get_batch()
glPushMatrix()
glTranslatef(peg.x, peg.y, 0)
glRotatef(peg.angle, 0, 0, 1)
batch.draw()
glPopMatrix()
开发者ID:msarch,项目名称:py,代码行数:7,代码来源:shapes.py
示例17: drawSpace
def drawSpace(self, window):
gl.glPushMatrix()
# GL matrices are applied last-added-first, so this *is* the right
# order for pushing them.
gl.glTranslatef(-self.viewportOrigin[0], -self.viewportOrigin[1], 0.0)
if self.shake is not None:
# We want to rotate around the center of the current viewport
# vpc = view port center
vpc_x = self.viewportOrigin[0] + self.windowProps.windowWidth//2
vpc_y = self.viewportOrigin[1] + self.windowProps.windowHeight//2
gl.glTranslatef(vpc_x, vpc_y, 0.0)
gl.glRotatef(self.shake.getAngle(), 0, 0, 1)
gl.glTranslatef(-vpc_x, -vpc_y, 0.0)
ge = self.gameElements
ge.starField.draw()
ge.swarm.draw()
if not self.explodedMarker.done():
ge.ship.draw()
if self.endGame and not self.drawFrameMarker.done():
self.endGame.draw(window)
for shot in ge.shots:
if shot.alive:
shot.draw()
gl.glPopMatrix()
开发者ID:sergio-py2,项目名称:meteor,代码行数:34,代码来源:gamephase.py
示例18: draw
def draw(self):
glPushMatrix()
glTranslatef(self.xoffset, self.yoffset, self.zoffset)
def color(i):
if i % self.graduations_major == 0:
glColor4f(*self.color_grads_major)
elif i % (self.graduations_major / 2) == 0:
glColor4f(*self.color_grads_interm)
else:
if self.light: return False
glColor4f(*self.color_grads_minor)
return True
# draw the grid
glBegin(GL_LINES)
for i in range(0, int(math.ceil(self.width + 1))):
if color(i):
glVertex3f(float(i), 0.0, 0.0)
glVertex3f(float(i), self.depth, 0.0)
for i in range(0, int(math.ceil(self.depth + 1))):
if color(i):
glVertex3f(0, float(i), 0.0)
glVertex3f(self.width, float(i), 0.0)
glEnd()
# draw fill
glColor4f(*self.color_fill)
glRectf(0.0, 0.0, float(self.width), float(self.depth))
glPopMatrix()
开发者ID:Metamaquina,项目名称:Printrun,代码行数:33,代码来源:actors.py
示例19: draw
def draw(self):
# Update list of entities
# TODO this should actually update instead of recomputing all day, but, whatever
entity_batch = pyglet.graphics.Batch()
for _, entity in self.map_layer.children_names['entities'].children:
x, y = entity.position
w, h = entity.size
x0 = entity.position[0] - entity.image_anchor[0] * entity.scale
y0 = entity.position[1] - entity.image_anchor[1] * entity.scale
x1, y1 = x0 + w, y0 + h
entity_batch.add(4, gl.GL_QUADS, self.outlines_group,
('v2f', (x0, y0, x0, y1, x1, y1, x1, y0)),
('c4f', (1.0, 1.0, 0.0, 0.5) * 4))
# This is a diamond but at scale it looks enough like a dot
D = 3
entity_batch.add(4, gl.GL_QUADS, None,
('v2f', (x + D, y, x, y - D, x - D, y, x, y + D)),
('c4f', (1.0, 1.0, 0.0, 1.0) * 4))
# Collision footprint... kinda
R = entity.entity_type.shape
entity_batch.add(4, gl.GL_QUADS, None,
('v2f', (x - R, y - R, x + R, y - R, x + R, y + R, x - R, y + R)),
('c4f', (1.0, 1.0, 0.0, 0.2) * 4))
# TODO wtf is GL_CURRENT_BIT
gl.glPushMatrix()
self.transform()
self.grid_batch.draw()
entity_batch.draw()
gl.glPopMatrix()
开发者ID:eevee,项目名称:flora,代码行数:33,代码来源:debugger.py
示例20: draw_objects
def draw_objects(self):
'''called in the middle of ondraw after the buffer has been cleared'''
self.create_objects()
glPushMatrix()
# 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)
light_z = max(self.parent.platform.width, self.parent.platform.depth)
glLightfv(GL_LIGHT0, GL_POSITION, vec(0,
self.parent.platform.depth / 2,
light_z, 0))
glLightfv(GL_LIGHT1, GL_POSITION, vec(self.parent.platform.width,
self.parent.platform.depth / 2,
light_z, 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()
开发者ID:brodykenrick,项目名称:Printrun,代码行数:34,代码来源:gcview.py
注:本文中的pyglet.gl.glPushMatrix函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论