当前位置: 首页>>代码示例>>Python>>正文


Python gl.glClearColor函数代码示例

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


在下文中一共展示了glClearColor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: 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

示例2: draw_objects

	def draw_objects( self ):
		"""Draws the objects on the canvas"""
		if not self.GLinitialized:
			return

		gl.glClearColor(0.93, 0.93, 0.93, 1)
		if self._image is None:
			return
		# Convert PIL image to pyglet image
		srcImage = pyglet.image.create(*self._image.size).get_image_data()
		pitch = -len('RGBA') * srcImage.width
		data = self._image.tostring()
		srcImage.set_data('RGBA', pitch, data)
		# Clear the canvas and calculate the region to draw
		tile_width = srcImage.width / self._rows
		tile_height = srcImage.height / self._columns
		x = self._coord[0] * tile_width
		y = self._coord[1] * tile_height
		y = srcImage.height - y - tile_height
		subimage = srcImage.get_region(x, y, tile_width, tile_height)
		subimage.align_x = subimage.align_y = 0
		# Branch by what mode is selected to draw
		if self._drawmode == 0: self.CropAndShrink(subimage)
		elif self._drawmode == 1: self.Shrink(subimage)
		elif self._drawmode == 2: self.StretchAspect(subimage)
		elif self._drawmode == 3: self.Cropped(subimage)
		elif self._drawmode == 4: self.Stretch(subimage)
		else: self.TopLeft(subimage)
		del (srcImage)
开发者ID:boisei0,项目名称:arcreator,代码行数:29,代码来源:EditorGLPanel.py

示例3: 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

示例4: setup

    def setup(self):
        """ Set up the game and initialize the variables. """

        # Set background to white
        GL.glClearColor(1, 1, 1, 1)

        self.rect_list = []
        self.shape_list = []

        for i in range(2000):
            x = random.randrange(0, SCREEN_WIDTH)
            y = random.randrange(0, SCREEN_HEIGHT)
            width = random.randrange(20, 71)
            height = random.randrange(20, 71)

            d_x = random.randrange(-3, 4)
            d_y = random.randrange(-3, 4)

            red = random.randrange(256)
            blue = random.randrange(256)
            green = random.randrange(256)
            alpha = random.randrange(256)
            color = (red, blue, green, alpha)

            shape = Shape()
            shape.x = x
            shape.y = y
            self.shape_list.append(shape)

            add_rect(self.rect_list, 0, 0, width, height, color)

        print("Creating vbo for {} vertices.".format(len(self.rect_list) // 2))
        self.rect_vbo = create_vbo_for_rects(self.rect_list)
        print("VBO {}".format(self.rect_vbo.vbo_id))
开发者ID:apalm112,项目名称:arcade,代码行数:34,代码来源:a_quick_test5.py

示例5: setup

def setup():
    """ Basic OpenGL configuration.

    """
    # Set the color of "clear", i.e. the sky, in rgba.
    gl.glClearColor(0.5, 0.69, 1.0, 1)
    # Enable culling (not rendering) of back-facing facets -- facets that aren't
    # visible to you.
    gl.glEnable(gl.GL_CULL_FACE)

    #gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_DST_ALPHA)
    #gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glBlendFunc(gl.GL_ZERO, gl.GL_SRC_COLOR)
    gl.glEnable(gl.GL_BLEND)
    gl.glAlphaFunc(gl.GL_GREATER, 0.5);
    gl.glEnable(gl.GL_ALPHA_TEST);
    # Set the texture minification/magnification function to GL_NEAREST (nearest
    # in Manhattan distance) to the specified texture coordinates. GL_NEAREST
    # "is generally faster than GL_LINEAR, but it can produce textured images
    # with sharper edges because the transition between texture elements is not
    # as smooth."
    gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
    gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
    gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE)
    setup_fog()
开发者ID:spillz,项目名称:minepy,代码行数:25,代码来源:main.py

示例6: 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

示例7: on_draw

    def on_draw():
        gl.glClearColor(1.0,1.0,1.0,1.0)
	window.clear()

        # Compute
        gl.glViewport(0, 0, width, height)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glOrtho(0, 1, 0, 1, -1, 1)
        gl.glMatrixMode(gl.GL_MODELVIEW)

        gl.glActiveTexture( gl.GL_TEXTURE1 )
	gl.glBindTexture(texture_s.target, texture_s.id)

        gl.glActiveTexture( gl.GL_TEXTURE0 )
	gl.glBindTexture(texture_uv.target, texture_uv.id)

        gl.glBindFramebufferEXT(gl.GL_FRAMEBUFFER_EXT, framebuffer)
	reaction_shader.bind()
        texture_uv.blit(x=0.0, y=0.0, width=1.0, height=1.0)
	reaction_shader.unbind()
        gl.glBindFramebufferEXT(gl.GL_FRAMEBUFFER_EXT, 0)

        # Render
        gl.glViewport(0, 0, window.width, window.height)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glOrtho(0, 1, 0, 1, -1, 1)
        gl.glMatrixMode(gl.GL_MODELVIEW)

	color_shader.bind()
        texture_uv.blit(x=0.0, y=0.0, width=1.0, height=1.0)
	color_shader.bind()
开发者ID:rougier,项目名称:grayscott,代码行数:33,代码来源:grayscott.py

示例8: setup

def setup():
    # One-time GL setup
    glClearColor(1, 1, 1, 1)
    glColor3f(1, 0, 0)
    glEnable(GL_DEPTH_TEST)
    glEnable(GL_CULL_FACE)

    # Uncomment this line for a wireframe view
    #glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)

    # Simple light setup.  On Windows GL_LIGHT0 is enabled by default,
    # but this is not the case on Linux or Mac, so remember to always
    # include it.
    glEnable(GL_LIGHTING)
    glEnable(GL_LIGHT0)
    glEnable(GL_LIGHT1)

    # Define a simple function to create ctypes arrays of floats:
    def vec(*args):
        return (GLfloat * len(args))(*args)

    glLightfv(GL_LIGHT0, GL_POSITION, vec(.5, .5, 1, 0))
    glLightfv(GL_LIGHT0, GL_SPECULAR, vec(.5, .5, 1, 1))
    glLightfv(GL_LIGHT0, GL_DIFFUSE, vec(1, 1, 1, 1))
    glLightfv(GL_LIGHT1, GL_POSITION, vec(1, 0, .5, 0))
    glLightfv(GL_LIGHT1, GL_DIFFUSE, vec(.5, .5, .5, 1))
    glLightfv(GL_LIGHT1, GL_SPECULAR, vec(1, 1, 1, 1))

    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, vec(0.5, 0, 0.3, 1))
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, vec(1, 1, 1, 1))
    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50)
