• Stars
    star
    11
  • Rank 1,641,068 (Top 34 %)
  • Language
    Zig
  • Created almost 6 years ago
  • Updated almost 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
236
star
2

zig-regex

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

zig-rosetta

Rosettacode examples in zig
Makefile
30
star
4

libhcs

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

zligc

libc implementation in zig
C
27
star
6

zig-lua

zig interfacing with lua example
C
22
star
7

zig-nng-example

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

HeborisC7EX

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

nanopack

Lightweight Msgpack Encoder
C
15
star
10

zig-raytrace

simple raytracer in zig
Zig
14
star
11

zig-ryu

Zig port of https://github.com/ulfjack/ryu
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

zig-simd-mem

std.mem rewrites using vectorization
Zig
4
star
20

zig-dlmalloc

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

zig-compiler-completions

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

zstack

Line-race tetris mode in Zig
Zig
4
star
23

euler

Solutions for
C
3
star
24

ansiz

ansi escape code library for zig
3
star
25

QuickEdit

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

Football-Fumble

Android game
Java
3
star
27

zig-docgen

documentation generator for zig
3
star
28

tetrs

A Tetris Engine in Rust
Rust
3
star
29

zig-notes

notes about the zig programming language
3
star
30

zig-deflate

DEFLATE implementation for zig
C
2
star
31

lwan-api-example

C
2
star
32

quartic

Music Fundamentals Library
Rust
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

mpe

Tetris in C++17
C++
1
star
37

advent-of-code-2019

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

dotfiles

Dotfiles
Vim Script
1
star
39

mptet

Multiple-Precision Tetris
C
1
star
40

zig-cli-experiment

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

golfscript-rs

Golfscript Interpreter in Rust
Rust
1
star
42

chrono

Timing library in C
C
1
star
43

Snake

Play snake on the terminal
C
1
star
44

int_traits

Extended Traits for Rust Integer Types
Rust
1
star