コード例 #1
0
    def on_draw(self):
        gl.glClearColor(0, 0.0, 0.0, 1.)
        self.clear()
        width, height = self.get_size()
        gl.glViewport(0, 0, width, height)

        K_gl = get_projector_gl_intrinsics()
        TF = get_extrinsics()
        R = np.array([[-1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., -1., 0.],
                      [0., 0., 0., 1.]])
        full_mat = np.ascontiguousarray((K_gl.dot(TF.dot(R))).astype('f4'))
        with self.prog.using():
            self.prog.uniforms.Mvp = full_mat.tolist()
            gl.glEnable(gl.GL_DEPTH_TEST)
            gl.glEnable(gl.GL_BLEND)
            gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
            gl.glPointSize(25.)
            distance = (0, 0, 1)
            gl.glPointParameterfv(gl.GL_POINT_DISTANCE_ATTENUATION,
                                  (gl.GLfloat * 3)(*distance))
            gl.glEnable(gl.GL_POINT_SPRITE)
            self.vertex_info.draw(gl.GL_POINTS)

        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glOrtho(0, width, 0, height, -1, 1)
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()
        gl.glMatrixMode(gl.GL_TEXTURE)
        gl.glLoadIdentity()
        gl.glDisable(gl.GL_DEPTH_TEST)
        gl.glDisable(gl.GL_BLEND)

        self.fps_display.draw()
コード例 #2
0
    def setup_scene(self):
        " Load the assets in the scene "

        # Get the suzanne object from the blend file
        assets = blend.BlenderFile('_assets.blend')
        bsuzanne = assets.list('Object').find_by_name('Suzanne')

        # Get the vertices data of the suzanne object
        suz_data = bsuzanne.data
        vertices, indices = [], []

        for v in suz_data.mvert:
            vertices.append(v.co)

        for edge in suz_data.medge:
            indices.append((edge.v1, edge.v2))

        # Pack the vertices data of the suzanne object to be used by opengl
        suzanne = Buffer.array('(3f)[position]', GL_STATIC_DRAW)
        suzanne_indices = Buffer.element('(2S)[elem]', GL_STATIC_DRAW)
        suzanne.init(vertices)
        suzanne_indices.init(indices)
        self.suzanne = (suzanne, suzanne_indices, len(suzanne_indices) * 2)

        # Map the attribute and bind the buffer
        suzanne.bind()
        suzanne_indices.bind()
        self.shader.map_attributes(suzanne)

        # Set the background color
        glClearColor(0.1, 0.1, 0.1, 1.0)

        # Close the assets file
        assets.close()
コード例 #3
0
ファイル: OGLshapes.py プロジェクト: jgkawell/HARE
    def __init__(self,
                 objList=[],
                 caption='Pyglet Rendering Window',
                 dispWidth=640,
                 dispHeight=480,
                 clearColor=[0.7, 0.7, 0.8, 1]):
        """ Instantiate the environment with a list of objhects to render """
        super(OGL_App, self).__init__(resizable=True,
                                      caption=caption,
                                      width=dispWidth,
                                      height=dispHeight)
        glClearColor(*clearColor)  # Set the BG color for the OGL window

        # URL: https://www.opengl.org/discussion_boards/showthread.php/165839-Use-gluLookAt-to-navigate-around-the-world
        self.camera = [
            2,
            2,
            2,  # eyex    , eyey    , eyez    : Camera location , point (world) , XYZ
            0,
            0,
            0,  # centerx , centery , centerz : Center of the camera focus , point (world) , XYZ
            0,
            0,
            1
        ]  # upx     , upy     , upz     : Direction of "up" in the world frame , vector , XYZ

        self.renderlist = objList
        self.showFPS = False
コード例 #4
0
ファイル: main.py プロジェクト: spillz/minepy
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()
コード例 #5
0
    def draw(self):
        # draw a black background
        gl.glClearColor(0, 0, 0, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
#        gl.glMatrixMode(gl.GL_PROJECTION)
#        gl.glLoadIdentity()
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()
        gl.glDisable(gl.GL_DEPTH_TEST)
        self.camera.set_matrix()
        self.starfield.draw(self.camera)

        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glEnable(gl.GL_BLEND)
        particle_system.draw()

        vp = self.camera.get_viewport()
        culled = self.spatial_hash.potential_intersection(vp)
        for o in culled:
            o.draw()

        for o in self.non_collidable_objects:
            o.draw()

        self.hud.draw()
コード例 #6
0
ファイル: EditorGLPanel.py プロジェクト: boisei0/arcreator
	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)
