# std.raylib

Native Raylib bindings. Requires an installed Raylib library. C symbol names are preserved. See docs/guide/native-bindings.md for ABI rules. Struct calls currently require arm64 macOS. Checked against Raylib 6.0.

```tea
use raylib from "std.raylib"
```

Examples may be fragments requiring the module import or additional setup.

## std.raylib.SetConfigFlags

```tea
pub extern "raylib" def SetConfigFlags(flags: CUInt) -> Void
```

Configure window flags before InitWindow.

## std.raylib.SetWindowMinSize

```tea
pub extern "raylib" def SetWindowMinSize(width: CInt, height: CInt) -> Void
```

Set the minimum size of a resizable window.

## std.raylib.LoadTexture

```tea
pub extern "raylib" def LoadTexture(path: CString) -> Texture
```

Load an image file into GPU memory; requires an open graphics context. Check IsTextureValid, then pair each successful load with one UnloadTexture.

## std.raylib.IsTextureValid

```tea
pub extern "raylib" def IsTextureValid(texture: Texture) -> CBool
```

Validate texture metadata after loading; this does not detect a previously unloaded handle.

## std.raylib.UnloadTexture

```tea
pub extern "raylib" def UnloadTexture(texture: Texture) -> Void
```

Release a texture before closing its graphics context. Never use any copies afterward.

## std.raylib.DrawTexture

```tea
pub extern "raylib" def DrawTexture(texture: Texture, x: CInt, y: CInt, tint: Color) -> Void
```

Draw a texture at an integer position.

## std.raylib.DrawTextureV

```tea
pub extern "raylib" def DrawTextureV(texture: Texture, position: Vector2, tint: Color) -> Void
```

Draw a texture at a two-dimensional position.

## std.raylib.DrawTexturePro

```tea
pub extern "raylib" def DrawTexturePro(texture: Texture, source: Rectangle, destination: Rectangle, origin: Vector2, rotation: CFloat, tint: Color) -> Void
```

Draw part of a texture with scaling and rotation.

## std.raylib.SetTextureFilter

```tea
pub extern "raylib" def SetTextureFilter(texture: Texture, filter: CInt) -> Void
```

Choose a texture scaling filter.

## std.raylib.InitWindow

```tea
pub extern "raylib" def InitWindow(width: CInt, height: CInt, title: CStaticString) -> Void
```

Create the window and graphics context. Call from the main thread.

## std.raylib.CloseWindow

```tea
pub extern "raylib" def CloseWindow() -> Void
```

Close the window and release its graphics context.

## std.raylib.WindowShouldClose

```tea
pub extern "raylib" def WindowShouldClose() -> CBool
```

Check whether the close button or exit key requested shutdown.

## std.raylib.IsWindowReady

```tea
pub extern "raylib" def IsWindowReady() -> CBool
```

Check whether window initialization succeeded.

## std.raylib.SetWindowTitle

```tea
pub extern "raylib" def SetWindowTitle(title: CStaticString) -> Void
```

Change the window title. Raylib retains this read-only string.

## std.raylib.SetWindowSize

```tea
pub extern "raylib" def SetWindowSize(width: CInt, height: CInt) -> Void
```

Resize the window.

## std.raylib.GetScreenWidth

```tea
pub extern "raylib" def GetScreenWidth() -> CInt
```

Get the window's logical width.

## std.raylib.GetScreenHeight

```tea
pub extern "raylib" def GetScreenHeight() -> CInt
```

Get the window's logical height.

## std.raylib.BeginDrawing

```tea
pub extern "raylib" def BeginDrawing() -> Void
```

Begin drawing a frame.

## std.raylib.EndDrawing

```tea
pub extern "raylib" def EndDrawing() -> Void
```

Present the frame and process timing/input.

## std.raylib.rlClearScreenBuffers

```tea
pub extern "raylib" def rlClearScreenBuffers() -> Void
```

Clear the frame using rlgl's current clear color (black by default). Prefer ClearBackground for the public drawing API.

## std.raylib.DrawFPS

```tea
pub extern "raylib" def DrawFPS(x: CInt, y: CInt) -> Void
```

Draw the current frame rate at a screen position.

## std.raylib.ClearBackground

```tea
pub extern "raylib" def ClearBackground(color: Color) -> Void
```

Clear the frame to a color.

## std.raylib.DrawCircleV

```tea
pub extern "raylib" def DrawCircleV(center: Vector2, radius: CFloat, color: Color) -> Void
```

Draw a filled circle at a two-dimensional position.

## std.raylib.DrawRectangleRec

```tea
pub extern "raylib" def DrawRectangleRec(rectangle: Rectangle, color: Color) -> Void
```

Draw a filled rectangle.

## std.raylib.DrawText

```tea
pub extern "raylib" def DrawText(text: CString, x: CInt, y: CInt, font_size: CInt, color: Color) -> Void
```

Draw text using the default font; the string is borrowed for this call only.

## std.raylib.GetMousePosition

```tea
pub extern "raylib" def GetMousePosition() -> Vector2
```

Get the mouse position in screen coordinates.

## std.raylib.Fade

```tea
pub extern "raylib" def Fade(color: Color, alpha: CFloat) -> Color
```

Return a color with the supplied alpha between zero and one.

## std.raylib.GetCollisionRec

```tea
pub extern "raylib" def GetCollisionRec(first: Rectangle, second: Rectangle) -> Rectangle
```

Return the intersection of two rectangles.

## std.raylib.SetTargetFPS

```tea
pub extern "raylib" def SetTargetFPS(fps: CInt) -> Void
```

Limit the frame rate.

## std.raylib.GetFrameTime

```tea
pub extern "raylib" def GetFrameTime() -> CFloat
```

Return the most recent frame's duration in seconds.

## std.raylib.GetTime

```tea
pub extern "raylib" def GetTime() -> CDouble
```

Return elapsed time since initialization, in seconds.

## std.raylib.IsKeyDown

```tea
pub extern "raylib" def IsKeyDown(key: CInt) -> CBool
```

Test whether a keyboard key is held down.

## std.raylib.IsKeyPressed

```tea
pub extern "raylib" def IsKeyPressed(key: CInt) -> CBool
```

Test whether a keyboard key was pressed this frame.

## std.raylib.SetRandomSeed

```tea
pub extern "raylib" def SetRandomSeed(seed: CUInt) -> Void
```

Seed Raylib's random number generator.

## std.raylib.GetRandomValue

```tea
pub extern "raylib" def GetRandomValue(min: CInt, max: CInt) -> CInt
```

Return a random integer in the inclusive range.

## std.raylib.with_window

```tea
pub def with_window(width: Int, height: Int, title: String, run: Func() -> Void) -> Bool
```

Run a callback with an open window, then close it. Returns false on initialization failure. Call on the main thread; windows cannot be nested (Raylib has one global context). The callback may return early. It cannot throw; panic/exit/process termination bypass cleanup. Release textures inside the callback, before this helper closes the graphics context.

## std.raylib.with_texture

```tea
pub def with_texture(filename: String, run: Func(Texture) -> Void) -> Bool
```

Borrow a loaded texture for a callback, then unload it. Returns false if loading fails. Do not unload the borrowed texture or retain/use copies outside the callback. Panic/exit/process termination bypass cleanup; this is not automatic ownership checking.

## std.raylib.drawing

```tea
pub def drawing(run: Func() -> Void) -> Void
```

Pair BeginDrawing/EndDrawing around a non-throwing callback, including early returns.
