texture
FreeBodyEngine.graphics.gl44.texture
#
Identical to graphics/gl33/texture.py - ordinary 2D texture creation and binding hasn't changed between GL 3.3 and 4.4. Kept as a separate copy (rather than importing gl33's) so this backend has no runtime dependency on gl33 at all, matching every other file in this module.
GL44TextureManager(*args, **kwargs)
#
Bases: TextureManager
The GL 4.4 implementation of TextureManager: creates standalone/atlas/
font-atlas textures and texture-array stacks as real GL objects, and maps
each one onto a GL texture unit on demand (see _allocate_slot) rather
than binding every texture up front.
Sets up the id<->texture-unit maps used to lazily assign GL texture units, and queries the driver's actual texture unit count (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS) rather than assuming the GL 3.3-era minimum of 16, since 4.4 hardware/drivers commonly expose more.
max_texture_slots = glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS)
instance-attribute
#
next_texture_slot = 0
instance-attribute
#
slot_textures = {}
instance-attribute
#
texture_slots = {}
instance-attribute
#
begin_draw()
#
Resets the id<->texture-unit assignment for a new frame, so every texture bound last frame is re-allocated a (possibly different) unit as it's used again rather than assuming last frame's bindings are still valid.
bind_texture(id)
#
Ensures standalone/atlas texture id is bound to some GL texture
unit and returns that unit's index, reusing its existing unit if
this frame already bound it (see _allocate_slot). Returns None
(after warning) if id doesn't resolve to a live GL texture.
bind_texture_stack(id)
#
Like bind_texture, but for a GL_TEXTURE_2D_ARRAY-backed
TextureStack id.
gen_id()
#
Generates a fresh backend-agnostic id for a new texture resource, independent of the underlying GL texture name.
get_atlas_id_from_path(file_path)
#
Looks up the manager-owned id of the atlas GL texture that was
built from file_path, or None if no atlas has been created from
that file yet.
set_texture_filter(id, nearest)
#
Switches texture id between nearest-neighbor filtering (crisp
pixel art, with mipmapping still enabled via
GL_NEAREST_MIPMAP_NEAREST so minified sprites don't alias) and the
default full-trilinear GL_LINEAR_MIPMAP_LINEAR/GL_LINEAR pair.
wrap_external_texture(gl_texture_id)
#
Registers a GL_TEXTURE_2D that wasn't created by this manager (e.g. a GL44ComputeShader dispatch's output texture, see GL44ComputeShader.get_output_texture()) under a generated id, so it can flow through the same Texture/slot-binding machinery as any other texture.