コード例 #7
0
ファイル: rendering.py プロジェクト: lyu-xg/gym-gridverse
    def render(self, return_rgb_array=False, *, other_drawables=[]):
        glClearColor(1, 1, 1, 1)
        self.window.switch_to()
        self.window.dispatch_events()
        self.window.clear()

        self.transform.enable()
        for geom in self.geoms:
            geom.render()
        for geom in self.onetime_geoms:
            geom.render()
        self.transform.disable()

        for drawable in other_drawables:
            drawable.draw()

        arr = None
        if return_rgb_array:
            buff = pyglet.image.get_buffer_manager().get_color_buffer()
            image_data = buff.get_image_data()
            arr = np.frombuffer(image_data.get_data(), dtype=np.uint8)
            # 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(buff.height, buff.width, 4)
            arr = arr[::-1, :, 0:3]

        self.window.flip()
        self.onetime_geoms = []
        return arr if return_rgb_array else self.isopen
コード例 #8
0
ファイル: a_quick_test5.py プロジェクト: apalm112/arcade
    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))
コード例 #9
0
 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()
コード例 #10
0
    def on_draw(self):
        gl.glClearColor(0, 0, 0, 0)
        self.clear()
        gl.glViewport(0, 0, self.width, self.height)
        now = time.clock() - self._start_time
        now *= self._speed
        with self.bufferA:
            with self.shaderA:
                self.shaderA.uniformf("iTime", now)
                self.shaderA.uniformi("iFrame", self._frame_count)
                gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)

        with self.bufferB:
            with self.shaderB:
                self.shaderB.uniformf("iTime", now)
                gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)

        with self.shaderC:
            self.shaderC.uniformf("iTime", now)
            gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)

        if self.video_on and (self._frame_count % self.sample_rate == 0):
            self.write_video_frame()

        self._frame_count += 1
コード例 #11
0
ファイル: gluball.py プロジェクト: irskep/Gluball
 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
コード例 #12
0
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)
コード例 #13
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        gl.glClearColor(0.2, 0.3, 0.2, 0.1)
        self.triangle = drawing.Triangle((-.5, -.5), (.5, -.5), (0, .5))
        self.rect = drawing.Rect((-.5, -.5), (.5, -.5), (.5, .5), (-.5, .5),
                                 color=(180, 0, 0))
コード例 #14
0
ファイル: start.py プロジェクト: Zelenskiy/white_board_pylet
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     # E9FBCA    233/255,251/255,202/255
     self.set_minimum_size(400, 30)
     self.fonColor = (233 / 255, 251 / 255, 202 / 255, 1.0)
     self.gridColor = (208 / 255, 208 / 255, 208 / 255, 1.0)
     glClearColor(233 / 255, 251 / 255, 202 / 255, 1.0)
     self.figures = []
     self.buttons = [
         {
             'id': 1,
             'x': 5,
             'y': 5,
             'text': 'Pen',
             'image': pyglet.resource.image('img/pen.png'),
             'tool': 1
         },
         {
             'id': 2,
             'x': 40,
             'y': 5,
             'text': 'Erazer',
             'image': pyglet.resource.image('img/err.png'),
             'tool': 2
         },
         {
             'id': 3,
             'x': 75,
             'y': 5,
             'text': 'line',
             'image': pyglet.resource.image('img/line.png'),
             'tool': 3
         },
         {
             'id': 4,
             'x': 110,
             'y': 5,
             'text': 'line',
             'image': pyglet.resource.image('img/_ClearFill.png'),
             'tool': 4
         },
         {
             'id': 26,
             'x': 145,
             'y': 5,
             'text': 'line',
             'image': pyglet.resource.image('img/shot.png'),
             'tool': 26
         },
     ]
     self.poly = []
     self.x0, self.y0 = 0, 0
     self.cx, self.cy = 0, 0
     self.penWidth = 4
     self.errSize = 20
     self.tool = 1
     self.f = True
     self.fullscr = True
     self.penColor = (1, 0, 0, 1)
     self.step = 50
