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


Python gl.glTexParameteri函数代码示例

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


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

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

示例2: tex_from_m

def tex_from_m(m, resize=4):
    #m = m.T
    shape = m.shape

    m = np.clip(m, -1, 1)
    m += 1
    m /= 2

    m *= 255

    # we need to flatten the array
    m.shape = -1

    # convert to GLubytes
    tex_data = (gl.GLubyte * m.size)( *m.astype('uint8') )

    # create an image
    # pitch is 'texture width * number of channels per element * per channel size in bytes'
    img = pyglet.image.ImageData(shape[1], shape[0], "I", tex_data, pitch = shape[1] * 1 * 1)

    texture = img.get_texture()   
    gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)   

    texture.width = shape[1] * resize                                                                                                                                                            
    texture.height = -shape[0] * resize                                                                                                                                                                                                                                                                                                                       
    return texture
开发者ID:JonComo,项目名称:stumbly,代码行数:26,代码来源:engine.py

示例3: buffer_texture

def buffer_texture(width, height):
    id_ = gl.GLuint()
    gl.glGenTextures(1, byref(id_))

    gl.glPushAttrib(gl.GL_ENABLE_BIT | gl.GL_TEXTURE_BIT)
    gl.glActiveTexture(gl.GL_TEXTURE0)
    gl.glEnable(gl.GL_TEXTURE_2D)

    gl.glBindTexture(gl.GL_TEXTURE_2D, id_)

    gl.glTexParameteri(gl.GL_TEXTURE_2D,
                       gl.GL_TEXTURE_MIN_FILTER,
                       gl.GL_LINEAR)
    gl.glTexParameteri(gl.GL_TEXTURE_2D,
                       gl.GL_TEXTURE_MAG_FILTER,
                       gl.GL_LINEAR)
    gl.glTexImage2D(
        gl.GL_TEXTURE_2D, 0, gl.GL_RGBA,
        width, height,
        0,
        gl.GL_RGBA, gl.GL_UNSIGNED_BYTE,
        (gl.GLubyte * (width*height * 4))(),
    )
    gl.glFlush()

    gl.glBindTexture(gl.GL_TEXTURE_2D, 0)
    gl.glPopAttrib()

    return id_
开发者ID:edne,项目名称:pineal,代码行数:29,代码来源:framebuffer.py

示例4: load_image

def load_image(filename, anchor_x=None, anchor_y=None):
    gl.glTexParameteri( gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE ) 
    gl.glTexParameteri( gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE )    
    img = pyglet.image.load(filename)#.get_texture(rectangle=True)
    img.anchor_x = anchor_x if anchor_x is not None else img.width // 2
    img.anchor_y = anchor_y if anchor_y is not None else img.height // 2 
    return img
开发者ID:facepalm,项目名称:bliss-station-game,代码行数:7,代码来源:main-pyglet.py

示例5: get_sprite

def get_sprite(filename):
    image = pyglet.image.load(os.path.join('sprites', filename))
    texture = image.get_texture()
    gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
    texture.width = texture.width * settings.scale
    texture.height = texture.height * settings.scale
    return texture
开发者ID:akstrfn,项目名称:flap.py,代码行数:7,代码来源:utils.py

示例6: register_font

