Skip to content

stdlib/sdlView source ↗

sdl

83 items · generated by scribe fromstdlib/sdl.fd· synced 2026-11-15

stdlib/sdl83 items

Contents

SDL_INIT_VIDEO:

pub const SDL_INIT_VIDEO: i64 = 0x00000020; pub const SDL_INIT_AUDIO: i64 = 0x00000010; pub const SDL_INIT_EVENTS: i64 = 0x00004000; pub const SDL_INIT_GAMECONTROLLER: i64 = 0x00002000;

Defined at line 85


SDL_WINDOWPOS_CENTERED:

pub const SDL_WINDOWPOS_CENTERED: i64 = 0x2FFF0000; pub const SDL_WINDOWPOS_UNDEFINED: i64 = 0x1FFF0000;

Defined at line 87


SDL_WINDOW_FULLSCREEN:

pub const SDL_WINDOW_FULLSCREEN: i64 = 0x00000001; pub const SDL_WINDOW_OPENGL: i64 = 0x00000002; pub const SDL_WINDOW_RESIZABLE: i64 = 0x00000020; pub const SDL_WINDOW_SHOWN: i64 = 0x00000004;

Defined at line 89


SDL_RENDERER_ACCELERATED:

pub const SDL_RENDERER_ACCELERATED: i64 = 0x00000002; pub const SDL_RENDERER_VSYNC: i64 = 0x00000004; pub const SDL_RENDERER_SOFTWARE: i64 = 0x00000001;

Defined at line 91


SDL_QUIT:

pub const SDL_QUIT: i64 = 0x100; pub const SDL_KEYDOWN: i64 = 0x300; pub const SDL_KEYUP: i64 = 0x301; pub const SDL_MOUSEMOTION: i64 = 0x400; pub const SDL_MOUSEBUTTONDOWN: i64 = 0x401; pub const SDL_MOUSEBUTTONUP: i64 = 0x402;

Defined at line 93


SDL_SCANCODE_UNKNOWN:

pub const SDL_SCANCODE_UNKNOWN: i64 = 0; pub const SDL_SCANCODE_A: i64 = 4; pub const SDL_SCANCODE_B: i64 = 5; pub const SDL_SCANCODE_C: i64 = 6; pub const SDL_SCANCODE_D: i64 = 7; pub const SDL_SCANCODE_E: i64 = 8; pub const SDL_SCANCODE_F: i64 = 9; pub const SDL_SCANCODE_G: i64 = 10; pub const SDL_SCANCODE_H: i64 = 11; pub const SDL_SCANCODE_I: i64 = 12; pub const SDL_SCANCODE_J: i64 = 13; pub const SDL_SCANCODE_K: i64 = 14; pub const SDL_SCANCODE_L: i64 = 15; pub const SDL_SCANCODE_M: i64 = 16; pub const SDL_SCANCODE_N: i64 = 17; pub const SDL_SCANCODE_O: i64 = 18; pub const SDL_SCANCODE_P: i64 = 19; pub const SDL_SCANCODE_Q: i64 = 20; pub const SDL_SCANCODE_R: i64 = 21; pub const SDL_SCANCODE_S: i64 = 22; pub const SDL_SCANCODE_T: i64 = 23; pub const SDL_SCANCODE_U: i64 = 24; pub const SDL_SCANCODE_V: i64 = 25; pub const SDL_SCANCODE_W: i64 = 26; pub const SDL_SCANCODE_X: i64 = 27; pub const SDL_SCANCODE_Y: i64 = 28; pub const SDL_SCANCODE_Z: i64 = 29; pub const SDL_SCANCODE_1: i64 = 30; pub const SDL_SCANCODE_2: i64 = 31; pub const SDL_SCANCODE_3: i64 = 32; pub const SDL_SCANCODE_4: i64 = 33; pub const SDL_SCANCODE_5: i64 = 34; pub const SDL_SCANCODE_6: i64 = 35; pub const SDL_SCANCODE_7: i64 = 36; pub const SDL_SCANCODE_8: i64 = 37; pub const SDL_SCANCODE_9: i64 = 38; pub const SDL_SCANCODE_0: i64 = 39; pub const SDL_SCANCODE_RETURN: i64 = 40; pub const SDL_SCANCODE_ESCAPE: i64 = 41; pub const SDL_SCANCODE_BACKSPACE: i64 = 42; pub const SDL_SCANCODE_TAB: i64 = 43; pub const SDL_SCANCODE_SPACE: i64 = 44; pub const SDL_SCANCODE_LEFT: i64 = 80; pub const SDL_SCANCODE_RIGHT: i64 = 79; pub const SDL_SCANCODE_UP: i64 = 82; pub const SDL_SCANCODE_DOWN: i64 = 81; pub const SDL_SCANCODE_LSHIFT: i64 = 225; pub const SDL_SCANCODE_RSHIFT: i64 = 229; pub const SDL_SCANCODE_LCTRL: i64 = 224; pub const SDL_SCANCODE_RCTRL: i64 = 228;