コード例 #15
0
 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
コード例 #16
0
    def on_draw():
        glClearColor(0.1, 0.1, 0.1, 1.0)
        window.clear()
        glLoadIdentity()

        for boid in boids:
            boid.draw()
コード例 #17
0
ファイル: grayscott.py プロジェクト: yumo509/grayscott
    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()
コード例 #18
0
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)
コード例 #19
0
 def on_draw(self):
     gl.glClearColor(0, 0, 0, 0)
     self.clear()
     gl.glViewport(0, 0, self.width, self.height)
     with self.shader:
         self.shader.uniformf("iTime", time.clock() - self._start_time)
         gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)
コード例 #20
0
ファイル: renderer_opengl.py プロジェクト: eulerlab/QDSpy
 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
コード例 #21
0
	def on_draw(self):
		# create projection matrix

		self.p_matrix.load_identity()
		self.p_matrix.perspective(90, float(self.width) / self.height, 0.1, 500)

		# create model view matrix

		self.mv_matrix.load_identity()
		self.mv_matrix.translate(0, 0, -1)
		self.mv_matrix.rotate_2d(self.x, math.sin(self.x / 3 * 2) / 2)

		# multiply the two matrices together and send to the shader program

		mvp_matrix = self.mv_matrix * self.p_matrix
		self.shader.uniform_matrix(self.shader_matrix_location, mvp_matrix)

		# draw stuff

		gl.glClearColor(0.0, 0.0, 0.0, 1.0)
		self.clear()

		gl.glDrawElements(
			gl.GL_TRIANGLES,
			len(indices),
			gl.GL_UNSIGNED_INT,
			None)
コード例 #22
0
ファイル: camera.py プロジェクト: Knio/miru
 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()
コード例 #23
0
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)
コード例 #24
0
ファイル: viewer.py プロジェクト: embr/trimesh
    def init_gl(self):
        gl.glClearColor(.93, .93, 1, 1)
        #glColor3f(1, 0, 0)

        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glEnable(gl.GL_CULL_FACE)
        gl.glEnable(gl.GL_LIGHTING)
        gl.glEnable(gl.GL_LIGHT0)
        gl.glEnable(gl.GL_LIGHT1)

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

        gl.glColorMaterial(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT_AND_DIFFUSE)
        gl.glEnable(gl.GL_COLOR_MATERIAL)
        gl.glShadeModel(gl.GL_SMOOTH)

        gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, _gl_vector(0.192250, 0.192250, 0.192250))
        gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, _gl_vector(0.507540, 0.507540, 0.507540))
        gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, _gl_vector(.5082730,.5082730,.5082730))

        gl.glMaterialf(gl.GL_FRONT, gl.GL_SHININESS, .4 * 128.0);

        gl.glEnable(gl.GL_BLEND) 
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) 
コード例 #25
0
def on_draw():
    # Draw the apriltag image on a quad with vert edges
    # from the vert buffer.

    gl.glClearColor(1.0, 0.0, 1.0, 1.0)
    window.clear()

    width, height = window.get_size()
    print("On draw %dx%d" % (width, height))
    gl.glViewport(0, 0, width, height)

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

    texture = base_tag.get_texture()
    gl.glTexParameteri(texture.target, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
    gl.glTexParameteri(texture.target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)

    base_tag.blit(apriltag_x,
                  apriltag_y,
                  width=apriltag_size,
                  height=apriltag_size)
    print("Done with draw")
コード例 #26
0
ファイル: Pac-Man v2.py プロジェクト: anden3/Python
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()
コード例 #27
0
ファイル: main.py プロジェクト: spillz/minepy
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()
コード例 #28
0
    def glSetup(self):
        gl.glClearColor(0.2, 0.2, 0.3, 1)
        gl.glColor3f(1, 1, 1)
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glEnable(gl.GL_CULL_FACE)
        gl.glEnable(gl.GL_NORMALIZE)

        gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, vec(50, 50, 10, 0))
        gl.glLightfv(gl.GL_LIGHT0, gl.GL_SPECULAR, vec(5, 5, 10, 1))
        gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, vec(1, 1, 1, 1))
        gl.glLightfv(gl.GL_LIGHT1, gl.GL_AMBIENT, vec(0, 0, 0, 1.0))
        gl.glLightfv(gl.GL_LIGHT1, gl.GL_SPECULAR, vec(0.6, 0.6, 0.6, 1.0))
        gl.glLightfv(gl.GL_LIGHT1, gl.GL_DIFFUSE, vec(0.8, 0.8, 0.8, 1))
        gl.glLightfv(gl.GL_LIGHT1, gl.GL_POSITION, vec(-10.0, -20.0, 20.0, 0))

        # Create a Material and Group for the Model
        diffuse = [0.5, 0.5, 0.3, 1.0]
        ambient = [0.5, 0.5, 0.3, 1.0]
        specular = [1.0, 1.0, 1.0, 1.0]
        emission = [0.0, 0.0, 0.0, 1.0]
        shininess = 50
        material = pyglet.model.Material("", diffuse, ambient, specular,
                                         emission, shininess)
        self.group = pyglet.model.MaterialGroup(material=material)

        # Create a Material and Group for the ground plane
        diffuse = [0.02, 0.02, 0.023, 1.0]
        ambient = [0.01, 0.01, 0.01, 1.0]
        specular = [0.05, 0.05, 0.07, 1.0]
        emission = [0.0, 0.0, 0.0, 1.0]
        shininess = 10
        material2 = pyglet.model.Material("ground", diffuse, ambient, specular,
                                          emission, shininess)
        self.group2 = pyglet.model.MaterialGroup(material=material2)
