abstract class
Eagle::GPU::Device
- Eagle::GPU::Device
- Reference
- Object
Overview
The interface every graphics backend implements. Custom rendering code can call it
through GPU.device, but prefer Graphics, Shader, Texture and Mesh, which
handle state and batching for you.
Defined in:
eagle/gpu/device.crInstance Method Summary
-
#bind_render_target(target : RenderTargetHandle | Nil) : Nil
Draws into target, or the screen with
nil. -
#bind_texture(unit : Int32, id : UInt32) : Nil
Binds a texture to a sampler unit.
-
#blend_mode(mode : BlendMode) : Nil
Sets the blend mode.
-
#check_errors(where : String = "") : Nil
Logs any pending GPU errors, tagged with where.
-
#clear(color : Color | Nil = nil, depth : Bool = false, stencil : Bool = false) : Nil
--- frame state --- Clears the current target's color, depth and stencil as requested.
-
#create_depth_target(w : Int32, h : Int32) : RenderTargetHandle
Creates a depth-only target whose depth can be sampled, for shadow maps.
-
#create_geometry(layout : VertexLayout) : UInt32
--- geometry (vertex + index buffers with a layout) --- Creates vertex and index buffers for a layout.
-
#create_program(vertex : String, fragment : String, attribs : Array(String)) : UInt32
--- programs --- Compiles and links a shader program.
-
#create_render_target(w : Int32, h : Int32, depth : Bool, filter : Filter) : RenderTargetHandle
--- render targets --- Creates an off-screen color target, optionally with depth.
-
#create_texture(w : Int32, h : Int32, format : PixelFormat, data : Bytes | Nil, filter : Filter, wrap : Wrap, mipmaps : Bool) : UInt32
--- textures --- Creates a texture, optionally with initial pixels.
-
#cull(mode : CullMode) : Nil
Sets which faces are culled.
-
#current_target : RenderTargetHandle | Nil
The target being drawn into, or
nilfor the screen. -
#delete_geometry(geom : UInt32) : Nil
Frees geometry buffers.
-
#delete_program(id : UInt32) : Nil
Frees a shader program.
-
#delete_render_target(target : RenderTargetHandle) : Nil
Frees a render target.
-
#delete_texture(id : UInt32) : Nil
Frees a texture.
-
#depth_test(enabled : Bool, write : Bool = true, func : DepthFunc = DepthFunc::Less) : Nil
Configures depth testing and depth writes.
-
#draw(geom : UInt32, primitive : Primitive, count : Int32, offset : Int32 = 0, indexed : Bool = false, instances : Int32 = 1) : Nil
Draws geometry.
-
#emulate_wireframe? : Bool
True on backends without wireframe fill modes, such as WebGL.
-
#front_face_ccw(ccw : Bool) : Nil
Sets whether counter-clockwise triangles face forward.
-
#max_texture_size : Int32
Largest texture width or height the GPU supports.
-
#name : String
Human-readable backend and driver name, as logged at startup.
-
#read_pixels(x : Int32, y : Int32, w : Int32, h : Int32) : Bytes
Reads RGBA pixels back from the current target.
-
#scissor(rect : Rect | Nil, framebuffer_height : Int32) : Nil
Clips drawing to rect, or turns clipping off with
nil. -
#set_uniform(location : Int32, value : UniformValue) : Nil
Sets a uniform on the current program.
-
#shader_prelude(stage : Symbol) : String
The
#versionline and precision statements added to shaders for stage. -
#texture_params(id : UInt32, filter : Filter, wrap : Wrap, mipmaps : Bool) : Nil
Changes filtering, wrapping and mipmaps.
-
#uniform_location(program : UInt32, name : String) : Int32
Looks up a uniform, returning -1 when the program doesn't use it.
-
#update_texture(id : UInt32, x : Int32, y : Int32, w : Int32, h : Int32, format : PixelFormat, data : Bytes) : Nil
Replaces part of a texture.
-
#upload_indices(geom : UInt32, data : Slice(UInt32), usage : Usage) : Nil
Uploads triangle indices.
-
#upload_vertices(geom : UInt32, data : Slice(Float32), usage : Usage) : Nil
Uploads vertex data as floats.
-
#upload_vertices(geom : UInt32, data : Bytes, usage : Usage) : Nil
Uploads vertex data as raw bytes.
-
#use_program(id : UInt32) : Nil
Makes a program current.
-
#viewport(x : Int32, y : Int32, w : Int32, h : Int32) : Nil
Sets the drawing area in pixels.
-
#wireframe(enabled : Bool) : Nil
Turns wireframe rendering on or off where supported.
-
#wireframe? : Bool
True while wireframe rendering is on.
Instance Method Detail
Draws into target, or the screen with nil.
Logs any pending GPU errors, tagged with where. Enable with EAGLE_GL_DEBUG=1.
--- frame state --- Clears the current target's color, depth and stencil as requested.
Creates a depth-only target whose depth can be sampled, for shadow maps.
--- geometry (vertex + index buffers with a layout) --- Creates vertex and index buffers for a layout.
--- programs ---
Compiles and links a shader program. Raises ShaderError on failure.
--- render targets --- Creates an off-screen color target, optionally with depth.
--- textures --- Creates a texture, optionally with initial pixels.
The target being drawn into, or nil for the screen.
Configures depth testing and depth writes.
Draws geometry.
True on backends without wireframe fill modes, such as WebGL. Meshes then draw their edges as lines.
Sets whether counter-clockwise triangles face forward.
Reads RGBA pixels back from the current target.
Clips drawing to rect, or turns clipping off with nil.
Sets a uniform on the current program.
The #version line and precision statements added to shaders for stage.
Changes filtering, wrapping and mipmaps.
Looks up a uniform, returning -1 when the program doesn't use it.
Replaces part of a texture.
Uploads triangle indices.
Uploads vertex data as floats.
Uploads vertex data as raw bytes.
Sets the drawing area in pixels.