Defined at line 95


SDL_BUTTON_LEFT:

pub const SDL_BUTTON_LEFT: i64 = 1; pub const SDL_BUTTON_MIDDLE: i64 = 2; pub const SDL_BUTTON_RIGHT: i64 = 3;

Defined at line 97


AUDIO_S16SYS:

pub const AUDIO_S16SYS: i64 = 0x8010;

Defined at line 99


sdl_init

Initialize SDL with the given subsystem flags. Returns 0 on success, -1 on failure.

pub fn sdl_init(flags: i64) -> i64 {

Parameters:

  • flags: i64

Returns: i64

Defined at line 104


sdl_quit

Shut down SDL and free all resources.

pub fn sdl_quit() -> void {

Returns: void

Defined at line 109


sdl_create_window

Create a window with centered position. Returns window handle (i64 pointer) or 0 on failure.

pub fn sdl_create_window(title: str, width: i64, height: i64) -> i64 {

Parameters:

  • title: str
  • width: i64
  • height: i64

Returns: i64

Defined at line 115


sdl_create_renderer

Create a hardware-accelerated renderer with vsync. Returns renderer handle or 0 on failure.

pub fn sdl_create_renderer(win: i64) -> i64 {

Parameters:

  • win: i64

Returns: i64

Defined at line 121


sdl_destroy_renderer

Destroy a renderer.

pub fn sdl_destroy_renderer(ren: i64) -> void {

Parameters:

  • ren: i64

Returns: void

Defined at line 126


sdl_destroy_window

Destroy a window.

pub fn sdl_destroy_window(win: i64) -> void {

Parameters:

  • win: i64

Returns: void

Defined at line 131


sdl_render_clear

Clear the screen with the current draw color.

pub fn sdl_render_clear(ren: i64) -> void {

Parameters:

  • ren: i64

Returns: void

Defined at line 136


sdl_render_present

Present the rendered frame (swap buffers).

pub fn sdl_render_present(ren: i64) -> void {

Parameters:

  • ren: i64

Returns: void

Defined at line 141


sdl_set_draw_color

Set the draw color (r, g, b, a — each 0-255).

pub fn sdl_set_draw_color(ren: i64, r: i64, g: i64, b: i64, a: i64) -> void {

Parameters:

  • ren: i64
  • r: i64
  • g: i64
  • b: i64
  • a: i64

Returns: void

Defined at line 146


sdl_fill_rect

Draw a filled rectangle (pass 0 for rect to fill entire screen).

pub fn sdl_fill_rect(ren: i64, rect: i64) -> void {

Parameters:

  • ren: i64
  • rect: i64

Returns: void

Defined at line 151


sdl_draw_line

Draw a line from (x1,y1) to (x2,y2).

pub fn sdl_draw_line(ren: i64, x1: i64, y1: i64, x2: i64, y2: i64) -> void {

Parameters:

  • ren: i64
  • x1: i64
  • y1: i64
  • x2: i64
  • y2: i64

Returns: void

Defined at line 156


sdl_draw_point

Draw a single point at (x, y).

pub fn sdl_draw_point(ren: i64, x: i64, y: i64) -> void {

Parameters:

  • ren: i64
  • x: i64
  • y: i64

Returns: void

Defined at line 161


sdl_delay

Delay (sleep) for the given milliseconds.

pub fn sdl_delay(ms: i64) -> void {

Parameters:

  • ms: i64

Returns: void

Defined at line 166


sdl_get_ticks

Get ticks (milliseconds since SDL init).

pub fn sdl_get_ticks() -> i64 {

Returns: i64

Defined at line 171


sdl_get_error

Get the last SDL error message.

pub fn sdl_get_error() -> str {

Returns: str

Defined at line 176


SdlInputState

pub struct SdlInputState {

Fields:

NameType
keysVec<i64>
prev_keysVec<i64>
mouse_xi64
mouse_yi64
mouse_buttonsi64
prev_mouse_buttonsi64
quit_requestedbool

Defined at line 183


sdl_input_create

Create a new input state tracker.

pub fn sdl_input_create() -> SdlInputState {

Returns: SdlInputState

Defined at line 197


sdl_poll_events

Poll SDL events and update input state. Call this once per frame before checking input.

pub fn sdl_poll_events(state: & mut SdlInputState) -> void {

Parameters:

  • state: & mut SdlInputState

Returns: void

Defined at line 213


sdl_key_held

Check if a key is currently held down.

pub fn sdl_key_held(state: & SdlInputState, scancode: i64) -> bool {

Parameters:

  • state: & SdlInputState
  • scancode: i64

Returns: bool

Defined at line 243


sdl_key_pressed

Check if a key was just pressed this frame (held now, not held last frame).

pub fn sdl_key_pressed(state: & SdlInputState, scancode: i64) -> bool {

Parameters:

  • state: & SdlInputState
  • scancode: i64

Returns: bool

Defined at line 251


sdl_key_released

Check if a key was just released this frame (not held now, held last frame).

pub fn sdl_key_released(state: & SdlInputState, scancode: i64) -> bool {

Parameters:

  • state: & SdlInputState
  • scancode: i64

Returns: bool

Defined at line 259


sdl_mouse_held

Check if a mouse button is held (button: SDL_BUTTON_LEFT/MIDDLE/RIGHT).

pub fn sdl_mouse_held(state: & SdlInputState, button: i64) -> bool {

Parameters:

  • state: & SdlInputState
  • button: i64

Returns: bool

Defined at line 267


sdl_mouse_pressed

Check if a mouse button was just pressed.

pub fn sdl_mouse_pressed(state: & SdlInputState, button: i64) -> bool {

Parameters:

  • state: & SdlInputState
  • button: i64

Returns: bool

Defined at line 272


sdl_mouse_x

Get mouse X position.

pub fn sdl_mouse_x(state: & SdlInputState) -> i64 {

Parameters:

  • state: & SdlInputState

Returns: i64

Defined at line 279


sdl_mouse_y

Get mouse Y position.

pub fn sdl_mouse_y(state: & SdlInputState) -> i64 {

Parameters:

  • state: & SdlInputState

Returns: i64

Defined at line 284


sdl_quit_requested

Check if the user requested quit (close button, Alt+F4).

pub fn sdl_quit_requested(state: & SdlInputState) -> bool {

Parameters:

  • state: & SdlInputState

Returns: bool

Defined at line 289


sdl_load_texture

Load an image file (PNG, JPG, BMP) as a texture. Returns texture handle or 0 on failure.

pub fn sdl_load_texture(ren: i64, path: str) -> i64 {

Parameters:

  • ren: i64
  • path: str

Returns: i64

Defined at line 297


sdl_destroy_texture

Destroy a texture.

pub fn sdl_destroy_texture(tex: i64) -> void {

Parameters:

  • tex: i64

Returns: void

Defined at line 308


sdl_draw_texture

Draw a texture at position (x, y) with width w and height h. Pass 0 for src to draw the whole texture.

pub fn sdl_draw_texture(ren: i64, tex: i64, x: i64, y: i64, w: i64, h: i64) -> void {

Parameters:

  • ren: i64
  • tex: i64
  • x: i64
  • y: i64
  • w: i64
  • h: i64

Returns: void

Defined at line 314


sdl_audio_init

Initialize SDL_mixer audio (44100 Hz, 16-bit, stereo, 1024 chunk). Returns 0 on success, -1 on failure.

pub fn sdl_audio_init() -> i64 {

Returns: i64

Defined at line 329


sdl_audio_shutdown

Shut down SDL_mixer.

pub fn sdl_audio_shutdown() -> void {

Returns: void

Defined at line 334


sdl_audio_load

Load a WAV file. Returns chunk handle or 0 on failure.

pub fn sdl_audio_load(path: str) -> i64 {

Parameters:

  • path: str

Returns: i64

Defined at line 339


sdl_audio_play

Play a sound on a channel. Returns the channel used, or -1 on failure. Pass -1 for channel to use any free channel. Pass 0 for loops to play once, -1 for infinite looping.

pub fn sdl_audio_play(channel: i64, chunk: i64, loops: i64) -> i64 {

Parameters:

  • channel: i64
  • chunk: i64
  • loops: i64

Returns: i64

Defined at line 346


sdl_audio_stop

Stop playback on a channel. Pass -1 for all channels.

pub fn sdl_audio_stop(channel: i64) -> void {

Parameters:

  • channel: i64

Returns: void

Defined at line 351


sdl_audio_volume

Set volume for a channel (0-128). Pass -1 for all channels.

pub fn sdl_audio_volume(channel: i64, volume: i64) -> void {

Parameters:

  • channel: i64
  • volume: i64

Returns: void

Defined at line 356


sdl_audio_free

Free a loaded sound chunk.

pub fn sdl_audio_free(chunk: i64) -> void {

Parameters:

  • chunk: i64

Returns: void

Defined at line 361


sdl_audio_playing

Check if a channel is currently playing.

pub fn sdl_audio_playing(channel: i64) -> bool {

Parameters:

  • channel: i64

Returns: bool

Defined at line 366


sdl_audio_pause

Pause a channel.

pub fn sdl_audio_pause(channel: i64) -> void {

Parameters:

  • channel: i64

Returns: void

Defined at line 371


sdl_audio_resume

Resume a paused channel.

pub fn sdl_audio_resume(channel: i64) -> void {

Parameters:

  • channel: i64

Returns: void

Defined at line 376


Generated by scribe, the Fides documentation generator