コード例 #29
0
    def on_draw(self):
        gl.glClearColor(0, 0, 0, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        # vertex_list.draw(vert_mode)

        # window.clear()
        self.polys.draw(GL_TRIANGLES)
コード例 #30
0
ファイル: unmain.py プロジェクト: Aradina/PygClar
def setup():
    # Sets the color of the sky.
    gl.glClearColor(0.5, 0.69, 1.0, 1)
    gl.glEnable(gl.GL_CULL_FACE)
    # Enables multisampling.
    gl.glEnable(gl.GL_MULTISAMPLE)
    setup_fog()
コード例 #31
0
 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)
コード例 #32
0
    def __init__(self,
                 width: int,
                 height: int,
                 cube_size: int = 3,
                 paused: bool = False,
                 record: bool = False):
        config = pyglet.gl.Config(sample_buffers=1, samples=4, depth_size=1)
        super(Window, self).__init__(width, height, config=config)
        gl.glClearColor(0.5, 0.5, 0.5, 1)
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glEnable(gl.GL_CULL_FACE)

        self.position = [0, 0, -10]
        self.rotation = [30.0, -45.0, 0]

        self.cube = cb.Cube(cube_size)
        rot_method, self.moves = Window.rotation_wrapper_mapping(cube_size)
        self.rotation_method = getattr(self.cube, rot_method)

        self.faces = pyglet.graphics.Batch()
        self.cubies = []
        for piece in self.cube.pieces:
            self.cubies.append(Cubie(piece, batch=self.faces))

        self.angle_step = np.pi / 20
        self.commands = []
        self.current_command = [None, 0]
        self.current_state = 0.0
        self.is_paused = paused

        self.record = record
        self.frame_count = 0
コード例 #33
0
ファイル: rendering.py プロジェクト: NetColby/DNRL
 def render(self, return_rgb_array: bool = False) -> np.array:
     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()
         if hasattr(image_data, "data"):
             image_data = image_data.data
             arr = np.fromstring(image_data, dtype=np.uint8, sep="")
         elif hasattr(image_data, "get_data"):
             arr = np.fromstring(image_data.get_data(),
                                 dtype=np.uint8,
                                 sep="")
         else:
             return
         # 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
コード例 #34
0
ファイル: render.py プロジェクト: tartley/gloopy
 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)
