• Stars
    star
    12
  • Rank 1,597,372 (Top 32 %)
  • Language
    Zig
  • Created over 6 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SDL2 bindings for Zig
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_`.

More Repositories

1

2048-cli

The game 2048 for your Linux terminal (https://github.com/gabrielecirulli/2048)
C
245
star
2

zig-regex

A regex implementation for the zig programming language
Zig
181
star
3

zig-rosetta

Rosettacode examples in zig
Zig
31
star
4

libhcs

A partially Homomorphic C library.
C++
31
star
5

zligc

libc implementation in zig
C
29
star
6

zig-lua

zig interfacing with lua example
C
24
star
7

zig-nng-example

Example of using nanomsg-next-generation with Zig
Zig
17
star
8

HeborisC7EX

A high speed puzzle action game
C++
16
star
9

nanopack

Lightweight Msgpack Encoder
C
15
star
10

zig-ryu

Zig port of https://github.com/ulfjack/ryu
Zig
15
star
11

zig-raytrace

simple raytracer in zig
Zig
14
star
12

zig-gameboy

A gameboy emulator in zig
Zig
13
star
13

zig-benchmarks-game

The Computer Language Benchmarks Game in Zig
C
12
star
14

faststack

If you want to stack blocks kind of quick
C
10
star
15

zig-bn

big numbers for zig
Zig
8
star
16

zig-ctags

ctags definition for zig
8
star
17

zig-replace-c

5
star
18

zig-parsefloat

Float parsing library for Zig
Zig
5
star
19

zstack

Line-race tetris mode in Zig
Zig
5
star
20

tetrs

A Tetris Engine in Rust
Rust
4
star
21

quartic

Music Fundamentals Library
Rust
4
star
22

zig-dlmalloc

Work in progress port of dlmalloc-2.8.6 to Zig
C
4
star
23

zig-compiler-completions

bash and zsh completions for the zig compiler
Rust
4
star
24

euler

Solutions for
C
3
star
25

zig-simd-mem

std.mem rewrites using vectorization
Zig
3
star
26

ansiz

ansi escape code library for zig
3
star
27

QuickEdit

A (very) small editor for quick editing of large files.
C
3
star
28

Football-Fumble

Android game
Java
3
star
29

zig-docgen

documentation generator for zig
3
star
30

zig-notes

notes about the zig programming language
3
star
31

zig-deflate

DEFLATE implementation for zig
C
2
star
32

lwan-api-example

C
2
star
33

linguist-color-checker

Compares colors of linguist languages
Go
2
star
34

libhcs-voting

An example of a voting system using libhcs
C++
1
star
35

cihttp

Simple Case-Insensitive File Server
Go
1
star
36

zig-xxh3

XXH3 implementation in Zig
C
1
star
37

mpe

Tetris in C++17
C++
1
star
38

advent-of-code-2019

https://adventofcode.com/2019
Zig
1
star
39

dotfiles

Dotfiles
Python
1
star
40

mptet

Multiple-Precision Tetris
C
1
star
41

zig-cli-experiment

Experiment in how to handle the cli interface for zig
Shell
1
star
42

golfscript-rs

Golfscript Interpreter in Rust
Rust
1
star
43

chrono

Timing library in C
C
1
star
44

Snake

Play snake on the terminal
C
1
star
45

int_traits

Extended Traits for Rust Integer Types
Rust
1
star