Expand description
Immediate-mode drawing with UnityEngine.GL, for use inside an
on_render callback (it’s only valid during rendering).
use hao_il2cpp_unity::{gl, on_render, Color, Vector3};
on_render(|_camera| {
gl::load_pixel_matrix(0.0, 1920.0, 0.0, 1080.0);
gl::draw(gl::Mode::Triangles, || {
gl::color(Color::rgb(1.0, 0.0, 0.0));
gl::vertex(16.0, 16.0);
gl::vertex(216.0, 16.0);
gl::vertex(16.0, 116.0);
});
})?;An egui (or other GPU UI) backend would translate its tessellated output into these calls, or hook the native graphics present for a full GPU surface — that part is renderer-specific and up to the mod.
Enums§
Functions§
- begin
- Begins a primitive of
mode. Pair withend; preferdraw. - clear
- Clears the active render target to
color(and optionally the depth buffer). - color
- Sets the current vertex colour.
- draw
- Draws a primitive: calls
begin, runsbody(which emitscolorandvertex/vertex3), thenend, even ifbodyreturns an error. - end
- Ends the primitive started by
begin. - load_
ortho - Sets up an orthographic projection with coordinates from (0, 0) to (1, 1).
- load_
pixel_ matrix - Sets up a pixel-space projection:
(left, bottom)to(right, top)in pixels. - pop_
matrix - Restores the matrices saved by
push_matrix. - push_
matrix - Saves the projection/model-view matrix; restore with
pop_matrix. - tex_
coord - Sets the texture coordinate for the next vertex.
- vertex
- Emits a 2D vertex at z = 0.
- vertex3
- Emits a 3D vertex.