NativeBridge Reference
NativeBridge (managed/rendering/NativeBridge.cs) provides all P/Invoke bindings to the C++ Vulkan renderer.
Renderer Lifecycle
NativeBridge.renderer_init(800, 600, "Window Title"); // create window + Vulkan
NativeBridge.renderer_cleanup(); // destroy everything
Main Loop
NativeBridge.renderer_should_close(); // true when user closes window
NativeBridge.renderer_poll_events(); // process window/input events
NativeBridge.renderer_render_frame(); // draw all active entities
Mesh & Entity Management
int meshId = NativeBridge.LoadMesh("path/to/model.glb");
int entityId = NativeBridge.CreateEntity(meshId);
NativeBridge.SetEntityTransform(entityId, float[16] matrix);
NativeBridge.RemoveEntity(entityId);
Procedural Primitives
Generate meshes for common 3D shapes without external model files. Each method returns a mesh ID usable with CreateEntity().
With Color
int box = NativeBridge.CreateBoxMesh(2f, 1f, 3f, new Color(0.8f, 0.2f, 0.2f));
int sph = NativeBridge.CreateSphereMesh(0.5f, 32, 16, new Color(0.2f, 0.8f, 0.2f));
int pln = NativeBridge.CreatePlaneMesh(10f, 10f, new Color(0.3f, 0.8f, 0.3f));
int cyl = NativeBridge.CreateCylinderMesh(0.4f, 1f, 32, new Color(0.2f, 0.2f, 0.8f));
int cap = NativeBridge.CreateCapsuleMesh(0.3f, 0.6f, 32, 16, new Color(0.9f, 0.8f, 0.2f));
Convenience (default grey)
All shapes have convenience overloads that use default grey color (0.7) and default tessellation (32 segments, 16 rings):
int box = NativeBridge.CreateBoxMesh(1f, 1f, 1f);
int sph = NativeBridge.CreateSphereMesh(0.5f);
int pln = NativeBridge.CreatePlaneMesh(10f, 10f);
int cyl = NativeBridge.CreateCylinderMesh(0.4f, 1f);
int cap = NativeBridge.CreateCapsuleMesh(0.3f, 0.6f);
Raw float overloads
The original float r, float g, float b signatures are still available for direct use:
int box = NativeBridge.CreateBoxMesh(2f, 1f, 3f, 0.8f, 0.2f, 0.2f);
See Primitive Shapes for full parameter tables and ECS usage examples.
Camera
NativeBridge.SetCamera(
eyeX, eyeY, eyeZ, // camera position
targetX, targetY, targetZ, // look-at point
upX, upY, upZ, // up vector
fovDegrees // vertical FOV
);
Sets the view and projection matrices. If never called, defaults to eye (0,0,3), target (0,0,0), up (0,1,0), FOV 45. Typically called by CameraFollowSystem rather than directly.
bool pressed = NativeBridge.IsKeyPressed(NativeBridge.KEY_W);
See Input for the full list of key constants.
Cursor
NativeBridge.SetCursorLocked(true); // capture cursor
NativeBridge.SetCursorLocked(false); // release cursor
bool locked = NativeBridge.IsCursorLocked();
double mx, my;
NativeBridge.GetCursorPos(out mx, out my);
Time
NativeBridge.renderer_update_time(); // sample glfwGetTime, compute delta
float dt = NativeBridge.renderer_get_delta_time(); // seconds since last update
float total = NativeBridge.renderer_get_total_time(); // seconds since init
Lighting
NativeBridge.SetLight(index, type,
posX, posY, posZ,
dirX, dirY, dirZ,
r, g, b, intensity,
radius, innerCone, outerCone);
NativeBridge.ClearLight(index); // disable a light slot
NativeBridge.SetAmbient(intensity); // set ambient light level
Note
The innerCone and outerCone parameters expect cosine values, not degrees. The LightSyncSystem handles this conversion automatically from the Light component's degree fields.
Debug Overlay
NativeBridge.SetDebugOverlay(true); // show overlay
NativeBridge.SetDebugOverlay(false); // hide overlay
int count = NativeBridge.GetEntityCount(); // active entities in renderer
The overlay is managed by DebugOverlaySystem which toggles it via the F3 key. See Debug Overlay for details.
Debug Wireframe Entities
Debug entities are rendered as wireframes using a separate Vulkan pipeline (VK_POLYGON_MODE_LINE). They are only drawn when the debug overlay is enabled.
int debugId = NativeBridge.CreateDebugEntity(meshId);
NativeBridge.SetDebugEntityTransform(debugId, float[16] matrix);
NativeBridge.RemoveDebugEntity(debugId);
NativeBridge.ClearDebugEntities(); // remove all debug entities
These are used by DebugColliderRenderSystem to visualize physics collider shapes. See Debug Overlay for details.