开发者ID:encukou,项目名称:pyglet_helper,代码行数:31,代码来源:opengl.py

示例9: setup

 def setup(self):
   # One-time GL setup
   gl.glClearColor(1, 1, 1, 0)
   gl.glColor3f(1, 0, 0)
   gl.glEnable(gl.GL_DEPTH_TEST)
   gl.glEnable(gl.GL_CULL_FACE)
   gl.glDisable(gl.GL_LIGHTING)
开发者ID:mnzaki,项目名称:dlogical,代码行数:7,代码来源:circuit_drawing_area.py

示例10: create_window

 def create_window(self, _iScr=0, _title="", _dx=0, _dy=0, _left=0, _top=0,
                   _scale=1.0, _isScrOvl=False, _iScrGUI=0, _offset=(0,0)):
   """ If the renderer was initialized, create a window instance and store
       it in the internal window list. For parameters, see Window class.
   """
   if self.isReady:
     self.winList.append(Window(self, _iScr, _title, _dx, _dy, _left, _top,
                                _scale, _isScrOvl, _iScrGUI, _offset))    
     '''
     if len(self.winList) == 1:
     # Is the first window, set some general OpenGL properties
     #
     '''
     GL.glClearColor(0., 0., 0., 0.)
     GL.glColor3f(1., 1., 1.)
     GL.glDisable(GL.GL_DEPTH_TEST)
     GL.glEnable(GL.GL_BLEND)
     GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
     '''
     GL.glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
     GL.glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
 
     GL.glShadeModel(GL_FLAT) # GL_FLAT or GL_SMOOTH
     GL.glEnable(GL_POINT_SMOOTH)
     '''
     return self.winList[-1]
   else:  
     return None
开发者ID:eulerlab,项目名称:QDSpy,代码行数:28,代码来源:renderer_opengl.py

示例11: _setLightsAndEffects

 def _setLightsAndEffects(self):
     fNoLight = (4 * gl.GLfloat)()
     fNoLight[:] = [0,0,0,0]
     gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, fNoLight);
     gl.glClearColor(*self.clear_color)
     for effect in self.camera.effects:
         effect.enable()
开发者ID:Knio,项目名称:miru,代码行数:7,代码来源:camera.py

示例12: copy_texture_to_screen

