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


Python gl.GL_TEXTURE_MAG_FILTER属性代码示例

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


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

示例1: create_image_texture

# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import GL_TEXTURE_MAG_FILTER [as 别名]
def create_image_texture(imgfile):
    """Create a 2D texture from an image file.
    """
    image = pyglet.image.load(imgfile)
    data = image.get_data("RGBA", image.width * 4)
    tex = gl.GLuint()
    gl.glGenTextures(1, ct.pointer(tex))
    gl.glBindTexture(gl.GL_TEXTURE_2D, tex)
    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.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)
    gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA,
                    image.width, image.height, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, data)
    gl.glBindTexture(tex, 0)
    return tex 
开发者ID:neozhaoliang,项目名称:pywonderland,代码行数:18,代码来源:texture.py

示例2: create_cubemap_texture

# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import GL_TEXTURE_MAG_FILTER [as 别名]
def create_cubemap_texture(imgfiles):
    """Create a cubemap texture from image files.
    """
    if len(imgfiles) != 6:
        raise ValueError("exactly six images are required for a cubemap texture")

    # generate a new texture
    cubemap = gl.GLuint()
    gl.glGenTextures(1, ct.pointer(cubemap))

    # bind it to `GL_TEXTURE_CUBE_MAP` and set the filter and wrap mode
    gl.glBindTexture(gl.GL_TEXTURE_CUBE_MAP, cubemap)
    gl.glTexParameteri(gl.GL_TEXTURE_CUBE_MAP, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
    gl.glTexParameteri(gl.GL_TEXTURE_CUBE_MAP, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR_MIPMAP_LINEAR)
    gl.glTexParameteri(gl.GL_TEXTURE_CUBE_MAP, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
    gl.glTexParameteri(gl.GL_TEXTURE_CUBE_MAP, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)
    gl.glTexParameteri(gl.GL_TEXTURE_CUBE_MAP, gl.GL_TEXTURE_WRAP_R, gl.GL_CLAMP_TO_EDGE)

    faces = [Image.open(img) for img in imgfiles]
    # set the faces of the cubemap texture
    for i, face in enumerate(faces):
        width, height = face.size
        try:
            data = face.tobytes("raw", "RGBX", 0, -1)
        except TypeError:
            data = face.tobytes("raw", "RGBA", 0, -1)

        gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, gl.GL_RGBA,
                        width, height, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, data)

    gl.glGenerateMipmap(gl.GL_TEXTURE_CUBE_MAP)
    gl.glBindTexture(gl.GL_TEXTURE_CUBE_MAP, 0)
    return cubemap 
开发者ID:neozhaoliang,项目名称:pywonderland,代码行数:35,代码来源:texture.py

示例3: imshow

# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import GL_TEXTURE_MAG_FILTER [as 别名]
def imshow(self, arr):

        H, W, C = arr.shape
        assert C==3
        image = pyglet.image.ImageData(W, H, 'RGB', arr.tobytes(), pitch=W*-3)
        self.clear()
        self.switch_to()
        self.dispatch_events()
        texture = image.get_texture()
        gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
        texture.width  = W
        texture.height = H
        texture.blit(0, 0, width=self.win_w, height=self.win_h)
        self.flip() 
开发者ID:GOAL-Robots,项目名称:REALCompetitionStartingKit,代码行数:16,代码来源:test.py

示例4: _bind_texture

# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import GL_TEXTURE_MAG_FILTER [as 别名]
def _bind_texture(self, i):
        gl.glActiveTexture((gl.GL_TEXTURE0, gl.GL_TEXTURE1, gl.GL_TEXTURE2)[i])
        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glBindTexture(gl.GL_TEXTURE_2D, self.texture[i].id)
        gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_COMBINE)
        gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_COMBINE_ALPHA, gl.GL_REPLACE if i == 0 else gl.GL_ADD)
        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) 
开发者ID:pyglet,项目名称:pyglet,代码行数:10,代码来源:test_multitexture.py

示例5: buffer_texture

# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import GL_TEXTURE_MAG_FILTER [as 别名]
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,代码行数:31,代码来源:framebuffer.py


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