Version: 1.1.0
Last Updated: February 2026
Complete API documentation for RayMap projection mapping library.
- Core Types
- Surface Management
- Rendering
- Calibration
- Configuration I/O
- Geometry Utilities
- Point Mapping
- Video Extension (RayMapVid)
- Constants & Macros
- Error Handling
typedef struct {
Vector2 topLeft;
Vector2 topRight;
Vector2 bottomRight;
Vector2 bottomLeft;
} RM_Quad;Description:
Defines a 4-point quadrilateral in screen space. Corner order is counter-clockwise starting from top-left.
Fields:
topLeft- Top-left corner position (screen coordinates)topRight- Top-right corner positionbottomRight- Bottom-right corner positionbottomLeft- Bottom-left corner position
Example:
RM_Quad quad = {
.topLeft = {100, 100},
.topRight = {1820, 100},
.bottomRight = {1820, 980},
.bottomLeft = {100, 980}
};Notes:
- Coordinates are in pixels (screen space)
- Quad should be convex for best results
- Minimum area: 100 square pixels
- Minimum corner distance: 1 pixel
typedef enum {
RM_MAP_BILINEAR = 0, // Simple bilinear interpolation
RM_MAP_HOMOGRAPHY // Perspective-correct homography
} RM_MapMode;Description:
Mapping algorithm used for surface warping.
Values:
| Mode | Description | Use Case | Default Mesh |
|---|---|---|---|
RM_MAP_BILINEAR |
Fast bilinear interpolation | Flat/slightly curved surfaces | 16×16 |
RM_MAP_HOMOGRAPHY |
Perspective-correct transform | Projections, 3D surfaces | 32×32 |
Performance:
- Bilinear: ~10% faster
- Homography: More accurate for perspective
typedef struct RM_Surface RM_Surface; // Opaque typeDescription:
Opaque handle to a mappable surface. Contains render texture, mesh, and transformation state.
Lifecycle:
RM_Surface *surf = RM_CreateSurface(...); // Create
// ... use surface ...
RM_DestroySurface(surf); // DestroyInternal State (not directly accessible):
- Render texture (user draws to this)
- Deformed mesh (GPU geometry)
- Quad corner positions
- Homography matrix (cached)
- Mesh resolution settings
- Dirty flags for lazy updates
typedef struct {
bool showCorners; // Display corner handles
bool showGrid; // Display deformation grid
bool showBorder; // Display quad border
Color cornerColor; // Default corner color
Color selectedCornerColor; // Active corner color
Color gridColor; // Grid line color
Color borderColor; // Border color
float cornerRadius; // Corner handle radius (pixels)
int gridResolutionX; // Horizontal grid subdivisions
int gridResolutionY; // Vertical grid subdivisions
} RM_CalibrationConfig;Description:
Visual configuration for calibration overlay.
Default Values:
{
.showCorners = true,
.showGrid = true,
.showBorder = true,
.cornerColor = YELLOW,
.selectedCornerColor = GREEN,
.gridColor = ColorAlpha(WHITE, 0.3f),
.borderColor = RED,
.cornerRadius = 15.0f,
.gridResolutionX = 8,
.gridResolutionY = 8
}Customization:
RM_Calibration calib = RM_CalibrationDefault(surface);
calib.config.cornerRadius = 20.0f; // Bigger handles
calib.config.gridColor = ColorAlpha(BLUE, 0.5f);
calib.config.showGrid = false; // Hide gridtypedef struct {
RM_Surface *surface; // Target surface
RM_CalibrationConfig config; // Visual settings
int activeCorner; // Currently selected corner (-1 if none)
Vector2 dragOffset; // Mouse drag offset
bool enabled; // Calibration mode active/inactive
} RM_Calibration;Description:
Calibration state for interactive corner adjustment.
Usage Pattern:
RM_Calibration calib = RM_CalibrationDefault(surface);
// In update loop:
RM_UpdateCalibrationInput(&calib, KEY_C); // Toggle with C
// In draw loop:
RM_DrawCalibration(calib);Corner Indices:
0- Top-left1- Top-right2- Bottom-right3- Bottom-left-1- No corner selected
RM_Surface *RM_CreateSurface(int width, int height, RM_MapMode mode);Description:
Creates a new mappable surface with render texture and mesh.
Parameters:
width- Render texture width in pixels (1-8192)height- Render texture height in pixels (1-8192)mode- Mapping algorithm (RM_MAP_BILINEARorRM_MAP_HOMOGRAPHY)
Returns:
- Pointer to new surface on success
NULLon failure (check logs)
Errors:
- Invalid dimensions (≤0 or >8192)
- Memory allocation failure
- GPU texture creation failure
- Mesh generation failure
Example:
// HD surface with homography
RM_Surface *surf = RM_CreateSurface(1920, 1080, RM_MAP_HOMOGRAPHY);
if (!surf) {
TraceLog(LOG_ERROR, "Failed to create surface!");
return -1;
}Notes:
- Initial quad is centered rectangle matching texture dimensions
- Mesh is generated immediately
- Default resolution: 16×16 (bilinear) or 32×32 (homography)
void RM_DestroySurface(RM_Surface *surface);Description:
Destroys surface and frees all resources (texture, mesh, memory).
Parameters:
surface- Surface to destroy (can beNULL, safe to call)
Example:
RM_DestroySurface(surface);
surface = NULL; // Good practiceCleanup Order:
- Mesh (GPU buffers + CPU arrays)
- Material
- Render texture
- Surface struct
Thread Safety:
Not thread-safe. Do not destroy while drawing.
bool RM_SetQuad(RM_Surface *surface, RM_Quad quad);Description:
Sets quad corner positions. Validates and applies transformation.
Parameters:
surface- Target surfacequad- New quad corner positions
Returns:
trueif quad is valid and appliedfalseif quad is rejected (surface unchanged)
Validation:
- Minimum area: 100 square pixels
- Minimum corner distance: 1 pixel
- All corners must be distinct
Example:
RM_Quad trapezoid = {
{200, 100}, // Top-left
{1720, 100}, // Top-right (wider)
{1600, 980}, // Bottom-right (narrower)
{320, 980} // Bottom-left (narrower)
};
if (!RM_SetQuad(surface, trapezoid)) {
TraceLog(LOG_WARNING, "Invalid quad rejected");
}Side Effects:
- Sets
meshNeedsUpdate = true - Sets
homographyNeedsUpdate = true - Mesh regenerated on next
RM_DrawSurface()
RM_Quad RM_GetQuad(const RM_Surface *surface);Description:
Gets current quad corner positions.
Parameters:
surface- Surface to query
Returns:
- Current quad positions
- Zero quad if surface is
NULL
Example:
RM_Quad current = RM_GetQuad(surface);
TraceLog(LOG_INFO, "Top-left: %.0f, %.0f",
current.topLeft.x, current.topLeft.y);void RM_GetSurfaceSize(const RM_Surface *surface, int *width, int *height);Description:
Gets render texture dimensions.
Parameters:
surface- Surface to querywidth- Output: texture width (can beNULL)height- Output: texture height (can beNULL)
Example:
int w, h;
RM_GetSurfaceSize(surface, &w, &h);
TraceLog(LOG_INFO, "Surface size: %dx%d", w, h);void RM_SetMeshResolution(RM_Surface *surface, int columns, int rows);Description:
Sets mesh subdivision resolution. Higher = smoother warping, lower performance.
Parameters:
surface- Target surfacecolumns- Horizontal subdivisions (4-64, clamped)rows- Vertical subdivisions (4-64, clamped)
Example:
// High detail for curved surface
RM_SetMeshResolution(surface, 64, 64); // 4225 vertices
// Low detail for flat surface
RM_SetMeshResolution(surface, 8, 8); // 81 verticesPerformance Impact:
| Resolution | Vertices | Triangles | FPS (RTX 3060) |
|---|---|---|---|
| 4×4 | 25 | 32 | 3000+ |
| 16×16 | 289 | 512 | 2000+ |
| 32×32 | 1089 | 2048 | 1500+ |
| 64×64 | 4225 | 8192 | 800+ |
Notes:
- No effect if values unchanged
- Mesh regenerated on next draw
- Higher resolution needed for homography mode
void RM_GetMeshResolution(const RM_Surface *surface, int *columns, int *rows);Description:
Gets current mesh resolution.
Parameters:
surface- Surface to querycolumns- Output: horizontal subdivisions (can beNULL)rows- Output: vertical subdivisions (can beNULL)
Example:
int cols, rows;
RM_GetMeshResolution(surface, &cols, &rows);
TraceLog(LOG_INFO, "Mesh: %dx%d", cols, rows);void RM_BeginSurface(RM_Surface *surface);Description:
Begins drawing to surface render texture. All raylib draw calls will be captured.
Parameters:
surface- Surface to draw to
Example:
RM_BeginSurface(surface);
ClearBackground(BLACK);
DrawText("Content", 100, 100, 40, WHITE);
DrawCircle(400, 300, 50, RED);
RM_EndSurface(surface);Notes:
- Must be paired with
RM_EndSurface() - Cannot nest surface drawing
- Equivalent to
BeginTextureMode(surface->target)
void RM_EndSurface(RM_Surface *surface);Description:
Ends drawing to surface render texture.
Parameters:
surface- Surface being drawn to
Notes:
- Must match previous
RM_BeginSurface() - Equivalent to
EndTextureMode()
void RM_DrawSurface(RM_Surface *surface);Description:
Draws the warped surface to the screen. Applies mesh transformation.
Parameters:
surface- Surface to render
Example:
BeginDrawing();
ClearBackground(BLACK);
RM_DrawSurface(surface); // Draws warped surface
EndDrawing();Internal Behavior:
- Lazy mesh update (if quad changed)
- Validate mesh/texture
- Disable depth test/backface culling
- Draw mesh with texture
- Restore GL state
Performance:
- Mesh update only when needed (dirty flag)
- Single draw call per surface
- GPU-accelerated transformation
void RM_SetMapMode(RM_Surface *surface, RM_MapMode mode);Description:
Changes mapping algorithm. Triggers mesh regeneration.
Parameters:
surface- Target surfacemode- New mapping mode
Example:
// Switch to homography for better perspective
RM_SetMapMode(surface, RM_MAP_HOMOGRAPHY);
// Toggle mode
RM_MapMode current = RM_GetMapMode(surface);
RM_SetMapMode(surface,
current == RM_MAP_BILINEAR ? RM_MAP_HOMOGRAPHY : RM_MAP_BILINEAR);Side Effects:
- Updates default mesh resolution for new mode
- Sets
meshNeedsUpdate = true - No-op if mode unchanged
RM_MapMode RM_GetMapMode(const RM_Surface *surface);Description:
Gets current mapping mode.
Parameters:
surface- Surface to query
Returns:
- Current map mode
RM_MAP_BILINEARif surface isNULL
RM_Calibration RM_CalibrationDefault(RM_Surface *surface);Description:
Creates calibration state with default visual settings.
Parameters:
surface- Surface to calibrate
Returns:
- Calibration struct with default config
- Enabled by default
Example:
RM_Calibration calib = RM_CalibrationDefault(surface);
// Customize
calib.config.cornerRadius = 20.0f;
calib.config.borderColor = BLUE;Default Config:
- Yellow corners (green when selected)
- White semi-transparent grid (8×8)
- Red border
- 15px corner radius
- All overlays enabled
void RM_UpdateCalibration(RM_Calibration *calibration);Description:
Updates calibration state. Handles mouse input for corner dragging.
Parameters:
calibration- Calibration to update
Example:
// In main loop (update section)
if (calibration.enabled) {
RM_UpdateCalibration(&calibration);
}Input Handling:
- Mouse Down - Check if clicked on corner (within radius × 1.5)
- Mouse Drag - Move active corner with offset
- Mouse Up - Release corner
Notes:
- Only processes input if
enabled == true - Call every frame when calibration is active
- Does not toggle enabled state (use
RM_ToggleCalibrationorRM_UpdateCalibrationInput)
void RM_UpdateCalibrationInput(RM_Calibration *calibration, int toggleKey);Description:
Updates calibration with automatic toggle key handling.
Parameters:
calibration- Calibration to updatetoggleKey- Key to toggle calibration (0 = no toggle, e.g.,KEY_C)
Example:
// Toggle with C, drag corners with mouse
RM_UpdateCalibrationInput(&calib, KEY_C);Equivalent To:
if (toggleKey != 0 && IsKeyPressed(toggleKey)) {
RM_ToggleCalibration(calibration);
}
RM_UpdateCalibration(calibration);void RM_ToggleCalibration(RM_Calibration *calibration);Description:
Toggles calibration on/off. Releases active corner when disabled.
Parameters:
calibration- Calibration to toggle
Example:
if (IsKeyPressed(KEY_C)) {
RM_ToggleCalibration(&calib);
}State Changes:
enabled = !enabledactiveCorner = -1(if disabling)
void RM_DrawCalibration(RM_Calibration calibration);Description:
Draws complete calibration overlay (border + grid + corners).
Parameters:
calibration- Calibration to draw
Example:
BeginDrawing();
RM_DrawSurface(surface);
RM_DrawCalibration(calib); // Draw overlay on top
EndDrawing();Draw Order:
- Border (if
showBorder) - Grid (if
showGrid) - Corners (if
showCorners)
Equivalent To:
RM_DrawCalibrationBorder(calib);
RM_DrawCalibrationGrid(calib);
RM_DrawCalibrationCorners(calib);void RM_DrawCalibrationCorners(RM_Calibration calibration);Description:
Draws only corner handles with labels.
Parameters:
calibration- Calibration to draw
Visual:
- Filled circle (color depends on selection state)
- White outline
- Black text label (0-3)
void RM_DrawCalibrationBorder(RM_Calibration calibration);Description:
Draws only quad border lines.
Parameters:
calibration- Calibration to draw
Visual:
- 2px thick lines connecting corners
- Color:
config.borderColor
void RM_DrawCalibrationGrid(RM_Calibration calibration);Description:
Draws only deformation grid.
Parameters:
calibration- Calibration to draw
Visual:
- Horizontal lines (top to bottom interpolation)
- Vertical lines (left to right interpolation)
- Resolution from
config.gridResolutionX/Y - Color:
config.gridColor
void RM_ResetCalibrationQuad(RM_Calibration *calibration,
int screenWidth, int screenHeight);Description:
Resets quad to centered rectangle matching surface dimensions.
Parameters:
calibration- Calibration to resetscreenWidth- Screen width for centeringscreenHeight- Screen height for centering
Example:
if (IsKeyPressed(KEY_R)) {
RM_ResetCalibrationQuad(&calib, 1920, 1080);
}Equivalent To:
RM_ResetQuad(calibration->surface, screenWidth, screenHeight);void RM_ResetQuad(RM_Surface *surface, int screenWidth, int screenHeight);Description:
Resets surface quad to centered rectangle.
Parameters:
surface- Surface to resetscreenWidth- Screen widthscreenHeight- Screen height
Example:
// Reset to center of 1920x1080 screen
RM_ResetQuad(surface, 1920, 1080);Calculation:
int x = (screenWidth - surface->width) / 2;
int y = (screenHeight - surface->height) / 2;
// Quad becomes:
// (x, y) ----------- (x+w, y)
// | |
// (x, y+h) --------- (x+w, y+h)int RM_GetActiveCorner(RM_Calibration calibration);Description:
Gets index of currently selected corner.
Parameters:
calibration- Calibration to query
Returns:
0-3- Corner index-1- No corner selected
bool RM_IsCalibrating(RM_Calibration calibration);Description:
Checks if user is currently dragging a corner.
Parameters:
calibration- Calibration to check
Returns:
trueif actively dragging cornerfalseotherwise
Logic:
return (calibration.activeCorner >= 0 && IsMouseButtonDown(MOUSE_LEFT_BUTTON));bool RM_SaveConfig(const RM_Surface *surface, const char *filepath);Description:
Saves surface configuration to text file.
Parameters:
surface- Surface to savefilepath- Output file path
Returns:
trueon successfalseon failure
File Format:
# RAYMAP Config File
# Format: text/plain v1.0
[Surface]
width=1920
height=1080
[Mode]
mode=HOMOGRAPHY
[Mesh]
columns=32
rows=32
[Quad]
topLeft=200.00,100.00
topRight=1720.00,100.00
bottomRight=1600.00,980.00
bottomLeft=320.00,980.00Example:
if (IsKeyPressed(KEY_S)) {
if (RM_SaveConfig(surface, "calibration.cfg")) {
TraceLog(LOG_INFO, "Saved!");
}
}Errors:
NULLparameters- File cannot be opened for writing
- Disk full
bool RM_LoadConfig(RM_Surface *surface, const char *filepath);Description:
Loads surface configuration from text file.
Parameters:
surface- Surface to configurefilepath- Input file path
Returns:
trueon successfalseon failure
Example:
if (IsKeyPressed(KEY_L)) {
if (RM_LoadConfig(surface, "calibration.cfg")) {
TraceLog(LOG_INFO, "Loaded!");
}
}Parsing:
- Ignores comments (
#) - Ignores empty lines
- Ignores section headers (
[...]) - Parses
key=valuepairs
Applied Settings:
- Mapping mode
- Mesh resolution
- Quad corners
Errors:
- File not found
- Invalid format
- No quad data found
Notes:
- Surface dimensions not validated (must match)
- Quad validated (min area, distinct corners)
bool RM_PointInQuad(Vector2 point, RM_Quad quad);Description:
Tests if point is inside quad using same-side method.
Parameters:
point- Point to test (screen coordinates)quad- Quad to test against
Returns:
trueif point inside quadfalseif outside
Example:
Vector2 mousePos = GetMousePosition();
if (RM_PointInQuad(mousePos, quad)) {
DrawText("Inside!", 10, 10, 20, GREEN);
}Algorithm:
- Compute quad center
- Check if point is on same side of each edge as center
- All 4 checks must pass
Limitations:
- Assumes convex quad
- May fail for highly concave quads
Rectangle RM_GetQuadBounds(RM_Quad quad);Description:
Computes axis-aligned bounding box of quad.
Parameters:
quad- Quad to bound
Returns:
- Rectangle containing quad (min/max of all corners)
Example:
Rectangle bounds = RM_GetQuadBounds(quad);
DrawRectangleLinesEx(bounds, 2, BLUE); // Debug visualizationUses:
- Culling tests
- UI layout
- Click detection optimization
Vector2 RM_GetQuadCenter(RM_Quad quad);Description:
Computes geometric center (average of corners).
Parameters:
quad- Quad to center
Returns:
- Center point
Formula:
center.x = (topLeft.x + topRight.x + bottomRight.x + bottomLeft.x) / 4
center.y = (topLeft.y + topRight.y + bottomRight.y + bottomLeft.y) / 4Example:
Vector2 center = RM_GetQuadCenter(quad);
DrawCircle(center.x, center.y, 10, YELLOW); // Mark centerfloat RM_GetQuadArea(RM_Quad quad);Description:
Calculates quad area using shoelace formula.
Parameters:
quad- Quad to measure
Returns:
- Area in square pixels
Formula:
area = 0.5 * |x1(y2-y4) + x2(y3-y1) + x3(y4-y2) + x4(y1-y3)|Example:
float area = RM_GetQuadArea(quad);
TraceLog(LOG_INFO, "Quad area: %.0f px²", area);Uses:
- Validation (min area = 100px²)
- Quality metrics
- Deformation analysis
Vector2 RM_MapPoint(RM_Surface *surface, Vector2 texturePoint);Description:
Maps point from texture space [0,1] to screen space using current transformation.
Parameters:
surface- Surface with transformationtexturePoint- Point in texture UV coordinates (0,0 = top-left, 1,1 = bottom-right)
Returns:
- Point in screen coordinates
(-1, -1)if surface isNULL
Example:
// Map texture center (0.5, 0.5) to screen
Vector2 texCenter = {0.5f, 0.5f};
Vector2 screenPos = RM_MapPoint(surface, texCenter);
DrawCircle(screenPos.x, screenPos.y, 10, RED);Algorithm:
- Bilinear mode: Bilinear interpolation between quad corners
- Homography mode: Apply homography matrix transformation
Clamping:
- Input clamped to [0,1]
- Output can be anywhere in screen space
Vector2 RM_UnmapPoint(RM_Surface *surface, Vector2 screenPoint);Description:
Maps point from screen space to texture space [0,1] using inverse transformation.
Parameters:
surface- Surface with transformationscreenPoint- Point in screen coordinates
Returns:
- Point in texture UV coordinates [0,1]
(-1, -1)if point is outside quad or surface isNULL
Example:
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) {
Vector2 mousePos = GetMousePosition();
Vector2 texCoords = RM_UnmapPoint(surface, mousePos);
if (texCoords.x >= 0) {
TraceLog(LOG_INFO, "Clicked at UV: %.2f, %.2f",
texCoords.x, texCoords.y);
}
}Algorithm:
- Check if point inside quad (
RM_PointInQuad) - Compute inverse homography matrix
- Apply inverse transform
- Clamp result to [0,1]
Notes:
- Always uses homography inverse (even in bilinear mode)
- Returns
(-1,-1)if point outside quad - Clamped output ensures valid texture coordinates
Use Cases:
- Click detection on warped surface
- Touch input mapping
- Interactive content
typedef struct RMV_Video RMV_Video; // Opaque typeDescription:
Opaque handle to video decoder and playback state.
Lifecycle:
RMV_Video *video = RMV_LoadVideo("video.mp4");
// ... use video ...
RMV_UnloadVideo(video);typedef struct {
int width; // Video width in pixels
int height; // Video height in pixels
float duration; // Duration in seconds
float fps; // Frames per second
const char *codec; // Codec name (e.g., "h264")
const char *format; // Container format (e.g., "mp4")
bool hasAudio; // Audio stream present
RMV_HWAccelType hwaccel; // Active hardware acceleration
} RMV_VideoInfo;Description:
Video metadata and properties.
Example:
RMV_VideoInfo info = RMV_GetVideoInfo(video);
TraceLog(LOG_INFO, "Video: %dx%d @ %.0f fps, codec=%s",
info.width, info.height, info.fps, info.codec);typedef enum {
RMV_STATE_STOPPED = 0,
RMV_STATE_PLAYING,
RMV_STATE_PAUSED,
RMV_STATE_ERROR
} RMV_PlaybackState;Description:
Video playback state.
RMV_Video *RMV_LoadVideo(const char *filepath);Description:
Loads video file and initializes decoder.
Parameters:
filepath- Path to video file
Returns:
- Video handle on success
NULLon failure
Supported Formats:
- MP4, MOV, AVI, MKV, WebM
- Codecs: H.264, H.265/HEVC, VP8, VP9, AV1
Example:
RMV_Video *video = RMV_LoadVideo("content.mp4");
if (!video) {
TraceLog(LOG_ERROR, "Failed to load video!");
return -1;
}Errors:
- File not found
- Unsupported codec
- Invalid video stream
- Memory allocation failure
void RMV_UnloadVideo(RMV_Video *video);Description:
Unloads video and frees all resources.
Parameters:
video- Video to unload (can beNULL)
Example:
RMV_UnloadVideo(video);
video = NULL;RMV_VideoInfo RMV_GetVideoInfo(const RMV_Video *video);Description:
Gets video metadata.
Parameters:
video- Video to query
Returns:
- Video info struct
- Zero struct if video is
NULLor unloaded
Texture2D RMV_GetVideoTexture(const RMV_Video *video);Description:
Gets current frame as raylib texture.
Parameters:
video- Video to get texture from
Returns:
- Texture with current frame
- Empty texture if video invalid
Example:
RMV_UpdateVideo(video, GetFrameTime());
RM_BeginSurface(surface);
Texture2D videoTex = RMV_GetVideoTexture(video);
DrawTexture(videoTex, 0, 0, WHITE);
RM_EndSurface(surface);Notes:
- Texture created lazily on first call
- Same texture reused (UpdateTexture internally)
- Do NOT unload the returned texture
void RMV_UpdateVideo(RMV_Video *video, float deltaTime);Description:
Updates video playback. Decodes frames based on delta time.
Parameters:
video- Video to updatedeltaTime- Time since last update (seconds)
Example:
while (!WindowShouldClose()) {
float dt = GetFrameTime();
RMV_UpdateVideo(video, dt);
// ... render ...
}Behavior:
- Only updates when
state == RMV_STATE_PLAYING - Decodes frames to match target FPS
- Handles looping if enabled
- Updates texture automatically
Frame Timing:
- Accumulates delta time
- Decodes when accumulated ≥ frame duration
- Prevents frame skipping/dropping
void RMV_PlayVideo(RMV_Video *video);Description:
Starts/resumes video playback.
Parameters:
video- Video to play
Example:
RMV_PlayVideo(video); // Start playingvoid RMV_PauseVideo(RMV_Video *video);Description:
Pauses video playback.
Parameters:
video- Video to pause
void RMV_StopVideo(RMV_Video *video);Description:
Stops video and resets to beginning.
Parameters:
video- Video to stop
Effects:
state = RMV_STATE_STOPPEDcurrentTime = 0.0f
void RMV_ToggleVideoPause(RMV_Video *video);Description:
Toggles between playing and paused states.
Parameters:
video- Video to toggle
Example:
if (IsKeyPressed(KEY_SPACE)) {
RMV_ToggleVideoPause(video);
}RMV_PlaybackState RMV_GetVideoState(const RMV_Video *video);Description:
Gets current playback state.
Parameters:
video- Video to query
Returns:
- Current state
RMV_STATE_ERRORif video invalid
bool RMV_IsVideoPlaying(const RMV_Video *video);Description:
Checks if video is currently playing.
Parameters:
video- Video to check
Returns:
trueifstate == RMV_STATE_PLAYINGfalseotherwise
bool RMV_IsVideoLoaded(const RMV_Video *video);Description:
Checks if video is loaded and valid.
Parameters:
video- Video to check
Returns:
trueif video is loadedfalseifNULLor unloaded
void RMV_SetVideoLoop(RMV_Video *video, bool loop);Description:
Enables/disables video looping.
Parameters:
video- Video to configureloop-trueto enable looping
Example:
RMV_SetVideoLoop(video, true); // Loop foreverBehavior:
- When loop enabled: seek to start on EOF
- When loop disabled: stop on EOF
#ifndef RMAPI
#define RMAPI extern
#endifDescription:
API function prefix. Allows DLL export/import customization.
Custom Usage:
#define RMAPI __declspec(dllexport) // Windows DLL
#include "raymap.h"#ifndef RMMALLOC
#define RMMALLOC(sz) malloc(sz)
#endif
#ifndef RMCALLOC
#define RMCALLOC(n, sz) calloc(n, sz)
#endif
#ifndef RMFREE
#define RMFREE(p) free(p)
#endifDescription:
Memory allocation macros. Override for custom allocators.
Custom Usage:
#define RMMALLOC(sz) my_pool_alloc(pool, sz)
#define RMCALLOC(n,sz) my_pool_calloc(pool, n, sz)
#define RMFREE(p) my_pool_free(pool, p)
#define RAYMAP_IMPLEMENTATION
#include "raymap.h"#ifdef RAYMAP_DEBUG
RMAPI Mesh *RM_GetSurfaceMesh(RM_Surface *surface);
#endifDescription:
Enables debug functions when RAYMAP_DEBUG is defined.
Usage:
#define RAYMAP_DEBUG
#define RAYMAP_IMPLEMENTATION
#include "raymap.h"
// Access internal mesh for debugging
Mesh *mesh = RM_GetSurfaceMesh(surface);
TraceLog(LOG_INFO, "Vertex count: %d", mesh->vertexCount);** Warning:** Do NOT modify or free the returned mesh!
#define RM_EPSILON 1e-4f // Floating-point epsilonDescription:
Precision threshold for geometric calculations.
RayMap uses Raylib's TraceLog for all error reporting.
Log Levels:
LOG_INFO- Informational messagesLOG_WARNING- Warnings (operation continues)LOG_ERROR- Errors (operation fails)LOG_DEBUG- Debug info (verbose)
Example:
SetTraceLogLevel(LOG_ALL); // Enable all logs
RM_Surface *surf = RM_CreateSurface(10000, 10000, RM_MAP_BILINEAR);
// LOG_ERROR: "RAYMAP: Invalid width 10000 (must be 1-8192)"NULL Pointers:
RM_CreateSurface()returnsNULLon failureRMV_LoadVideo()returnsNULLon failure
Boolean Returns:
RM_SetQuad()returnsfalseif quad invalidRM_SaveConfig()/RM_LoadConfig()returnfalseon I/O error
Safe Patterns:
// Check creation
RM_Surface *surf = RM_CreateSurface(800, 600, RM_MAP_BILINEAR);
if (!surf) {
TraceLog(LOG_ERROR, "Surface creation failed!");
return -1;
}
// Check quad validation
if (!RM_SetQuad(surf, newQuad)) {
TraceLog(LOG_WARNING, "Invalid quad, keeping old one");
}
// Check I/O
if (!RM_LoadConfig(surf, "config.cfg")) {
TraceLog(LOG_WARNING, "Using default calibration");
}Invalid Parameters:
RM_DrawSurface(NULL); // LOG_WARNING + early returnDimension Errors:
RM_CreateSurface(0, 1080, ...); // LOG_ERROR + NULL
RM_CreateSurface(10000, 1080, ...); // LOG_ERROR + NULLQuad Validation:
// Area too small
RM_Quad tiny = {{0,0}, {5,0}, {5,5}, {0,5}}; // 25px²
RM_SetQuad(surf, tiny); // LOG_WARNING + false
// Corners too close
RM_Quad degenerate = {{100,100}, {100.5,100}, {100.5,100.5}, {100,100.5}};
RM_SetQuad(surf, degenerate); // LOG_WARNING + falseResource Exhaustion:
// GPU out of memory
RM_SetMeshResolution(surf, 256, 256); // May fail silently if GPU OOMRayMap is NOT thread-safe.
Single-threaded only:
- All functions must be called from the same thread
- Do not create/destroy surfaces from different threads
- Do not update/draw from different threads
Known Issues:
rmv_GetFFmpegError()uses static buffer (data race)
Workarounds:
- Use mutex if multi-threading needed
- Create separate surfaces per thread (no sharing)
// Low detail (fast) - 289 vertices
RM_SetMeshResolution(surface, 16, 16);
// High detail (slow) - 4225 vertices
RM_SetMeshResolution(surface, 64, 64);Choose based on:
- Flat surface → 8×8 or 16×16
- Moderate warp → 32×32
- Highly curved → 64×64
// Don't set quad every frame!
if (quadChanged) {
RM_SetQuad(surface, newQuad); // Triggers mesh regen
}
// Mesh only regenerates on next RM_DrawSurface()// Lower resolution = higher FPS
RMV_LoadVideo("720p.mp4"); // Faster than 1080p- README.md - Library overview
- Examples - Code examples
- Raylib Documentation
Last Updated: February 2026
Version: 1.1.0