def copy_texture_to_screen():
    # select the target to draw into
    gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0)
    gl.glViewport(0, 0, window.width, window.height)

    # clear the destination
    gl.glClearColor(0.4, 0.4, 0.4, 1.0)
    gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

    # select the program for drawing
    gl.glUseProgram(copy_program)

    # send the vertex data
    data = (TEXTURE_VERTEX * 8)(((-0.9, -0.9), (0.0, 0.0)),
                                ((0.5, -0.9), (1.0, 0.0)),
                                ((0.5, 0.5), (1.0, 1.0)),
                                ((-0.9, 0.5), (0.0, 1.0)),

                                ((0.6, 0.6), (0.0, 1.0)),
                                ((1.0, 0.6), (1.0, 1.0)),
                                ((1.0, 1.0), (1.0, 0.0)),
                                ((0.6, 1.0), (0.0, 0.0)),
                                )

    gl.glBindBuffer(gl.GL_ARRAY_BUFFER, copy_vertexbuffer)
    gl.glBufferData(gl.GL_ARRAY_BUFFER, ctypes.sizeof(data), data, gl.GL_DYNAMIC_DRAW)


    # draw
    gl.glBindVertexArray(copy_vao)
    gl.glDrawArrays(gl.GL_QUADS, 0, 8)
    gl.glBindVertexArray(0)
开发者ID:carloscabo,项目名称:geometric-bot,代码行数:32,代码来源:test_pyglet_gl.py

示例13: render

 def render(self, return_rgb_array=False):
     gl.glClearColor(1,1,1,1)
     self.window.clear()
     self.window.switch_to()
     self.window.dispatch_events()
     self.transform.enable()
     for geom in self.geoms:
         geom.render()
     for geom in self.onetime_geoms:
         geom.render()
     self.transform.disable()
     arr = None
     if return_rgb_array:
         buffer = pyglet.image.get_buffer_manager().get_color_buffer()
         image_data = buffer.get_image_data()
         arr = np.fromstring(image_data.data, dtype=np.uint8, sep='')
         # In https://github.com/openai/gym-http-api/issues/2, we
         # discovered that someone using Xmonad on Arch was having
         # a window of size 598 x 398, though a 600 x 400 window
         # was requested. (Guess Xmonad was preserving a pixel for
         # the boundary.) So we use the buffer height/width rather
         # than the requested one.
         arr = arr.reshape(buffer.height, buffer.width, 4)
         arr = arr[::-1,:,0:3]
     self.window.flip()
     self.onetime_geoms = []
     return arr
开发者ID:PangYanbo,项目名称:gym-extensions,代码行数:27,代码来源:gym_rendering.py

示例14: update_display

def update_display(verts,tex_coords,texture=bird_texture):
    gl.glClearColor(0.2, 0.4, 0.5, 1.0)

    gl.glEnable(texture.target)
    gl.glBindTexture(texture.target, texture.id)

    gl.glPushAttrib(gl.GL_COLOR_BUFFER_BIT)
   
    gl.glEnable(gl.GL_ALPHA_TEST)                                                            
    gl.glAlphaFunc (gl.GL_GREATER, .1)                             
    #gl.glEnable(gl.GL_BLEND)                                                            
    #gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)                             
    gl.glEnable(gl.GL_DEPTH_TEST) 

    gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
    gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY)

    n=len(verts[:])
    #TODO verts._buffer.ctypes.data is awkward
    gl.glVertexPointer(3, vert_dtype.gl, 0, verts[:].ctypes.data)
    gl.glTexCoordPointer(3, tex_dtype.gl, 0, tex_coords[:].ctypes.data)
    gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, n)
    #unset state
    gl.glPopAttrib()
    gl.glDisable(texture.target)
开发者ID:Permafacture,项目名称:data-oriented-pyglet,代码行数:25,代码来源:animated_test.py

示例15: setup

    def setup(self):
        """ Set up the game and initialize the variables. """

        # Set background to white
        GL.glClearColor(1, 1, 1, 1)

        self.shape_list = []

        for i in range(2000):
            x = random.randrange(0, SCREEN_WIDTH)
            y = random.randrange(0, SCREEN_HEIGHT)
            width = random.randrange(20, 71)
            height = random.randrange(20, 71)

            d_x = random.randrange(-3, 4)
            d_y = random.randrange(-3, 4)

            red = random.randrange(256)
            green = random.randrange(256)
            blue = random.randrange(256)
            alpha = random.randrange(256)
            shape_type = random.randrange(2)
            shape = Rectangle(x, y, width, height, d_x, d_y,
                              (red, green, blue))
            self.shape_list.append(shape)
开发者ID:apalm112,项目名称:arcade,代码行数:25,代码来源:vbo_test_01.py


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