diff options
| author | Vlad-Stefan Harbuz <vlad@vladh.net> | 2022-02-07 13:08:52 +0100 |
|---|---|---|
| committer | Drew DeVault <sir@cmpwn.com> | 2022-02-07 18:56:08 +0100 |
| commit | 2276dc7ad067f7af7504783239103c1abd7b4433 (patch) | |
| tree | 20f2f98f4af8b2ff0efeb3b15f1a26e09702e908 | |
| parent | correct indentation (diff) | |
| download | hare-chip8-2276dc7ad067f7af7504783239103c1abd7b4433.tar.gz | |
refactor names from e.g. sdl2::init() to sdl2::SDL_Init()
Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
| -rw-r--r-- | cmd/demo/main.ha | 110 | ||||
| -rw-r--r-- | sdl2/audio.ha | 18 | ||||
| -rw-r--r-- | sdl2/blendmode.ha | 2 | ||||
| -rw-r--r-- | sdl2/errors.ha | 6 | ||||
| -rw-r--r-- | sdl2/events.ha | 200 | ||||
| -rw-r--r-- | sdl2/gamecontroller.ha | 42 | ||||
| -rw-r--r-- | sdl2/gl.ha | 18 | ||||
| -rw-r--r-- | sdl2/image/image.ha | 34 | ||||
| -rw-r--r-- | sdl2/joystick.ha | 8 | ||||
| -rw-r--r-- | sdl2/keyboard.ha | 384 | ||||
| -rw-r--r-- | sdl2/mixer/channels.ha | 10 | ||||
| -rw-r--r-- | sdl2/mixer/general.ha | 32 | ||||
| -rw-r--r-- | sdl2/mixer/samples.ha | 32 | ||||
| -rw-r--r-- | sdl2/pixels.ha | 12 | ||||
| -rw-r--r-- | sdl2/rect.ha | 8 | ||||
| -rw-r--r-- | sdl2/render.ha | 158 | ||||
| -rw-r--r-- | sdl2/rwops.ha | 38 | ||||
| -rw-r--r-- | sdl2/sdl2.ha | 10 | ||||
| -rw-r--r-- | sdl2/surface.ha | 12 | ||||
| -rw-r--r-- | sdl2/timer.ha | 10 | ||||
| -rw-r--r-- | sdl2/video.ha | 32 |
21 files changed, 588 insertions, 588 deletions
diff --git a/cmd/demo/main.ha b/cmd/demo/main.ha index 3cac391..a6f2a92 100644 --- a/cmd/demo/main.ha +++ b/cmd/demo/main.ha @@ -1,13 +1,13 @@ use fmt; use fs; use sdl2; -use sdl2::{ controller_axis, event_type, renderer_flags, window_flags }; +use sdl2::{ SDL_GameControllerAxis, SDL_EventType, SDL_RendererFlags, SDL_WindowFlags }; use sdl2::image; use sdl2::mixer; use strings; type object = struct { - tex: *sdl2::texture, + tex: *sdl2::SDL_Texture, w: int, h: int, x: int, y: int, dx: int, dy: int, @@ -15,8 +15,8 @@ type object = struct { type state = struct { quit: bool, - window: *sdl2::window, - render: *sdl2::renderer, + window: *sdl2::SDL_Window, + render: *sdl2::SDL_Renderer, nbutton: int, hare: object, cat: object, @@ -33,49 +33,49 @@ export fn main() void = { }; fn run() (void | fs::error | sdl2::error) = { - sdl2::init(sdl2::init_flags::VIDEO + sdl2::SDL_Init(sdl2::init_flags::VIDEO | sdl2::init_flags::AUDIO | sdl2::init_flags::GAMECONTROLLER)!; - defer sdl2::quit(); - image::init(image::init_flags::PNG | image::init_flags::JPG)!; - defer image::quit(); - - mixer::init(mixer::init_flags::OGG)!; - defer mixer::quit(); - mixer::open_audio(mixer::DEFAULT_FREQUENCY, mixer::DEFAULT_FORMAT, - mixer::DEFAULT_CHANNELS, 1024)!; - defer mixer::close_audio(); - - const win = sdl2::create_window("Hare SDL2 demo", - sdl2::WINDOWPOS_UNDEFINED, sdl2::WINDOWPOS_UNDEFINED, - 640, 480, window_flags::NONE)?; - defer sdl2::destroy_window(win); - - const render = sdl2::create_renderer(win, -1, renderer_flags::NONE)?; - defer sdl2::destroy_renderer(render); - - let controller: nullable *sdl2::gamecontroller = null; - for (let i = 0; i < sdl2::numjoysticks()?; i += 1) { - if (!sdl2::is_game_controller(i)) { + defer sdl2::SDL_Quit(); + image::IMG_Init(image::IMG_InitFlags::PNG | image::IMG_InitFlags::JPG)!; + defer image::IMG_Quit(); + + mixer::Mix_Init(mixer::MIX_InitFlags::OGG)!; + defer mixer::Mix_Quit(); + mixer::Mix_OpenAudio(mixer::MIX_DEFAULT_FREQUENCY, mixer::MIX_DEFAULT_FORMAT, + mixer::MIX_DEFAULT_CHANNELS, 1024)!; + defer mixer::Mix_CloseAudio(); + + const win = sdl2::SDL_CreateWindow("Hare SDL2 demo", + sdl2::SDL_WINDOWPOS_UNDEFINED, sdl2::SDL_WINDOWPOS_UNDEFINED, + 640, 480, SDL_WindowFlags::NONE)?; + defer sdl2::SDL_DestroyWindow(win); + + const render = sdl2::SDL_CreateRenderer(win, -1, SDL_RendererFlags::NONE)?; + defer sdl2::SDL_DestroyRenderer(render); + + let controller: nullable *sdl2::SDL_GameController = null; + for (let i = 0; i < sdl2::SDL_NumJoysticks()?; i += 1) { + if (!sdl2::SDL_IsGameController(i)) { continue; }; - match (sdl2::game_controller_open(i)) { - case let c: *sdl2::gamecontroller => + match (sdl2::SDL_GameControllerOpen(i)) { + case let c: *sdl2::SDL_GameController => controller = c; - sdl2::game_controller_rumble(c, 0x4000, 0x4000, 1000): void; + sdl2::SDL_GameControllerRumble(c, 0x4000, 0x4000, 1000): void; break; case sdl2::error => void; }; }; defer match (controller) { case null => void; - case let c: *sdl2::gamecontroller => - sdl2::game_controller_close(c); + case let c: *sdl2::SDL_GameController => + sdl2::SDL_GameControllerClose(c); }; let sample = mixer::load_file("sample.ogg")?; - defer mixer::free_chunk(sample); - mixer::play_channel(0, sample, -1)?; + defer mixer::Mix_FreeChunk(sample); + mixer::Mix_PlayChannelTimed(0, sample, -1)?; let state = state { window = win, @@ -84,8 +84,8 @@ fn run() (void | fs::error | sdl2::error) = { cat = load_object(render, "cat.png")?, ... }; - defer sdl2::destroy_texture(state.hare.tex); - defer sdl2::destroy_texture(state.cat.tex); + defer sdl2::SDL_DestroyTexture(state.hare.tex); + defer sdl2::SDL_DestroyTexture(state.cat.tex); state.hare.dx = 2; state.hare.dy = 2; @@ -93,33 +93,33 @@ fn run() (void | fs::error | sdl2::error) = { for (!state.quit) { update(&state)?; draw(&state)?; - sdl2::delay(1000 / 60); + sdl2::SDL_Delay(1000 / 60); }; }; fn update(state: *state) (void | sdl2::error) = { let ev = sdl2::event { ... }; - for (sdl2::poll_event(&ev)? == 1) switch (ev.event_type) { - case event_type::QUIT => + for (sdl2::SDL_PollEvent(&ev)? == 1) switch (ev.event_type) { + case SDL_EventType::QUIT => state.quit = true; return; - case event_type::CONTROLLERAXISMOTION => - let delta = ev.caxis.value: int * 10 / sdl2::JOYSTICK_AXIS_MAX; + case SDL_EventType::CONTROLLERAXISMOTION => + let delta = ev.caxis.value: int * 10 / sdl2::SDL_JOYSTICK_AXIS_MAX; if (axis_x(ev.caxis.axis)) { state.cat.dx = delta; }; if (axis_y(ev.caxis.axis)) { state.cat.dy = delta; }; - case event_type::CONTROLLERBUTTONDOWN => + case SDL_EventType::CONTROLLERBUTTONDOWN => state.nbutton += 1; - case event_type::CONTROLLERBUTTONUP => + case SDL_EventType::CONTROLLERBUTTONUP => state.nbutton -= 1; case => void; }; let width = 0, height = 0; - sdl2::get_window_size(state.window, &width, &height); + sdl2::SDL_GetWindowSize(state.window, &width, &height); state.hare.x += state.hare.dx; state.hare.y += state.hare.dy; @@ -148,19 +148,19 @@ fn update(state: *state) (void | sdl2::error) = { fn draw(state: *state) (void | sdl2::error) = { if (state.nbutton == 0) { - sdl2::set_render_draw_color(state.render, 50, 50, 50, 255)?; + sdl2::SDL_SetRenderDrawColor(state.render, 50, 50, 50, 255)?; } else { - sdl2::set_render_draw_color(state.render, 50, 50, 200, 255)?; + sdl2::SDL_SetRenderDrawColor(state.render, 50, 50, 200, 255)?; }; - sdl2::render_clear(state.render)?; + sdl2::SDL_RenderClear(state.render)?; draw_object(state, &state.hare)?; draw_object(state, &state.cat)?; - sdl2::render_present(state.render); + sdl2::SDL_RenderPresent(state.render); }; fn draw_object(state: *state, obj: *object) (void | sdl2::error) = { - sdl2::render_copy(state.render, obj.tex, null, &sdl2::rect { + sdl2::SDL_RenderCopy(state.render, obj.tex, null, &sdl2::SDL_Rect { x = obj.x, y = obj.y, w = obj.w, @@ -168,28 +168,28 @@ fn draw_object(state: *state, obj: *object) (void | sdl2::error) = { })?; }; -fn axis_x(axis: controller_axis) bool = { +fn axis_x(axis: SDL_GameControllerAxis) bool = { switch (axis) { - case controller_axis::LEFTX, controller_axis::RIGHTX => + case SDL_GameControllerAxis::LEFTX, SDL_GameControllerAxis::RIGHTX => return true; case => return false; }; }; -fn axis_y(axis: controller_axis) bool = { +fn axis_y(axis: SDL_GameControllerAxis) bool = { switch (axis) { - case controller_axis::LEFTY, controller_axis::RIGHTY => + case SDL_GameControllerAxis::LEFTY, SDL_GameControllerAxis::RIGHTY => return true; case => return false; }; }; -fn load_object(render: *sdl2::renderer, path: str) (object | sdl2::error) = { - const tex = image::load_texture(render, path)?; +fn load_object(render: *sdl2::SDL_Renderer, path: str) (object | sdl2::error) = { + const tex = image::IMG_LoadTexture(render, path)?; let w = 0, h = 0; - sdl2::query_texture(tex, null, null, &w, &h)?; + sdl2::SDL_QueryTexture(tex, null, null, &w, &h)?; return object { tex = tex, w = w, diff --git a/sdl2/audio.ha b/sdl2/audio.ha index 42c4b95..1b78880 100644 --- a/sdl2/audio.ha +++ b/sdl2/audio.ha @@ -11,21 +11,21 @@ // || || || +---sample bit size---+ // || || || | | // 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 -export type audio_format = u16; +export type SDL_AudioFormat = u16; // Unsigned 8-bit samples -export def AUDIO_U8: audio_format = 0x0008; +export def AUDIO_U8: SDL_AudioFormat = 0x0008; // Signed 8-bit samples -export def AUDIO_S8: audio_format = 0x8008; +export def AUDIO_S8: SDL_AudioFormat = 0x8008; // Unsigned 16-bit samples, little-endian -export def AUDIO_U16LSB: audio_format = 0x0010; +export def AUDIO_U16LSB: SDL_AudioFormat = 0x0010; // Signed 16-bit samples, little-endian -export def AUDIO_S16LSB: audio_format = 0x8010; +export def AUDIO_S16LSB: SDL_AudioFormat = 0x8010; // Unsigned 16-bit samples, big-endian -export def AUDIO_U16MSB: audio_format = 0x1010; +export def AUDIO_U16MSB: SDL_AudioFormat = 0x1010; // Signed 16-bit samples, big-endian -export def AUDIO_S16MSB: audio_format = 0x9010; +export def AUDIO_S16MSB: SDL_AudioFormat = 0x9010; // Unsigned 16-bit samples -export def AUDIO_U16: audio_format = AUDIO_U16LSB; +export def AUDIO_U16: SDL_AudioFormat = AUDIO_U16LSB; // Signed 16-bit samples -export def AUDIO_S16: audio_format = AUDIO_S16LSB; +export def AUDIO_S16: SDL_AudioFormat = AUDIO_S16LSB; diff --git a/sdl2/blendmode.ha b/sdl2/blendmode.ha index 11649cf..25acab6 100644 --- a/sdl2/blendmode.ha +++ b/sdl2/blendmode.ha @@ -1,7 +1,7 @@ // TODO: Flesh me out // The blend mode used in SDL_RenderCopy() and drawing operations. -export type blend_mode = enum { +export type SDL_BlendMode = enum { NONE = 0x00000000, BLEND = 0x00000001, ADD = 0x00000002, diff --git a/sdl2/errors.ha b/sdl2/errors.ha index bc02505..52d23a0 100644 --- a/sdl2/errors.ha +++ b/sdl2/errors.ha @@ -8,7 +8,7 @@ export fn strerror(err: error) str = { return err: str; }; -@symbol("SDL_GetError") fn geterror() const *char; +@symbol("SDL_GetError") fn SDL_GetError() const *char; export fn wrapvoid(ret: int) (void | error) = { wrapint(ret)?; @@ -16,7 +16,7 @@ export fn wrapvoid(ret: int) (void | error) = { export fn wrapint(ret: int) (int | error) = { if (ret < 0) { - return strings::fromc(geterror()): error; + return strings::fromc(SDL_GetError()): error; }; return ret; }; @@ -26,6 +26,6 @@ export fn wrapptr(ret: nullable *void) (*void | error) = { case let v: *void => return v; case null => - return strings::fromc(geterror()): error; + return strings::fromc(SDL_GetError()): error; }; }; diff --git a/sdl2/events.ha b/sdl2/events.ha index a8be41c..1003af1 100644 --- a/sdl2/events.ha +++ b/sdl2/events.ha @@ -1,4 +1,4 @@ -export type event_type = enum u32 { +export type SDL_EventType = enum u32 { FIRSTEVENT = 0, QUIT = 0x100, @@ -70,14 +70,14 @@ export type event_type = enum u32 { }; // Fields shared by every event -export type common_event = struct { - event_type: event_type, +export type SDL_CommonEvent = struct { + event_type: SDL_EventType, timestamp: u32, }; // Display state change event data (event.display.*) -export type display_event = struct { - common_event, +export type SDL_DisplayEvent = struct { + SDL_CommonEvent, display: u32, event: u8, padding1: u8, @@ -87,8 +87,8 @@ export type display_event = struct { }; // Window state change event data (event.window.*) -export type window_event = struct { - common_event, +export type SDL_WindowEvent = struct { + SDL_CommonEvent, window_id: u32, event: u8, padding1: u8, @@ -99,41 +99,41 @@ export type window_event = struct { }; // Keyboard button event structure (event.key.*) -export type keyboard_event = struct { - common_event, +export type SDL_KeyboardEvent = struct { + SDL_CommonEvent, window_id: u32, state: u8, repeat: u8, padding2: u8, padding3: u8, - keysym: keysym, + keysym: SDL_Keysym, }; -// Size of the [[text_editing_event]] 'text' field. +// Size of the [[SDL_TextEditingEvent]] 'text' field. export def TEXTEDITINGEVENT_TEXT_SIZE: size = 32; // Keyboard text editing event structure (event.edit.*) -export type text_editing_event = struct { - common_event, +export type SDL_TextEditingEvent = struct { + SDL_CommonEvent, window_id: u32, text: [TEXTEDITINGEVENT_TEXT_SIZE]char, start: i32, length: i32, }; -// Size of the [[text_input_event]] 'text' field. +// Size of the [[SDL_TextInputEvent]] 'text' field. export def TEXTINPUTEVENT_TEXT_SIZE: size = 32; // Keyboard text input event structure (event.text.*) -export type text_input_event = struct { - common_event, +export type SDL_TextInputEvent = struct { + SDL_CommonEvent, window_id: u32, text: [TEXTINPUTEVENT_TEXT_SIZE]char, }; // Mouse motion event structure (event.motion.*) -export type mouse_motion_event = struct { - common_event, +export type SDL_MouseMotionEvent = struct { + SDL_CommonEvent, window_id: u32, which: u32, state: u32, @@ -144,8 +144,8 @@ export type mouse_motion_event = struct { }; // Mouse button event structure (event.button.*) -export type mouse_button_event = struct { - common_event, +export type SDL_MouseButtonEvent = struct { + SDL_CommonEvent, window_id: u32, which: u32, button: u8, @@ -157,8 +157,8 @@ export type mouse_button_event = struct { }; // Mouse wheel event structure (event.wheel.*) -export type mouse_wheel_event = struct { - common_event, +export type SDL_MouseWheelEvent = struct { + SDL_CommonEvent, window_id: u32, which: u32, x: i32, @@ -167,8 +167,8 @@ export type mouse_wheel_event = struct { }; // Joystick axis motion event structure (event.jaxis.*) -export type joy_axis_event = struct { - common_event, +export type SDL_JoyAxisEvent = struct { + SDL_CommonEvent, which: i32, // TODO: Rig me up with the JoystickID type axis: u8, padding1: u8, @@ -179,8 +179,8 @@ export type joy_axis_event = struct { }; // Joystick trackball motion event structure (event.jball.*) -export type joy_ball_event = struct { - common_event, +export type SDL_JoyBallEvent = struct { + SDL_CommonEvent, which: i32, // TODO: Rig me up with the JoystickID type ball: u8, padding1: u8, @@ -191,8 +191,8 @@ export type joy_ball_event = struct { }; // Joystick hat position change event structure (event.jhat.*) -export type joy_hat_event = struct { - common_event, +export type SDL_JoyHatEvent = struct { + SDL_CommonEvent, which: i32, // TODO: Rig me up with the JoystickID type hat: u8, value: u8, // TODO: Rig me up with HAT_UP et al @@ -201,8 +201,8 @@ export type joy_hat_event = struct { }; // Joystick button event structure (event.jbutton.*) -export type joy_button_event = struct { - common_event, +export type SDL_JoyButtonEvent = struct { + SDL_CommonEvent, which: i32, // TODO: Rig me up with the JoystickID type button: u8, state: u8, @@ -211,16 +211,16 @@ export type joy_button_event = struct { }; // Joystick device event structure (event.jdevice.*) -export type joy_device_event = struct { - common_event, +export type SDL_JoyDeviceEvent = struct { + SDL_CommonEvent, which: i32, }; // Game controller axis motion event structure (event.caxis.*) -export type controller_axis_event = struct { - common_event, +export type SDL_ControllerAxisEvent = struct { + SDL_CommonEvent, which: i32, // TODO - axis: controller_axis, + axis: SDL_GameControllerAxis, padding1: u8, padding2: u8, padding3: u8, @@ -229,8 +229,8 @@ export type controller_axis_event = struct { }; // Game controller button event structure (event.cbutton.*) -export type controller_button_event = struct { - common_event, +export type SDL_ControllerButtonEvent = struct { + SDL_CommonEvent, which: i32, button: u8, state: u8, @@ -239,14 +239,14 @@ export type controller_button_event = struct { }; // Controller device event structure (event.cdevice.*) -export type controller_device_event = struct { - common_event, +export type SDL_ControllerDeviceEvent = struct { + SDL_CommonEvent, which: i32, }; // Audio device event structure (event.adevice.*) -export type audio_device_event = struct { - common_event, +export type SDL_AudioDeviceEvent = struct { + SDL_CommonEvent, which: u32, iscapture: u8, padding1: u8, @@ -255,8 +255,8 @@ export type audio_device_event = struct { }; // Touch finger event structure (event.tfinger.*) -export type touch_finger_event = struct { - common_event, +export type SDL_TouchFingerEvent = struct { + SDL_CommonEvent, touch_id: i64, // TODO finger_id: i64, // TODO x: f32, @@ -267,8 +267,8 @@ export type touch_finger_event = struct { }; // Multiple Finger Gesture Event (event.mgesture.*) -export type multi_gesture_event = struct { - common_event, +export type SDL_MultiGestureEvent = struct { + SDL_CommonEvent, touch_id: i64, // TODO dtheta: f32, ddist: f32, @@ -279,8 +279,8 @@ export type multi_gesture_event = struct { }; // Dollar Gesture Event (event.dgesture.*) -export type dollar_gesture_event = struct { - common_event, +export type SDL_DollarGestureEvent = struct { + SDL_CommonEvent, touch_id: i64, // TODO gesture_id: i64, // TODO num_fingers: u32, @@ -292,32 +292,32 @@ export type dollar_gesture_event = struct { // An event used to request a file open by the system (event.drop.*) // This event is enabled by default, you can disable it with [[eventstate]]. // If this event is enabled, you must free the filename in the event. -export type drop_event = struct { - common_event, +export type SDL_DropEvent = struct { + SDL_CommonEvent, file: *char, window_id: u32, }; // Sensor event structure (event.sensor.*) -export type sensor_event = struct { - common_event, +export type SDL_SensorEvent = struct { + SDL_CommonEvent, which: i32, data: [6]f32, }; // The "quit requested" event -export type quit_event = struct { - common_event, +export type SDL_QuitEvent = struct { + SDL_CommonEvent, }; // OS Specific event -export type os_event = struct { - common_event, +export type SDL_OSEvent = struct { + SDL_CommonEvent, }; // A user-defined event type (event.user.*) -export type user_event = struct { - common_event, +export type SDL_UserEvent = struct { + SDL_CommonEvent, window_id: u32, code: i32, data1: *void, @@ -326,40 +326,40 @@ export type user_event = struct { // A video driver dependent system event (event.syswm.*) // This event is disabled by default, you can enable it with [[eventstate]]. -export type syswm_event = struct { - common_event, +export type SDL_SysWMEvent = struct { + SDL_CommonEvent, msg: *void, // TODO }; // General event structure export type event = union { - event_type: event_type, - common: common_event, - display: display_event, - window: window_event, - key: keyboard_event, - edit: text_editing_event, - text: text_input_event, - motion: mouse_motion_event, - button: mouse_button_event, - wheel: mouse_wheel_event, - jaxis: joy_axis_event, - jball: joy_ball_event, - jhat: joy_hat_event, - jbutton: joy_button_event, - jdevice: joy_device_event, - caxis: controller_axis_event, - cbutton: controller_button_event, - cdevice: controller_device_event, - adevice: audio_device_event, - sensor: sensor_event, - quit: quit_event, - user: user_event, - syswm: syswm_event, - tfinger: touch_finger_event, - mgesture: multi_gesture_event, - dgestures: dollar_gesture_event, - drop: drop_event, + event_type: SDL_EventType, + common: SDL_CommonEvent, + display: SDL_DisplayEvent, + window: SDL_WindowEvent, + key: SDL_KeyboardEvent, + edit: SDL_TextEditingEvent, + text: SDL_TextInputEvent, + motion: SDL_MouseMotionEvent, + button: SDL_MouseButtonEvent, + wheel: SDL_MouseWheelEvent, + jaxis: SDL_JoyAxisEvent, + jball: SDL_JoyBallEvent, + jhat: SDL_JoyHatEvent, + jbutton: SDL_JoyButtonEvent, + jdevice: SDL_JoyDeviceEvent, + caxis: SDL_ControllerAxisEvent, + cbutton: SDL_ControllerButtonEvent, + cdevice: SDL_ControllerDeviceEvent, + adevice: SDL_AudioDeviceEvent, + sensor: SDL_SensorEvent, + quit: SDL_QuitEvent, + user: SDL_UserEvent, + syswm: SDL_SysWMEvent, + tfinger: SDL_TouchFingerEvent, + mgesture: SDL_MultiGestureEvent, + dgestures: SDL_DollarGestureEvent, + drop: SDL_DropEvent, padding: [56]u8, }; @@ -369,7 +369,7 @@ export type event = union { // This function updates the event queue and internal input device state. // // This should only be run in the thread that sets the video mode. -export @symbol("SDL_PumpEvents") fn pump_events() void; +export @symbol("SDL_PumpEvents") fn SDL_PumpEvents() void; export type eventaction = enum { ADDEVENT, @@ -378,7 +378,7 @@ export type eventaction = enum { }; @symbol("SDL_PeepEvents") fn _peep_events(events: *event, numevents: int, - action: eventaction, mintype: event_type, maxtype: event_type) int; + action: eventaction, mintype: SDL_EventType, maxtype: SDL_EventType) int; // Checks the event queue for messages and optionally returns them. // @@ -394,33 +394,33 @@ export type eventaction = enum { // will be removed from the queue. // // This function is thread-safe. -export fn peep_events( +export fn SDL_PeepEvents( events: *event, numevents: int, action: eventaction, - mintype: event_type, - maxtype: event_type, + mintype: SDL_EventType, + maxtype: SDL_EventType, ) (int | error) = { return wrapint(_peep_events(events, numevents, action, mintype, maxtype)); }; // Checks to see if certain event types are in the event queue. -export @symbol("SDL_HasEvent") fn has_event(event_type: event_type) bool; +export @symbol("SDL_HasEvent") fn SDL_HasEvent(SDL_EventType: SDL_EventType) bool; // Checks to see if certain event types are in the event queue. -export @symbol("SDL_HasEvents") fn has_events(mintype: event_type, maxtype: event_type) bool; +export @symbol("SDL_HasEvents") fn SDL_HasEvents(mintype: SDL_EventType, maxtype: SDL_EventType) bool; // This function clears events from the event queue // This function only affects currently queued events. If you want to make // sure that all pending OS events are flushed, you can call SDL_PumpEvents() // on the main thread immediately before the flush call. -export @symbol("SDL_FlushEvent") fn flush_event(event_type: event_type) void; +export @symbol("SDL_FlushEvent") fn flush_event(SDL_EventType: SDL_EventType) void; // This function clears events from the event queue // This function only affects currently queued events. If you want to make // sure that all pending OS events are flushed, you can call SDL_PumpEvents() // on the main thread immediately before the flush call. -export @symbol("SDL_FlushEvents") fn flush_events(mintype: event_type, maxtype: event_type) void; +export @symbol("SDL_FlushEvents") fn SDL_FlushEvents(mintype: SDL_EventType, maxtype: SDL_EventType) void; @symbol("SDL_PollEvent") fn _poll_event(event: nullable *event) int; @@ -430,7 +430,7 @@ export @symbol("SDL_FlushEvents") fn flush_events(mintype: event_type, maxtype: // // If 'event' is not null, the next event is removed from the queue and stored // in that area. -export fn poll_event(event: nullable *event) (int | error) = { +export fn SDL_PollEvent(event: nullable *event) (int | error) = { return wrapint(_poll_event(event)); }; @@ -440,7 +440,7 @@ export fn poll_event(event: nullable *event) (int | error) = { // // If 'event' is not null, the next event is removed from the queue and stored // in that area. -export fn wait_event(event: nullable *event) (void | error) = { +export fn SDL_WaitEvent(event: nullable *event) (void | error) = { return wrapvoid(_wait_event(event)); }; @@ -448,11 +448,11 @@ export fn wait_event(event: nullable *event) (void | error) = { event: nullable *event, timeout: int) int; // Waits until the specified timeout (in milliseconds) for the next available event. -// +// // If 'event' is not null, the next event is removed from the queue and stored // in that area. The 'timeout' is the time (in milliseconds) to wait for next // event. -export fn wait_event_timeout( +export fn SDL_WaitEventTimeout( event: nullable *event, timeout: int, ) (void | error) = { @@ -462,7 +462,7 @@ export fn wait_event_timeout( @symbol("SDL_PushEvent") fn _push_event(event: *event) int; // Add an event to the event queue. -export fn push_event(event: *event) (void | error) = { +export fn SDL_PushEvent(event: *event) (void | error) = { return wrapvoid(_push_event(event)); }; diff --git a/sdl2/gamecontroller.ha b/sdl2/gamecontroller.ha index 7bf2e18..113bb37 100644 --- a/sdl2/gamecontroller.ha +++ b/sdl2/gamecontroller.ha @@ -1,18 +1,18 @@ // TODO: Flesh me out -// The gamecontroller structure used to identify an SDL game controller. +// The SDL_GameController structure used to identify an SDL game controller. // (Opaque) -export type gamecontroller = void; +export type SDL_GameController = void; // The list of axes available from a controller // -// Thumbstick axis values range from [[JOYSTICK_AXIS_MIN]] to -// [[JOYSTICK_AXIS_MAX]], and are centered within ~8000 of zero, though advanced +// Thumbstick axis values range from [[SDL_JOYSTICK_AXIS_MIN]] to +// [[SDL_JOYSTICK_AXIS_MAX]], and are centered within ~8000 of zero, though advanced // UI will allow users to set or autodetect the dead zone, which varies between // controllers. // -// Trigger axis values range from 0 to [[JOYSTICK_AXIS_MAX]]. -export type controller_axis = enum u8 { +// Trigger axis values range from 0 to [[SDL_JOYSTICK_AXIS_MAX]]. +export type SDL_GameControllerAxis = enum u8 { LEFTX, LEFTY, RIGHTX, @@ -23,7 +23,7 @@ export type controller_axis = enum u8 { }; // The list of buttons available from a controller -export type controller_button = enum u8 { +export type SDL_GameControllerBUtton = enum u8 { INVALID = 255, A = 0, B, @@ -49,31 +49,31 @@ export type controller_button = enum u8 { }; // Check if the given joystick is supported by the game controller interface. -// +// // 'joystick_index' is the same as the 'device_index' passed to // [[joystick_open]]. -// +// // Returns true if the given joystick is supported by the game controller // interface, false if it isn't or it's an invalid index. -export @symbol("SDL_IsGameController") fn is_game_controller( +export @symbol("SDL_IsGameController") fn SDL_IsGameController( joystick_index: int) bool; @symbol("SDL_GameControllerOpen") fn _game_controller_open( - joystick_index: int) nullable *gamecontroller; + joystick_index: int) nullable *SDL_GameController; // Get the SDL_GameController associated with an instance id. -export fn game_controller_open( +export fn SDL_GameControllerOpen( joystick_index: int, -) (*gamecontroller | error) = { - return wrapptr(_game_controller_open(joystick_index))?: *gamecontroller; +) (*SDL_GameController | error) = { + return wrapptr(_game_controller_open(joystick_index))?: *SDL_GameController; }; // Close a game controller previously opened with [[game_controller_open]]. -export @symbol("SDL_GameControllerClose") fn game_controller_close( - gamecontroller: *gamecontroller) void; +export @symbol("SDL_GameControllerClose") fn SDL_GameControllerClose( + gamecontroller: *SDL_GameController) void; -@symbol("SDL_GameControllerRumble") fn _game_controller_rumble( - gamecontroller: *gamecontroller, +@symbol("SDL_GameControllerRumble") fn _SDL_GameControllerRumble( + gamecontroller: *SDL_GameController, low_frequency_rumble: u16, high_frequency_rumble: u16, duration_ms: u32) int; @@ -85,13 +85,13 @@ export @symbol("SDL_GameControllerClose") fn game_controller_close( // // The low-frequency motor is generally on the left, and the high-frequency // motor is generally on the right. -export fn game_controller_rumble( - gamecontroller: *gamecontroller, +export fn SDL_GameControllerRumble( + gamecontroller: *SDL_GameController, low_frequency_rumble: u16, high_frequency_rumble: u16, duration_ms: u32, ) (void | error) = { - return wrapvoid(_game_controller_rumble( + return wrapvoid(_SDL_GameControllerRumble( gamecontroller, low_frequency_rumble, high_frequency_rumble, @@ -1,12 +1,12 @@ -export type glcontext = void; +export type SDL_GLContext = void; -export type glprofile = enum int { +export type SDL_GLprofile = enum int { GL_CONTEXT_PROFILE_CORE = 0x0001, GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, GL_CONTEXT_PROFILE_ES = 0x0004, }; -export type glattr = enum { +export type SDL_GLattr = enum { GL_RED_SIZE, GL_GREEN_SIZE, GL_BLUE_SIZE, @@ -36,10 +36,10 @@ export type glattr = enum { GL_CONTEXT_NO_ERROR, }; -export @symbol("SDL_GL_CreateContext") fn gl_create_context( - window: *window) *glcontext; -export @symbol("SDL_GL_GetProcAddress") fn gl_get_proc_address( +export @symbol("SDL_GL_CreateContext") fn SDL_GL_CreateContext( + window: *SDL_Window) *SDL_GLContext; +export @symbol("SDL_GL_GetProcAddress") fn SDL_GL_GetProcAddress( proc: *const char) *void; -export @symbol("SDL_GL_SetAttribute") fn gl_set_attribute( - attr: glattr, value: int) *void; -export @symbol("SDL_GL_SwapWindow") fn gl_swap_window(window: *window) void; +export @symbol("SDL_GL_SetAttribute") fn SDL_GL_SetAttribute( + attr: SDL_GLattr, value: int) *void; +export @symbol("SDL_GL_SwapWindow") fn SDL_GL_SwapWindow(window: *SDL_Window) void; diff --git a/sdl2/image/image.ha b/sdl2/image/image.ha index 8a48009..8684f83 100644 --- a/sdl2/image/image.ha +++ b/sdl2/image/image.ha @@ -3,8 +3,8 @@ use sdl2; use strings; -// Flags for [[init]]. -export type init_flags = enum int { +// Flags for [[IMG_Init]]. +export type IMG_InitFlags = enum int { NONE = 0, JPG = 0x00000001, PNG = 0x00000002, @@ -12,35 +12,35 @@ export type init_flags = enum int { WEBP = 0x00000008, }; -@symbol("IMG_Init") fn _init(flags: init_flags) int; +@symbol("IMG_Init") fn _IMG_Init(flags: IMG_InitFlags) int; // Loads dynamic libraries and prepares them for use. Flags should be one or -// more flags from [[init_flags]] OR'd together. -export fn init(flags: init_flags) (void | sdl2::error) = { - return sdl2::wrapvoid(_init(flags)); +// more flags from [[IMG_InitFlags]] OR'd together. +export fn IMG_Init(flags: IMG_InitFlags) (void | sdl2::error) = { + return sdl2::wrapvoid(_IMG_Init(flags)); }; -// Unloads libraries loaded with [[init]] -export @symbol("IMG_Quit") fn quit() void; +// Unloads libraries loaded with [[IMG_Init]] +export @symbol("IMG_Quit") fn IMG_Quit() void; -@symbol("IMG_Load") fn _load(file: const *char) nullable *sdl2::surface; +@symbol("IMG_Load") fn _IMG_Load(file: const *char) nullable *sdl2::SDL_Surface; // Load an image from a file path. -export fn load(file: str) (*sdl2::surface | sdl2::error) = { +export fn IMG_Load(file: str) (*sdl2::SDL_Surface | sdl2::error) = { const file = strings::to_c(file); defer free(file); - return sdl2::wrapptr(_load(file))?: *sdl2::surface; + return sdl2::wrapptr(_IMG_Load(file))?: *sdl2::SDL_Surface; }; -@symbol("IMG_LoadTexture") fn _load_texture(renderer: *sdl2::renderer, - file: const *char) nullable *sdl2::texture; +@symbol("IMG_LoadTexture") fn _IMG_LoadTexture(SDL_Renderer: *sdl2::SDL_Renderer, + file: const *char) nullable *sdl2::SDL_Texture; // Load an image directly into a render texture. -export fn load_texture( - renderer: *sdl2::renderer, +export fn IMG_LoadTexture( + SDL_Renderer: *sdl2::SDL_Renderer, file: str, -) (*sdl2::texture | sdl2::error) = { +) (*sdl2::SDL_Texture | sdl2::error) = { const file = strings::to_c(file); defer free(file); - return sdl2::wrapptr(_load_texture(renderer, file))?: *sdl2::texture; + return sdl2::wrapptr(_IMG_LoadTexture(SDL_Renderer, file))?: *sdl2::SDL_Texture; }; diff --git a/sdl2/joystick.ha b/sdl2/joystick.ha index adbcd14..2234aff 100644 --- a/sdl2/joystick.ha +++ b/sdl2/joystick.ha @@ -1,12 +1,12 @@ // TODO: Flesh me out // Minimum value for a joystick axis. -export def JOYSTICK_AXIS_MIN: i16 = -32768; +export def SDL_JOYSTICK_AXIS_MIN: i16 = -32768; // Minimum value for a joystick axis. -export def JOYSTICK_AXIS_MAX: i16 = 32767; +export def SDL_JOYSTICK_AXIS_MAX: i16 = 32767; -@symbol("SDL_NumJoysticks") fn _numjoysticks() int; +@symbol("SDL_NumJoysticks") fn _SDL_NumJoysticks() int; // Returns the number of joysticks attached to the system. -export fn numjoysticks() (int | error) = wrapint(_numjoysticks()); +export fn SDL_NumJoysticks() (int | error) = wrapint(_SDL_NumJoysticks()); diff --git a/sdl2/keyboard.ha b/sdl2/keyboard.ha index 4e1325f..97b0a21 100644 --- a/sdl2/keyboard.ha +++ b/sdl2/keyboard.ha @@ -1,6 +1,6 @@ use strings; -export type scancode = enum uint { +export type SDL_Scancode = enum uint { UNKNOWN = 0, // Usage page 0x07 @@ -343,7 +343,7 @@ export type scancode = enum uint { NUM_SCANCODES = 512, }; -export type keycode = enum uint { +export type SDL_Keycode = enum uint { UNKNOWN = 0, RETURN = '\r', @@ -419,190 +419,190 @@ export type keycode = enum uint { y = 'y', z = 'z', - CAPSLOCK = scancode::CAPSLOCK | 1: scancode << 30, - - F1 = scancode::F1 | 1: scancode << 30, - F2 = scancode::F2 | 1: scancode << 30, - F3 = scancode::F3 | 1: scancode << 30, - F4 = scancode::F4 | 1: scancode << 30, - F5 = scancode::F5 | 1: scancode << 30, - F6 = scancode::F6 | 1: scancode << 30, - F7 = scancode::F7 | 1: scancode << 30, - F8 = scancode::F8 | 1: scancode << 30, - F9 = scancode::F9 | 1: scancode << 30, - F10 = scancode::F10 | 1: scancode << 30, - F11 = scancode::F11 | 1: scancode << 30, - F12 = scancode::F12 | 1: scancode << 30, - - PRINTSCREEN = scancode::PRINTSCREEN | 1: scancode << 30, - SCROLLLOCK = scancode::SCROLLLOCK | 1: scancode << 30, - PAUSE = scancode::PAUSE | 1: scancode << 30, - INSERT = scancode::INSERT | 1: scancode << 30, - HOME = scancode::HOME | 1: scancode << 30, - PAGEUP = scancode::PAGEUP | 1: scancode << 30, + CAPSLOCK = SDL_Scancode::CAPSLOCK | 1: SDL_Scancode << 30, + + F1 = SDL_Scancode::F1 | 1: SDL_Scancode << 30, + F2 = SDL_Scancode::F2 | 1: SDL_Scancode << 30, + F3 = SDL_Scancode::F3 | 1: SDL_Scancode << 30, + F4 = SDL_Scancode::F4 | 1: SDL_Scancode << 30, + F5 = SDL_Scancode::F5 | 1: SDL_Scancode << 30, + F6 = SDL_Scancode::F6 | 1: SDL_Scancode << 30, + F7 = SDL_Scancode::F7 | 1: SDL_Scancode << 30, + F8 = SDL_Scancode::F8 | 1: SDL_Scancode << 30, + F9 = SDL_Scancode::F9 | 1: SDL_Scancode << 30, + F10 = SDL_Scancode::F10 | 1: SDL_Scancode << 30, + F11 = SDL_Scancode::F11 | 1: SDL_Scancode << 30, + F12 = SDL_Scancode::F12 | 1: SDL_Scancode << 30, + + PRINTSCREEN = SDL_Scancode::PRINTSCREEN | 1: SDL_Scancode << 30, + SCROLLLOCK = SDL_Scancode::SCROLLLOCK | 1: SDL_Scancode << 30, + PAUSE = SDL_Scancode::PAUSE | 1: SDL_Scancode << 30, + INSERT = SDL_Scancode::INSERT | 1: SDL_Scancode << 30, + HOME = SDL_Scancode::HOME | 1: SDL_Scancode << 30, + PAGEUP = SDL_Scancode::PAGEUP | 1: SDL_Scancode << 30, DELETE = '\x7F', - END = scancode::END | 1: scancode << 30, - PAGEDOWN = scancode::PAGEDOWN | 1: scancode << 30, - RIGHT = scancode::RIGHT | 1: scancode << 30, - LEFT = scancode::LEFT | 1: scancode << 30, - DOWN = scancode::DOWN | 1: scancode << 30, - UP = scancode::UP | 1: scancode << 30, - - NUMLOCKCLEAR = scancode::NUMLOCKCLEAR | 1: scancode << 30, - KP_DIVIDE = scancode::KP_DIVIDE | 1: scancode << 30, - KP_MULTIPLY = scancode::KP_MULTIPLY | 1: scancode << 30, - KP_MINUS = scancode::KP_MINUS | 1: scancode << 30, - KP_PLUS = scancode::KP_PLUS | 1: scancode << 30, - KP_ENTER = scancode::KP_ENTER | 1: scancode << 30, - KP_1 = scancode::KP_1 | 1: scancode << 30, - KP_2 = scancode::KP_2 | 1: scancode << 30, - KP_3 = scancode::KP_3 | 1: scancode << 30, - KP_4 = scancode::KP_4 | 1: scancode << 30, - KP_5 = scancode::KP_5 | 1: scancode << 30, - KP_6 = scancode::KP_6 | 1: scancode << 30, - KP_7 = scancode::KP_7 | 1: scancode << 30, - KP_8 = scancode::KP_8 | 1: scancode << 30, - KP_9 = scancode::KP_9 | 1: scancode << 30, - KP_0 = scancode::KP_0 | 1: scancode << 30, - KP_PERIOD = scancode::KP_PERIOD | 1: scancode << 30, - - APPLICATION = scancode::APPLICATION | 1: scancode << 30, - POWER = scancode::POWER | 1: scancode << 30, - KP_EQUALS = scancode::KP_EQUALS | 1: scancode << 30, - F13 = scancode::F13 | 1: scancode << 30, - F14 = scancode::F14 | 1: scancode << 30, - F15 = scancode::F15 | 1: scancode << 30, - F16 = scancode::F16 | 1: scancode << 30, - F17 = scancode::F17 | 1: scancode << 30, - F18 = scancode::F18 | 1: scancode << 30, - F19 = scancode::F19 | 1: scancode << 30, - F20 = scancode::F20 | 1: scancode << 30, - F21 = scancode::F21 | 1: scancode << 30, - F22 = scancode::F22 | 1: scancode << 30, - F23 = scancode::F23 | 1: scancode << 30, - F24 = scancode::F24 | 1: scancode << 30, - EXECUTE = scancode::EXECUTE | 1: scancode << 30, - HELP = scancode::HELP | 1: scancode << 30, - MENU = scancode::MENU | 1: scancode << 30, - SELECT = scancode::SELECT | 1: scancode << 30, - STOP = scancode::STOP | 1: scancode << 30, - AGAIN = scancode::AGAIN | 1: scancode << 30, - UNDO = scancode::UNDO | 1: scancode << 30, - CUT = scancode::CUT | 1: scancode << 30, - COPY = scancode::COPY | 1: scancode << 30, - PASTE = scancode::PASTE | 1: scancode << 30, - FIND = scancode::FIND | 1: scancode << 30, - MUTE = scancode::MUTE | 1: scancode << 30, - VOLUMEUP = scancode::VOLUMEUP | 1: scancode << 30, - VOLUMEDOWN = scancode::VOLUMEDOWN | 1: scancode << 30, - KP_COMMA = scancode::KP_COMMA | 1: scancode << 30, - KP_EQUALSAS400 = scancode::KP_EQUALSAS400 | 1: scancode << 30, - - ALTERASE = scancode::ALTERASE | 1: scancode << 30, - SYSREQ = scancode::SYSREQ | 1: scancode << 30, - CANCEL = scancode::CANCEL | 1: scancode << 30, - CLEAR = scancode::CLEAR | 1: scancode << 30, - PRIOR = scancode::PRIOR | 1: scancode << 30, - RETURN2 = scancode::RETURN2 | 1: scancode << 30, - SEPARATOR = scancode::SEPARATOR | 1: scancode << 30, - OUT = scancode::OUT | 1: scancode << 30, - OPER = scancode::OPER | 1: scancode << 30, - CLEARAGAIN = scancode::CLEARAGAIN | 1: scancode << 30, - CRSEL = scancode::CRSEL | 1: scancode << 30, - EXSEL = scancode::EXSEL | 1: scancode << 30, - - KP_00 = scancode::KP_00 | 1: scancode << 30, - KP_000 = scancode::KP_000 | 1: scancode << 30, - THOUSANDSSEPARATOR = scancode::THOUSANDSSEPARATOR | 1: scancode << 30, - DECIMALSEPARATOR = scancode::DECIMALSEPARATOR | 1: scancode << 30, - CURRENCYUNIT = scancode::CURRENCYUNIT | 1: scancode << 30, - CURRENCYSUBUNIT = scancode::CURRENCYSUBUNIT | 1: scancode << 30, - KP_LEFTPAREN = scancode::KP_LEFTPAREN | 1: scancode << 30, - KP_RIGHTPAREN = scancode::KP_RIGHTPAREN | 1: scancode << 30, - KP_LEFTBRACE = scancode::KP_LEFTBRACE | 1: scancode << 30, - KP_RIGHTBRACE = scancode::KP_RIGHTBRACE | 1: scancode << 30, - KP_TAB = scancode::KP_TAB | 1: scancode << 30, - KP_BACKSPACE = scancode::KP_BACKSPACE | 1: scancode << 30, - KP_A = scancode::KP_A | 1: scancode << 30, - KP_B = scancode::KP_B | 1: scancode << 30, - KP_C = scancode::KP_C | 1: scancode << 30, - KP_D = scancode::KP_D | 1: scancode << 30, - KP_E = scancode::KP_E | 1: scancode << 30, - KP_F = scancode::KP_F | 1: scancode << 30, - KP_XOR = scancode::KP_XOR | 1: scancode << 30, - KP_POWER = scancode::KP_POWER | 1: scancode << 30, - KP_PERCENT = scancode::KP_PERCENT | 1: scancode << 30, - KP_LESS = scancode::KP_LESS | 1: scancode << 30, - KP_GREATER = scancode::KP_GREATER | 1: scancode << 30, - KP_AMPERSAND = scancode::KP_AMPERSAND | 1: scancode << 30, - KP_DBLAMPERSAND = scancode::KP_DBLAMPERSAND | 1: scancode << 30, - KP_VERTICALBAR = scancode::KP_VERTICALBAR | 1: scancode << 30, - KP_DBLVERTICALBAR = scancode::KP_DBLVERTICALBAR | 1: scancode << 30, - KP_COLON = scancode::KP_COLON | 1: scancode << 30, - KP_HASH = scancode::KP_HASH | 1: scancode << 30, - KP_SPACE = scancode::KP_SPACE | 1: scancode << 30, - KP_AT = scancode::KP_AT | 1: scancode << 30, - KP_EXCLAM = scancode::KP_EXCLAM | 1: scancode << 30, - KP_MEMSTORE = scancode::KP_MEMSTORE | 1: scancode << 30, - KP_MEMRECALL = scancode::KP_MEMRECALL | 1: scancode << 30, - KP_MEMCLEAR = scancode::KP_MEMCLEAR | 1: scancode << 30, - KP_MEMADD = scancode::KP_MEMADD | 1: scancode << 30, - KP_MEMSUBTRACT = scancode::KP_MEMSUBTRACT | 1: scancode << 30, - KP_MEMMULTIPLY = scancode::KP_MEMMULTIPLY | 1: scancode << 30, - KP_MEMDIVIDE = scancode::KP_MEMDIVIDE | 1: scancode << 30, - KP_PLUSMINUS = scancode::KP_PLUSMINUS | 1: scancode << 30, - KP_CLEAR = scancode::KP_CLEAR | 1: scancode << 30, - KP_CLEARENTRY = scancode::KP_CLEARENTRY | 1: scancode << 30, - KP_BINARY = scancode::KP_BINARY | 1: scancode << 30, - KP_OCTAL = scancode::KP_OCTAL | 1: scancode << 30, - KP_DECIMAL = scancode::KP_DECIMAL | 1: scancode << 30, - KP_HEXADECIMAL = scancode::KP_HEXADECIMAL | 1: scancode << 30, - - LCTRL = scancode::LCTRL | 1: scancode << 30, - LSHIFT = scancode::LSHIFT | 1: scancode << 30, - LALT = scancode::LALT | 1: scancode << 30, - LGUI = scancode::LGUI | 1: scancode << 30, - RCTRL = scancode::RCTRL | 1: scancode << 30, - RSHIFT = scancode::RSHIFT | 1: scancode << 30, - RALT = scancode::RALT | 1: scancode << 30, - RGUI = scancode::RGUI | 1: scancode << 30, - - MODE = scancode::MODE | 1: scancode << 30, - - AUDIONEXT = scancode::AUDIONEXT | 1: scancode << 30, - AUDIOPREV = scancode::AUDIOPREV | 1: scancode << 30, - AUDIOSTOP = scancode::AUDIOSTOP | 1: scancode << 30, - AUDIOPLAY = scancode::AUDIOPLAY | 1: scancode << 30, - AUDIOMUTE = scancode::AUDIOMUTE | 1: scancode << 30, - MEDIASELECT = scancode::MEDIASELECT | 1: scancode << 30, - WWW = scancode::WWW | 1: scancode << 30, - MAIL = scancode::MAIL | 1: scancode << 30, - CALCULATOR = scancode::CALCULATOR | 1: scancode << 30, - COMPUTER = scancode::COMPUTER | 1: scancode << 30, - AC_SEARCH = scancode::AC_SEARCH | 1: scancode << 30, - AC_HOME = scancode::AC_HOME | 1: scancode << 30, - AC_BACK = scancode::AC_BACK | 1: scancode << 30, - AC_FORWARD = scancode::AC_FORWARD | 1: scancode << 30, - AC_STOP = scancode::AC_STOP | 1: scancode << 30, - AC_REFRESH = scancode::AC_REFRESH | 1: scancode << 30, - AC_BOOKMARKS = scancode::AC_BOOKMARKS | 1: scancode << 30, - - BRIGHTNESSDOWN = scancode::BRIGHTNESSDOWN | 1: scancode << 30, - BRIGHTNESSUP = scancode::BRIGHTNESSUP | 1: scancode << 30, - DISPLAYSWITCH = scancode::DISPLAYSWITCH | 1: scancode << 30, - KBDILLUMTOGGLE = scancode::KBDILLUMTOGGLE | 1: scancode << 30, - KBDILLUMDOWN = scancode::KBDILLUMDOWN | 1: scancode << 30, - KBDILLUMUP = scancode::KBDILLUMUP | 1: scancode << 30, - EJECT = scancode::EJECT | 1: scancode << 30, - SLEEP = scancode::SLEEP | 1: scancode << 30, - APP1 = scancode::APP1 | 1: scancode << 30, - APP2 = scancode::APP2 | 1: scancode << 30, - - AUDIOREWIND = scancode::AUDIOREWIND | 1: scancode << 30, - AUDIOFASTFORWARD = scancode::AUDIOFASTFORWARD | 1: scancode << 30 + END = SDL_Scancode::END | 1: SDL_Scancode << 30, + PAGEDOWN = SDL_Scancode::PAGEDOWN | 1: SDL_Scancode << 30, + RIGHT = SDL_Scancode::RIGHT | 1: SDL_Scancode << 30, + LEFT = SDL_Scancode::LEFT | 1: SDL_Scancode << 30, + DOWN = SDL_Scancode::DOWN | 1: SDL_Scancode << 30, + UP = SDL_Scancode::UP | 1: SDL_Scancode << 30, + + NUMLOCKCLEAR = SDL_Scancode::NUMLOCKCLEAR | 1: SDL_Scancode << 30, + KP_DIVIDE = SDL_Scancode::KP_DIVIDE | 1: SDL_Scancode << 30, + KP_MULTIPLY = SDL_Scancode::KP_MULTIPLY | 1: SDL_Scancode << 30, + KP_MINUS = SDL_Scancode::KP_MINUS | 1: SDL_Scancode << 30, + KP_PLUS = SDL_Scancode::KP_PLUS | 1: SDL_Scancode << 30, + KP_ENTER = SDL_Scancode::KP_ENTER | 1: SDL_Scancode << 30, + KP_1 = SDL_Scancode::KP_1 | 1: SDL_Scancode << 30, + KP_2 = SDL_Scancode::KP_2 | 1: SDL_Scancode << 30, + KP_3 = SDL_Scancode::KP_3 | 1: SDL_Scancode << 30, + KP_4 = SDL_Scancode::KP_4 | 1: SDL_Scancode << 30, + KP_5 = SDL_Scancode::KP_5 | 1: SDL_Scancode << 30, + KP_6 = SDL_Scancode::KP_6 | 1: SDL_Scancode << 30, + KP_7 = SDL_Scancode::KP_7 | 1: SDL_Scancode << 30, + KP_8 = SDL_Scancode::KP_8 | 1: SDL_Scancode << 30, + KP_9 = SDL_Scancode::KP_9 | 1: SDL_Scancode << 30, + KP_0 = SDL_Scancode::KP_0 | 1: SDL_Scancode << 30, + KP_PERIOD = SDL_Scancode::KP_PERIOD | 1: SDL_Scancode << 30, + + APPLICATION = SDL_Scancode::APPLICATION | 1: SDL_Scancode << 30, + POWER = SDL_Scancode::POWER | 1: SDL_Scancode << 30, + KP_EQUALS = SDL_Scancode::KP_EQUALS | 1: SDL_Scancode << 30, + F13 = SDL_Scancode::F13 | 1: SDL_Scancode << 30, + F14 = SDL_Scancode::F14 | 1: SDL_Scancode << 30, + F15 = SDL_Scancode::F15 | 1: SDL_Scancode << 30, + F16 = SDL_Scancode::F16 | 1: SDL_Scancode << 30, + F17 = SDL_Scancode::F17 | 1: SDL_Scancode << 30, + F18 = SDL_Scancode::F18 | 1: SDL_Scancode << 30, + F19 = SDL_Scancode::F19 | 1: SDL_Scancode << 30, + F20 = SDL_Scancode::F20 | 1: SDL_Scancode << 30, + F21 = SDL_Scancode::F21 | 1: SDL_Scancode << 30, + F22 = SDL_Scancode::F22 | 1: SDL_Scancode << 30, + F23 = SDL_Scancode::F23 | 1: SDL_Scancode << 30, + F24 = SDL_Scancode::F24 | 1: SDL_Scancode << 30, + EXECUTE = SDL_Scancode::EXECUTE | 1: SDL_Scancode << 30, + HELP = SDL_Scancode::HELP | 1: SDL_Scancode << 30, + MENU = SDL_Scancode::MENU | 1: SDL_Scancode << 30, + SELECT = SDL_Scancode::SELECT | 1: SDL_Scancode << 30, + STOP = SDL_Scancode::STOP | 1: SDL_Scancode << 30, + AGAIN = SDL_Scancode::AGAIN | 1: SDL_Scancode << 30, + UNDO = SDL_Scancode::UNDO | 1: SDL_Scancode << 30, + CUT = SDL_Scancode::CUT | 1: SDL_Scancode << 30, + COPY = SDL_Scancode::COPY | 1: SDL_Scancode << 30, + PASTE = SDL_Scancode::PASTE | 1: SDL_Scancode << 30, + FIND = SDL_Scancode::FIND | 1: SDL_Scancode << 30, + MUTE = SDL_Scancode::MUTE | 1: SDL_Scancode << 30, + VOLUMEUP = SDL_Scancode::VOLUMEUP | 1: SDL_Scancode << 30, + VOLUMEDOWN = SDL_Scancode::VOLUMEDOWN | 1: SDL_Scancode << 30, + KP_COMMA = SDL_Scancode::KP_COMMA | 1: SDL_Scancode << 30, + KP_EQUALSAS400 = SDL_Scancode::KP_EQUALSAS400 | 1: SDL_Scancode << 30, + + ALTERASE = SDL_Scancode::ALTERASE | 1: SDL_Scancode << 30, + SYSREQ = SDL_Scancode::SYSREQ | 1: SDL_Scancode << 30, + CANCEL = SDL_Scancode::CANCEL | 1: SDL_Scancode << 30, + CLEAR = SDL_Scancode::CLEAR | 1: SDL_Scancode << 30, + PRIOR = SDL_Scancode::PRIOR | 1: SDL_Scancode << 30, + RETURN2 = SDL_Scancode::RETURN2 | 1: SDL_Scancode << 30, + SEPARATOR = SDL_Scancode::SEPARATOR | 1: SDL_Scancode << 30, + OUT = SDL_Scancode::OUT | 1: SDL_Scancode << 30, + OPER = SDL_Scancode::OPER | 1: SDL_Scancode << 30, + CLEARAGAIN = SDL_Scancode::CLEARAGAIN | 1: SDL_Scancode << 30, + CRSEL = SDL_Scancode::CRSEL | 1: SDL_Scancode << 30, + EXSEL = SDL_Scancode::EXSEL | 1: SDL_Scancode << 30, + + KP_00 = SDL_Scancode::KP_00 | 1: SDL_Scancode << 30, + KP_000 = SDL_Scancode::KP_000 | 1: SDL_Scancode << 30, + THOUSANDSSEPARATOR = SDL_Scancode::THOUSANDSSEPARATOR | 1: SDL_Scancode << 30, + DECIMALSEPARATOR = SDL_Scancode::DECIMALSEPARATOR | 1: SDL_Scancode << 30, + CURRENCYUNIT = SDL_Scancode::CURRENCYUNIT | 1: SDL_Scancode << 30, + CURRENCYSUBUNIT = SDL_Scancode::CURRENCYSUBUNIT | 1: SDL_Scancode << 30, + KP_LEFTPAREN = SDL_Scancode::KP_LEFTPAREN | 1: SDL_Scancode << 30, + KP_RIGHTPAREN = SDL_Scancode::KP_RIGHTPAREN | 1: SDL_Scancode << 30, + KP_LEFTBRACE = SDL_Scancode::KP_LEFTBRACE | 1: SDL_Scancode << 30, + KP_RIGHTBRACE = SDL_Scancode::KP_RIGHTBRACE | 1: SDL_Scancode << 30, + KP_TAB = SDL_Scancode::KP_TAB | 1: SDL_Scancode << 30, + KP_BACKSPACE = SDL_Scancode::KP_BACKSPACE | 1: SDL_Scancode << 30, + KP_A = SDL_Scancode::KP_A | 1: SDL_Scancode << 30, + KP_B = SDL_Scancode::KP_B | 1: SDL_Scancode << 30, + KP_C = SDL_Scancode::KP_C | 1: SDL_Scancode << 30, + KP_D = SDL_Scancode::KP_D | 1: SDL_Scancode << 30, + KP_E = SDL_Scancode::KP_E | 1: SDL_Scancode << 30, + KP_F = SDL_Scancode::KP_F | 1: SDL_Scancode << 30, + KP_XOR = SDL_Scancode::KP_XOR | 1: SDL_Scancode << 30, + KP_POWER = SDL_Scancode::KP_POWER | 1: SDL_Scancode << 30, + KP_PERCENT = SDL_Scancode::KP_PERCENT | 1: SDL_Scancode << 30, + KP_LESS = SDL_Scancode::KP_LESS | 1: SDL_Scancode << 30, + KP_GREATER = SDL_Scancode::KP_GREATER | 1: SDL_Scancode << 30, + KP_AMPERSAND = SDL_Scancode::KP_AMPERSAND | 1: SDL_Scancode << 30, + KP_DBLAMPERSAND = SDL_Scancode::KP_DBLAMPERSAND | 1: SDL_Scancode << 30, + KP_VERTICALBAR = SDL_Scancode::KP_VERTICALBAR | 1: SDL_Scancode << 30, + KP_DBLVERTICALBAR = SDL_Scancode::KP_DBLVERTICALBAR | 1: SDL_Scancode << 30, + KP_COLON = SDL_Scancode::KP_COLON | 1: SDL_Scancode << 30, + KP_HASH = SDL_Scancode::KP_HASH | 1: SDL_Scancode << 30, + KP_SPACE = SDL_Scancode::KP_SPACE | 1: SDL_Scancode << 30, + KP_AT = SDL_Scancode::KP_AT | 1: SDL_Scancode << 30, + KP_EXCLAM = SDL_Scancode::KP_EXCLAM | 1: SDL_Scancode << 30, + KP_MEMSTORE = SDL_Scancode::KP_MEMSTORE | 1: SDL_Scancode << 30, + KP_MEMRECALL = SDL_Scancode::KP_MEMRECALL | 1: SDL_Scancode << 30, + KP_MEMCLEAR = SDL_Scancode::KP_MEMCLEAR | 1: SDL_Scancode << 30, + KP_MEMADD = SDL_Scancode::KP_MEMADD | 1: SDL_Scancode << 30, + KP_MEMSUBTRACT = SDL_Scancode::KP_MEMSUBTRACT | 1: SDL_Scancode << 30, + KP_MEMMULTIPLY = SDL_Scancode::KP_MEMMULTIPLY | 1: SDL_Scancode << 30, + KP_MEMDIVIDE = SDL_Scancode::KP_MEMDIVIDE | 1: SDL_Scancode << 30, + KP_PLUSMINUS = SDL_Scancode::KP_PLUSMINUS | 1: SDL_Scancode << 30, + KP_CLEAR = SDL_Scancode::KP_CLEAR | 1: SDL_Scancode << 30, + KP_CLEARENTRY = SDL_Scancode::KP_CLEARENTRY | 1: SDL_Scancode << 30, + KP_BINARY = SDL_Scancode::KP_BINARY | 1: SDL_Scancode << 30, + KP_OCTAL = SDL_Scancode::KP_OCTAL | 1: SDL_Scancode << 30, + KP_DECIMAL = SDL_Scancode::KP_DECIMAL | 1: SDL_Scancode << 30, + KP_HEXADECIMAL = SDL_Scancode::KP_HEXADECIMAL | 1: SDL_Scancode << 30, + + LCTRL = SDL_Scancode::LCTRL | 1: SDL_Scancode << 30, + LSHIFT = SDL_Scancode::LSHIFT | 1: SDL_Scancode << 30, + LALT = SDL_Scancode::LALT | 1: SDL_Scancode << 30, + LGUI = SDL_Scancode::LGUI | 1: SDL_Scancode << 30, + RCTRL = SDL_Scancode::RCTRL | 1: SDL_Scancode << 30, + RSHIFT = SDL_Scancode::RSHIFT | 1: SDL_Scancode << 30, + RALT = SDL_Scancode::RALT | 1: SDL_Scancode << 30, + RGUI = SDL_Scancode::RGUI | 1: SDL_Scancode << 30, + + MODE = SDL_Scancode::MODE | 1: SDL_Scancode << 30, + + AUDIONEXT = SDL_Scancode::AUDIONEXT | 1: SDL_Scancode << 30, + AUDIOPREV = SDL_Scancode::AUDIOPREV | 1: SDL_Scancode << 30, + AUDIOSTOP = SDL_Scancode::AUDIOSTOP | 1: SDL_Scancode << 30, + AUDIOPLAY = SDL_Scancode::AUDIOPLAY | 1: SDL_Scancode << 30, + AUDIOMUTE = SDL_Scancode::AUDIOMUTE | 1: SDL_Scancode << 30, + MEDIASELECT = SDL_Scancode::MEDIASELECT | 1: SDL_Scancode << 30, + WWW = SDL_Scancode::WWW | 1: SDL_Scancode << 30, + MAIL = SDL_Scancode::MAIL | 1: SDL_Scancode << 30, + CALCULATOR = SDL_Scancode::CALCULATOR | 1: SDL_Scancode << 30, + COMPUTER = SDL_Scancode::COMPUTER | 1: SDL_Scancode << 30, + AC_SEARCH = SDL_Scancode::AC_SEARCH | 1: SDL_Scancode << 30, + AC_HOME = SDL_Scancode::AC_HOME | 1: SDL_Scancode << 30, + AC_BACK = SDL_Scancode::AC_BACK | 1: SDL_Scancode << 30, + AC_FORWARD = SDL_Scancode::AC_FORWARD | 1: SDL_Scancode << 30, + AC_STOP = SDL_Scancode::AC_STOP | 1: SDL_Scancode << 30, + AC_REFRESH = SDL_Scancode::AC_REFRESH | 1: SDL_Scancode << 30, + AC_BOOKMARKS = SDL_Scancode::AC_BOOKMARKS | 1: SDL_Scancode << 30, + + BRIGHTNESSDOWN = SDL_Scancode::BRIGHTNESSDOWN | 1: SDL_Scancode << 30, + BRIGHTNESSUP = SDL_Scancode::BRIGHTNESSUP | 1: SDL_Scancode << 30, + DISPLAYSWITCH = SDL_Scancode::DISPLAYSWITCH | 1: SDL_Scancode << 30, + KBDILLUMTOGGLE = SDL_Scancode::KBDILLUMTOGGLE | 1: SDL_Scancode << 30, + KBDILLUMDOWN = SDL_Scancode::KBDILLUMDOWN | 1: SDL_Scancode << 30, + KBDILLUMUP = SDL_Scancode::KBDILLUMUP | 1: SDL_Scancode << 30, + EJECT = SDL_Scancode::EJECT | 1: SDL_Scancode << 30, + SLEEP = SDL_Scancode::SLEEP | 1: SDL_Scancode << 30, + APP1 = SDL_Scancode::APP1 | 1: SDL_Scancode << 30, + APP2 = SDL_Scancode::APP2 | 1: SDL_Scancode << 30, + + AUDIOREWIND = SDL_Scancode::AUDIOREWIND | 1: SDL_Scancode << 30, + AUDIOFASTFORWARD = SDL_Scancode::AUDIOFASTFORWARD | 1: SDL_Scancode << 30 }; -export type keymod = enum u16 { +export type SDL_Keymod = enum u16 { NONE = 0x0000, LSHIFT = 0x0001, RSHIFT = 0x0002, @@ -625,21 +625,21 @@ export type keymod = enum u16 { RESERVED = SCROLL, }; -export type keysym = struct { - scancode: scancode, - sym: keycode, - mod: keymod, +export type SDL_Keysym = struct { + scancode: SDL_Scancode, + sym: SDL_Keycode, + mod: SDL_Keymod, unused: u32, }; -@symbol("SDL_GetKeyFromName") fn _get_key_from_name(name: *const char) keycode; +@symbol("SDL_GetKeyFromName") fn _SDL_GetKeyFromName(name: *const char) SDL_Keycode; -export fn get_key_from_name(name: str) (keycode | error) = { +export fn SDL_GetKeyFromName(name: str) (SDL_Keycode | error) = { const name = strings::to_c(name); defer free(name); - const sym = _get_key_from_name(name); - if (sym == keycode::UNKNOWN) { - return strings::fromc(geterror()): error; + const sym = _SDL_GetKeyFromName(name); + if (sym == SDL_Keycode::UNKNOWN) { + return strings::fromc(SDL_GetError()): error; }; return sym; }; diff --git a/sdl2/mixer/channels.ha b/sdl2/mixer/channels.ha index 4bf4820..fffccd0 100644 --- a/sdl2/mixer/channels.ha +++ b/sdl2/mixer/channels.ha @@ -1,8 +1,8 @@ use sdl2; -@symbol("Mix_PlayChannelTimed") fn _play_channel_timed( +@symbol("Mix_PlayChannelTimed") fn _Mix_PlayChannelTimed( channel: int, - sample: *chunk, + sample: *Mix_Chunk, loops: int, ticks: int, ) int; @@ -11,10 +11,10 @@ use sdl2; // channel. The sample will play for loops+1 number of times, unless stopped by // halt, or fade out, or setting a new expiration time of less time than it // would have originally taken to play the loops, or closing the mixer. -export fn play_channel( +export fn Mix_PlayChannelTimed( channel: int, - sample: *chunk, + sample: *Mix_Chunk, loops: int, ) (void | sdl2::error) = { - return sdl2::wrapvoid(_play_channel_timed(channel, sample, loops, -1)); + return sdl2::wrapvoid(_Mix_PlayChannelTimed(channel, sample, loops, -1)); }; diff --git a/sdl2/mixer/general.ha b/sdl2/mixer/general.ha index 32c7b38..4f819bf 100644 --- a/sdl2/mixer/general.ha +++ b/sdl2/mixer/general.ha @@ -1,7 +1,7 @@ use sdl2; // Flags for [[init]]. -export type init_flags = enum { +export type MIX_InitFlags = enum { FLAC = 0x00000001, MOD = 0x00000002, MP3 = 0x00000008, @@ -11,42 +11,42 @@ export type init_flags = enum { }; // The default mixer has 8 simultaneous mixing channels -export def CHANNELS: int = 8; +export def MIX_CHANNELS: int = 8; // Good default frequency for a PC soundcard -export def DEFAULT_FREQUENCY: int = 22050; +export def MIX_DEFAULT_FREQUENCY: int = 22050; // Good default channels for a PC soundcard -export def DEFAULT_CHANNELS: int = 2; +export def MIX_DEFAULT_CHANNELS: int = 2; // XXX: This should choose MSB on a big-endian system: // Good default format for a PC soundcard -export def DEFAULT_FORMAT: sdl2::audio_format = sdl2::AUDIO_S16LSB; +export def MIX_DEFAULT_FORMAT: sdl2::SDL_AudioFormat = sdl2::AUDIO_S16LSB; -@symbol("Mix_Init") fn _init(flags: int) int; +@symbol("Mix_Init") fn _Mix_Init(flags: int) int; // Loads dynamic libraries and prepares them for use. Flags should be -// one or more flags from [[init_flags]] OR'd together. -export fn init(flags: init_flags) (void | sdl2::error) = { - return sdl2::wrapvoid(_init(flags)); +// one or more flags from [[MIX_InitFlags]] OR'd together. +export fn Mix_Init(flags: MIX_InitFlags) (void | sdl2::error) = { + return sdl2::wrapvoid(_Mix_Init(flags)); }; -// Unloads libraries loaded with [[init]]. -export @symbol("Mix_Quit") fn quit() void; +// Unloads libraries loaded with [[Mix_Init]]. +export @symbol("Mix_Quit") fn Mix_Quit() void; -@symbol("Mix_OpenAudio") fn _openaudio(frequency: int, +@symbol("Mix_OpenAudio") fn _Mix_OpenAudio(frequency: int, format: u16, channels: int, chunksize: int) int; // Open the mixer with a certain audio format -export fn open_audio( +export fn Mix_OpenAudio( frequency: int, - format: sdl2::audio_format, + format: sdl2::SDL_AudioFormat, channels: int, chunksize: int, ) (void | sdl2::error) = { - return sdl2::wrapvoid(_openaudio(frequency, format, channels, chunksize)); + return sdl2::wrapvoid(_Mix_OpenAudio(frequency, format, channels, chunksize)); }; // Close the mixer, halting all playing audio -export @symbol("Mix_CloseAudio") fn close_audio() void; +export @symbol("Mix_CloseAudio") fn Mix_CloseAudio() void; diff --git a/sdl2/mixer/samples.ha b/sdl2/mixer/samples.ha index aaf1ad1..2dce2ef 100644 --- a/sdl2/mixer/samples.ha +++ b/sdl2/mixer/samples.ha @@ -3,37 +3,37 @@ use io; use os; use sdl2; -// The internal format for an audio chunk -export type chunk = struct { +// The internal format for an audio Mix_Chunk +export type Mix_Chunk = struct { allocated: int, abuf: *u8, alen: u32, volume: u8, }; -@symbol("Mix_LoadWAV_RW") fn _loadwav_rw(src: *sdl2::rwops, freesrc: int) nullable *chunk; +@symbol("Mix_LoadWAV_RW") fn _Mix_LoadWAV_RW(src: *sdl2::SDL_RWops, freesrc: int) nullable *Mix_Chunk; // Loads a sample from an [[io::handle]]. The stream will not be closed for you. -export fn load(src: io::handle) (*chunk | sdl2::error) = { +export fn Mix_LoadWAV_RW(src: io::handle) (*Mix_Chunk | sdl2::error) = { const rw = sdl2::rw_from_handle(src); - defer sdl2::rwclose(rw); - return sdl2::wrapptr(_loadwav_rw(rw, 0))?: *chunk; + defer sdl2::SDL_RWclose(rw); + return sdl2::wrapptr(_Mix_LoadWAV_RW(rw, 0))?: *Mix_Chunk; }; // Loads a sample from a file path. -export fn load_file(src: str) (*chunk | fs::error | sdl2::error) = { +export fn load_file(src: str) (*Mix_Chunk | fs::error | sdl2::error) = { const file = os::open(src)?; defer io::close(file); - return load(file); + return Mix_LoadWAV_RW(file); }; -// Free the memory used in chunk, and free chunk itself as well. Do not use -// chunk after this without loading a new sample to it. Note: It's a bad idea to -// free a chunk that is still being played... -export @symbol("Mix_FreeChunk") fn free_chunk(chunk: *chunk) void; +// Free the memory used in Mix_Chunk, and free Mix_Chunk itself as well. Do not use +// Mix_Chunk after this without loading a new sample to it. Note: It's a bad idea to +// free a Mix_Chunk that is still being played... +export @symbol("Mix_FreeChunk") fn Mix_FreeChunk(Mix_Chunk: *Mix_Chunk) void; -// Maximum volume for a chunk. -export def MAX_VOLUME: int = 128; // XXX: SDL_mixer derives this from SDL_MIX_MAXVOLUME +// Maximum volume for a Mix_Chunk. +export def MIX_MAX_VOLUME: int = 128; // XXX: SDL_mixer derives this from SDL_MIX_MAXVOLUME -// Sets the chunk volume as specified, returning the previous value. -export @symbol("Mix_VolumeChunk") fn volume_chunk(chunk: *chunk, volume: int) int; +// Sets the Mix_Chunk volume as specified, returning the previous value. +export @symbol("Mix_VolumeChunk") fn Mix_VolumeChunk(Mix_Chunk: *Mix_Chunk, volume: int) int; diff --git a/sdl2/pixels.ha b/sdl2/pixels.ha index 8227067..618a3c5 100644 --- a/sdl2/pixels.ha +++ b/sdl2/pixels.ha @@ -1,23 +1,23 @@ // TODO: Flesh me out -export type color = struct { +export type SDL_Color = struct { r: u8, g: u8, b: u8, a: u8, }; -export type palette = struct { +export type SDL_Palette = struct { ncolors: int, - colors: *color, + colors: *SDL_Color, version: u32, refcount: int, }; // Note: Everything in the pixel format structure is read-only. -export type pixelformat = struct { +export type SDL_PixelFormat = struct { format: u32, // TODO - palette: *palette, + palette: *SDL_Palette, bitsperpixel: u8, bytesperpixel: u8, padding: [2]u8, @@ -34,5 +34,5 @@ export type pixelformat = struct { bshift: u8, ashift: u8, refcount: int, - next: nullable *pixelformat, + next: nullable *SDL_PixelFormat, }; diff --git a/sdl2/rect.ha b/sdl2/rect.ha index 00fae87..012088e 100644 --- a/sdl2/rect.ha +++ b/sdl2/rect.ha @@ -1,19 +1,19 @@ // TODO: Flesh me out // The structure that defines a point (integer) -export type point = struct { +export type SDL_Point = struct { x: int, y: int, }; // The structure that defines a point (floating point) -export type fpoint = struct { +export type SDL_FPoint = struct { x: f32, y: f32, }; // A rectangle, with the origin at the upper left (integer). -export type rect = struct { +export type SDL_Rect = struct { x: int, y: int, w: int, @@ -21,7 +21,7 @@ export type rect = struct { }; // A rectangle, with the origin at the upper left (floating point). -export type frect = struct { +export type SDL_FRect = struct { x: f32, y: f32, w: f32, diff --git a/sdl2/render.ha b/sdl2/render.ha index 2c53183..d607712 100644 --- a/sdl2/render.ha +++ b/sdl2/render.ha @@ -1,13 +1,13 @@ // TODO: Flesh me out // A structure representing rendering state. (Opaque) -export type renderer = void; +export type SDL_Renderer = void; // An efficient driver-specific representation of pixel data. (Opaque) -export type texture = void; +export type SDL_Texture = void; // Flags used when creating a rendering context. -export type renderer_flags = enum u32 { +export type SDL_RendererFlags = enum u32 { NONE = 0, SOFTWARE = 0x00000001, ACCELERATED = 0x00000002, @@ -15,96 +15,96 @@ export type renderer_flags = enum u32 { TARGETTEXTURE = 0x00000008, }; -@symbol("SDL_CreateWindowAndRenderer") fn _create_window_and_renderer( - width: int, height: int, window_flags: window_flags, - window: nullable **window, renderer: nullable **renderer) int; +@symbol("SDL_CreateWindowAndRenderer") fn _SDL_CreateWindowAndRenderer( + width: int, height: int, SDL_WindowFlags: SDL_WindowFlags, + window: nullable **SDL_Window, renderer: nullable **SDL_Renderer) int; // Create a window and default renderer. // // 'width' and 'height' set the width and height of the window, in screen -// coordinates. 'window_flags' configure additional window parameters. +// coordinates. 'SDL_WindowFlags' configure additional window parameters. // // 'window' and 'renderer' are out parameters, or null, which are filled in with // the created window and renderer respectively. -export fn create_window_and_renderer( +export fn SDL_CreateWindowAndRenderer( width: int, height: int, - window_flags: window_flags, - window: nullable **window, - renderer: nullable **renderer, -) (void | error) = wrapvoid(_create_window_and_renderer(width, height, - window_flags, window, renderer)); + SDL_WindowFlags: SDL_WindowFlags, + window: nullable **SDL_Window, + renderer: nullable **SDL_Renderer, +) (void | error) = wrapvoid(_SDL_CreateWindowAndRenderer(width, height, + SDL_WindowFlags, window, renderer)); -@symbol("SDL_CreateRenderer") fn _create_renderer(window: *window, - index: int, flags: renderer_flags) nullable *renderer; +@symbol("SDL_CreateRenderer") fn _SDL_CreateRenderer(window: *SDL_Window, + index: int, flags: SDL_RendererFlags) nullable *SDL_Renderer; // Create a 2D rendering context for a window. -// +// // 'window' is the window where rendering is displayed. 'index' is the index of // the rendering driver to initialize, or -1 to initialize the first one // supporting the requested flags. -// +// // See also: [[create_software_renderer]], [[get_renderer_info]], -// [[destroy_renderer]]. -export fn create_renderer( - window: *window, +// [[SDL_DestroyRenderer]]. +export fn SDL_CreateRenderer( + window: *SDL_Window, index: int, - flags: renderer_flags, -) (*renderer | error) = - wrapptr(_create_renderer(window, index, flags))?: *renderer; + flags: SDL_RendererFlags, +) (*SDL_Renderer | error) = + wrapptr(_SDL_CreateRenderer(window, index, flags))?: *SDL_Renderer; // Destroy the rendering context for a window and free associated textures. // -// See also: [[create_renderer]]. -export @symbol("SDL_DestroyRenderer") fn destroy_renderer(renderer: *renderer) void; +// See also: [[SDL_CreateRenderer]]. +export @symbol("SDL_DestroyRenderer") fn SDL_DestroyRenderer(renderer: *SDL_Renderer) void; // Opaque value for the alpha channel (255). export def ALPHA_OPAQUE: u8 = 255; -@symbol("SDL_SetRenderDrawColor") fn _set_render_draw_color(renderer: *renderer, +@symbol("SDL_SetRenderDrawColor") fn _SDL_SetRenderDrawColor(renderer: *SDL_Renderer, r: u8, g: u8, b: u8, a: u8) int; // Set the color used for drawing operations (Rect, Line and Clear). -// +// // 'renderer' is the renderer for which drawing color should be set. 'r', 'g', // 'b', and 'a' respectively set the red, gree, blue, and alpha channels. -export fn set_render_draw_color( - renderer: *renderer, +export fn SDL_SetRenderDrawColor( + renderer: *SDL_Renderer, r: u8, g: u8, b: u8, a: u8, -) (void | error) = wrapvoid(_set_render_draw_color(renderer, r, g, b, a)); +) (void | error) = wrapvoid(_SDL_SetRenderDrawColor(renderer, r, g, b, a)); -@symbol("SDL_RenderClear") fn _render_clear(renderer: *renderer) int; +@symbol("SDL_RenderClear") fn _SDL_RenderClear(renderer: *SDL_Renderer) int; // Clear the current rendering target with the drawing color // // This function clears the entire rendering target, ignoring the viewport and // the clip rectangle. -export fn render_clear(renderer: *renderer) (void | error) = { - return wrapvoid(_render_clear(renderer)); +export fn SDL_RenderClear(renderer: *SDL_Renderer) (void | error) = { + return wrapvoid(_SDL_RenderClear(renderer)); }; // Update the screen with rendering performed. -export @symbol("SDL_RenderPresent") fn render_present(renderer: *renderer) void; +export @symbol("SDL_RenderPresent") fn SDL_RenderPresent(renderer: *SDL_Renderer) void; // Destroy the specified texture. -export @symbol("SDL_DestroyTexture") fn destroy_texture(texture: *texture) void; +export @symbol("SDL_DestroyTexture") fn SDL_DestroyTexture(texture: *SDL_Texture) void; -@symbol("SDL_QueryTexture") fn _query_texture(texture: *texture, +@symbol("SDL_QueryTexture") fn _SDL_QueryTexture(texture: *SDL_Texture, format: nullable *u32, access: nullable *int, w: nullable *int, h: nullable *int) int; // Query the attributes of a texture -export fn query_texture( - texture: *texture, +export fn SDL_QueryTexture( + texture: *SDL_Texture, format: nullable *u32, access: nullable *int, w: nullable *int, h: nullable *int, ) (void | error) = { - return wrapvoid(_query_texture(texture, format, access, w, h)); + return wrapvoid(_SDL_QueryTexture(texture, format, access, w, h)); }; -@symbol("SDL_SetTextureColorMod") fn _set_texture_color_mod( - texture: *texture, r: u8, g: u8, b: u8) int; +@symbol("SDL_SetTextureColorMod") fn _SDL_SetTextureColorMod( + texture: *SDL_Texture, r: u8, g: u8, b: u8) int; // Set an additional color value multiplied into render copy operations. // @@ -116,14 +116,14 @@ export fn query_texture( // // Color modulation is not always supported by the renderer; it will return -1 // if color modulation is not supported. -export fn set_texture_color_mod( - texture: *texture, +export fn SDL_SetTextureColorMod( + texture: *SDL_Texture, r: u8, g: u8, b: u8, ) (void | error) = { - return wrapvoid(_set_texture_color_mod(texture, r, g, b)); + return wrapvoid(_SDL_SetTextureColorMod(texture, r, g, b)); }; -@symbol("SDL_SetTextureAlphaMod") fn _set_texture_alpha_mod(texture: *texture, a: u8) int; +@symbol("SDL_SetTextureAlphaMod") fn _SDL_SetTextureAlphaMod(texture: *SDL_Texture, a: u8) int; // Set an additional alpha value multiplied into render copy operations. // @@ -134,64 +134,64 @@ export fn set_texture_color_mod( // // Alpha modulation is not always supported by the renderer; it will return an // error if alpha modulation is not supported. -export fn set_texture_alpha_mod(texture: *texture, a: u8) (void | error) = { +export fn SDL_SetTextureAlphaMod(texture: *SDL_Texture, a: u8) (void | error) = { // TODO: Double check errors - return wrapvoid(_set_texture_alpha_mod(texture, a)); + return wrapvoid(_SDL_SetTextureAlphaMod(texture, a)); }; -@symbol("SDL_SetTextureBlendMode") fn _set_texture_blend_mode( - texture: *texture, mode: blend_mode) int; +@symbol("SDL_SetTextureBlendMode") fn _SDL_SetTextureBlendMode( + texture: *SDL_Texture, mode: SDL_BlendMode) int; // Set the blend mode for a texture, used by SDL_RenderCopy(). -export fn set_texture_blend_mode( - texture: *texture, - mode: blend_mode, +export fn SDL_SetTextureBlendMode( + texture: *SDL_Texture, + mode: SDL_BlendMode, ) (void | error) = { - return wrapvoid(_set_texture_blend_mode(texture, mode)); + return wrapvoid(_SDL_SetTextureBlendMode(texture, mode)); }; -@symbol("SDL_SetRenderDrawBlendMode") fn _set_render_draw_blend_mode( - renderer: *renderer, mode: blend_mode) int; +@symbol("SDL_SetRenderDrawBlendMode") fn _SDL_SetRenderDrawBlendMode( + renderer: *SDL_Renderer, mode: SDL_BlendMode) int; // Set the blend mode used for drawing operations (fill and line). -export fn set_render_draw_blend_mode( - renderer: *renderer, - mode: blend_mode, +export fn SDL_SetRenderDrawBlendMode( + renderer: *SDL_Renderer, + mode: SDL_BlendMode, ) (void | error) = { - return wrapvoid(_set_render_draw_blend_mode(renderer, mode)); + return wrapvoid(_SDL_SetRenderDrawBlendMode(renderer, mode)); }; -@symbol("SDL_RenderCopy") fn _render_copy(renderer: *renderer, - texture: *texture, srcrect: nullable *rect, dstrect: nullable *rect) int; +@symbol("SDL_RenderCopy") fn _SDL_RenderCopy(renderer: *SDL_Renderer, + texture: *SDL_Texture, srcrect: nullable *SDL_Rect, dstrect: nullable *SDL_Rect) int; // Copy a portion of the texture to the current rendering target. -export fn render_copy( - renderer: *renderer, - texture: *texture, - srcrect: nullable *rect, - dstrect: nullable *rect, +export fn SDL_RenderCopy( + renderer: *SDL_Renderer, + texture: *SDL_Texture, + srcrect: nullable *SDL_Rect, + dstrect: nullable *SDL_Rect, ) (void | error) = { - return wrapvoid(_render_copy(renderer, texture, srcrect, dstrect)); + return wrapvoid(_SDL_RenderCopy(renderer, texture, srcrect, dstrect)); }; -@symbol("SDL_RenderDrawRect") fn _render_draw_rect( - renderer: *renderer, rect: const nullable *rect) int; +@symbol("SDL_RenderDrawRect") fn _SDL_RenderDrawRect( + renderer: *SDL_Renderer, rect: const nullable *SDL_Rect) int; // Draw a rectangle on the current rendering target. -export fn render_draw_rect( - renderer: *renderer, - rect: const nullable *rect, +export fn SDL_RenderDrawRect( + renderer: *SDL_Renderer, + rect: const nullable *SDL_Rect, ) (void | error) = { - return wrapvoid(_render_draw_rect(renderer, rect)); + return wrapvoid(_SDL_RenderDrawRect(renderer, rect)); }; -@symbol("SDL_RenderFillRect") fn _render_fill_rect( - renderer: *renderer, rect: const nullable *rect) int; +@symbol("SDL_RenderFillRect") fn _SDL_RenderFillRect( + renderer: *SDL_Renderer, rect: const nullable *SDL_Rect) int; // Fills a rectangle on the current rendering target. -export fn render_fill_rect( - renderer: *renderer, - rect: const nullable *rect, +export fn SDL_RenderFillRect( + renderer: *SDL_Renderer, + rect: const nullable *SDL_Rect, ) (void | error) = { - return wrapvoid(_render_fill_rect(renderer, rect)); + return wrapvoid(_SDL_RenderFillRect(renderer, rect)); }; diff --git a/sdl2/rwops.ha b/sdl2/rwops.ha index 4638c29..d497750 100644 --- a/sdl2/rwops.ha +++ b/sdl2/rwops.ha @@ -12,12 +12,12 @@ export type rwops_type = enum u32 { }; // The read/write operation structure -- very basic. -export type rwops = struct { - sz: *fn(ctx: *rwops) i64, - seek: *fn(ctx: *rwops, offs: i64, whence: int) i64, - read: *fn(ctx: *rwops, ptr: *void, sz: size, maxnum: size) size, - write: *fn(ctx: *rwops, ptr: *void, sz: size, num: size) size, - close: *fn(ctx: *rwops) void, +export type SDL_RWops = struct { + sz: *fn(ctx: *SDL_RWops) i64, + seek: *fn(ctx: *SDL_RWops, offs: i64, whence: int) i64, + read: *fn(ctx: *SDL_RWops, ptr: *void, sz: size, maxnum: size) size, + write: *fn(ctx: *SDL_RWops, ptr: *void, sz: size, num: size) size, + close: *fn(ctx: *SDL_RWops) void, type_: rwops_type, // XXX: This union is platform-specific @@ -41,25 +41,25 @@ export type rwops = struct { @symbol("SDL_RWFromFile") fn _rw_from_file( file: const *char, mode: const *char, -) *rwops; +) *SDL_RWops; -// Returns the size of an [[rwops]], or 0 if unknown or error. +// Returns the size of an [[SDL_RWops]], or 0 if unknown or error. // // See [[stream_from_rw]] for a more idiomatic Hare interface to SDL_RWops. -export @symbol("SDL_RWsize") fn rwsize(ctx: *rwops) i64; +export @symbol("SDL_RWsize") fn SDL_RWsize(ctx: *SDL_RWops) i64; -// Closes an [[rwops]], returning 1 on success or 0 on error. +// Closes an [[SDL_RWops]], returning 1 on success or 0 on error. // // See [[stream_from_rw]] for a more idiomatic Hare interface to SDL_RWops. -export @symbol("SDL_RWclose") fn rwclose(ctx: *rwops) int; +export @symbol("SDL_RWclose") fn SDL_RWclose(ctx: *SDL_RWops) int; // TODO: Other RWops wrappers -// Creates an [[rwops]] from an [[io::handle]]. Closing the rwops does not close +// Creates an [[SDL_RWops]] from an [[io::handle]]. Closing the rwops does not close // the underlying stream. -export fn rw_from_handle(in: io::handle) *rwops = { +export fn rw_from_handle(in: io::handle) *SDL_RWops = { // TODO: Add stream_from_rw - let rw = alloc(rwops { + let rw = alloc(SDL_RWops { sz = &stream_size, seek = &stream_seek, read = &stream_read, @@ -75,7 +75,7 @@ export fn rw_from_handle(in: io::handle) *rwops = { return rw; }; -fn stream_size(ctx: *rwops) i64 = { +fn stream_size(ctx: *SDL_RWops) i64 = { const handle = *(&ctx.hidden.unknown.data1: *io::handle); const old = match (io::tell(handle)) { case let o: io::off => @@ -89,7 +89,7 @@ fn stream_size(ctx: *rwops) i64 = { return sz; }; -fn stream_seek(ctx: *rwops, offs: i64, whence: int) i64 = { +fn stream_seek(ctx: *SDL_RWops, offs: i64, whence: int) i64 = { const handle = *(&ctx.hidden.unknown.data1: *io::handle); // Note: whence values in stdio.h match io::whence match (io::seek(handle, offs: io::off, whence: io::whence)) { @@ -100,7 +100,7 @@ fn stream_seek(ctx: *rwops, offs: i64, whence: int) i64 = { }; }; -fn stream_read(ctx: *rwops, ptr: *void, sz: size, maxnum: size) size = { +fn stream_read(ctx: *SDL_RWops, ptr: *void, sz: size, maxnum: size) size = { const handle = *(&ctx.hidden.unknown.data1: *io::handle); let buf = ptr: *[*]u8; match (io::readitems(handle, buf[..sz * maxnum], sz)) { @@ -111,7 +111,7 @@ fn stream_read(ctx: *rwops, ptr: *void, sz: size, maxnum: size) size = { }; }; -fn stream_write(ctx: *rwops, ptr: *void, sz: size, num: size) size = { +fn stream_write(ctx: *SDL_RWops, ptr: *void, sz: size, num: size) size = { const handle = *(&ctx.hidden.unknown.data1: *io::handle); let buf = ptr: *[*]u8; match (io::writeitems(handle, buf[..sz * num], sz)) { @@ -122,7 +122,7 @@ fn stream_write(ctx: *rwops, ptr: *void, sz: size, num: size) size = { }; }; -fn stream_close(ctx: *rwops) void = { +fn stream_close(ctx: *SDL_RWops) void = { const handle = *(&ctx.hidden.unknown.data1: *io::handle); free(ctx); }; diff --git a/sdl2/sdl2.ha b/sdl2/sdl2.ha index 08e1234..d36ff2b 100644 --- a/sdl2/sdl2.ha +++ b/sdl2/sdl2.ha @@ -1,4 +1,4 @@ -// These are the flags which may be passed to [[init]]. You should specify the +// These are the flags which may be passed to [[SDL_Init]]. You should specify the // subsystems which you will be using in your application. export type init_flags = enum uint { TIMER = 0x00000001u, @@ -13,13 +13,13 @@ export type init_flags = enum uint { EVERYTHING = TIMER | AUDIO | VIDEO | EVENTS | JOYSTICK | HAPTIC | GAMECONTROLLER | SENSOR, }; -@symbol("SDL_Init") fn _init(flags: init_flags) int; +@symbol("SDL_Init") fn _SDL_Init(flags: init_flags) int; // This function initializes the subsystems specified by 'flags'. -export fn init(flags: init_flags) (void | error) = { - return wrapvoid(_init(flags)); +export fn SDL_Init(flags: init_flags) (void | error) = { + return wrapvoid(_SDL_Init(flags)); }; // This function cleans up all initialized subsystems. You should call it upon // all exit conditions. -export @symbol("SDL_Quit") fn quit() void; +export @symbol("SDL_Quit") fn SDL_Quit() void; diff --git a/sdl2/surface.ha b/sdl2/surface.ha index 7bbe850..39d4d2a 100644 --- a/sdl2/surface.ha +++ b/sdl2/surface.ha @@ -1,10 +1,10 @@ // A collection of pixels used in software blitting. -// +// // This structure should be treated as read-only, except for 'pixels', which, if // not null, contains the raw pixel data for the surface. -export type surface = struct { +export type SDL_Surface = struct { flags: u32, - format: *pixelformat, + format: *SDL_PixelFormat, w: int, h: int, pitch: int, @@ -15,11 +15,11 @@ export type surface = struct { locked: int, lock_data: *void, - clip_rect: rect, + clip_rect: SDL_Rect, - map: *blitmap, + map: *SDL_BlitMap, refcount: int, }; -export type blitmap = void; +export type SDL_BlitMap = void; diff --git a/sdl2/timer.ha b/sdl2/timer.ha index 1b315ec..d90511a 100644 --- a/sdl2/timer.ha +++ b/sdl2/timer.ha @@ -4,7 +4,7 @@ // // Returns an unsigned 32-bit value representing the number of milliseconds // since the SDL library initialized. -export @symbol("SDL_GetTicks") fn get_ticks() u32; +export @symbol("SDL_GetTicks") fn SDL_GetTicks() u32; // Get the current value of the high resolution counter. // @@ -12,21 +12,21 @@ export @symbol("SDL_GetTicks") fn get_ticks() u32; // // The counter values are only meaningful relative to each other. Differences // between values can be converted to times by using -// [[getperformancefrequency]]. +// [[SDL_GetPerformanceFrequency]]. // // Returns the current counter value. -export @symbol("SDL_GetPerformanceCounter") fn get_performance_counter() u64; +export @symbol("SDL_GetPerformanceCounter") fn SDL_GetPerformanceCounter() u64; // Get the count per second of the high resolution counter. // // Returns a platform-specific count per second. -export @symbol("SDL_GetPerformanceFrequency") fn get_performance_frequency() u64; +export @symbol("SDL_GetPerformanceFrequency") fn SDL_GetPerformanceFrequency() u64; // Wait a specified number of milliseconds before returning. // // This function waits a specified number of milliseconds before returning. It // waits at least the specified time, but possibly longer due to OS // scheduling. -export @symbol("SDL_Delay") fn delay(ms: u32) void; +export @symbol("SDL_Delay") fn SDL_Delay(ms: u32) void; // TODO: Timers diff --git a/sdl2/video.ha b/sdl2/video.ha index b1f8b22..874a8bd 100644 --- a/sdl2/video.ha +++ b/sdl2/video.ha @@ -2,10 +2,10 @@ use strings; // The type used to identify a window. (Opaque) -export type window = void; +export type SDL_Window = void; // The flags on a window -export type window_flags = enum u32 { +export type SDL_WindowFlags = enum u32 { NONE = 0, FULLSCREEN = 0x00000001, OPENGL = 0x00000002, @@ -27,22 +27,22 @@ export type window_flags = enum u32 { UTILITY = 0x00020000, TOOLTIP = 0x00040000, POPUP_MENU = 0x00080000, - VULKAN = 0x10000000 + VULKAN = 0x10000000 }; -export def WINDOWPOS_UNDEFINED: int = 0x1FFF0000; -export def WINDOWPOS_CENTERED: int = 0x2FFF0000; +export def SDL_WINDOWPOS_UNDEFINED: int = 0x1FFF0000; +export def SDL_WINDOWPOS_CENTERED: int = 0x2FFF0000; -@symbol("SDL_CreateWindow") fn _create_window(title: const *char, - x: int, y: int, w: int, h: int, flags: window_flags) nullable *window; +@symbol("SDL_CreateWindow") fn _SDL_CreateWindow(title: const *char, + x: int, y: int, w: int, h: int, flags: SDL_WindowFlags) nullable *SDL_Window; // Create a window with the specified position, dimensions, and flags. // // 'title' is the title of the window, in UTF-8 encoding. See [[strings::to_c]] // to prepare a suitable string. // -// 'x' and 'y' set the position of the window, or use [[WINDOWPOS_CENTERED]] or -// [[WINDOWPOS_UNDEFINED]]. +// 'x' and 'y' set the position of the window, or use [[SDL_WINDOWPOS_CENTERED]] or +// [[SDL_WINDOWPOS_UNDEFINED]]. // // 'w' and 'h' set the width and height of the window, in screen coordinates. // @@ -69,22 +69,22 @@ export def WINDOWPOS_CENTERED: int = 0x2FFF0000; // Vulkan loader or link to a dynamic library version. This limitation may be // removed in a future version of SDL. // -// See also: [[destroy_window]] [[gl_loadlibrary]], [[vulkan_loadlibrary]]. -export fn create_window( +// See also: [[SDL_DestroyWindow]] [[gl_loadlibrary]], [[vulkan_loadlibrary]]. +export fn SDL_CreateWindow( title: str, x: int, y: int, w: int, h: int, - flags: window_flags, -) (*window | error) = { + flags: SDL_WindowFlags, +) (*SDL_Window | error) = { let title = strings::to_c(title); defer free(title); - return wrapptr(_create_window(title, x, y, w, h, flags))?: *window; + return wrapptr(_SDL_CreateWindow(title, x, y, w, h, flags))?: *SDL_Window; }; // Destroy a window. -export @symbol("SDL_DestroyWindow") fn destroy_window(window: *window) void; +export @symbol("SDL_DestroyWindow") fn SDL_DestroyWindow(window: *SDL_Window) void; // Get the size of a window's client area. // @@ -96,5 +96,5 @@ export @symbol("SDL_DestroyWindow") fn destroy_window(window: *window) void; // support (e.g. iOS or macOS). Use [[gl_getdrawablesize]], // [[vulkan_getdrawablesize]], or [[getrendereroutputsize]] to get the real // client area size in pixels. -export @symbol("SDL_GetWindowSize") fn get_window_size(window: *window, +export @symbol("SDL_GetWindowSize") fn SDL_GetWindowSize(window: *SDL_Window, w: nullable *int, h: nullable *int) void; |