コード例 #35
0
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)
コード例 #36
0
ファイル: Craftmine.py プロジェクト: anden3/Python
    def on_draw(self):
        gl.glClearColor(0.5, 0.69, 1.0, 1.0)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        self.cam.apply()

        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glEnable(gl.GL_LIGHTING)
        gl.glEnable(gl.GL_CULL_FACE)

        render_light((2, 10, -2))

        gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT_AND_DIFFUSE, to_gl_float([0.7, 0.7, 0.7, 1.0]))

        check_draw_distance(self.cam.current_chunk)

        if len(meshing_list) > 0:
            chunks[meshing_list.pop(0)].mesh()

        for chunk in active_chunks:
            chunks[chunk].vbo.draw()

        self.cam.ui_mode()

        self.cam.ui.draw()

        self.cam.perspective()
        self.cam.apply()
コード例 #37
0
ファイル: Engine.py プロジェクト: DomNomNom/Jumpy2D
  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()
コード例 #38
0
ファイル: panel.py プロジェクト: pavlog/Printrun
 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()
コード例 #39
0
 def on_resize(self, width, height):
     '''
     calculate perspective matrix
     '''
     v_ar = width/float(height)
     usableWidth = int(min(width, height*v_ar))
     usableHeight = int(min(height, width/v_ar))
     ox = (width - usableWidth) // 2
     oy = (height - usableHeight) // 2
     glViewport(ox, oy, usableWidth, usableHeight)
     glMatrixMode(GL_PROJECTION)
     glLoadIdentity()
     gluPerspective(60, usableWidth/float(usableHeight), 0.1, 3000.0)
     ''' set camera position on modelview matrix
     '''
     glMatrixMode(GL_MODELVIEW)
     glLoadIdentity()
     gluLookAt(width/2.0, height/2.0, height/1.1566,
         width/2.0, height/2.0, 0,
         0.0, 1.0, 0.0)
     ''' update scene controller with size
     '''
     self.controller.resize(width, height)
     #clears to a grey.
     glClearColor(0.4,0.4,0.4,0.)
     return pyglet.event.EVENT_HANDLED
コード例 #40
0
ファイル: main.py プロジェクト: Tythos/hypyr
	def setupOpenGL(self):
		gl.glClearColor(0., 0., 0., 1.)
		gl.glColor4f(1.0, 0.0, 0.0, 0.5)
		gl.glEnable(gl.GL_DEPTH_TEST)
		#gl.glEnable(gl.GL_CULL_FACE)
		gl.glEnable(gl.GL_BLEND)
		gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
コード例 #41
0
ファイル: joystick.py プロジェクト: sergio-py2/meteor
def main():
    global gJoyStick
    global show

    gl.glClearColor(0.0, 0.0, 0.0, 0.0)
    gl.glEnable( gl.GL_BLEND)
    gl.glBlendFunc( gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)


    #pyglet.clock.set_fps_limit(60)
    pyglet.clock.schedule_interval(update, 1/30.)

    window.set_vsync(True)

    for x in pyglet.input.get_joysticks():
        #readStick(x)
        pass

    gJoyStick = pyglet.input.get_joysticks()[0]
    gJoyStick.open()

    for x in gJoyStick.device.get_controls():
        #print x
        pass

    if len(sys.argv) > 1 and sys.argv[1] == '-b':
        show = 'buttons'
    else:
        show = 'axes'


    pyglet.app.run()
    print ""
コード例 #42
0
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)
コード例 #43
0
ファイル: rendering.py プロジェクト: zhoushiyang12/PettingZoo
    def render(self, return_rgb_array=False):
        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()

        pyglet.gl.glMatrixMode(pyglet.gl.GL_PROJECTION)
        pyglet.gl.glLoadIdentity()
        gluOrtho2D(0, self.window.width, 0, self.window.height)
        for geom in self.text_lines:
            geom.render()

        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.get_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
コード例 #44
0
ファイル: vbo_test_01.py プロジェクト: apalm112/arcade
    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)
コード例 #45
0
ファイル: Pac-Man v2.py プロジェクト: anden3/Python
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()
コード例 #46
0
ファイル: gl_helper.py プロジェクト: whiteRa2bit/hmr2.0
def gl_set_background(background):
    # if user passed a background color use it
    if background is None:
        background = np.ones(4)  # default background color is white
    else:
        background = background.astype(np.float64) / 255.0  # convert to 0.0-1.0 float

    gl.glClearColor(*background)
