2D Graphics & Immediate Rendering (`engine.Graphics`)

Hardware-accelerated OpenGL 2D immediate rendering primitives for geometric shapes, textured sprites, and bitmap text overlay.

Functions Reference

Function Signature Description
engine.Graphics.clear(r, g, b, a) (num, num, num, num) → void Clears the frame color buffer. Color channels are normalized floats from 0.0 to 1.0.
engine.Graphics.drawRect(x, y, w, h, r, g, b, a) (num, num, num, num, num, num, num, num) → void Renders a solid filled colored rectangle.
engine.Graphics.drawCircle(x, y, rad, r, g, b, a) (num, num, num, num, num, num, num) → void Renders a filled colored circle centered at (x, y).
engine.Graphics.drawLine(x1, y1, x2, y2, r, g, b, a) (num, num, num, num, num, num, num, num) → void Renders a line between two points.
engine.Graphics.drawSprite(tex, x, y, [w, h]) (Texture, num, num, [num, num]) → void Draws a texture sprite. Defaults to original image dimensions if w, h are omitted.
engine.Graphics.drawText(text, x, y, [scale, r, g, b, a]) (str, num, num, [num, num, num, num, num]) → void Renders 2D bitmap text with customizable scale multiplier and RGBA tinting.

Scene Drawing Example

draw_scene.lua
import engine

-- Inside engine.run { draw = function() ... }
engine.Graphics.clear(0.08, 0.08, 0.12, 1.0)

-- Draw a green ground platform:
engine.Graphics.drawRect(0, 650, 1280, 70, 0.2, 0.8, 0.3, 1.0)

-- Draw glowing circular particle:
engine.Graphics.drawCircle(300, 200, 24, 1.0, 0.8, 0.2, 0.9)

-- Render HUD title:
engine.Graphics.drawText("STAGE 1 - RUINS", 20, 20, 2.0, 1.0, 1.0, 1.0, 1.0)