def register_font(name, filename, width, height, font_map=None):
    """
    Register a PixFont.

    :Parameters:

        `name` : string
            Name of the font. It will be used to access it using `pixfont.get_font` and
            `pixfont.free_font`.
        `filename`: string
            File name of the image containing the pixel font.
        `width` : int
            Width of a character.
        `height`: int
            Height of a character.
        `font_map` : string (optional)
            String containing all the characters in the pixel font. By default the map is:

            `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?()@:/'., `

    After a font is registered by `register_font`, it can be used by obtaining a PixFont
    object with `pixfont.get_font`.

    """
    _map = font_map or default_map
    _fonts[name] = PixFont(name=name, image=pyglet.resource.image(filename), width=width, height=height, font_map=_map)
    gl.glTexParameteri(_fonts[name].texture.target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
    gl.glTexParameteri(_fonts[name].texture.target, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
开发者ID:reidrac,项目名称:pyglet-pixfont,代码行数:28,代码来源:pixfont.py

示例7: get_blocky_image

def get_blocky_image(name):
	import pyglet.gl as gl
	image = pyglet.resource.image(name)
	gl.glBindTexture(image.target, image.id)
	gl.glTexParameteri(image.target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
	gl.glTexParameteri(image.target, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
	return image
开发者ID:wkevina,项目名称:logic-game,代码行数:7,代码来源:entity.py

示例8: texture_from_data

def texture_from_data(internalformat, size, data_format, data_type, data):
    '''Create texture from a data buffer (whatever can be passed as pointer to ctypes)
    internalformat - GL_RGBA8 or GL_RGB8 recommended
    size - a 1-, 2- or 3-tuple describing the image sizes
    data_format - see 'format' parameter of glDrawPixels
    data_type - see 'type' parameter of glDrawPixels
    data - pointer to memory'''

    size = list(size)
    dimensions = len(size)
    binding = getattr(gl, 'GL_TEXTURE_BINDING_{0:d}D'.format(dimensions))
    target = getattr(gl,'GL_TEXTURE_{0:d}D'.format(dimensions))
    texImage = getattr(gl,'glTexImage{0:d}D'.format(dimensions))
    oldbind = ctypes.c_uint(0)
    gl.glGetIntegerv(binding, ctypes.cast(ctypes.byref(oldbind), ctypes.POINTER(ctypes.c_int)))
    texid = ctypes.c_uint(0)
    gl.glEnable(target)
    gl.glGenTextures(1, ctypes.byref(texid))
    gl.glBindTexture(target, texid)
    gl.glTexParameteri(target, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
    gl.glTexParameteri(target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)

    args = [target, 0, internalformat] + size + [0, data_format, data_type, data]

    texImage(*args)
    gl.glBindTexture(target, oldbind)
    return texid
开发者ID:moshev,项目名称:project-viking,代码行数:27,代码来源:sprite.py

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

示例10: from_atlas

    def from_atlas(cls, name, firstgid, file, tile_width, tile_height):
        image = pyglet.image.load(file)
        rows = image.height // tile_height
        columns = image.width // tile_width
        image_grid = pyglet.image.ImageGrid(image, rows, columns)
        atlas = pyglet.image.TextureGrid(image_grid)
        id = firstgid
        ts = cls(name, {})
        ts.firstgid = firstgid
        for j in range(rows-1, -1, -1):
            for i in range(columns):
                tile_image = image.get_region(atlas[j, i].x, 
                                              atlas[j, i].y, 
                                              atlas[j, i].width, 
                                              atlas[j, i].height)

                # Set texture clamping to avoid mis-rendering subpixel edges
                gl.glBindTexture(tile_image.texture.target, id)
                gl.glTexParameteri(tile_image.texture.target, 
                    gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
                gl.glTexParameteri(tile_image.texture.target, 
                    gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)

                ts[id] = Tile(id, {}, tile_image)
                id += 1
        return ts
开发者ID:WizardWizardSomething,项目名称:wizardwar,代码行数:26,代码来源:tiles.py

示例11: __init__

 def __init__(self, atlas_img, coords_file):
     img = pyglet.image.load(  atlas_img )
     self.atlas = pyglet.image.atlas.TextureAtlas( img.width, img.height )
     self.atlas.texture = img.texture
     gl.glTexParameteri( img.texture.target, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE )
     gl.glTexParameteri( img.texture.target, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE )
     self.map = dict([
         (k, pyglet.image.TextureRegion( rect[0], rect[1], 0, rect[2], rect[3], self.atlas.texture ))
         for k, rect in simplejson.load(open(coords_file)).items()])
开发者ID:ricardoquesada,项目名称:aiamsori,代码行数:9,代码来源:atlas.py

示例12: load_sprite

def load_sprite(filename, anchor_x=None, anchor_y=None, batch=None):
    gl.glTexParameteri( gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_REPEAT ) 
    gl.glTexParameteri( gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_REPEAT )
    img = pyglet.image.load(filename)#.get_texture(rectangle=True)
    img.anchor_x = anchor_x if anchor_x is not None else img.width // 2
    img.anchor_y = anchor_y if anchor_y is not None else img.height // 2 
    sprite = CollideSprite(img, batch=batch)
    
    return sprite
开发者ID:facepalm,项目名称:bliss-station-game,代码行数:9,代码来源:main-pyglet.py

示例13: _updateFrameTexture

    def _updateFrameTexture(self):
        if self._nextFrameT is None:
            # movie has no current position, need to reset the clock
            # to zero in order to have the timing logic work
            # otherwise the video stream would skip frames until the
            # time since creating the movie object has passed
            self._videoClock.reset()
            self._nextFrameT = 0

        #only advance if next frame (half of next retrace rate)
        if self._nextFrameT > self.duration:
            self._onEos()
        elif (self._numpyFrame is not None) and \
            (self._nextFrameT > (self._videoClock.getTime()-self._retraceInterval/2.0)):
            return None
        self._numpyFrame = self._mov.get_frame(self._nextFrameT)
        useSubTex=self.useTexSubImage2D
        if self._texID is None:
            self._texID = GL.GLuint()
            GL.glGenTextures(1, ctypes.byref(self._texID))
            useSubTex=False

        #bind the texture in openGL
        GL.glEnable(GL.GL_TEXTURE_2D)
        GL.glBindTexture(GL.GL_TEXTURE_2D, self._texID)#bind that name to the target
        GL.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_WRAP_S,GL.GL_REPEAT) #makes the texture map wrap (this is actually default anyway)
        GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)  # data from PIL/numpy is packed, but default for GL is 4 bytes
        #important if using bits++ because GL_LINEAR
        #sometimes extrapolates to pixel vals outside range
        if self.interpolate:
            GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR)
            GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR)
            if useSubTex is False:
                GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB8,
                    self._numpyFrame.shape[1],self._numpyFrame.shape[0], 0,
                    GL.GL_RGB, GL.GL_UNSIGNED_BYTE, self._numpyFrame.ctypes)
            else:
                GL.glTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0,
                    self._numpyFrame.shape[1], self._numpyFrame.shape[0],
                    GL.GL_RGB, GL.GL_UNSIGNED_BYTE, self._numpyFrame.ctypes)

        else:
            GL.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MAG_FILTER,GL.GL_NEAREST)
            GL.glTexParameteri(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MIN_FILTER,GL.GL_NEAREST)
            if useSubTex is False:
                GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB8,
                                self._numpyFrame.shape[1],self._numpyFrame.shape[0], 0,
                                GL.GL_BGR, GL.GL_UNSIGNED_BYTE, self._numpyFrame.ctypes)
            else:
                GL.glTexSubImage2D(GL.GL_TEXTURE_2D, 0, 0, 0,
                    self._numpyFrame.shape[1], self._numpyFrame.shape[0],
                    GL.GL_BGR, GL.GL_UNSIGNED_BYTE, self._numpyFrame.ctypes)
        GL.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE)#?? do we need this - think not!

        if not self.status==PAUSED:
            self._nextFrameT += self._frameInterval
开发者ID:papr,项目名称:psychopy,代码行数:56,代码来源:movie3.py

示例14: draw_sprites

    def draw_sprites():
        gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
        gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)

        for item in world:
            if hasattr(item, "sprite"):
                item.sprite.x = item.position.x
                item.sprite.y = item.position.y
                item.sprite.rot = item.angle * RADIANS_TO_DEGREES
                item.sprite.render()
开发者ID:tartley,项目名称:zerkcom,代码行数:10,代码来源:sprite.py

示例15: __init__

 def __init__(self,filename):
     DummyTile.__init__(self,filename)
     gl.glTexParameteri( gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE )
     gl.glTexParameteri( gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE )
     image = pyglet.image.load(self.filename)
     image.anchor_x = image.width  // 2
     image.anchor_y = image.height // 2
     pyglet.sprite.Sprite.__init__(self,image)
     
     self.highlighted = False
开发者ID:Hugoagogo,项目名称:citySquare,代码行数:10,代码来源:main.py


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