本文整理汇总了Python中pyglet.gl.glTranslatef函数的典型用法代码示例。如果您正苦于以下问题:Python glTranslatef函数的具体用法?Python glTranslatef怎么用?Python glTranslatef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glTranslatef函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: SetOrigin
def SetOrigin(self):
size = self.GetVirtualSize()
self.SetScrollbar(wx.HORIZONTAL, self.GetScrollPos(wx.HORIZONTAL), size[0],
self.map.width * 32 * self.zoom, refresh=True)
self.SetScrollbar(wx.VERTICAL, self.GetScrollPos(wx.VERTICAL), size[1],
self.map.height * 32 * self.zoom, refresh=True)
size = self.GetGLExtents()
if size.width <= 0:
size.width = 1
if size.height <= 0:
size.height = 1
self.tilemap.updateDimmingSprite(
int(size.width) + 2, int(size.height) + 2, 1 / self.zoom)
gl.glViewport(0, 0, size.width, size.height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(
0, size.width / self.zoom, 0, size.height / self.zoom, -1, 1)
x = (-self.GetScrollPos(wx.HORIZONTAL)) / self.zoom
y = ((-(self.map.height * 32) + size.height / self.zoom) +
self.GetScrollPos(wx.VERTICAL) / self.zoom)
gl.glTranslatef(x, y, 0)
self.translateX = -x + size.width / 2 / self.zoom
self.translateY = -y + size.height / 2 / self.zoom
self.onscreenwidth = int(size.width / self.zoom)
self.onscreenheight = int(size.height / self.zoom)
self.tilemap.setDimXY(self.translateX - 1, self.translateY + 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
开发者ID:borisblizzard,项目名称:arcreator,代码行数:28,代码来源:tilemap_panel.py
示例2: on_draw
def on_draw():
window.clear()
# Reset the "eye" back to the default location.
glLoadIdentity()
# Move the "eye" to the current location on the map.
# glTranslatef(delta[0], delta[1], 0.0)
offset = int(-mech.x+(window.width/2)-(mech.frame_size[0]/2)), int(-mech.y+(window.height/2)-(mech.frame_size[1]/2))
glTranslatef(offset[0], offset[1], 0.0)
ui_manager.frame_offset = offset
# TODO: [21:03] thorbjorn: DR0ID_: You can generally determine the range of tiles that are visible before your drawing loop, which is much faster than looping over all tiles and checking whether it is visible for each of them.
# [21:06] DR0ID_: probably would have to rewrite the pyglet demo to use a similar render loop as you mentioned
# [21:06] thorbjorn: Yeah.
# [21:06] DR0ID_: I'll keep your suggestion in mind, thanks
# [21:06] thorbjorn: I haven't written a specific OpenGL renderer yet, so not sure what's the best approach for a tile map.
# [21:07] thorbjorn: Best to create a single texture with all your tiles, bind it, set up your vertex arrays and fill it with the coordinates of the tiles currently on the screen, and then let OpenGL draw the bunch.
# [21:08] DR0ID_: for each layer?
# [21:08] DR0ID_: yeah, probably a good approach
# [21:09] thorbjorn: Ideally for all layers at the same time, if you don't have to draw anything in between.
# [21:09] DR0ID_: well, the NPC and other dynamic things need to be drawn in between, right?
# [21:09] thorbjorn: Right, so maybe once for the bottom layers, then your complicated stuff, and then another time for the layers on top.
game.tiles.draw()
game.humans.draw()
game.characters.draw()
game.projectile_batch.draw()
game.structure_batch.draw()
glLoadIdentity()
glTranslatef(0, 0, 0.0)
ui_manager.batch.draw()
game.message_queue.draw()
开发者ID:JStation,项目名称:omphalos,代码行数:32,代码来源:main.py
示例3: 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
示例4: 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
示例5: 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
示例6: 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
示例7: on_draw
def on_draw():
window.clear()
# Reset the "eye" back to the default location.
glLoadIdentity()
# Move the "eye" to the current location on the map.
glTranslatef(delta[0], delta[1], 0.0)
batch.draw()
开发者ID:bivab,项目名称:they_stole_two_million,代码行数:7,代码来源:tiledtmxloader.py
示例8: circle
def circle(pos, radius, color=(1.0,1.0,1.0), alpha=1.0,segments=6):
"""
Draws a circle with gluDisk
:param pos: center of the circle
:type pos: 2-float tuple
:param radius: radius of the circle
:type radius: float
:param color: the color in [0..1] range
:type color: 3-float tuple
:param alpha: the alpha value in [0..1] range
:param segments: number of segments
:type segments: int
"""
glDisable(GL_TEXTURE_2D)
c = gluNewQuadric()
glColor4f(color[0], color[1], color[2], alpha)
glPushMatrix()
glTranslatef(pos[0], pos[1], 0)
gluDisk(c, 0, radius, segments, 1)
glPopMatrix()
glColor4f(1.0,1.0,1.0,1.0)
glEnable(GL_TEXTURE_2D)
开发者ID:xoryouyou,项目名称:NetArgos,代码行数:30,代码来源:pool.py
示例9: on_draw
def on_draw(self):
"""
Render the screen.
"""
start = time.time()
float_size = ctypes.sizeof(ctypes.c_float)
record_len = 10 * float_size
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
GL.glColor4ub(255, 0, 0, 255)
GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.rect_vbo.vbo_id)
GL.glVertexPointer(2, GL.GL_FLOAT, record_len, 0)
for i in range(len(self.shape_list)):
shape = self.shape_list[i]
GL.glLoadIdentity()
GL.glTranslatef(shape.x, shape.y, 0)
GL.glDrawArrays(GL.GL_QUADS, i * 8, 8)
# GL.glDrawArrays(GL.GL_QUADS,
# 0,
# self.rect_vbo.size)
elapsed = time.time() - start
print(elapsed)
开发者ID:apalm112,项目名称:arcade,代码行数:30,代码来源:a_quick_test5.py
示例10: pan
def pan(self):
"""Performs panning (translation). Suggested to use with pan during displazing the scene:
1.cam.zoomAndRotate()
2.cam.pan()
3.draw(some 3D objects)
"""
glTranslatef(-self.position.x, -self.position.y, -self.position.z)
开发者ID:Ryu-CZ,项目名称:pyglet-lidar-viewer,代码行数:7,代码来源:controls.py
示例11: set_3d
def set_3d(self):
""" Configure OpenGL to draw in 3d.
"""
width, height = self.get_size()
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glViewport(0, 0, width, height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.gluPerspective(65.0, width / float(height), 0.1, DIST)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
x, y = self.rotation
gl.glRotatef(x, 0, 1, 0)
gl.glRotatef(-y, math.cos(math.radians(x)), 0, math.sin(math.radians(x)))
x, y, z = self.position
gl.glTranslatef(-x, -y, -z)
gl.glEnable(gl.GL_LIGHTING)
gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, GLfloat4(0.05,0.05,0.05,1.0))
gl.glEnable(gl.GL_COLOR_MATERIAL)
gl.glColorMaterial(gl.GL_FRONT, gl.GL_AMBIENT_AND_DIFFUSE)
#gl.glLightfv(gl.GL_LIGHT1,gl.GL_SPOT_DIRECTION, GLfloat3(0,0,-1))
gl.glLightfv(gl.GL_LIGHT1, gl.GL_AMBIENT, GLfloat4(0.5,0.5,0.5,1.0))
gl.glLightfv(gl.GL_LIGHT1, gl.GL_DIFFUSE, GLfloat4(1.0,1.0,1.0,1.0))
gl.glLightfv(gl.GL_LIGHT1, gl.GL_POSITION, GLfloat4(0.35,1.0,0.65,0.0))
#gl.glLightfv(gl.GL_LIGHT0,gl.GL_SPECULAR, GLfloat4(1,1,1,1))
gl.glDisable(gl.GL_LIGHT0)
gl.glEnable(gl.GL_LIGHT1)
开发者ID:spillz,项目名称:minepy,代码行数:32,代码来源:main.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():
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
# Gradient sky
l, b = world_to_screen((0, 0))
r, t = world_to_screen((W, H))
horizon = 177 / 255.0, 202 / 255.0, 1.0
zenith = 68 / 255.0, 0.5, 1.0
pyglet.graphics.draw(4, gl.GL_QUADS,
('v2f', [l, b, l, t, r, t, r, b]),
('c3f', sum([horizon, zenith, zenith, horizon], ())),
)
cx, cy = camera
tx, ty = world_to_screen((-cx + W * 0.5, -cy + H * 0.5))
gl.glTranslatef(tx, ty, 0)
batch.draw()
# Water
l, b = world_to_screen((0, 0))
r, t = world_to_screen((1000, WATER_LEVEL))
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
pyglet.graphics.draw(4, gl.GL_QUADS,
('v2f', [l, b, l, t, r, t, r, b]),
('c4f', [0, 0.2, 0.8, 0.5] * 4),
)
开发者ID:ChunyangSun,项目名称:VisionAndPhysicsEngine,代码行数:28,代码来源:combined.py
示例14: draw
def draw(self, frame):
# The gneneral plan here is:
# 1. Get the dots in the range of 0-255.
# 2. Create a texture with the dots data.
# 3. Draw the texture, scaled up with nearest-neighbor.
# 4. Draw a mask over the dots to give them a slightly more realistic look.
gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glLoadIdentity()
# Draw the dots in this color:
#gl.glColor3f(1.0, 0.5, 0.25)
gl.glScalef(1, -1, 1)
gl.glTranslatef(0, -DMD_SIZE[1]*DMD_SCALE, 0)
#data = frame.get_data_mult()
#this new jk_get_data will read the dots using the dmd function
#and convert them via the map to rGB.
data = self.jk_get_data(frame)
image = pyglet.image.ImageData(DMD_SIZE[0], DMD_SIZE[1], 'RGB', data, pitch=DMD_SIZE[0] * 3)
gl.glTexParameteri(image.get_texture().target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
image.blit(0, 0, width=DMD_SIZE[0]*DMD_SCALE, height=DMD_SIZE[1]*DMD_SCALE)
del image
gl.glScalef(DMD_SCALE/float(MASK_SIZE), DMD_SCALE/float(MASK_SIZE), 1.0)
gl.glColor4f(1.0, 1.0, 1.0, 1.0)
self.mask_texture.blit_tiled(x=0, y=0, z=0, width=DMD_SIZE[0]*MASK_SIZE, height=DMD_SIZE[1]*MASK_SIZE)
开发者ID:horseyhorsey,项目名称:SkeletonProcVisualPinball10,代码行数:33,代码来源:desktop_pyglet.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: translate
def translate(self,dx,dy,dz):
glPushMatrix()
glLoadIdentity()
glTranslatef(dx,dy,dz)
glMultMatrixf(self.matrix)
self.matrix=get_model_matrix()
glPopMatrix()
开发者ID:fos,项目名称:fos-legacy,代码行数:7,代码来源:camera.py
示例17: draw
def draw(self):
self.loadStartPosition()
gl.glRotatef(90.0, 0.0, 0.0, 1.0)
gl.glBegin(gl.GL_QUADS)
gl.glColor3f(1.0, 1.0, 0.0)
tenth = math.pi * 2.0 / 10.0
for z in [-0.1, 0.1]:
for i in xrange(5):
a = float(i) * tenth * 2.0
gl.glVertex3f(0.0, 0.0, z)
gl.glVertex3f(0.4 * math.cos(a - tenth), 0.4 * math.sin(a - tenth), z)
gl.glVertex3f(math.cos(a), math.sin(a), z)
gl.glVertex3f(0.4 * math.cos(a + tenth), 0.4 * math.sin(a + tenth), z)
for i in xrange(5):
a = float(i) * tenth * 2.0
gl.glVertex3f(0.4 * math.cos(a - tenth), 0.4 * math.sin(a - tenth), 0.1)
gl.glVertex3f(math.cos(a), math.sin(a), 0.1)
gl.glVertex3f(math.cos(a), math.sin(a), -0.1)
gl.glVertex3f(0.4 * math.cos(a - tenth), 0.4 * math.sin(a - tenth), -0.1)
gl.glVertex3f(0.4 * math.cos(a + tenth), 0.4 * math.sin(a + tenth), 0.1)
gl.glVertex3f(math.cos(a), math.sin(a), 0.1)
gl.glVertex3f(math.cos(a), math.sin(a), -0.1)
gl.glVertex3f(0.4 * math.cos(a + tenth), 0.4 * math.sin(a + tenth), -0.1)
gl.glEnd()
self.loadStartPosition()
gl.glTranslatef(0.0, 0.0, 0.1)
gl.glScalef(0.01, 0.01, 0.0)
self.label.draw()
gl.glLoadIdentity()
开发者ID:benatkin,项目名称:pyglet-stuff,代码行数:31,代码来源:goldstar.py
示例18: 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
示例19: 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
示例20: set_state
def set_state(self):
gl.glPushAttrib(gl.GL_ENABLE_BIT | gl.GL_TRANSFORM_BIT | gl.GL_CURRENT_BIT)
gl.glEnable(gl.GL_BLEND)
gl.glBlendFuncSeparate(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA, gl.GL_ONE, gl.GL_ONE_MINUS_SRC_ALPHA)
# To Allow Normal Rendering when Buffering with FrameBufferObject
# Without this option : problem with alpha blending when rendering buffered GUI textures
#Also in context.glContext
# Disable clipping planes to check culling.
gl.glEnable(gl.GL_CLIP_PLANE0)
gl.glEnable(gl.GL_CLIP_PLANE1)
gl.glEnable(gl.GL_CLIP_PLANE2)
gl.glEnable(gl.GL_CLIP_PLANE3)
# Left
gl.glClipPlane(gl.GL_CLIP_PLANE0, (gl.GLdouble * 4)(
1, 0, 0, -(self._clip_x - 1)))
# Top
gl.glClipPlane(gl.GL_CLIP_PLANE1, (gl.GLdouble * 4)(
0, -1, 0, self._clip_y))
# Right
gl.glClipPlane(gl.GL_CLIP_PLANE2, (gl.GLdouble * 4)(
-1, 0, 0, self._clip_x + self._clip_width + 1))
# Bottom
gl.glClipPlane(gl.GL_CLIP_PLANE3, (gl.GLdouble * 4)(
0, 1, 0, -(self._clip_y - self._clip_height)))
gl.glTranslatef(self.translate_x, self.translate_y, 0)
开发者ID:samcorcoran,项目名称:Kytten,代码行数:26,代码来源:override.py
注:本文中的pyglet.gl.glTranslatef函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论