Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Guigui220D/zig-sfml-wrapper
A zig wrapper for csfml
https://github.com/Guigui220D/zig-sfml-wrapper
binding csfml sfml wrapper zig zig-package
Last synced: about 2 months ago
JSON representation
A zig wrapper for csfml
- Host: GitHub
- URL: https://github.com/Guigui220D/zig-sfml-wrapper
- Owner: Guigui220D
- License: other
- Created: 2020-10-29T16:25:03.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-02T11:42:03.000Z (5 months ago)
- Last Synced: 2024-08-02T13:14:41.452Z (5 months ago)
- Topics: binding, csfml, sfml, wrapper, zig, zig-package
- Language: Zig
- Homepage:
- Size: 7.16 MB
- Stars: 45
- Watchers: 3
- Forks: 8
- Open Issues: 6
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- awesome-zig - zig-sfml-wrapper๐๏ธA zig wrapper for csfml
README
# Zig [SFML](https://www.sfml-dev.org/) Wrapper
## A pretty interface to use CSFML in a way that looks Object-Oriented in zig!
### What this is
This is a wrapper for CSFML. Theres no problem importing CSFML in Zig, but the resulting code can be a little bit messy.
My goal is to make things close enough to SFML, with nice methods.This currently for Zig 0.12 (should work with 0.13) and CSFML 2.6.1.
### Adding to your project
Add using Zig's package manager like so: `zig fetch --save https://github.com/Guigui220D/zig-sfml-wrapper/archive/d5272051a937c8a3756bb96eab8276b76a271de4.tar.gz` (replace the commit hash if you want an other version).
Add this to your exe compile in `build.zig`:
```zig
exe.root_module.addImport("sfml", b.dependency("sfml", .{}).module("sfml"));
sfml.link(exe);
```Check the [wiki](../../wiki) for more details on how to compile your project or the examples.
### Small example
This is a small example of how you use this sfml wrapper:
```zig
//! 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.6/start-vc.phpconst 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();
}
}
```### Projects made with this wrapper
Feel free to add your project to this list!
- [Pong clone I made](https://github.com/Guigui220D/sfml-pong-zig)
- [Minez](https://github.com/Guigui220D/minez) an arcade looking minecraft inspired mining game
- [quran-warsh](https://github.com/muslimDevCommunity/quran-warsh) a desktop quran app
### How much is doneMost of the classes are wrapped and you should be able to write games with this wrapper.
The network module is a recent addition and does not contain all classes yet (HTTP, FTP, ...).
Threads are not available yet.