vulk.graphic package¶
Subpackages¶
Submodules¶
vulk.graphic.camera module¶
-
class
vulk.graphic.camera.
Camera
[source]¶ Bases:
abc.ABC
-
class
vulk.graphic.camera.
OrthographicCamera
(viewport_width, viewport_height)[source]¶ Bases:
vulk.graphic.camera.Camera
-
class
vulk.graphic.camera.
PerspectiveCamera
(fov, viewport_width, viewport_height)[source]¶ Bases:
vulk.graphic.camera.Camera
vulk.graphic.mesh module¶
This module contains mesh
-
class
vulk.graphic.mesh.
Mesh
(context, max_vertices, max_indices, attributes)[source]¶ Bases:
object
-
bind
(cmd)[source]¶ Bind the buffers during command buffer registering
Parameters:
- command: CommandBufferRegister
-
draw
(cmd, offset=0, count=0)[source]¶ Draw the mesh during command buffer registration
Parameters:
- cmd: CommandBufferRegister
- offset: Start drawing at offset vertices
- count: Draw count vertices
Note: `offset` and `count` target indices if mesh is indexed
-
set_indices
(indices, offset=0)[source]¶ Set indices of mesh
Parameters:
- indices: list of float
- offset: Offset in mesh indices array
Note: Mesh must be indexed
-
set_vertex
(index, vertex)[source]¶ Set one vertex of the mesh at position index
Parameters:
- index: Vertex index
- vertex: Vertex data (tuple format)
Exemple:
For a mesh with two attributes (2 components and 4 components):
` vertex = ([x, y], [r, g, b, a]) mesh.set_vertex(idx, vertex) `
-
set_vertices
(vertices, offset=0)[source]¶ Set vertices of the mesh. Report to set_vertex, it works the same but it waits for an array of vertex.
Parameters:
- vertices: list of Vertex data (see set_vertex)
- offset: Offset in the mesh vertices array
-
upload
(context)[source]¶ Upload vertices and indices to graphic card
Parameters:
- context: VulkContext
-
vulk.graphic.texture module¶
This module allows to load texture and to sample from it
-
class
vulk.graphic.texture.
BinaryTexture
(context, width, height, texture_format, raw_bitmap, mip_levels=1)[source]¶ Bases:
vulk.graphic.texture.RawTexture
RawTexture with provided bitmap buffer.
Warning: You are responsible of the bitmap buffer
-
generate_mipmaps
(context)[source]¶ Generate mipmap automatically
This method generates mipmap on processor and then upload it on GPU. This method is heavy, use it with care. You shouldn’t need to call it several times unless raw_bitmap is modified.
You must call upload to update the texture in Graphic Card.
- Args:
- context (VulkContext)
-
-
class
vulk.graphic.texture.
HighQualityTexture
(context, path_file, anisotropy=0)[source]¶ Bases:
vulk.graphic.texture.Texture
Texture with best quality
To get best quality, we generate automatically all mipmaps and set filter to trilinear or anisotropy filtering. It’s really just a helper class.
-
class
vulk.graphic.texture.
RawTexture
(context, width, height, texture_format, mip_levels=1)[source]¶ Bases:
object
A Raw texture is not initialized with an image file but can be filled manually
-
set_sampler
(context, mag_filter=<Filter.NONE: 0>, min_filter=<Filter.NONE: 0>, mipmap_mode=<SamplerMipmapMode.NONE: 0>, address_mode_u=<SamplerAddressMode.NONE: 0>, address_mode_v=<SamplerAddressMode.NONE: 0>, address_mode_w=<SamplerAddressMode.NONE: 0>, anisotropy_enable=False, max_anisotropy=16)[source]¶ Set the texture sampler
By default, sampler is configured for the best performance. If you want better quality, you must enable manually bilinear, trilinear or anisotropic filtering.
- Args:
- context (VulkContext): Context mag_filter (Filter): Magnification filter to apply to lookups min_filter (Filter): Minification filter to apply to lookups mipmap_mode (SamplerMipmapMode): Mipmap filter to apply to lookups address_mode_u (SamplerAddressMode): address_mode_v (SamplerAddressMode): address_mode_w (SamplerAddressMode): anisotropy_enable (bool): Whether to enable anisotropy max_anisotropy (int): Anisotropy value clamp
-
-
class
vulk.graphic.texture.
Texture
(context, path_file, mip_levels=1)[source]¶ Bases:
vulk.graphic.texture.BinaryTexture
BinaryTexture with file managing
-
class
vulk.graphic.texture.
TextureRegion
(texture, u=0, v=0, u2=1, v2=1)[source]¶ Bases:
object
Defines a rectangular area of a texture. The coordinate system used has its origin in the upper left corner with the x-axis pointing to the right and the y axis pointing downwards.
-
static
from_pixels
(texture, x, y, width, height)[source]¶ Create a TextureRegion with pixel coordinates
- Args:
- texture (Texture): Base texture of region x (int): X offset (left to right) y (int): Y offset (top to bottom) width (int): Region width height (int): Region height
- Returns:
- The new TextureRegion
-
set_region
(u, u2, v, v2)[source]¶ Set coordinate relatively to texture size
Parameters:
- u, u2: X coordinate relative to texture size
- v, v2: Y coordinate relative to texture size
-
static