arcade.gl package¶
Buffer¶
-
class
arcade.gl.
Buffer
(ctx: Context, data: Optional[Any] = None, reserve: int = 0, usage: str = 'static')[source]¶ Bases:
object
OpenGL buffer object. Buffers store byte data and upload it to graphics memory so shader programs can process the data. They are used for storage of vertex data, element data (vertex indexing), uniform block data etc.
Buffer objects should be created using
arcade.gl.Context.buffer()
-
__init__
(ctx: Context, data: Optional[Any] = None, reserve: int = 0, usage: str = 'static')[source]¶ - Parameters
-
bind_to_uniform_block
(binding: int = 0, offset: int = 0, size: int = - 1)[source]¶ Bind this buffer to a uniform block location. In most cases it will be sufficient to only provice a binding location.
-
copy_from_buffer
(source: arcade.gl.buffer.Buffer, size=- 1, offset=0, source_offset=0)[source]¶ Copy data into this buffer from another buffer
-
property
ctx
¶ The context this resource belongs to.
- Type
-
property
glo
¶ The OpenGL resource id
- Type
gl.GLuint
-
orphan
(size=- 1, double: bool = False)[source]¶ Re-allocate the entire buffer memory. This can be used to resize a buffer or for re-specification (orphan the buffer to avoid blocking).
If the current buffer is busy in redering operations it will be deallocated by OpenGL when completed.
-
static
release
(ctx: Context, glo: ctypes.c_ulong)[source]¶ Release/delete open gl buffer. This is automatically called when the object is garbage collected.
-
BufferDescription¶
-
class
arcade.gl.
BufferDescription
(buffer: arcade.gl.buffer.Buffer, formats: str, attributes: Iterable[str], normalized: Optional[Iterable[str]] = None, instanced: bool = False)[source]¶ Bases:
object
Buffer Object description used with
arcade.gl.Geometry
.This class provides a Buffer object with a description of its content, allowing the a
Geometry
object to correctly map shader attributes to a program/shader.The formats is a string providing the number and type of each attribute. Currently we only support f (float), i (integer) and B (unsigned byte).
normalized
enumerates the attributes which must have their values normalized. This is useful for instance for colors attributes given as unsigned byte and normalized to floats with values between 0.0 and 1.0.instanced
allows this buffer to be used as instanced buffer. Each value will be used once for the whole geometry. The geometry will be repeated a number of times equal to the number of items in the Buffer.Example:
# Describe my_buffer # It contains two floating point numbers being a 2d position # and two floating point numbers being texture coordinates. # We expect the shader using this buffer to have an in_pos and in_uv attribute (exact name) BufferDescription( my_buffer, '2f 2f', ['in_pos', 'in_uv'], )
- Parameters
-
__init__
(buffer: arcade.gl.buffer.Buffer, formats: str, attributes: Iterable[str], normalized: Optional[Iterable[str]] = None, instanced: bool = False)[source]¶
-
attributes
¶ List of string attributes
-
formats
¶ Formats of each attribute
-
instanced
¶ Instanced flag (bool)
-
normalized
¶ List of normalied attributes
-
num_vertices
¶ Number of vertices in the buffer
-
stride
¶ The byte stride of the buffer
Context¶
-
class
arcade.gl.
Context
(window: pyglet.window.BaseWindow)[source]¶ Bases:
object
Represents an OpenGL context. This context belongs to a
pyglet.Window
normally accessed throughwindow.ctx
.The Context class contains methods for creating resources, global states and commonly used enums. All enums also exist in the
gl
module. (ctx.BLEND
orarcade.gl.BLEND
).-
BLEND
= 3042¶ Context flag: Blending
-
BLEND_ADDITIVE
= (1, 1)¶ Blend mode shortcut for additive blending:
ONE, ONE
-
BLEND_DEFAULT
= (770, 771)¶ Blend mode shortcut for default blend mode:
SRC_ALPHA, ONE_MINUS_SRC_ALPHA
-
BLEND_PREMULTIPLIED_ALPHA
= (770, 1)¶ Blend mode shortcut for premultipled alpha:
SRC_ALPHA, ONE
-
CLAMP_TO_BORDER
= 33069¶
-
CLAMP_TO_EDGE
= 33071¶
-
CULL_FACE
= 2884¶ Context flag: Face culling
-
DEPTH_TEST
= 2929¶ Context flag: Depth testing
-
DST_ALPHA
= 772¶ Blend function
-
DST_COLOR
= 774¶ Blend function
-
FUNC_ADD
= 32774¶ source + destination
-
FUNC_REVERSE_SUBTRACT
= 32779¶ Blend equations: destination - source
-
FUNC_SUBTRACT
= 32778¶ Blend equations: source - destination
-
LINEAR
= 9729¶ Texture interpolation: Linear interpolate
-
LINEAR_MIPMAP_LINEAR
= 9987¶ Texture interpolation: Minification filter for mipmaps
-
LINEAR_MIPMAP_NEAREST
= 9985¶ Texture interpolation: Minification filter for mipmaps
-
LINES
= 1¶ Primitive mode
-
LINES_ADJACENCY
= 10¶ Primitive mode
-
LINE_STRIP
= 3¶ Primitive mode
-
LINE_STRIP_ADJACENCY
= 11¶ Primitive mode
-
MAX
= 32776¶ Blend equations: Maximum of source and destination
-
MIN
= 32775¶ Blend equations: Minimum of source and destination
-
MIRRORED_REPEAT
= 33648¶
-
NEAREST
= 9728¶ Texture interpolation: Nearest pixel
-
NEAREST_MIPMAP_LINEAR
= 9986¶ Texture interpolation: Minification filter for mipmaps
-
NEAREST_MIPMAP_NEAREST
= 9984¶ Texture interpolation: Minification filter for mipmaps
-
ONE
= 1¶ Blend function
-
ONE_MINUS_DST_ALPHA
= 773¶ Blend function
-
ONE_MINUS_DST_COLOR
= 775¶ Blend function
-
ONE_MINUS_SRC_ALPHA
= 771¶ Blend function
-
ONE_MINUS_SRC_COLOR
= 769¶ Blend function
-
PATCHES
= 14¶ Patch mode (tessellation)
-
POINTS
= 0¶ Primitive mode
-
PROGRAM_POINT_SIZE
= 34370¶ Context flag: Enable
gl_PointSize
in shaders.
-
REPEAT
= 10497¶ Texture wrap mode: Repeat
-
SRC_ALPHA
= 770¶ Blend function
-
SRC_COLOR
= 768¶ Blend function
-
TRIANGLES
= 4¶ Primitive mode
-
TRIANGLES_ADJACENCY
= 12¶ Primitive mode
-
TRIANGLE_FAN
= 6¶ Primitive mode
-
TRIANGLE_STRIP
= 5¶ Primitive mode
-
TRIANGLE_STRIP_ADJACENCY
= 13¶ Primitive mode
-
ZERO
= 0¶ Blend function
-
classmethod
activate
(ctx: arcade.gl.context.Context)[source]¶ Mark a context as the currently active one
-
active
: Optional[arcade.gl.context.Context] = None¶ The active context
-
property
blend_func
¶ Get or the blend function:
ctx.blend_func = ctx.ONE, ctx.ONE
- Type
tuple (src, dst)
-
buffer
(*, data: Optional[Any] = None, reserve: int = 0, usage: str = 'static') → arcade.gl.buffer.Buffer[source]¶ Create a new OpenGL Buffer object.
-
depth_texture
(size: Tuple[int, int], *, data=None) → arcade.gl.texture.Texture[source]¶ Create a 2D depth texture
- Parameters
int] size (Tuple[int,) – The size of the texture
data (Any) – The texture data (optional). Can be bytes or an object supporting the buffer protocol.
-
disable
(*args)[source]¶ Disable one or more context flags:
# Single flag ctx.disable(ctx.BLEND) # Multiple flags ctx.disable(ctx.DEPTH_TEST, ctx.CULL_FACE)
-
enable
(*args)[source]¶ Enables one or more context flags:
# Single flag ctx.enable(ctx.BLEND) # Multiple flags ctx.enable(ctx.DEPTH_TEST, ctx.CULL_FACE)
-
enable_only
(*args)[source]¶ Enable only some flags. This will disable all other flags. This is a simple way to ensure that context flag states are not lingering from other sections of your code base:
# Ensure all flags are disabled (enable no flags) ctx.enable_only() # Make sure only blending is enabled ctx.enable_only(ctx.BLEND) # Make sure only depth test and culling is enabled ctx.enable_only(ctx.DEPTH_TEST, ctx.CULL_FACE)
-
property
error
¶ Check OpenGL error
Returns a string representation of the occurring error or
None
of no errors has occurred.Example:
err = ctx.error if err: raise RuntimeError("OpenGL error: {err}")
- Type
-
property
fbo
¶ Get the currently active framebuffer. This property is read-only
-
framebuffer
(*, color_attachments: Optional[Union[arcade.gl.texture.Texture, List[arcade.gl.texture.Texture]]] = None, depth_attachment: Optional[arcade.gl.texture.Texture] = None) → arcade.gl.framebuffer.Framebuffer[source]¶ Create a Framebuffer.
- Parameters
color_attachments (List[arcade.gl.Texture]) – List of textures we want to render into
depth_attachment (arcade.gl.Texture) – Depth texture
- Return type
-
geometry
(content: Optional[Sequence[arcade.gl.types.BufferDescription]] = None, index_buffer: Optional[arcade.gl.buffer.Buffer] = None, mode: Optional[int] = None, index_element_size: int = 4)[source]¶ Create a Geomtry instance.
- Parameters
content (list) – List of
BufferDescription
(optional)index_buffer (Buffer) – Index/element buffer (optional)
mode (int) – The default draw mode (optional)
mode – The default draw mode (optional)
index_element_size (int) – Byte size of the index buffer type. Can be 1, 2 or 4 (8, 16 or 32 bit unsigned integer)
-
property
patch_vertices
¶ Get or set number of vertices that will be used to make up a single patch primitive. Patch primitives are consumed by the tessellation control shader (if present) and subsequently used for tessellation.
- Type
-
property
point_size
¶ float: Get or set the point size.
-
property
primitive_restart_index
¶ Get or set the primitive restart index. Default is -1
-
program
(*, vertex_shader: str, fragment_shader: Optional[str] = None, geometry_shader: Optional[str] = None, tess_control_shader: Optional[str] = None, tess_evaluation_shader: Optional[str] = None, defines: Optional[Dict[str, str]] = None) → arcade.gl.program.Program[source]¶ Create a
Program
given the vertex, fragment and geometry shader.- Parameters
vertex_shader (str) – vertex shader source
fragment_shader (str) – fragment shader source (optional)
geometry_shader (str) – geometry shader source (optional)
tess_control_shader (str) – tessellation control shader source (optional)
tess_evaluation_shader (str) – tessellation evaluation shader source (optional)
defines (dict) – Substitute #defines values in the source (optional)
- Return type
-
property
screen
¶ The framebuffer for the window.
- Type
Framebuffer
-
texture
(size: Tuple[int, int], *, components: int = 4, dtype: str = 'f1', data: Optional[Any] = None, wrap_x: Optional[ctypes.c_ulong] = None, wrap_y: Optional[ctypes.c_ulong] = None, filter: Optional[Tuple[ctypes.c_ulong, ctypes.c_ulong]] = None) → arcade.gl.texture.Texture[source]¶ Create a 2D Texture.
Wrap modes:
GL_REPEAT
,GL_MIRRORED_REPEAT
,GL_CLAMP_TO_EDGE
,GL_CLAMP_TO_BORDER
Minifying filters:
GL_NEAREST
,GL_LINEAR
,GL_NEAREST_MIPMAP_NEAREST
,GL_LINEAR_MIPMAP_NEAREST
GL_NEAREST_MIPMAP_LINEAR
,GL_LINEAR_MIPMAP_LINEAR
Magnifying filters:
GL_NEAREST
,GL_LINEAR
- Parameters
int] size (Tuple[int,) – The size of the texture
components (int) – Number of components (1: R, 2: RG, 3: RGB, 4: RGBA)
dtype (str) – The data type of each component: f1, f2, f4 / i1, i2, i4 / u1, u2, u4
data (Any) – The texture data (optional). Can be bytes or an object supporting the buffer protocol.
wrap_x (GLenum) – How the texture wraps in x direction
wrap_y (GLenum) – How the texture wraps in y direction
filter (Tuple[GLenum,GLenum]) – Minification and magnification filter
-
property
viewport
¶ Get or set the viewport for the currently active framebuffer. The viewport simply describes what pixels of the screen OpenGL should render to. Normally it would be the size of the window’s framebuffer:
# 4:3 screen ctx.viewport = 0, 0, 800, 600 # 1080p ctx.viewport = 0, 0, 1920, 1080 # Using the current framebuffer size ctx.viewport = 0, 0, *ctx.screen.size
- Type
tuple (x, y, width, height)
-
property
window
¶ The window this context belongs to.
- Type
pyglet.Window
-
Framebuffer¶
-
class
arcade.gl.
Framebuffer
(ctx: Context, *, color_attachments=None, depth_attachment=None)[source]¶ Bases:
object
An offscreen render target also called a Framebuffer Object in OpenGL. This implementation is using texture attachments. When creating a Framebuffer we supply it with textures we want our scene rendered into. The advantage of using texture attachments is the ability we get to keep working on the contents of the framebuffer.
The best way to create framebuffer is through
arcade.gl.Context.framebuffer()
:# Create a 100 x 100 framebuffer with one attachment ctx.framebuffer(color_attachments=[ctx.texture((100, 100), components=4)]) # Create a 100 x 100 framebuffer with two attachments # Shaders can be configured writing to the different layers ctx.framebuffer( color_attachments=[ ctx.texture((100, 100), components=4), ctx.texture((100, 100), components=4), ] )
- Parameters
ctx (Context) – The context this framebuffer belongs to
color_attachments (List[arcade.gl.Texture]) – List of color attachments.
depth_attachment (arcade.gl.Texture) – A depth attachment (optional)
-
__init__
(ctx: Context, *, color_attachments=None, depth_attachment=None)[source]¶ - Parameters
ctx (Context) – The context this framebuffer belongs to
color_attachments (List[arcade.gl.Texture]) – List of color attachments.
depth_attachment (arcade.gl.Texture) – A depth attachment (optional)
-
clear
(color=(0.0, 0.0, 0.0, 0.0), *, depth: float = 1.0, normalized: bool = False)[source]¶ Clears the framebuffer:
# Clear framebuffer using the color red in normalized form fbo.clear(color=(1.0, 0.0, 0.0, 1.0), normalized=True) # Clear the framebuffer using arcade's colors (not normalized) fb.clear(color=arcade.color.WHITE)
-
property
color_attachments
¶ A list of color attachments
- Type
list of
arcade.gl.Texture
-
property
ctx
¶ The context this object belongs to.
- Type
-
property
depth_attachment
¶ Depth attachment
- Type
-
property
depth_mask
¶ Get or set the depth mask (default:
True
). It determines if depth values should be written to the depth texture when depth testing is enabled.The depth mask value is persistent all will automatically be applies every time the framebuffer is bound.
- Type
-
property
glo
¶ The OpenGL id/name of the framebuffer
- Type
GLuint
-
is_default
= False¶ Is this the default framebuffer? (window buffer)
-
read
(*, viewport=None, components=3, attachment=0, dtype='f1') → bytearray[source]¶ Read framebuffer pixels
-
static
release
(ctx, framebuffer_id)[source]¶ Destroys the framebuffer object
- Parameters
ctx – OpenGL context
framebuffer_id – Framebuffer to destroy (glo)
-
property
viewport
¶ Get or set the framebuffer’s viewport. The viewport parameter are
(x, y, width, height)
. It determines what part of the framebuffer should be redered to. By default the viewport is(0, 0, width, height)
.The viewport value is persistent all will automatically be applies every time the framebuffer is bound.
Two or four integer values can be assigned:
# Explicitly set x, y, width, height fb.viewport = 100, 100, 200, 200 # Implies 0, 0, 100, 100 fb.viewport = 100, 100
Geometry¶
-
class
arcade.gl.
Geometry
(ctx: Context, content: Optional[Sequence[arcade.gl.types.BufferDescription]], index_buffer: arcade.gl.buffer.Buffer = None, mode=None, index_element_size: int = 4)[source]¶ Bases:
object
A higher level abstraction of the VertexArray. It generates VertexArray instances on the fly internally matching the incoming program. This means we can render the same geometry with different programs as long as the
Program
andBufferDescription
have compatible attributes.Geometry objects should be created through
arcade.gl.Context.geometry()
- Parameters
-
__init__
(ctx: Context, content: Optional[Sequence[arcade.gl.types.BufferDescription]], index_buffer: arcade.gl.buffer.Buffer = None, mode=None, index_element_size: int = 4)[source]¶
-
instance
(program: arcade.gl.program.Program) → arcade.gl.vertex_array.VertexArray[source]¶ Get the
arcade.gl.VertexArray
compatible with this program
-
property
num_vertices
¶ Get or set the number of vertices. Be careful when modifying this properly and be absolutely sure what you are doing.
- Type
-
render
(program: arcade.gl.program.Program, *, mode: Optional[ctypes.c_ulong] = None, first: int = 0, vertices: Optional[int] = None, instances: int = 1) → None[source]¶ Render the geometry with a specific program.
-
transform
(program: arcade.gl.program.Program, buffer: arcade.gl.buffer.Buffer, *, first: int = 0, vertices: Optional[int] = None, instances: int = 1, buffer_offset: int = 0) → None[source]¶ Render with transform feedback. Instead of rendering to the screen or a framebuffer the result will instead end up in the
buffer
we supply.If a geometry shader is used the output primitive mode is automatically detected.
- Parameters
program (Program) – The Program to render with
buffer (Buffer) – The buffer to write the output
mode (gl.GLenum) – The input primitive mode
first (int) – Offset start vertex
vertices (int) – Number of vertices to render
instances (int) – Number of instances to render
buffer_offset (int) – Byte offset for the buffer
Program¶
-
class
arcade.gl.
Program
(ctx: Context, *, vertex_shader: str, fragment_shader: str = None, geometry_shader: str = None, tess_control_shader: str = None, tess_evaluation_shader: str = None, out_attributes: List[str] = None)[source]¶ Bases:
object
Compiled and linked shader program.
Currently supports vertex, fragment and geometry shaders. Transform feedback also supported when output attributes names are passed in the varyings parameter.
The best way to create a program instance is through
arcade.gl.Context.program()
Access Uniforms via the
[]
operator. Example:program['MyUniform'] = value
-
__init__
(ctx: Context, *, vertex_shader: str, fragment_shader: str = None, geometry_shader: str = None, tess_control_shader: str = None, tess_evaluation_shader: str = None, out_attributes: List[str] = None)[source]¶ Create a Program.
- Parameters
ctx (Context) – The context this program belongs to
vertex_shader (str) – vertex shader source
fragment_shader (str) – fragment shader source
geometry_shader (str) – geometry shader source
tess_control_shader (str) – tessellation control shader source
tess_evaluation_shader (str) – tessellation evaluation shader source
out_attributes (List[str]) – List of out attributes used in transform feedback.
-
attribute_key
¶ Internal cache key used with vertex arrays
-
property
attributes
¶ List of attribute information
-
static
compile_shader
(source: str, shader_type: ctypes.c_ulong) → ctypes.c_ulong[source]¶ Compile the shader code of the given type.
shader_type could be GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, …
Returns the shader id as a GLuint
-
property
ctx
¶ The context this program belongs to
- Type
-
property
geometry_input
¶ The geometry shader’s input primitive type. This an be compared with
GL_TRIANGLES
,GL_POINTS
etc. and is queried when the program is created.- Type
-
property
geometry_output
¶ The geometry shader’s output primitive type. This an be compared with
GL_TRIANGLES
,GL_POINTS
etc. and is queried when the program is created.- Type
-
property
geometry_vertices
¶ The maximum number of vertices that can be emitted. This is queried when the program is created.
- Type
-
property
out_attributes
¶ Out attributes names used in transform feedback
- Type
list of str
-
Query¶
-
class
arcade.gl.
Query
(ctx: Context)[source]¶ Bases:
object
A query object to perform low level measurements of OpenGL rendering calls.
The best way to create a program instance is through
arcade.gl.Context.query()
Example usage:
query = ctx.query() with query: geometry.render(..) print('samples_passed:', query.samples_passed) print('time_elapsed:', query.time_elapsed) print('primitives_generated:', query.primitives_generated)
-
property
ctx
¶ The context this query object belongs to
- Type
-
property
Texture¶
-
class
arcade.gl.
Texture
(ctx: Context, size: Tuple[int, int], *, components: int = 4, dtype: str = 'f1', data: Any = None, filter: Tuple[ctypes.c_ulong, ctypes.c_ulong] = None, wrap_x: ctypes.c_ulong = None, wrap_y: ctypes.c_ulong = None, target=3553, depth=False)[source]¶ Bases:
object
An OpenGL texture. We can create an empty black texture or a texture from byte data. A texture can also be created with different datatypes such as float, integer or unsigned integer.
The best way to create a texture instance is through
arcade.gl.Context.texture()
Supported
dtype
values are:# Float formats 'f1': UNSIGNED_BYTE 'f2': HALF_FLOAT 'f4': FLOAT # int formats 'i1': BYTE 'i2': SHORT 'i4': INT # uint formats 'u1': UNSIGNED_BYTE 'u2': UNSIGNED_SHORT 'u4': UNSIGNED_INT
- Parameters
ctx (Context) – The context the object belongs to
int] size (Tuple[int,) – The size of the texture
components (int) – The number of components (1: R, 2: RG, 3: RGB, 4: RGBA)
dtype (str) – The data type of each component: f1, f2, f4 / i1, i2, i4 / u1, u2, u4
data (Any) – The texture data (optional). Can be bytes or any object supporting the buffer protocol.
data – The byte data of the texture. bytes or anything supporting the buffer protocol.
filter (Tuple[gl.GLuint,gl.GLuint]) – The minification/magnification filter of the texture
wrap_x (gl.GLuint) – Wrap mode x
wrap_y (gl.GLuint) – Wrap mode y
-
__init__
(ctx: Context, size: Tuple[int, int], *, components: int = 4, dtype: str = 'f1', data: Any = None, filter: Tuple[ctypes.c_ulong, ctypes.c_ulong] = None, wrap_x: ctypes.c_ulong = None, wrap_y: ctypes.c_ulong = None, target=3553, depth=False)[source]¶ A texture can be created with or without initial data. NOTE: Currently does not support multisample textures even thought
samples
is exposed.- Parameters
ctx (Context) – The context the object belongs to
components (int) – The number of components (1: R, 2: RG, 3: RGB, 4: RGBA)
dtype (str) – The data type of each component: f1, f2, f4 / i1, i2, i4 / u1, u2, u4
data (Any) – The byte data of the texture. bytes or anything supporting the buffer protocol.
gl.GLuint] filter (Tuple[gl.GLuint,) – The minification/magnification filter of the texture
wrap_x (gl.GLuint) – Wrap mode x
wrap_y (gl.GLuint) – Wrap mode y
target (int) – The texture type
depth (bool) – creates a depth texture if True
-
build_mipmaps
(base: int = 0, max_level: int = 1000) → None[source]¶ Generate mipmaps for this texture. Leaveing the default arguments will usually does the job. Building mipmaps will create several smaller versions of the texture (256 x 256, 128 x 128, 64 x 64, 32 x 32 etc) helping OpenGL in rendering a nicer version of texture when it’s rendered to the screen in smaller version.
Note that mipmaps will only be used if the texture filter is configured with a mipmap-type minification:
# Set up linear interpolating minification filter texture.filter = ctx.LINEAR_MIPMAP_LINEAR, ctx.LINEAR
- Parameters
Also see: https://www.khronos.org/opengl/wiki/Texture#Mip_maps
-
property
compare_func
¶ Get or set the compare function for a depth texture:
texture.compare_func = None # Disable depth comparison completely texture.compare_func = '<=' # GL_LEQUAL texture.compare_func = '<' # GL_LESS texture.compare_func = '>=' # GL_GEQUAL texture.compare_func = '>' # GL_GREATER texture.compare_func = '==' # GL_EQUAL texture.compare_func = '!=' # GL_NOTEQUAL texture.compare_func = '0' # GL_NEVER texture.compare_func = '1' # GL_ALWAYS
- Type
-
property
filter
¶ Get or set the
(min, mag)
filter for this texture. These are rules for how a texture interpolates. The filter is specified for minification and magnification.Default value is
LINEAR, LINEAR
. Can be set toNEAREST, NEAREST
for pixelated graphics.When mipmapping is used the min filter needs to be one of the
MIPMAP
variants.Accepted values:
# Enums can be accessed on the context or arcade.gl NEAREST # Nearest pixel LINEAR # Linear interpolate NEAREST_MIPMAP_NEAREST # Minification filter for mipmaps LINEAR_MIPMAP_NEAREST # Minification filter for mipmaps NEAREST_MIPMAP_LINEAR # Minification filter for mipmaps LINEAR_MIPMAP_LINEAR # Minification filter for mipmaps
Also see
- Type
tuple (min filter, mag filter)
-
property
glo
¶ The OpenGL texture id
- Type
GLuint
-
static
release
(ctx: Context, glo: ctypes.c_ulong)[source]¶ Destroy the texture. This is called automatically when the object is garbage collected.
- Parameters
ctx (arcade.gl.Context) – OpenGL Context
glo (gl.GLuint) – The OpenGL texture id
-
use
(unit: int = 0) → None[source]¶ Bind the texture to a channel,
- Parameters
unit (int) – The texture unit to bind the texture.
-
property
wrap_x
¶ Get or set the horizontal wrapping of the texture. This decides how textures are read when texture coordinates are outside the
[0.0, 1.0]
area. Default value isREPEAT
.Valid options are:
# Note: Enums can also be accessed in arcade.gl # Repeat pixels on the y axis texture.wrap_x = ctx.REPEAT # Repeat pixels on the y axis mirrored texture.wrap_x = ctx.MIRRORED_REPEAT # Repeat the edge pixels when reading outside the texture texture.wrap_x = ctx.CLAMP_TO_EDGE # Use the border color (black by default) when reading outside the texture texture.wrap_x = ctx.CLAMP_TO_BORDER
- Type
-
property
wrap_y
¶ Get or set the horizontal wrapping of the texture. This decides how textures are read when texture coordinates are outside the
[0.0, 1.0]
area. Default value isREPEAT
.Valid options are:
# Note: Enums can also be accessed in arcade.gl # Repeat pixels on the x axis texture.wrap_x = ctx.REPEAT # Repeat pixels on the x axis mirrored texture.wrap_x = ctx.MIRRORED_REPEAT # Repeat the edge pixels when reading outside the texture texture.wrap_x = ctx.CLAMP_TO_EDGE # Use the border color (black by default) when reading outside the texture texture.wrap_x = ctx.CLAMP_TO_BORDER
- Type
VertexArray¶
-
class
arcade.gl.
VertexArray
(ctx: Context, program: arcade.gl.program.Program, content: Sequence[arcade.gl.types.BufferDescription], index_buffer: arcade.gl.buffer.Buffer = None, index_element_size: int = 4)[source]¶ Bases:
object
Wrapper for Vertex Array Objects (VAOs). This objects should not be instantiated from user code. Use
arcade.gl.Geometry
instead. It will create VAO instances for you automatically. There is a lot of complex interaction between programs and vertex arrays that will be done for you automatically.-
__init__
(ctx: Context, program: arcade.gl.program.Program, content: Sequence[arcade.gl.types.BufferDescription], index_buffer: arcade.gl.buffer.Buffer = None, index_element_size: int = 4)[source]¶
-
property
ctx
¶ The Context this object belongs to
- Type
-
glo
¶
-
property
ibo
¶ Element/index buffer
- Type
-
property
program
¶ The assigned program
- Type
-
static
release
(ctx: Context, glo: ctypes.c_ulong)[source]¶ Delete this object. This is automatically called when this object is garbage collected.
-
render
(mode: ctypes.c_ulong, first: int = 0, vertices: int = 0, instances: int = 1)[source]¶ Render the VertexArray to the currently active framebuffer.
-
transform
(buffer: arcade.gl.buffer.Buffer, mode: ctypes.c_ulong, output_mode: ctypes.c_ulong, first: int = 0, vertices: int = 0, instances: int = 1, buffer_offset=0)[source]¶ Run a transform feedback.
- Parameters
buffer (Buffer) – The buffer to write the output
mode (gl.GLenum) – The input primitive mode
output:mode (gl.GLenum) – The output primitive mode
first (int) – Offset start vertex
vertices (int) – Number of vertices to render
instances (int) – Number of instances to render
buffer_offset (int) – Byte offset for the buffer (target)
-
ShaderException¶
geometry¶
A module providing commonly used geometry
-
arcade.gl.geometry.
cube
(size=(1.0, 1.0, 1.0), center=(0.0, 0.0, 0.0)) → arcade.gl.vertex_array.Geometry[source]¶ Creates a cube with normals and texture coordinates.
- Parameters
- Return type
- Returns
A cube
-
arcade.gl.geometry.
quad_2d
(size: Tuple[float, float] = (1.0, 1.0), pos: Tuple[float, float] = (0.0, 0.0)) → arcade.gl.vertex_array.Geometry[source]¶ Creates 2D quad Geometry using 2 triangle strip with texture coordinates.
-
arcade.gl.geometry.
quad_2d_fs
() → arcade.gl.vertex_array.Geometry[source]¶ Creates a screen aligned quad using normalized device coordinates