Texture: abstraction to handle GL texture, and region

Texture: abstraction to handle GL texture, and region

class pymt.texture.Texture(width, height, target, texid, mipmap=False, rectangle=False)

Bases: object

Handle a OpenGL texture. This class can be used to create simple texture or complex texture based on ImageData.

bind()

Bind the texture to current opengl state

blit_buffer(buffer, size=None, mode='RGB', format=None, pos=(0, 0), buffertype=GL_UNSIGNED_BYTE)

Blit a buffer into a texture.

Parameters :
buffer : str

Image data

size : tuple, default to texture size

Size of the image (width, height)

mode : str, default to ‘RGB’

Image mode, can be one of RGB, RGBA, BGR, BGRA

format : glconst, default to None

if format is passed, it will be used instead of mode

pos : tuple, default to (0, 0)

Position to blit in the texture

buffertype : glglconst, default to GL_UNSIGNED_BYTE

Type of the data buffer

blit_data(im, pos=(0, 0))

Replace a whole texture with a image data

static create(width, height, format=GL_RGBA, rectangle=False, mipmap=False)

Create a texture based on size.

static create_from_data(im, rectangle=True, mipmap=False)

Create a texture from an ImageData class

disable()

Do the appropriate glDisable()

enable()

Do the appropriate glEnable()

flip_vertical()

Flip tex_coords for vertical displaying

get_region(x, y, width, height)

Return a part of the texture, from (x,y) with (width,height) dimensions

height

Return the height of the texture (readonly)

id

Return the OpenGL ID of the texture (readonly)

mag_filter

Get/set the GL_TEXTURE_MAG_FILTER property

min_filter

Get/set the GL_TEXTURE_MIN_FILTER property

mipmap

Return True if the texture have mipmap enabled (readonly)

rectangle

Return True if the texture is a rectangle texture (readonly)

target

Return the OpenGL target of the texture (readonly)

width

Return the width of the texture (readonly)

wrap

Get/set the GL_TEXTURE_WRAP_S,T property

class pymt.texture.TextureRegion(x, y, width, height, origin)

Bases: pymt.texture.Texture

Handle a region of a Texture class. Useful for non power-of-2 texture handling.

Previous topic

Resources: Search a file inside a list of paths

Next topic

Utils: generic toolbox

This Page