aboutsummaryrefslogtreecommitdiff
path: root/src/sfml/window
diff options
context:
space:
mode:
authortslil clingman <>2021-10-27 15:37:28 -0400
committertslil clingman <>2021-10-27 15:37:28 -0400
commit48dee0817f5fe8c09a085f0150e0c6b4a699ab7c (patch)
treed6ab0a54f2260cb73c79e00ca1489c034f555f09 /src/sfml/window
parent486935299e4b7e097754611d9f8dd40003351ae4 (diff)
Update SFML wrapper
Diffstat (limited to 'src/sfml/window')
-rw-r--r--src/sfml/window/context_settings.zig28
-rw-r--r--src/sfml/window/event.zig2
-rw-r--r--src/sfml/window/mouse.zig8
3 files changed, 33 insertions, 5 deletions
diff --git a/src/sfml/window/context_settings.zig b/src/sfml/window/context_settings.zig
new file mode 100644
index 0000000..19b8f03
--- /dev/null
+++ b/src/sfml/window/context_settings.zig
@@ -0,0 +1,28 @@
+const sf = @import("../sfml.zig");
+
+pub const ContextSettings = packed struct {
+ const PaddingType = @import("std").meta.Int(.unsigned, @bitSizeOf(c_int) - @bitSizeOf(bool));
+
+ depth_bits: c_uint = 0,
+ stencil_bits: c_uint = 0,
+ antialiasing_level: c_uint = 0,
+ major_version: c_uint = 1,
+ minor_version: c_uint = 1,
+ attribute_flags: u32 = 0,
+ srgb_capable: bool = false,
+ _padding: PaddingType = 0,
+
+ pub const Attribute = struct {
+ pub const default: u32 = 0;
+ pub const core: u32 = 1;
+ pub const debug: u32 = 4;
+ };
+
+ pub fn _toCSFML(self: ContextSettings) sf.c.sfContextSettings {
+ return @bitCast(sf.c.sfContextSettings, self);
+ }
+
+ pub fn _fromCSFML(context_settings: sf.c.sfContextSettings) ContextSettings {
+ return @bitCast(ContextSettings, context_settings);
+ }
+}; \ No newline at end of file
diff --git a/src/sfml/window/event.zig b/src/sfml/window/event.zig
index c9694f1..a73c192 100644
--- a/src/sfml/window/event.zig
+++ b/src/sfml/window/event.zig
@@ -35,7 +35,7 @@ pub const Event = union(Event.Type) {
// Big oof
/// Creates this event from a csfml one
- pub fn fromCSFML(event: sf.c.sfEvent) Self {
+ pub fn _fromCSFML(event: sf.c.sfEvent) Self {
return switch (event.type) {
sf.c.sfEvtClosed => .{ .closed = {} },
sf.c.sfEvtResized => .{ .resized = .{ .size = .{ .x = event.size.width, .y = event.size.height } } },
diff --git a/src/sfml/window/mouse.zig b/src/sfml/window/mouse.zig
index c788324..b60ff00 100644
--- a/src/sfml/window/mouse.zig
+++ b/src/sfml/window/mouse.zig
@@ -15,12 +15,12 @@ pub fn isButtonPressed(button: Button) bool {
/// Gets the position of the mouse cursor relative to the window passed or desktop
pub fn getPosition(window: ?sf.graphics.RenderWindow) sf.system.Vector2i {
if (window) |w| {
- return sf.system.Vector2i.fromCSFML(sf.c.sfMouse_getPosition(@ptrCast(*sf.c.sfWindow, w.ptr)));
- } else return sf.system.Vector2i.fromCSFML(sf.c.sfMouse_getPosition(null));
+ return sf.system.Vector2i._fromCSFML(sf.c.sfMouse_getPosition(@ptrCast(*sf.c.sfWindow, w._ptr)));
+ } else return sf.system.Vector2i._fromCSFML(sf.c.sfMouse_getPosition(null));
}
/// Set the position of the mouse cursor relative to the window passed or desktop
pub fn setPosition(position: sf.system.Vector2i, window: ?sf.graphics.RenderWindow) void {
if (window) |w| {
- sf.c.sfMouse_setPosition(position.toCSFML(), @ptrCast(*sf.c.sfWindow, w.ptr));
- } else sf.c.sfMouse_setPosition(position.toCSFML(), null);
+ sf.c.sfMouse_setPosition(position._toCSFML(), @ptrCast(*sf.c.sfWindow, w._ptr));
+ } else sf.c.sfMouse_setPosition(position._toCSFML(), null);
}