Render models, procedural geometry, lighting, and animation into a bitmap.
Link Catalyst::MacShared or Catalyst::MacStatic. A supplied output buffer is borrowed and must hold width × height × 4 bytes.
Create or load a model to obtain its ID, submit it with draw(), then call render(). Keep model IDs within the renderer that created them.
CRender
Types, constants & data
enum class WrapMode { Repeat, Clamp };
enum class FilterMode { Nearest, Linear };
Methods
Creates a renderer and output bitmap. A supplied buffer is borrowed and must hold width × height × 4 bytes; omit it for renderer-owned storage.
Returns borrowed pixel storage; keep the renderer alive while using it.
Resets the output bitmap to the background and resets depth storage. It retains loaded models and queued draw commands.
Renders the submitted model instances into the bitmap and consumes the draw-command list. Submit the instances again for another frame.
void setTextureWrap(WrapMode wrapU, WrapMode wrapV);
Selects repeat or edge-clamp behavior independently for the U and V texture coordinates.
void setTextureFilter(FilterMode filter);
Selects nearest or linear texture sampling for rendered model textures.
void setRaytracingBounces(size_t bounces);
Sets the allowed reflection/path bounce depth for the raytracing path. More bounces can increase rendering work.
void setToneMapping(bool enabled);
Enables or disables the tone-mapping step used to bring rendered brightness into the display range.
void setExposure(double exposure);
Sets a positive brightness multiplier for output color processing. This is a multiplier, not a value in photographic stops.
void setGamma(double gamma);
Sets a positive gamma value for output color processing.
size_t loadGLB(const cstr& path);
Loads a binary glTF model and returns a renderer-local model ID.
size_t animationCount(size_t modelId) const;
Returns the number of animation clips in a loaded model. Animation IDs are zero-based within that model.
cstr animationName(size_t modelId, size_t animationId) const;
Returns the loaded clip’s name. The model and animation IDs must be valid.
void setAnimation(size_t modelId, size_t animationId);
Selects a model’s active animation without resetting its time or speed. Use setAnimationTime() when an explicit starting position is needed.
void clearAnimation(size_t modelId);
Disables the model’s selected animation and restores its unanimated pose on the next render.
void setAnimationTime(size_t modelId, double seconds);
Sets the animation time in seconds for the next render. Call this each frame to drive playback explicitly; rendering does not advance animation time automatically.
void setAnimationLoop(size_t modelId, bool enabled);
Controls whether sampling wraps at the end of the clip or stops at its boundary.
void setAnimationSpeed(size_t modelId, double speed);
Sets the multiplier applied to animation sampling time. The actual frame position is controlled with setAnimationTime().
void playAnimation(size_t modelId, size_t animationId, double speed = 1.0, bool loop = true);
Selects a clip, clears blending, sets its speed and loop mode, and unpauses it. It does not start a rendering thread or reset the animation time.
void setAnimationPaused(size_t modelId, bool paused);
Sets the model’s playback pause flag. Drawing and rendering remain explicit operations.
bool animationPaused(size_t modelId) const;
bool animationLoop(size_t modelId) const;
double animationSpeed(size_t modelId) const;
double animationDuration(size_t modelId, size_t animationId) const;
Returns the selected clip’s duration in seconds. Both model and clip IDs must be valid.
void draw(size_t modelId, const double3& pos, const double3& size, const double4& rot);
void draw(size_t modelId, const double3& pos, const double3& size);
void draw(size_t modelId, const double3& pos);
Queues an instance of a loaded model at pos with per-axis scale size and quaternion rotation (x, y, z, w). Omitted scale is (1,1,1) and omitted rotation is identity; no pixels are produced until render().
void lookAt(const double3& pos);
Sets the world-space point toward which the camera looks. Use setCamera() to change the camera’s position.
void setCamera(const double3& pos);
Sets the camera position in world coordinates without changing its target.
void setProjection(double verticalFovDegrees, double nearClip, double farClip);
Sets vertical field of view in degrees and the near/far clipping planes.
void setBackfaceCulling(bool flag);
Controls whether triangles facing away from the camera are discarded during rendering.
void setFrustumCulling(bool flag);
Controls rejection of geometry outside the camera’s visible volume.
void setRaytracing(bool flag);
Switches between Metal ray tracing and Metal raster rendering. Enabling ray tracing throws when it is unavailable on the current Mac.
void setAntialiasing(bool flag);
Controls the renderer’s antialiasing step for smoother image edges.
void unload(size_t modelId);
Releases a loaded model and removes its queued instances. An unknown model ID is a no-op; a released ID must not be reused for drawing.
void setLightDirection(const double3& dir);
Sets the direction used for directional lighting. Supply a nonzero direction vector.
void setLight(double ambient, double diffuse);
Sets the ambient and diffuse lighting strengths used when shading geometry.
size_t box(const Colors& faceColors, const double3& size);
size_t box(const double4& color, const double3& size);
Creates box geometry and returns its model ID. The color overload applies one RGBA color throughout; the vector overload supplies per-face colors.
size_t sphere(const double4& color, double radius, size_t nlat, size_t nlon);
Creates sphere geometry and returns its model ID. nlat and nlon control latitude and longitude tessellation.
size_t capsule(const double4& color, double radius, double height, size_t slices, size_t stacks);
Creates capsule geometry and returns its model ID. Radius, height, slices, and stacks control its dimensions and tessellation.
size_t cylinder(const double4& color, double radius, double height, size_t slices);
Creates cylinder geometry and returns its model ID. slices controls radial tessellation.
size_t cone(const double4& color, double radius, double height, size_t slices);
Creates cone geometry and returns its model ID. slices controls radial tessellation.
size_t plane(const double4& color, const double2& size);
size_t plane(const double4& color, const double2& size, size_t nx, size_t ny);
Creates plane geometry and returns its model ID. The nx/ny overload subdivides the plane along its two axes.
size_t torus(const double4& color, double majorRadius, double minorRadius, size_t majorSegments, size_t minorSegments);
Creates torus geometry and returns its model ID. Major/minor radii describe the ring and tube; segment counts control their tessellation.
size_t icosphere(const double4& color, double radius, size_t subdivisions);
Creates a sphere by subdividing an icosahedron and returns its model ID. Increasing subdivisions increases geometry rapidly.
size_t roundedBox(const double4& color, const double3& size, double radius, size_t segments);
Creates rounded-box geometry and returns its model ID. Radius sets the corner rounding and segments control its approximation.