17#include <glm/gtc/type_ptr.hpp>
23#define g_device (ctx().tryGet<GfxDevice>())
24#define g_initialized (ctx().state().initialized)
25#define g_immediateDraw (ctx().tryGet<ImmediateDraw>())
26#define g_immediateDrawActive (ctx().state().immediate_draw_active)
27#define g_viewportWidth (ctx().state().viewport_width)
28#define g_viewportHeight (ctx().state().viewport_height)
29#define g_currentViewProjection (ctx().state().current_view_projection)
43 if (!matrixData)
return;
76 glm::vec2(fromX, fromY),
78 glm::vec4(r, g, b, a),
88 glm::vec3(fromX, fromY, fromZ),
89 glm::vec3(toX, toY, toZ),
90 glm::vec4(r, g, b, a),
100 glm::vec3(fromX, fromY, fromZ),
101 glm::vec3(toX, toY, toZ),
102 glm::vec4(r, g, b, a),
113 glm::vec3(anchorX, anchorY, anchorZ),
114 glm::vec2(fromX, fromY),
116 glm::vec4(r, g, b, a),
127 glm::vec2(width, height),
128 glm::vec4(r, g, b, a),
139 glm::vec2(width, height),
140 glm::vec4(r, g, b, a),
150 glm::vec2(centerX, centerY),
152 glm::vec4(r, g, b, a),
163 glm::vec2(centerX, centerY),
165 glm::vec4(r, g, b, a),
171void draw_triangles(uintptr_t positionsPtr,
u32 vertexCount, uintptr_t colorsPtr, uintptr_t indicesPtr,
u32 indexCount,
175 const f32 xform[6] = {xx, xy, yx, yy, tx, ty};
177 reinterpret_cast<const f32*
>(positionsPtr), vertexCount,
178 colorsPtr ?
reinterpret_cast<const f32*
>(colorsPtr) :
nullptr,
179 reinterpret_cast<const u32*
>(indicesPtr), indexCount,
180 glm::vec4(r, g, b, a), xform
187 reinterpret_cast<const f32*
>(positionsPtr), vertexCount,
188 colorsPtr ?
reinterpret_cast<const f32*
>(colorsPtr) :
nullptr,
189 reinterpret_cast<const u32*
>(indicesPtr), indexCount);
197void draw_triangleMesh(
u32 id,
f32 r,
f32 g,
f32 b,
f32 a,
f32 xx,
f32 xy,
f32 yx,
f32 yy,
f32 tx,
f32 ty) {
199 const f32 xform[6] = {xx, xy, yx, yy, tx, ty};
205 g_immediateDraw->drawMeshMany(
id,
reinterpret_cast<const void*
>(recordsPtr), count);
214 glm::vec2(width, height),
216 glm::vec4(r, g, b, a)
226 glm::vec2(width, height),
229 glm::vec4(r, g, b, a)
Blend mode enumeration for custom rendering.
Always-on validation for JS-supplied pointer+length pairs at the WASM boundary.
Custom geometry for user-defined mesh rendering.
#define g_immediateDrawActive
#define g_currentViewProjection
Abstract graphics device interface.
Rendering context containing all renderer state.
Frame resources and the shared scene rendering contract.
Central resource management system.
const T * boundarySpan(uintptr_t ptr, u64 count, const char *what)
Validates a JS-supplied pointer to count elements of T and returns it typed.
std::int32_t i32
Signed 32-bit integer.
void draw_rectOutline(f32 x, f32 y, f32 width, f32 height, f32 r, f32 g, f32 b, f32 a, f32 thickness)
void draw_line(f32 fromX, f32 fromY, f32 toX, f32 toY, f32 r, f32 g, f32 b, f32 a, f32 thickness)
void draw_setDepthTest(bool enabled)
void draw_line3DScreen(f32 fromX, f32 fromY, f32 fromZ, f32 toX, f32 toY, f32 toZ, f32 r, f32 g, f32 b, f32 a, f32 thickness)
void draw_destroyTriangleMesh(u32 id)
void draw_circle(f32 centerX, f32 centerY, f32 radius, f32 r, f32 g, f32 b, f32 a, bool filled, i32 segments)
void draw_setBlendMode(i32 mode)
u32 draw_getPrimitiveCount()
void draw_circleOutline(f32 centerX, f32 centerY, f32 radius, f32 r, f32 g, f32 b, f32 a, f32 thickness, i32 segments)
void draw_setDepth(f32 depth)
static void flushImmediateDrawIfActive()
void draw_begin(uintptr_t matrixPtr, i32 viewportWidth, i32 viewportHeight)
void draw_triangleMeshMany(u32 id, uintptr_t recordsPtr, u32 count)
u32 draw_getDrawCallCount()
void draw_triangleMesh(u32 id, f32 r, f32 g, f32 b, f32 a, f32 xx, f32 xy, f32 yx, f32 yy, f32 tx, f32 ty)
u32 draw_createTriangleMesh(uintptr_t positionsPtr, u32 vertexCount, uintptr_t colorsPtr, uintptr_t indicesPtr, u32 indexCount)
void draw_triangles(uintptr_t positionsPtr, u32 vertexCount, uintptr_t colorsPtr, uintptr_t indicesPtr, u32 indexCount, f32 r, f32 g, f32 b, f32 a, f32 xx, f32 xy, f32 yx, f32 yy, f32 tx, f32 ty)
std::uint32_t u32
Unsigned 32-bit integer.
BlendMode
Predefined blend modes for rendering.
void draw_rect(f32 x, f32 y, f32 width, f32 height, f32 r, f32 g, f32 b, f32 a, bool filled)
void draw_textureRotated(f32 x, f32 y, f32 width, f32 height, f32 rotation, u32 textureId, f32 r, f32 g, f32 b, f32 a)
void draw_line3D(f32 fromX, f32 fromY, f32 fromZ, f32 toX, f32 toY, f32 toZ, f32 r, f32 g, f32 b, f32 a, f32 thickness)
void draw_texture(f32 x, f32 y, f32 width, f32 height, u32 textureId, f32 r, f32 g, f32 b, f32 a)
static EstellaContext & ctx()
EstellaContext & activeCtx()
The engine context every binding routes through — single source of truth.
void draw_setDepthState(u32 flags)
void draw_setLayer(i32 layer)
void draw_line3DScreenOffset(f32 anchorX, f32 anchorY, f32 anchorZ, f32 fromX, f32 fromY, f32 toX, f32 toY, f32 r, f32 g, f32 b, f32 a, f32 thickness)
float f32
32-bit floating point
glm::mat4 current_view_projection
bool immediate_draw_active