• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python gl.glClear函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyglet.gl.glClear函数的典型用法代码示例。如果您正苦于以下问题:Python glClear函数的具体用法?Python glClear怎么用?Python glClear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了glClear函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:apalm112,项目名称:arcade,代码行数:25,代码来源:vbo_test_04.py


示例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)
开发者ID:apalm112,项目名称:arcade,代码行数:30,代码来源:a_quick_test5.py


示例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
开发者ID:jordanupmc,项目名称:soccersimulator,代码行数:30,代码来源:interfaces.py


示例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()
开发者ID:zzuzzy,项目名称:PyLadies,代码行数:29,代码来源:myPong.py


示例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()
开发者ID:Hugoagogo,项目名称:citySquare,代码行数:7,代码来源:menu.py


示例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()
开发者ID:Hugoagogo,项目名称:Alison-in-Wonderland,代码行数:34,代码来源:main.py


示例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()
开发者ID:Hugoagogo,项目名称:citySquare,代码行数:7,代码来源:main.py


示例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()
开发者ID:noonat,项目名称:deathbeam,代码行数:26,代码来源:draw.py


示例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()
开发者ID:anden3,项目名称:Python,代码行数:35,代码来源:Pac-Man+v2.py


示例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()
开发者ID:jackha,项目名称:mandel,代码行数:26,代码来源:mandel_gl.py


示例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)
开发者ID:ChunyangSun,项目名称:VisionAndPhysicsEngine,代码行数:7,代码来源:demo3.py


示例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()
开发者ID:noonat,项目名称:deathbeam,代码行数:28,代码来源:score.py


示例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)
开发者ID:Beliaar,项目名称:bGrease,代码行数:7,代码来源:world.py


示例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()
开发者ID:DomNomNom,项目名称:Jumpy2D,代码行数:30,代码来源:Engine.py


示例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)
开发者ID:carloscabo,项目名称:geometric-bot,代码行数:26,代码来源:test_pyglet_gl.py


示例16: on_draw

def on_draw():
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)
    gl.glMatrixMode(gl.GL_MODELVIEW)
    gl.glLoadIdentity()

    for block in blocks:
        draw_block(block)
开发者ID:ChunyangSun,项目名称:VisionAndPhysicsEngine,代码行数:7,代码来源:demo1.py


示例17: OnDraw

 def OnDraw(self, *args, **kwargs):
     """Draw the window."""
     self.pygletcontext.set_current()
     glClearColor(*self.color_background)
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     self.draw_objects()
     self.canvas.SwapBuffers()
开发者ID:pavlog,项目名称:Printrun,代码行数:7,代码来源:panel.py


示例18: on_draw

 def on_draw(self):
     gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
     gl.glMatrixMode(gl.GL_MODELVIEW)
     gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
     if self.app.show_fps:
         self.fps_display.draw()
     self.app.on_draw()
开发者ID:pauleveritt,项目名称:asteroids,代码行数:7,代码来源:arcadeng.py


示例19: clear_window

 def clear_window(self, color):
     '''
     Clear window color and depth buffers, using the given color
     '''
     r, g, b, _ = color
     gl.glClearColor(r, g, b, 1.0)
     gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
开发者ID:tartley,项目名称:gloopy,代码行数:7,代码来源:render.py


示例20: drawing

def drawing():
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)  # smaz obsah okna (vybarvi na cerno)
    gl.glColor3f(0, 1, 0)  # nastav barvu kresleni na zelenu

    ### Plots the snake body
    for i in range(0,len(snake_position)-1):
        draw_rectangle(PIECE*snake_position[i][0],PIECE*snake_position[i][1],PIECE*(snake_position[i][0]+1),PIECE*(snake_position[i][1]+1))

    ### Snake head in blue
    gl.glColor3f(0, 0, 1)
    draw_rectangle(PIECE*snake_position[-1][0],PIECE*snake_position[-1][1],PIECE*(snake_position[-1][0]+1),PIECE*(snake_position[-1][1]+1))
    
    ### Food
    draw_rectangle(PIECE*food_position[0],PIECE*food_position[1],PIECE*(food_position[0]+1),PIECE*(food_position[1]+1))
    ### Score
    draw_text(str(N-20),PIECE*SCORE_POSITION[0],PIECE*SCORE_POSITION[1],'left', PIECE*FONT_SIZE)
    ### Walls
    gl.glColor3f(0, 1, 0)  # nastav barvu kresleni na zelenu   
    draw_rectangle(0, 0, PIECE*WALL_THICKNESS, PIECE*HEIGHT)
    draw_rectangle(0, 0, PIECE*WIDTH, PIECE*WALL_THICKNESS)
    draw_rectangle(PIECE*WIDTH-PIECE*WALL_THICKNESS,0,PIECE*WIDTH,PIECE*HEIGHT)
    draw_rectangle(0,PIECE*HEIGHT-PIECE*WALL_THICKNESS,PIECE*WIDTH,PIECE*HEIGHT)

    if QUIT_SIGNAL==1:
        draw_text('GAME OVER',PIECE*WIDTH//2-PIECE*FONT_SIZE*4,PIECE*HEIGHT//2-PIECE*FONT_SIZE//2,'left', PIECE*FONT_SIZE)
开发者ID:SDRU,项目名称:had,代码行数:25,代码来源:Snake.py



注:本文中的pyglet.gl.glClear函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gl.glClearColor函数代码示例发布时间:2022-05-25
下一篇:
Python gl.glBlendFunc函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap