本文整理汇总了Python中pyglet.gl.glClear函数的典型用法代码示例。如果您正苦于以下问题:Python glClear函数的具体用法?Python glClear怎么用?Python glClear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glClear函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_draw
def on_draw(self):
"""
Render the screen.
"""
start = time.time()
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glDisable(GL.GL_BLEND)
GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.vertex_vbo_id)
GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
GL.glVertexPointer(2, GL.GL_FLOAT, 0, 0)
GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.color_vbo_id)
GL.glEnableClientState(GL.GL_COLOR_ARRAY)
GL.glColorPointer(3, GL.GL_FLOAT, 0, 0)
offset = 0
for shape in self.shape_list:
render_rect_filled(shape, offset)
offset += 4
elapsed = time.time() - start
print(elapsed)
示例2: 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)
示例3: render
def render(self):
try:
if self._kill:
pyg_stop()
return
if self.state:
if self._create_draw:
self.create_drawable_objects()
if self._to_update:
self._update_sprites()
if self._rebuild_panel:
self.panel.from_list(
sorted([(score.points, k[0], score.str_nocolor()) for k, score in self.scores.items()],
reverse=True))
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
self._background.draw()
for d in self._sprites.values():
d.draw()
self.hud.draw()
self.panel.draw()
return True
else:
for d in self.get_welcome():
d.draw()
return True
except Exception, e:
time.sleep(0.0001)
print(e, traceback.print_exc())
raise e
示例4: vykresli
def vykresli():
#Vykresleni hraciho pole
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
nakresli_obdelnik(0, 0, SIRKA, VYSKA, mode = gl.GL_LINE_STRIP)
#vykresleni pulici cary
nakresli_caru(SIRKA//2, 0, SIRKA//2, VYSKA)
#micek
nakresli_obdelnik(*micek, mode = gl.GL_QUADS)
#palky
nakresli_obdelnik(*palka1, mode = gl.GL_QUADS)
nakresli_obdelnik(*palka2, mode = gl.GL_QUADS)
#nazev hry
label = pyglet.text.Label("Hra PONG",
font_size = NADPIS_y,
x = window.width, y = window.height - NADPIS_y,
anchor_x = 'right')
label.draw()
#vykresleni micku
#vykresleni palek
#nastaveni pocatecniho skore, zobrazeni skor
vypis_skore()
示例5: on_draw
def on_draw(self):
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
gl.glColor3ub(255,255,255)
self.heading.draw()
for row in self.items:
for item in row:
item.draw()
示例6: on_draw
def on_draw(self):
self.parent.set_caption(str(pyglet.clock.get_fps()))
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
gl.glColor4ub(*[255,255,255,255])
self.room.bg.blit(0,0)
self.room.render()
gl.glColor4ub(255,255,255,255)
self.player.draw()
self.room.lightbatch.draw()
self.player.draw_eye()
self.player.draw_integrity()
if self.pause:
gl.glColor4ub(50,50,50,150)
left = self.message['text'].x-self.message['text'].width/2 -5
down = self.message['text'].y-self.message['text'].height/2 -5
right = self.message['text'].x+self.message['text'].width/2 + 5
up = self.message['text'].y+self.message['text'].height/2 + 5
gl.glRecti(left,down,right,up)
gl.glLineWidth(2)
gl.glColor4ub(200,200,200,200)
gl.glBegin(gl.GL_LINE_LOOP)
gl.glVertex2i(left,down)
gl.glVertex2i(left,up)
gl.glVertex2i(right,up)
gl.glVertex2i(right,down)
gl.glEnd()
gl.glLineWidth(1)
gl.glColor4ub(255,255,255,255)
self.message['text'].draw()
self.message['helper'].draw()
self.message['sprite'].draw()
示例7: on_draw
def on_draw(self):
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
self.grid.draw()
self.score_bar.draw()
self.time_bar.draw()
if self.show_scores:
self.grid.draw_scores()
示例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: start
def start():
gl.glClearColor(0.0, 0.0, 0.0, 1.0)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
global width, height, scale, pacman
pacman = Pacman()
scale = 20
w = board_width * scale
h = board_height * scale + 100
window.set_size(w, h)
x, y = window.get_location()
window.set_location(x, y - 150)
width = w // scale
height = h // scale
enemies['red'] = Enemy('red')
enemies['pink'] = Enemy('pink')
enemies['cyan'] = Enemy('cyan')
enemies['orange'] = Enemy('orange')
parse_board()
draw_board()
draw_dots()
draw_ui()
draw_score()
draw_lives()
set_speeds(0.075)
pyglet.clock.schedule_once(toggle_mode, 7)
pyglet.clock.schedule_interval(game_loop, 1 / 60)
pyglet.app.run()
示例10: run
def run(self):
while not self.has_exit:
dt = pyglet.clock.tick()
self.dispatch_events()
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
gl.glLoadIdentity()
self.shader.use()
self.shader["real"] = self.real
self.shader["w"] = self.w
self.shader["imag"] = self.imag
self.shader["h"] = self.h
gl.glBegin(gl.GL_QUADS)
gl.glVertex3f(0.0, 0.0, 0.0)
gl.glVertex3f(0.0, self.height, 0.0)
gl.glVertex3f(self.width, self.height, 0.0)
gl.glVertex3f(self.width, 0.0, 0.0)
gl.glEnd()
self.shader.stop()
if self.show_fps:
self.fps.draw()
if self.auto_zoom_in:
self.zoom_in(dt)
if self.auto_zoom_out:
self.zoom_out(dt)
self.key_move(dt=dt)
self.flip()
示例11: on_draw
def on_draw():
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
# draw_obj(bear, bear_tex)
draw_obj(ball, ball_tex)
示例12: draw
def draw(self):
gl.glClear(gl.GL_DEPTH_BUFFER_BIT)
if self.game.game_over:
if self.game.game_lost:
gl.glBegin(gl.GL_QUADS)
gl.glColor3f(1, 1, 1)
gl.glVertex3f(0, 0, -0.9)
gl.glVertex3f(0, defs.WINDOW_HEIGHT, -0.9)
gl.glVertex3f(defs.WINDOW_WIDTH, defs.WINDOW_HEIGHT, -0.9)
gl.glVertex3f(defs.WINDOW_WIDTH, 0, -0.9)
gl.glEnd()
self.you_died.draw()
self.you_died2.draw()
if not self.died:
for name in self.VALUES:
getattr(self, name + '_label').color = (0, 0, 0, 255)
self.died = True
else:
gl.glBegin(gl.GL_QUADS)
gl.glColor3f(0, 0, 0)
gl.glVertex3f(0, 0, -0.9)
gl.glVertex3f(0, defs.WINDOW_HEIGHT, -0.9)
gl.glVertex3f(defs.WINDOW_WIDTH, defs.WINDOW_HEIGHT, -0.9)
gl.glVertex3f(defs.WINDOW_WIDTH, 0, -0.9)
gl.glEnd()
self.you_win.draw()
for name in self.VALUES:
getattr(self, name + '_label').draw()
示例13: on_draw
def on_draw(self, gl=pyglet.gl):
"""Clear the current OpenGL context, reset the model/view matrix and
invoke the `draw()` methods of the renderers in order
"""
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
gl.glLoadIdentity()
BaseWorld.draw_renderers(self)
示例14: run
def run(self, dt):
## UPDATE ##
# timestep ala http://gafferongames.com/game-physics/fix-your-timestep/
if dt > .25: # avoid spiral of death (updating taking longer than framerate)
dt = .25
self.accumulatedFrameTime += dt
while self.accumulatedFrameTime >= self.updateRate:
self.accumulatedFrameTime -= self.updateRate
self.levelTime = time.time() - self.levelStartTime
for entity in self.groups['updating']:
entity.update(self.updateRate) # update all entities
self._processRemoving()
self._processAdding()
for level in self.groups['level']:
level.update(self.updateRate) # this will do the physics
## DRAW ##
gl.glClearColor(0,0,0, 0)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
gl.glLoadIdentity()
self.camera.track() # does camera work (such as what it focuses on)
for name in self.drawLayerNames:
shift = Vec2d() if name.startswith('UI') else None
with self.camera.shiftView(shift):
for entity in self.drawLayers[name]: # TODO: not iterate over batched things
entity.draw()
self.drawLayersBatch[name].draw()
self.fps_display.draw()
示例15: render_to_texture
def render_to_texture():
# select the target to draw into
gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, framebuffer)
draw_buffers = (gl.GLenum * 1)(gl.GL_COLOR_ATTACHMENT0)
gl.glDrawBuffers(1, draw_buffers)
gl.glViewport(0, 0, FB_WIDTH, FB_HEIGHT)
# clear the destination
gl.glClearColor(0.5, 0.6, 0.7, 1.0)
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
# prepare the rendering
gl.glUseProgram(render_program)
# send the vertex data
data = (COLOR_VERTEX * 3)(((-0.6, -0.5), (1.0, 0.0, 0.0, 1.0)),
((0.6, -0.5), (0.0, 1.0, 0.0, 1.0)),
((0.0, 0.5), (0.0, 0.0, 1.0, 1.0)))
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, render_vertexbuffer)
gl.glBufferData(gl.GL_ARRAY_BUFFER, ctypes.sizeof(data), data, gl.GL_DYNAMIC_DRAW)
# draw using the vertex array for vertex information
gl.glBindVertexArray(render_vao)
gl.glDrawArrays(gl.GL_TRIANGLES, 0, 3)
gl.glBindVertexArray(0)