|
|
|
@@ -0,0 +1,524 @@
|
|
|
|
|
// Raylib game surface for Ziran applications. Games import this module to
|
|
|
|
|
// open a window, read keyboard/mouse/touch input, load textures and audio,
|
|
|
|
|
// draw shapes and text, and use raylib's timing and random values with
|
|
|
|
|
// raylib's own names. Color, Texture2D, Vector2, Rectangle, and Camera come
|
|
|
|
|
// from the shared drawing and geometry modules and match the raylib C ABI,
|
|
|
|
|
// so every declaration here passes those values to raylib by value. Foreign
|
|
|
|
|
// declarations stay private to this module; games call the plain wrappers,
|
|
|
|
|
// and headless builds link C stubs under the raylib names instead of
|
|
|
|
|
// libraylib.
|
|
|
|
|
#import "c_string"
|
|
|
|
|
using Geometry :: #import "geometry";
|
|
|
|
|
using Drawing :: #import "drawing_props";
|
|
|
|
|
|
|
|
|
|
raylib :: #system_library "raylib";
|
|
|
|
|
libm :: #system_library "m";
|
|
|
|
|
libc :: #system_library "libc";
|
|
|
|
|
|
|
|
|
|
AudioStream :: struct {
|
|
|
|
|
buffer: *void
|
|
|
|
|
processor: *void
|
|
|
|
|
sample_rate: u32
|
|
|
|
|
sample_size: u32
|
|
|
|
|
channels: u32
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Wave :: struct {
|
|
|
|
|
frame_count: u32
|
|
|
|
|
sample_rate: u32
|
|
|
|
|
sample_size: u32
|
|
|
|
|
channels: u32
|
|
|
|
|
data: *void
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Sound :: struct {
|
|
|
|
|
stream: AudioStream
|
|
|
|
|
frame_count: u32
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Music :: struct {
|
|
|
|
|
stream: AudioStream
|
|
|
|
|
frame_count: u32
|
|
|
|
|
looping: bool
|
|
|
|
|
ctx_type: s32
|
|
|
|
|
ctx_data: *void
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AudioCallback :: #type (buffer: *void, frames: u32) -> void #c_call;
|
|
|
|
|
|
|
|
|
|
RenderTexture2D :: struct {
|
|
|
|
|
id: u32
|
|
|
|
|
texture: Texture2D
|
|
|
|
|
depth: Texture2D
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The raylib C image value is distinct from Kryon's Image widget.
|
|
|
|
|
RaylibImage :: struct {
|
|
|
|
|
data: *void
|
|
|
|
|
width: s32
|
|
|
|
|
height: s32
|
|
|
|
|
mipmaps: s32
|
|
|
|
|
format: s32
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Keyboard keys, mouse buttons, texture filters, blend modes, window flags,
|
|
|
|
|
// and palette colors the games use, with raylib's values.
|
|
|
|
|
KEY_NULL :: 0;
|
|
|
|
|
KEY_SPACE :: 32;
|
|
|
|
|
KEY_KB_MENU :: 348;
|
|
|
|
|
KEY_ESCAPE :: 256;
|
|
|
|
|
KEY_ENTER :: 257;
|
|
|
|
|
KEY_TAB :: 258;
|
|
|
|
|
KEY_BACKSPACE :: 259;
|
|
|
|
|
KEY_RIGHT :: 262;
|
|
|
|
|
KEY_LEFT :: 263;
|
|
|
|
|
KEY_DOWN :: 264;
|
|
|
|
|
KEY_UP :: 265;
|
|
|
|
|
KEY_A :: 65;
|
|
|
|
|
KEY_D :: 68;
|
|
|
|
|
KEY_E :: 69;
|
|
|
|
|
KEY_G :: 71;
|
|
|
|
|
KEY_M :: 77;
|
|
|
|
|
KEY_S :: 83;
|
|
|
|
|
KEY_W :: 87;
|
|
|
|
|
KEY_X :: 88;
|
|
|
|
|
KEY_BACK :: 4;
|
|
|
|
|
MOUSE_BUTTON_LEFT :: 0;
|
|
|
|
|
MOUSE_BUTTON_RIGHT :: 1;
|
|
|
|
|
MOUSE_LEFT_BUTTON :: 0;
|
|
|
|
|
TEXTURE_FILTER_POINT :: 0;
|
|
|
|
|
BLEND_ALPHA :: 0;
|
|
|
|
|
BLEND_ADDITIVE :: 1;
|
|
|
|
|
FLAG_WINDOW_RESIZABLE :: 4;
|
|
|
|
|
FLAG_WINDOW_HIDDEN :: 128;
|
|
|
|
|
FLAG_WINDOW_ALWAYS_RUN :: 256;
|
|
|
|
|
|
|
|
|
|
WHITE :: Color.{255, 255, 255, 255};
|
|
|
|
|
BLACK :: Color.{0, 0, 0, 255};
|
|
|
|
|
|
|
|
|
|
// Window and frame loop.
|
|
|
|
|
RaylibInitWindow :: (width: s32, height: s32, title: *u8) #foreign raylib "InitWindow";
|
|
|
|
|
RaylibCloseWindow :: () #foreign raylib "CloseWindow";
|
|
|
|
|
RaylibIsWindowReady :: () -> bool #foreign raylib "IsWindowReady";
|
|
|
|
|
RaylibWindowShouldClose :: () -> bool #foreign raylib "WindowShouldClose";
|
|
|
|
|
RaylibIsWindowHidden :: () -> bool #foreign raylib "IsWindowHidden";
|
|
|
|
|
RaylibIsWindowMinimized :: () -> bool #foreign raylib "IsWindowMinimized";
|
|
|
|
|
RaylibIsWindowFocused :: () -> bool #foreign raylib "IsWindowFocused";
|
|
|
|
|
RaylibSetConfigFlags :: (flags: u32) #foreign raylib "SetConfigFlags";
|
|
|
|
|
RaylibSetWindowState :: (flags: u32) #foreign raylib "SetWindowState";
|
|
|
|
|
RaylibClearWindowState :: (flags: u32) #foreign raylib "ClearWindowState";
|
|
|
|
|
RaylibRestoreWindow :: () #foreign raylib "RestoreWindow";
|
|
|
|
|
RaylibSetWindowFocused :: () #foreign raylib "SetWindowFocused";
|
|
|
|
|
RaylibSetTargetFPS :: (fps: s32) #foreign raylib "SetTargetFPS";
|
|
|
|
|
RaylibSetExitKey :: (key: s32) #foreign raylib "SetExitKey";
|
|
|
|
|
RaylibGetScreenWidth :: () -> s32 #foreign raylib "GetScreenWidth";
|
|
|
|
|
RaylibGetScreenHeight :: () -> s32 #foreign raylib "GetScreenHeight";
|
|
|
|
|
RaylibGetRenderWidth :: () -> s32 #foreign raylib "GetRenderWidth";
|
|
|
|
|
RaylibGetRenderHeight :: () -> s32 #foreign raylib "GetRenderHeight";
|
|
|
|
|
RaylibGetWindowScaleDPI :: () -> Vector2 #foreign raylib "GetWindowScaleDPI";
|
|
|
|
|
RaylibGetCurrentMonitor :: () -> s32 #foreign raylib "GetCurrentMonitor";
|
|
|
|
|
RaylibGetMonitorWidth :: (monitor: s32) -> s32 #foreign raylib "GetMonitorWidth";
|
|
|
|
|
RaylibGetMonitorHeight :: (monitor: s32) -> s32 #foreign raylib "GetMonitorHeight";
|
|
|
|
|
RaylibBeginDrawing :: () #foreign raylib "BeginDrawing";
|
|
|
|
|
RaylibEndDrawing :: () #foreign raylib "EndDrawing";
|
|
|
|
|
|
|
|
|
|
InitWindow :: (width: s32, height: s32, title: string) {
|
|
|
|
|
bytes: [256]u8
|
|
|
|
|
if !CopyCString(title, bytes[:]) { return }
|
|
|
|
|
RaylibInitWindow(width, height, *bytes[0])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CloseWindow :: () { RaylibCloseWindow() }
|
|
|
|
|
IsWindowReady :: () -> bool { return RaylibIsWindowReady() }
|
|
|
|
|
WindowShouldClose :: () -> bool { return RaylibWindowShouldClose() }
|
|
|
|
|
IsWindowHidden :: () -> bool { return RaylibIsWindowHidden() }
|
|
|
|
|
IsWindowMinimized :: () -> bool { return RaylibIsWindowMinimized() }
|
|
|
|
|
IsWindowFocused :: () -> bool { return RaylibIsWindowFocused() }
|
|
|
|
|
SetConfigFlags :: (flags: u32) { RaylibSetConfigFlags(flags) }
|
|
|
|
|
SetWindowState :: (flags: u32) { RaylibSetWindowState(flags) }
|
|
|
|
|
ClearWindowState :: (flags: u32) { RaylibClearWindowState(flags) }
|
|
|
|
|
RestoreWindow :: () { RaylibRestoreWindow() }
|
|
|
|
|
SetWindowFocused :: () { RaylibSetWindowFocused() }
|
|
|
|
|
SetTargetFPS :: (fps: s32) { RaylibSetTargetFPS(fps) }
|
|
|
|
|
SetExitKey :: (key: s32) { RaylibSetExitKey(key) }
|
|
|
|
|
GetScreenWidth :: () -> s32 { return RaylibGetScreenWidth() }
|
|
|
|
|
GetScreenHeight :: () -> s32 { return RaylibGetScreenHeight() }
|
|
|
|
|
GetRenderWidth :: () -> s32 { return RaylibGetRenderWidth() }
|
|
|
|
|
GetRenderHeight :: () -> s32 { return RaylibGetRenderHeight() }
|
|
|
|
|
GetWindowScaleDPI :: () -> Vector2 { return RaylibGetWindowScaleDPI() }
|
|
|
|
|
GetCurrentMonitor :: () -> s32 { return RaylibGetCurrentMonitor() }
|
|
|
|
|
GetMonitorWidth :: (monitor: s32) -> s32 { return RaylibGetMonitorWidth(monitor) }
|
|
|
|
|
GetMonitorHeight :: (monitor: s32) -> s32 { return RaylibGetMonitorHeight(monitor) }
|
|
|
|
|
BeginDrawing :: () { RaylibBeginDrawing() }
|
|
|
|
|
EndDrawing :: () { RaylibEndDrawing() }
|
|
|
|
|
|
|
|
|
|
// Timing and random values.
|
|
|
|
|
RaylibGetTime :: () -> float64 #foreign raylib "GetTime";
|
|
|
|
|
RaylibGetFrameTime :: () -> float32 #foreign raylib "GetFrameTime";
|
|
|
|
|
RaylibSetRandomSeed :: (seed: u32) #foreign raylib "SetRandomSeed";
|
|
|
|
|
RaylibGetRandomValue :: (minimum: s32, maximum: s32) -> s32 #foreign raylib "GetRandomValue";
|
|
|
|
|
|
|
|
|
|
GetTime :: () -> float64 { return RaylibGetTime() }
|
|
|
|
|
GetFrameTime :: () -> float32 { return RaylibGetFrameTime() }
|
|
|
|
|
SetRandomSeed :: (seed: u32) { RaylibSetRandomSeed(seed) }
|
|
|
|
|
GetRandomValue :: (minimum: s32, maximum: s32) -> s32 {
|
|
|
|
|
return RaylibGetRandomValue(minimum, maximum)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Input.
|
|
|
|
|
RaylibIsKeyPressed :: (key: s32) -> bool #foreign raylib "IsKeyPressed";
|
|
|
|
|
RaylibIsKeyDown :: (key: s32) -> bool #foreign raylib "IsKeyDown";
|
|
|
|
|
RaylibIsMouseButtonPressed :: (button: s32) -> bool #foreign raylib "IsMouseButtonPressed";
|
|
|
|
|
RaylibIsMouseButtonDown :: (button: s32) -> bool #foreign raylib "IsMouseButtonDown";
|
|
|
|
|
RaylibIsMouseButtonReleased :: (button: s32) -> bool #foreign raylib "IsMouseButtonReleased";
|
|
|
|
|
RaylibGetMousePosition :: () -> Vector2 #foreign raylib "GetMousePosition";
|
|
|
|
|
RaylibCheckCollisionPointRec :: (point: Vector2,
|
|
|
|
|
rectangle: Rectangle) -> bool #foreign raylib "CheckCollisionPointRec";
|
|
|
|
|
RaylibGetMouseDelta :: () -> Vector2 #foreign raylib "GetMouseDelta";
|
|
|
|
|
RaylibGetMouseWheelMove :: () -> float32 #foreign raylib "GetMouseWheelMove";
|
|
|
|
|
RaylibGetTouchPointCount :: () -> s32 #foreign raylib "GetTouchPointCount";
|
|
|
|
|
RaylibGetTouchPosition :: (index: s32) -> Vector2 #foreign raylib "GetTouchPosition";
|
|
|
|
|
|
|
|
|
|
IsKeyPressed :: (key: s32) -> bool { return RaylibIsKeyPressed(key) }
|
|
|
|
|
IsKeyDown :: (key: s32) -> bool { return RaylibIsKeyDown(key) }
|
|
|
|
|
IsMouseButtonPressed :: (button: s32) -> bool {
|
|
|
|
|
return RaylibIsMouseButtonPressed(button)
|
|
|
|
|
}
|
|
|
|
|
IsMouseButtonDown :: (button: s32) -> bool {
|
|
|
|
|
return RaylibIsMouseButtonDown(button)
|
|
|
|
|
}
|
|
|
|
|
IsMouseButtonReleased :: (button: s32) -> bool {
|
|
|
|
|
return RaylibIsMouseButtonReleased(button)
|
|
|
|
|
}
|
|
|
|
|
GetMousePosition :: () -> Vector2 { return RaylibGetMousePosition() }
|
|
|
|
|
CheckCollisionPointRec :: (point: Vector2, rectangle: Rectangle) -> bool {
|
|
|
|
|
return RaylibCheckCollisionPointRec(point, rectangle)
|
|
|
|
|
}
|
|
|
|
|
GetMouseDelta :: () -> Vector2 { return RaylibGetMouseDelta() }
|
|
|
|
|
GetMouseWheelMove :: () -> float32 { return RaylibGetMouseWheelMove() }
|
|
|
|
|
GetTouchPointCount :: () -> s32 { return RaylibGetTouchPointCount() }
|
|
|
|
|
GetTouchPosition :: (index: s32) -> Vector2 { return RaylibGetTouchPosition(index) }
|
|
|
|
|
|
|
|
|
|
// Drawing.
|
|
|
|
|
RaylibClearBackground :: (color: Color) #foreign raylib "ClearBackground";
|
|
|
|
|
RaylibDrawRectangle :: (pos_x: s32, pos_y: s32, width: s32, height: s32,
|
|
|
|
|
color: Color) #foreign raylib "DrawRectangle";
|
|
|
|
|
RaylibDrawCircle :: (center_x: s32, center_y: s32, radius: float32,
|
|
|
|
|
color: Color) #foreign raylib "DrawCircle";
|
|
|
|
|
RaylibDrawCircleV :: (center: Vector2, radius: float32,
|
|
|
|
|
color: Color) #foreign raylib "DrawCircleV";
|
|
|
|
|
RaylibDrawCircleGradient :: (center: Vector2, radius: float32, inner: Color,
|
|
|
|
|
outer: Color) #foreign raylib "DrawCircleGradient";
|
|
|
|
|
RaylibDrawEllipse :: (center_x: s32, center_y: s32, radius_h: float32,
|
|
|
|
|
radius_v: float32, color: Color) #foreign raylib "DrawEllipse";
|
|
|
|
|
RaylibDrawRing :: (center: Vector2, inner_radius: float32, outer_radius: float32,
|
|
|
|
|
start_angle: float32, end_angle: float32, segments: s32,
|
|
|
|
|
color: Color) #foreign raylib "DrawRing";
|
|
|
|
|
RaylibDrawTriangle :: (v1: Vector2, v2: Vector2, v3: Vector2,
|
|
|
|
|
color: Color) #foreign raylib "DrawTriangle";
|
|
|
|
|
RaylibDrawLineEx :: (start: Vector2, end: Vector2, thickness: float32,
|
|
|
|
|
color: Color) #foreign raylib "DrawLineEx";
|
|
|
|
|
RaylibBeginMode2D :: (camera: Camera) #foreign raylib "BeginMode2D";
|
|
|
|
|
RaylibEndMode2D :: () #foreign raylib "EndMode2D";
|
|
|
|
|
RaylibBeginBlendMode :: (mode: s32) #foreign raylib "BeginBlendMode";
|
|
|
|
|
RaylibEndBlendMode :: () #foreign raylib "EndBlendMode";
|
|
|
|
|
RaylibBeginScissorMode :: (x: s32, y: s32, width: s32,
|
|
|
|
|
height: s32) #foreign raylib "BeginScissorMode";
|
|
|
|
|
RaylibEndScissorMode :: () #foreign raylib "EndScissorMode";
|
|
|
|
|
|
|
|
|
|
ClearBackground :: (color: Color) { RaylibClearBackground(color) }
|
|
|
|
|
DrawRectangle :: (pos_x: s32, pos_y: s32, width: s32, height: s32,
|
|
|
|
|
color: Color) {
|
|
|
|
|
RaylibDrawRectangle(pos_x, pos_y, width, height, color)
|
|
|
|
|
}
|
|
|
|
|
DrawCircle :: (center_x: s32, center_y: s32, radius: float32, color: Color) {
|
|
|
|
|
RaylibDrawCircle(center_x, center_y, radius, color)
|
|
|
|
|
}
|
|
|
|
|
DrawCircleV :: (center: Vector2, radius: float32, color: Color) {
|
|
|
|
|
RaylibDrawCircleV(center, radius, color)
|
|
|
|
|
}
|
|
|
|
|
DrawCircleGradient :: (center: Vector2, radius: float32, inner: Color,
|
|
|
|
|
outer: Color) {
|
|
|
|
|
RaylibDrawCircleGradient(center, radius, inner, outer)
|
|
|
|
|
}
|
|
|
|
|
DrawEllipse :: (center_x: s32, center_y: s32, radius_h: float32,
|
|
|
|
|
radius_v: float32, color: Color) {
|
|
|
|
|
RaylibDrawEllipse(center_x, center_y, radius_h, radius_v, color)
|
|
|
|
|
}
|
|
|
|
|
DrawRing :: (center: Vector2, inner_radius: float32, outer_radius: float32,
|
|
|
|
|
start_angle: float32, end_angle: float32, segments: s32, color: Color) {
|
|
|
|
|
RaylibDrawRing(center, inner_radius, outer_radius, start_angle, end_angle,
|
|
|
|
|
segments, color)
|
|
|
|
|
}
|
|
|
|
|
DrawTriangle :: (v1: Vector2, v2: Vector2, v3: Vector2, color: Color) {
|
|
|
|
|
RaylibDrawTriangle(v1, v2, v3, color)
|
|
|
|
|
}
|
|
|
|
|
DrawLineEx :: (start: Vector2, end: Vector2, thickness: float32, color: Color) {
|
|
|
|
|
RaylibDrawLineEx(start, end, thickness, color)
|
|
|
|
|
}
|
|
|
|
|
BeginMode2D :: (camera: Camera) { RaylibBeginMode2D(camera) }
|
|
|
|
|
EndMode2D :: () { RaylibEndMode2D() }
|
|
|
|
|
BeginBlendMode :: (mode: s32) { RaylibBeginBlendMode(mode) }
|
|
|
|
|
EndBlendMode :: () { RaylibEndBlendMode() }
|
|
|
|
|
BeginScissorMode :: (x: s32, y: s32, width: s32, height: s32) {
|
|
|
|
|
RaylibBeginScissorMode(x, y, width, height)
|
|
|
|
|
}
|
|
|
|
|
EndScissorMode :: () { RaylibEndScissorMode() }
|
|
|
|
|
|
|
|
|
|
// Text with raylib's default font.
|
|
|
|
|
RaylibDrawText :: (value: *u8, pos_x: s32, pos_y: s32, font_size: s32,
|
|
|
|
|
color: Color) #foreign raylib "DrawText";
|
|
|
|
|
RaylibMeasureText :: (value: *u8, font_size: s32) -> s32 #foreign raylib "MeasureText";
|
|
|
|
|
|
|
|
|
|
DrawText :: (value: string, pos_x: s32, pos_y: s32, font_size: s32,
|
|
|
|
|
color: Color) {
|
|
|
|
|
bytes: [4096]u8
|
|
|
|
|
if !CopyCString(value, bytes[:]) { return }
|
|
|
|
|
RaylibDrawText(*bytes[0], pos_x, pos_y, font_size, color)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MeasureText :: (value: string, font_size: s32) -> s32 {
|
|
|
|
|
bytes: [4096]u8
|
|
|
|
|
if !CopyCString(value, bytes[:]) { return 0 }
|
|
|
|
|
return RaylibMeasureText(*bytes[0], font_size)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Textures and render targets.
|
|
|
|
|
RaylibLoadImageFromScreen :: () -> RaylibImage #foreign raylib "LoadImageFromScreen";
|
|
|
|
|
RaylibUnloadImage :: (image: RaylibImage) #foreign raylib "UnloadImage";
|
|
|
|
|
RaylibExportImage :: (image: RaylibImage, path: *u8) -> bool #foreign raylib "ExportImage";
|
|
|
|
|
RaylibLoadTexture :: (path: *u8) -> Texture2D #foreign raylib "LoadTexture";
|
|
|
|
|
RaylibUnloadTexture :: (texture: Texture2D) #foreign raylib "UnloadTexture";
|
|
|
|
|
RaylibSetTextureFilter :: (texture: Texture2D,
|
|
|
|
|
filter: s32) #foreign raylib "SetTextureFilter";
|
|
|
|
|
RaylibDrawTexturePro :: (texture: Texture2D, source: Rectangle,
|
|
|
|
|
destination: Rectangle, origin: Vector2, rotation: float32,
|
|
|
|
|
tint: Color) #foreign raylib "DrawTexturePro";
|
|
|
|
|
RaylibDrawTexture :: (texture: Texture2D, pos_x: s32, pos_y: s32,
|
|
|
|
|
tint: Color) #foreign raylib "DrawTexture";
|
|
|
|
|
RaylibLoadRenderTexture :: (width: s32,
|
|
|
|
|
height: s32) -> RenderTexture2D #foreign raylib "LoadRenderTexture";
|
|
|
|
|
RaylibUnloadRenderTexture :: (target: RenderTexture2D) #foreign raylib "UnloadRenderTexture";
|
|
|
|
|
RaylibBeginTextureMode :: (target: RenderTexture2D) #foreign raylib "BeginTextureMode";
|
|
|
|
|
RaylibEndTextureMode :: () #foreign raylib "EndTextureMode";
|
|
|
|
|
RaylibIsRenderTextureValid :: (target: RenderTexture2D) -> bool #foreign raylib "IsRenderTextureValid";
|
|
|
|
|
|
|
|
|
|
EmptyTexture :: () -> Texture2D {
|
|
|
|
|
empty: Texture2D
|
|
|
|
|
empty.id = 0
|
|
|
|
|
empty.width = 0
|
|
|
|
|
empty.height = 0
|
|
|
|
|
empty.mipmaps = 0
|
|
|
|
|
empty.format = 0
|
|
|
|
|
return empty
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LoadImageFromScreen :: () -> RaylibImage { return RaylibLoadImageFromScreen() }
|
|
|
|
|
UnloadImage :: (image: RaylibImage) { RaylibUnloadImage(image) }
|
|
|
|
|
ExportImage :: (image: RaylibImage, path: string) -> bool {
|
|
|
|
|
bytes: [1024]u8
|
|
|
|
|
if !CopyCString(path, bytes[:]) { return false }
|
|
|
|
|
return RaylibExportImage(image, *bytes[0])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EmptyWave :: () -> Wave {
|
|
|
|
|
empty: Wave
|
|
|
|
|
empty.frame_count = 0
|
|
|
|
|
empty.sample_rate = 0
|
|
|
|
|
empty.sample_size = 0
|
|
|
|
|
empty.channels = 0
|
|
|
|
|
empty.data = null
|
|
|
|
|
return empty
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EmptySound :: () -> Sound {
|
|
|
|
|
empty: Sound
|
|
|
|
|
empty.stream.buffer = null
|
|
|
|
|
empty.stream.processor = null
|
|
|
|
|
empty.stream.sample_rate = 0
|
|
|
|
|
empty.stream.sample_size = 0
|
|
|
|
|
empty.stream.channels = 0
|
|
|
|
|
empty.frame_count = 0
|
|
|
|
|
return empty
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EmptyMusic :: () -> Music {
|
|
|
|
|
empty: Music
|
|
|
|
|
empty.stream.buffer = null
|
|
|
|
|
empty.stream.processor = null
|
|
|
|
|
empty.stream.sample_rate = 0
|
|
|
|
|
empty.stream.sample_size = 0
|
|
|
|
|
empty.stream.channels = 0
|
|
|
|
|
empty.frame_count = 0
|
|
|
|
|
empty.looping = false
|
|
|
|
|
empty.ctx_type = 0
|
|
|
|
|
empty.ctx_data = null
|
|
|
|
|
return empty
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EmptyRenderTexture :: () -> RenderTexture2D {
|
|
|
|
|
empty: RenderTexture2D
|
|
|
|
|
empty.id = 0
|
|
|
|
|
empty.texture = EmptyTexture()
|
|
|
|
|
empty.depth = EmptyTexture()
|
|
|
|
|
return empty
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LoadTexture :: (path: string) -> Texture2D {
|
|
|
|
|
bytes: [1024]u8
|
|
|
|
|
if !CopyCString(path, bytes[:]) { return EmptyTexture() }
|
|
|
|
|
return RaylibLoadTexture(*bytes[0])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UnloadTexture :: (texture: Texture2D) { RaylibUnloadTexture(texture) }
|
|
|
|
|
SetTextureFilter :: (texture: Texture2D, filter: s32) {
|
|
|
|
|
RaylibSetTextureFilter(texture, filter)
|
|
|
|
|
}
|
|
|
|
|
DrawTexturePro :: (texture: Texture2D, source: Rectangle, destination: Rectangle,
|
|
|
|
|
origin: Vector2, rotation: float32, tint: Color) {
|
|
|
|
|
RaylibDrawTexturePro(texture, source, destination, origin, rotation, tint)
|
|
|
|
|
}
|
|
|
|
|
DrawTexture :: (texture: Texture2D, pos_x: s32, pos_y: s32, tint: Color) {
|
|
|
|
|
RaylibDrawTexture(texture, pos_x, pos_y, tint)
|
|
|
|
|
}
|
|
|
|
|
LoadRenderTexture :: (width: s32, height: s32) -> RenderTexture2D {
|
|
|
|
|
return RaylibLoadRenderTexture(width, height)
|
|
|
|
|
}
|
|
|
|
|
UnloadRenderTexture :: (target: RenderTexture2D) {
|
|
|
|
|
RaylibUnloadRenderTexture(target)
|
|
|
|
|
}
|
|
|
|
|
BeginTextureMode :: (target: RenderTexture2D) { RaylibBeginTextureMode(target) }
|
|
|
|
|
EndTextureMode :: () { RaylibEndTextureMode() }
|
|
|
|
|
IsRenderTextureValid :: (target: RenderTexture2D) -> bool {
|
|
|
|
|
return RaylibIsRenderTextureValid(target)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Audio.
|
|
|
|
|
RaylibInitAudioDevice :: () #foreign raylib "InitAudioDevice";
|
|
|
|
|
RaylibCloseAudioDevice :: () #foreign raylib "CloseAudioDevice";
|
|
|
|
|
RaylibIsAudioDeviceReady :: () -> bool #foreign raylib "IsAudioDeviceReady";
|
|
|
|
|
RaylibSetMasterVolume :: (volume: float32) #foreign raylib "SetMasterVolume";
|
|
|
|
|
RaylibPlaySound :: (sound: Sound) #foreign raylib "PlaySound";
|
|
|
|
|
RaylibStopSound :: (sound: Sound) #foreign raylib "StopSound";
|
|
|
|
|
RaylibPauseSound :: (sound: Sound) #foreign raylib "PauseSound";
|
|
|
|
|
RaylibIsSoundPlaying :: (sound: Sound) -> bool #foreign raylib "IsSoundPlaying";
|
|
|
|
|
RaylibUnloadSound :: (sound: Sound) #foreign raylib "UnloadSound";
|
|
|
|
|
RaylibSetSoundVolume :: (sound: Sound, volume: float32) #foreign raylib "SetSoundVolume";
|
|
|
|
|
RaylibSetSoundPitch :: (sound: Sound, pitch: float32) #foreign raylib "SetSoundPitch";
|
|
|
|
|
RaylibIsSoundValid :: (sound: Sound) -> bool #foreign raylib "IsSoundValid";
|
|
|
|
|
RaylibLoadWave :: (path: *u8) -> Wave #foreign raylib "LoadWave";
|
|
|
|
|
RaylibLoadWaveFromMemory :: (file_type: *u8, data: *u8,
|
|
|
|
|
size: s32) -> Wave #foreign raylib "LoadWaveFromMemory";
|
|
|
|
|
RaylibUnloadWave :: (wave: Wave) #foreign raylib "UnloadWave";
|
|
|
|
|
RaylibWaveFormat :: (wave: *Wave, sample_rate: s32,
|
|
|
|
|
sample_size: s32, channels: s32) #foreign raylib "WaveFormat";
|
|
|
|
|
RaylibLoadSoundFromWave :: (wave: Wave) -> Sound #foreign raylib "LoadSoundFromWave";
|
|
|
|
|
RaylibPlayMusicStream :: (music: Music) #foreign raylib "PlayMusicStream";
|
|
|
|
|
RaylibUpdateMusicStream :: (music: Music) #foreign raylib "UpdateMusicStream";
|
|
|
|
|
RaylibStopMusicStream :: (music: Music) #foreign raylib "StopMusicStream";
|
|
|
|
|
RaylibPauseMusicStream :: (music: Music) #foreign raylib "PauseMusicStream";
|
|
|
|
|
RaylibResumeMusicStream :: (music: Music) #foreign raylib "ResumeMusicStream";
|
|
|
|
|
RaylibIsMusicStreamPlaying :: (music: Music) -> bool #foreign raylib "IsMusicStreamPlaying";
|
|
|
|
|
RaylibSeekMusicStream :: (music: Music, position: float32) #foreign raylib "SeekMusicStream";
|
|
|
|
|
RaylibSetMusicVolume :: (music: Music, volume: float32) #foreign raylib "SetMusicVolume";
|
|
|
|
|
RaylibUnloadMusicStream :: (music: Music) #foreign raylib "UnloadMusicStream";
|
|
|
|
|
RaylibIsMusicValid :: (music: Music) -> bool #foreign raylib "IsMusicValid";
|
|
|
|
|
RaylibAttachAudioMixedProcessor :: (callback: AudioCallback) #foreign raylib "AttachAudioMixedProcessor";
|
|
|
|
|
RaylibDetachAudioMixedProcessor :: (callback: AudioCallback) #foreign raylib "DetachAudioMixedProcessor";
|
|
|
|
|
RaylibLoadSound :: (path: *u8) -> Sound #foreign raylib "LoadSound";
|
|
|
|
|
RaylibLoadMusicStream :: (path: *u8) -> Music #foreign raylib "LoadMusicStream";
|
|
|
|
|
|
|
|
|
|
InitAudioDevice :: () { RaylibInitAudioDevice() }
|
|
|
|
|
CloseAudioDevice :: () { RaylibCloseAudioDevice() }
|
|
|
|
|
IsAudioDeviceReady :: () -> bool { return RaylibIsAudioDeviceReady() }
|
|
|
|
|
SetMasterVolume :: (volume: float32) { RaylibSetMasterVolume(volume) }
|
|
|
|
|
PlaySound :: (sound: Sound) { RaylibPlaySound(sound) }
|
|
|
|
|
StopSound :: (sound: Sound) { RaylibStopSound(sound) }
|
|
|
|
|
PauseSound :: (sound: Sound) { RaylibPauseSound(sound) }
|
|
|
|
|
IsSoundPlaying :: (sound: Sound) -> bool {
|
|
|
|
|
return RaylibIsSoundPlaying(sound)
|
|
|
|
|
}
|
|
|
|
|
UnloadSound :: (sound: Sound) { RaylibUnloadSound(sound) }
|
|
|
|
|
SetSoundVolume :: (sound: Sound, volume: float32) {
|
|
|
|
|
RaylibSetSoundVolume(sound, volume)
|
|
|
|
|
}
|
|
|
|
|
SetSoundPitch :: (sound: Sound, pitch: float32) {
|
|
|
|
|
RaylibSetSoundPitch(sound, pitch)
|
|
|
|
|
}
|
|
|
|
|
IsSoundValid :: (sound: Sound) -> bool { return RaylibIsSoundValid(sound) }
|
|
|
|
|
LoadWave :: (path: string) -> Wave {
|
|
|
|
|
bytes: [1024]u8
|
|
|
|
|
if !CopyCString(path, bytes[:]) { return EmptyWave() }
|
|
|
|
|
return RaylibLoadWave(*bytes[0])
|
|
|
|
|
}
|
|
|
|
|
LoadWaveFromMemory :: (file_type: string, data: *u8,
|
|
|
|
|
size: s32) -> Wave {
|
|
|
|
|
extension: [32]u8
|
|
|
|
|
if data == null || size <= 0 ||
|
|
|
|
|
!CopyCString(file_type, extension[:]) { return EmptyWave() }
|
|
|
|
|
return RaylibLoadWaveFromMemory(*extension[0], data, size)
|
|
|
|
|
}
|
|
|
|
|
UnloadWave :: (wave: Wave) { RaylibUnloadWave(wave) }
|
|
|
|
|
WaveFormat :: (wave: *Wave, sample_rate: s32,
|
|
|
|
|
sample_size: s32, channels: s32) {
|
|
|
|
|
if wave == null { return }
|
|
|
|
|
RaylibWaveFormat(wave, sample_rate, sample_size, channels)
|
|
|
|
|
}
|
|
|
|
|
LoadSoundFromWave :: (wave: Wave) -> Sound {
|
|
|
|
|
return RaylibLoadSoundFromWave(wave)
|
|
|
|
|
}
|
|
|
|
|
PlayMusicStream :: (music: Music) { RaylibPlayMusicStream(music) }
|
|
|
|
|
UpdateMusicStream :: (music: Music) { RaylibUpdateMusicStream(music) }
|
|
|
|
|
StopMusicStream :: (music: Music) { RaylibStopMusicStream(music) }
|
|
|
|
|
PauseMusicStream :: (music: Music) { RaylibPauseMusicStream(music) }
|
|
|
|
|
ResumeMusicStream :: (music: Music) { RaylibResumeMusicStream(music) }
|
|
|
|
|
IsMusicStreamPlaying :: (music: Music) -> bool {
|
|
|
|
|
return RaylibIsMusicStreamPlaying(music)
|
|
|
|
|
}
|
|
|
|
|
SeekMusicStream :: (music: Music, position: float32) {
|
|
|
|
|
RaylibSeekMusicStream(music, position)
|
|
|
|
|
}
|
|
|
|
|
SetMusicVolume :: (music: Music, volume: float32) {
|
|
|
|
|
RaylibSetMusicVolume(music, volume)
|
|
|
|
|
}
|
|
|
|
|
UnloadMusicStream :: (music: Music) { RaylibUnloadMusicStream(music) }
|
|
|
|
|
IsMusicValid :: (music: Music) -> bool { return RaylibIsMusicValid(music) }
|
|
|
|
|
AttachAudioMixedProcessor :: (callback: AudioCallback) {
|
|
|
|
|
RaylibAttachAudioMixedProcessor(callback)
|
|
|
|
|
}
|
|
|
|
|
DetachAudioMixedProcessor :: (callback: AudioCallback) {
|
|
|
|
|
RaylibDetachAudioMixedProcessor(callback)
|
|
|
|
|
}
|
|
|
|
|
LoadSound :: (path: string) -> Sound {
|
|
|
|
|
bytes: [1024]u8
|
|
|
|
|
if !CopyCString(path, bytes[:]) { return EmptySound() }
|
|
|
|
|
return RaylibLoadSound(*bytes[0])
|
|
|
|
|
}
|
|
|
|
|
LoadMusicStream :: (path: string) -> Music {
|
|
|
|
|
bytes: [1024]u8
|
|
|
|
|
if !CopyCString(path, bytes[:]) { return EmptyMusic() }
|
|
|
|
|
return RaylibLoadMusicStream(*bytes[0])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Math from libm and libc, with the C names the games call.
|
|
|
|
|
RaylibSinf :: (value: float32) -> float32 #foreign libm "sinf";
|
|
|
|
|
RaylibCosf :: (value: float32) -> float32 #foreign libm "cosf";
|
|
|
|
|
RaylibSqrtf :: (value: float32) -> float32 #foreign libm "sqrtf";
|
|
|
|
|
RaylibFabsf :: (value: float32) -> float32 #foreign libm "fabsf";
|
|
|
|
|
RaylibExpf :: (value: float32) -> float32 #foreign libm "expf";
|
|
|
|
|
RaylibPowf :: (base: float32, exponent: float32) -> float32 #foreign libm "powf";
|
|
|
|
|
RaylibFmodf :: (value: float32, divisor: float32) -> float32 #foreign libm "fmodf";
|
|
|
|
|
RaylibAbs :: (value: s32) -> s32 #foreign libc "abs";
|
|
|
|
|
|
|
|
|
|
sinf :: (value: float32) -> float32 { return RaylibSinf(value) }
|
|
|
|
|
cosf :: (value: float32) -> float32 { return RaylibCosf(value) }
|
|
|
|
|
sqrtf :: (value: float32) -> float32 { return RaylibSqrtf(value) }
|
|
|
|
|
fabsf :: (value: float32) -> float32 { return RaylibFabsf(value) }
|
|
|
|
|
expf :: (value: float32) -> float32 { return RaylibExpf(value) }
|
|
|
|
|
powf :: (base: float32, exponent: float32) -> float32 {
|
|
|
|
|
return RaylibPowf(base, exponent)
|
|
|
|
|
}
|
|
|
|
|
fmodf :: (value: float32, divisor: float32) -> float32 {
|
|
|
|
|
return RaylibFmodf(value, divisor)
|
|
|
|
|
}
|
|
|
|
|
abs :: (value: s32) -> s32 { return RaylibAbs(value) }
|