Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tiehuis/zig-sdl2
SDL2 bindings for Zig
https://github.com/tiehuis/zig-sdl2
sdl zig
Last synced: about 2 months ago
JSON representation
SDL2 bindings for Zig
- Host: GitHub
- URL: https://github.com/tiehuis/zig-sdl2
- Owner: tiehuis
- Created: 2018-07-17T09:10:36.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-09T08:01:37.000Z (over 5 years ago)
- Last Synced: 2024-08-03T23:24:56.652Z (4 months ago)
- Topics: sdl, zig
- Language: Zig
- Size: 40 KB
- Stars: 12
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
- awesome-zig - tiehuis/zig-sdl2
README
DEPRECATED: This is no longer needed since Zig added specific C-pointer types for translated code.
I recommend using C import directly. If there is any issue with the automatic translation process, you can
make an issue on the main zig compiler repository and we can fix upstream.Minimal zig wrapper over SDL2.
For now, the standard SDL naming conventions are used but these will be changed
in the future to use zig namespacing.The only difference between this package and `@cImport(@cInclude("SDL.h"))` is
fixing and correcting single-pointer entries and completing macro definitions
that are otherwise untranslatable.## Example
use @import("src/index.zig");
pub fn main() u8 {
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) {
SDL_Log(c"failed to initialized SDL\n");
return 1;
}
defer SDL_Quit();var renderer: *SDL_Renderer = undefined;
var window: *SDL_Window = undefined;if (SDL_CreateWindowAndRenderer(640, 480, SDL_WINDOW_SHOWN, &window, &renderer) != 0) {
SDL_Log(c"failed to initialize window and renderer\n");
return 1;
}
defer SDL_DestroyRenderer(renderer);
defer SDL_DestroyWindow(window);SDL_SetWindowTitle(window, c"zig-sdl");
_ = SDL_SetRenderDrawColor(renderer, 0, 64, 128, 255);
_ = SDL_RenderClear(renderer);
_ = SDL_RenderPresent(renderer);SDL_Delay(3000);
return 0;
}## Todo
- Clean up remaining arguments to take single-item pointers and non-nullables
where applicable.
- Convert c_int return codes to bool where applicable.
- Potentially namespace functions to `sdl.` instead of the current `SDL_`.