Module qlibs.highlevel.graphics

Highlevel graphics things

class qlibs.highlevel.graphics.ObjectSpriteMaster(master)

Like the usual sprite master, but uses “Objects” to manipulate buffers.

More effient when you don’t need to update everything. (TODO)

add_sprite(id_, x, y, w, h, r=0, z=0, color=(1, 1, 1, 1))
render(mvp=<qlibs.math.matrix.Matrix4 object>)
render_centered(center, size)
class qlibs.highlevel.graphics.SpriteMaster(ctx, program=None)

Does loading, managing and drawing. All at once.

Can also calculate mvps.

Quite effient in terms of draw calls.

See SpriteMasterBase for more.

fork()

Create another sprite master with it’s own set of buffers(their content is not copied)

init()

Init. Call this after loading all required sprites. Uploads sprites to gpu.

load_file(sprite_id, file_id)

Load a sprite from file, using build-in resource system. Sprite from file_id will be mapped to sprite_id

class qlibs.highlevel.graphics.SpriteMasterBase(master)

Base SpriteMaster class which does not handle drawers. Used for forking

add_sprite_centered(id_, x, y, w, h, z=0, color=(1, 1, 1, 1), tpoints=((0, 0), (1, 0), (1, 1), (0, 1)))

Add sprite, specified by the rectangle, centered

add_sprite_rect(id_, x, y, w, h, z=0, color=(1, 1, 1, 1), tpoints=((0, 0), (1, 0), (1, 1), (0, 1)))

Add sprite, specified by the rectangle

add_sprite_rotated(id_, x, y, w, h, r, z=0, color=(1, 1, 1, 1), tpoints=((0, 0), (1, 0), (1, 1), (0, 1)))

Add sprite, specified by the rectangle, centered and rotated by r

clear()

Resets buffers

fork()

Create another sprite master with it’s own set of buffers

render(mvp=<qlibs.math.matrix.Matrix4 object>, reset=True)

Renders everything. When reset is True, resets buffers.

render_centered(center, size, reset=True)

Automatically calculates orthogonal projection and renders, using it. Area with center at center and of size size will be seen.

render_like(master, reset=True)

Renders with the same matrix another master did.

render_rescaled(x, y, w, h, reset=True)

Calculates orthogonal projection with the given parameters and renders, using it.