Skip to content

SDL2 input handling support for imgui-rs using only SDL2 FFI bindings

Notifications You must be signed in to change notification settings

EquinoxAlpha/imgui-sdl2-sys-support

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imgui-sdl2-sys

Simple SDL2 input handling support for imgui-rs using only C bindings

You will still need a renderer.

Why?

I was working on a project that involved hooking some SDL2 functions inside another program. For that reason, I only had access to their C representation (which makes using the sdl2 crate impossible), and other crates that provide this support all use the sdl2 crate. So I rewrote the original dear imgui SDL2 support in Rust.

However, the sdl2_sys bindings were missing a lot of definitions to make them suitable for this, so I had to generate my own with bindgen. The bindings can be found in the src/bindings directory.

Usage

Initialize the ImGuiSDL2 struct: let mut platform = ImGuiSDL2::new(&mut imgui)

Then, before calling imgui.frame() to begin a frame, call this, where sdl_window is a reference to SDL_Window. platform.prepare_frame(&mut imgui, &mut sdl_window);

Now you will also need to capture events somewhere, such as in a SDL_PollEvent hook. Call this in your hook, where "event" is a SDL_Event reference: platform.handle_event(&mut imgui, event)

About

SDL2 input handling support for imgui-rs using only SDL2 FFI bindings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published