コード例 #47
0
ファイル: renderer.py プロジェクト: tartley/sole-scion
 def clear(self, color):
     "Clear the window background with the given color"
     glClearColor(
         color[0] / 255,
         color[1] / 255,
         color[2] / 255,
         1.0)
     glClear(GL_COLOR_BUFFER_BIT)
コード例 #48
0
ファイル: glpanel.py プロジェクト: jamesra/nornir-pyre
 def _InitGLState(self):
     gl.glEnable(gl.GL_BLEND)
     gl.glBlendFunc(gl.GL_ONE, gl.GL_ONE)
     gl.glEnable(gl.GL_TEXTURE_2D)
     gl.glShadeModel(gl.GL_SMOOTH)
     gl.glClearColor(0, 0, 0, 1)
     # Rotated images can have a z-distance of more than one
     gl.glDepthRangef(0, 2)
コード例 #49
0
ファイル: glpanel.py プロジェクト: jamesra/nornir-pyre
 def _InitGLState(self):
     gl.glEnable(gl.GL_BLEND)
     gl.glBlendFunc(gl.GL_ONE, gl.GL_ONE)
     gl.glEnable(gl.GL_TEXTURE_2D)
     gl.glShadeModel(gl.GL_SMOOTH)
     gl.glClearColor(0, 0, 0, 1)
     #Rotated images can have a z-distance of more than one
     gl.glDepthRangef(0,2)
コード例 #50
0
ファイル: level_viewer.py プロジェクト: hakuji/game3
def init():
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glEnable(gl.GL_BLEND)
    gl.glClearColor(*BACKGROUND_COLOR)
    keys = key.KeyStateHandler()
    window.push_handlers(keys)
    state.khandler = keys
    pyglet.app.run()
コード例 #51
0
 def show(self):
     self.generate(600,400)
     self.window = pyglet.window.Window(self.image.width,self.image.height)
     gl.glClearColor(0,0,0,1)
     gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
     gl.glEnable(gl.GL_BLEND)
     self.window.push_handlers(self)
     pyglet.app.run()
コード例 #52
0
def set_background_color(color: Color):
    """
    This specifies the background color of the window.

    :param Color color: List of 3 or 4 bytes in RGB/RGBA format.
    """

    gl.glClearColor(color[0] / 255, color[1] / 255, color[2] / 255, 1)
コード例 #53
0
        def on_expose():
            gl.glClearColor(1.0, 1.0, 1.0, 1.0)
            gl.glClear(gl.GL_COLOR_BUFFER_BIT)

            img.blit(
                (win.width - img.width) / 2,
                (win.height - img.height) / 2
            )
コード例 #54
0
ファイル: wordle.py プロジェクト: rorito/TableTalk
 def show(self):
     self.generate(600,400)
     self.window = pyglet.window.Window(self.image.width,self.image.height)
     gl.glClearColor(0,0,0,1)
     gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
     gl.glEnable(gl.GL_BLEND)
     self.window.push_handlers(self)
     pyglet.app.run()
コード例 #55
0
ファイル: camera_test.py プロジェクト: tartley/sole-scion
 def setUp(self):
     self.window = Window(
         width=200, height=100, visible=False, caption="Camera_test setup")
     self.window.dispatch_events()
     glClearColor(0, 0, 0, 1)
     self.window.clear()
     self.world = World()
     self.camera = Camera((0, 0), 1)
コード例 #56
0
ファイル: preview.py プロジェクト: lidavidm/mathics-heroku
                def on_expose():
                    gl.glClearColor(1.0, 1.0, 1.0, 1.0)
                    gl.glClear(gl.GL_COLOR_BUFFER_BIT)

                    img.blit(
                        (win.width - img.width) / 2,
                        (win.height - img.height) / 2
                    )
コード例 #57
0
ファイル: hello_world.py プロジェクト: mraxilus/experiments
def on_draw():
    gl.glEnable(gl.GL_BLEND)
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glClearColor(0.5, 0.5, 0.5, 1)
    window.clear()
    label.draw()
    sprite.draw()
    fps_display.draw()
    pyglet.clock.tick()
コード例 #58
0
	def on_draw(self):
		gl.glClearColor(0.0, 0.0, 0.0, 1.0)
		self.clear()
		
		gl.glDrawElements(
			gl.GL_TRIANGLES,
			len(indices),
			gl.GL_UNSIGNED_INT,
			None)