diff options
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | build.zig | 4 | ||||
-rw-r--r-- | src/frontend/sdl.zig | 12 | ||||
m--------- | vendor/SDL | 0 |
4 files changed, 12 insertions, 7 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..caf199e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vendor/SDL"] + path = vendor/SDL + url = git@github.com:libsdl-org/SDL.git @@ -35,9 +35,11 @@ pub fn build(b: *std.Build) void { .target = target, .optimize = optimize, }); + exe.addLibraryPath(b.path("vendor/SDL/build")); + exe.addIncludePath(b.path("vendor/SDL/include")); exe.linkSystemLibrary("c"); exe.linkSystemLibrary("ncurses"); - exe.linkSystemLibrary("SDL2"); + exe.linkSystemLibrary("SDL3"); // This declares intent for the executable to be installed into the // standard location when the user invokes the "install" step (the default diff --git a/src/frontend/sdl.zig b/src/frontend/sdl.zig index c9a4bf2..bf2fbbb 100644 --- a/src/frontend/sdl.zig +++ b/src/frontend/sdl.zig @@ -1,6 +1,6 @@ const std = @import("std"); const sdl = @cImport({ - @cInclude("SDL.h"); + @cInclude("SDL3/SDL.h"); }); const Action = @import("../actions.zig").Action; const IOInterface = @import("io_interface.zig").IOInterface; @@ -31,7 +31,7 @@ pub const IO = struct { while (!quit) { _ = sdl.SDL_WaitEvent(&event); switch (event.type) { - sdl.SDL_QUIT => quit = true, + sdl.SDL_EVENT_QUIT => quit = true, else => {}, } } @@ -44,17 +44,17 @@ pub const IO = struct { io.allocator = allocator; io.sprites = std.ArrayList([*c]sdl.SDL_Surface).init(allocator); - if (sdl.SDL_Init(sdl.SDL_INIT_VIDEO) < 0) return error.SDL_Failed; + if (!sdl.SDL_Init(sdl.SDL_INIT_VIDEO)) return error.SDL_Failed; io.screen = sdl.SDL_CreateWindow( "urlg", - sdl.SDL_WINDOWPOS_UNDEFINED, - sdl.SDL_WINDOWPOS_UNDEFINED, 640, 480, 0, ); + if (io.screen == null) return error.SDL_Failed; + io.loadSprite() catch |err| { io.deinit(); return err; @@ -68,7 +68,7 @@ pub const IO = struct { pub fn deinit(self: *IO) void { for (self.sprites.items) |sprite| { - _ = sdl.SDL_FreeSurface(sprite); + _ = sdl.SDL_DestroySurface(sprite); } self.sprites.deinit(); diff --git a/vendor/SDL b/vendor/SDL new file mode 160000 +Subproject 535d80badefc83c5c527ec5748f2a20d6a9310f |