diff options
| author | tslil clingman <> | 2021-09-09 23:18:56 -0400 |
|---|---|---|
| committer | tslil clingman <> | 2021-09-09 23:29:10 -0400 |
| commit | d2f6860430f93291a52d1cdaccf6831cd57be9a5 (patch) | |
| tree | 27d7698d79e678cad961647ea6295da53b6a8a49 /src/sfml/graphics | |
| parent | cf1eb8fc551f5f3ee3bc0054fc236ff7d201f44a (diff) | |
Added ceilings and pos_z to sprites (they can now be on the ceiling)
Diffstat (limited to 'src/sfml/graphics')
| -rw-r--r-- | src/sfml/graphics/Image.zig | 11 | ||||
| -rw-r--r-- | src/sfml/graphics/texture.zig | 11 |
2 files changed, 4 insertions, 18 deletions
diff --git a/src/sfml/graphics/Image.zig b/src/sfml/graphics/Image.zig index 9fc6530..8ddf8e3 100644 --- a/src/sfml/graphics/Image.zig +++ b/src/sfml/graphics/Image.zig @@ -72,15 +72,8 @@ pub fn setPixel(self: Image, pixel_pos: sf.Vector2u, color: sf.Color) void { /// Gets the size of this image pub fn getSize(self: Image) sf.Vector2u { - // This is a hack - _ = sf.c.sfImage_getSize(self.ptr); - // Register Rax holds the return val of function calls that can fit in a register - const rax: usize = asm volatile ("" - : [ret] "={rax}" (-> usize) - ); - var x: u32 = @truncate(u32, (rax & 0x00000000FFFFFFFF) >> 00); - var y: u32 = @truncate(u32, (rax & 0xFFFFFFFF00000000) >> 32); - return sf.Vector2u{ .x = x, .y = y }; + const size = sf.c.sfImage_getSize(self.ptr); + return sf.Vector2u{ .x = size.x, .y = size.y }; } /// Pointer to the csfml texture diff --git a/src/sfml/graphics/texture.zig b/src/sfml/graphics/texture.zig index ac4cfbb..317738a 100644 --- a/src/sfml/graphics/texture.zig +++ b/src/sfml/graphics/texture.zig @@ -75,15 +75,8 @@ pub const Texture = union(TextureType) { /// Gets the size of this image pub fn getSize(self: Self) sf.Vector2u { - // This is a hack - _ = sf.c.sfTexture_getSize(self.get()); - // Register Rax holds the return val of function calls that can fit in a register - const rax: usize = asm volatile ("" - : [ret] "={rax}" (-> usize) - ); - var x: u32 = @truncate(u32, (rax & 0x00000000FFFFFFFF) >> 00); - var y: u32 = @truncate(u32, (rax & 0xFFFFFFFF00000000) >> 32); - return sf.Vector2u{ .x = x, .y = y }; + const size = sf.c.sfTexture_getSize(self.get()); + return sf.Vector2u{ .x = size.x, .y = size.y }; } /// Gets the pixel count of this image pub fn getPixelCount(self: Self) usize { |
