#SFML for Zig

1 messages · Page 1 of 1 (latest)

stone iron
#

Hello! This is a Zig wrapper for SFML (CSFML), which is the Simple and Fast Media Library, a library for 2D graphics, windowing, input, sound and network.

https://github.com/Guigui220D/zig-sfml-wrapper
https://www.sfml-dev.org/index.php

The wrapper offers an object oriented layer to use SFML similarly to how you would in C++.
Here's a small example:

//! This is a translation of the c++ code the sfml website gives you to test if SFML works
//! for instance, in this page: https://www.sfml-dev.org/tutorials/2.5/start-vc.php

const sf = struct {
    usingnamespace @import("sfml");
    usingnamespace sf.graphics;
};

pub fn main() !void {
    var window = try sf.RenderWindow.createDefault(.{ .x = 200, .y = 200 }, "SFML works!");
    defer window.destroy();

    var shape = try sf.CircleShape.create(100.0);
    defer shape.destroy();
    shape.setFillColor(sf.Color.Green);

    while (window.isOpen()) {
        while (window.pollEvent()) |event| {
            if (event == .closed)
                window.close();
        }

        window.clear(sf.Color.Black);
        window.draw(shape, null);
        window.display();
    }
}
GitHub

A zig wrapper for csfml. Contribute to Guigui220D/zig-sfml-wrapper development by creating an account on GitHub.

#

This is not a new project but I felt like making a post since I want to come back to maintaining it

#

I just updated the project to Zig 0.12/0.13, and soon I will try to update to SFML 2.6

stone iron
#

Works with 2.6 now! Theres not every single feature but being exaustive takes some work so if theres ever an sfml feature you want ask me

knotty summit
#

Is Imgui support planned for this? or can it be possible?

dark bough
#

Is it just me or do other people see SFML as (Soo, F*** My Life)

stone iron
#

Would need to either do a c bindings of imgui-sfml, or write a new cimgui/zigimgui backend for zig-sfml-wrapper