summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GameInitDispose.cpp52
-rw-r--r--src/main.zig6
-rw-r--r--src/misc.zig12
3 files changed, 36 insertions, 34 deletions
diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp
index 3930a05..94ad884 100644
--- a/src/GameInitDispose.cpp
+++ b/src/GameInitDispose.cpp
@@ -1630,33 +1630,33 @@ void initGl(Game* game)
 	glPolygonOffset(-8,0);
 	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 
-	game->text.FontTexture = loadTexture("Font.png");
+	game->text.FontTexture = loadTexture("font.png");
 	game->text.BuildFont();
-	game->personspritetextureptr = loadTexture("Personsprite.png");
-	game->deadpersonspritetextureptr = loadTexture("DeadPersonsprite.png");
-	game->scopetextureptr = loadTexture("Scope.png");
-	game->flaretextureptr = loadTexture("Flare.png");
-
-	sprites.flaretextureptr = loadTexture("HitFlash.png");
-	sprites.muzzleflaretextureptr = loadTexture("MuzzleFlash.png");
-	sprites.smoketextureptr = loadTexture("Smoke.png");
-	sprites.bloodtextureptr = loadTexture("Blood.png");
-	sprites.raintextureptr = loadTexture("rain.png");
-	sprites.snowtextureptr = loadTexture("snow.png");
-
-	decals.bulletholetextureptr = loadTexture("BulletHole.png");
-	decals.cratertextureptr = loadTexture("Crater.png");
-	decals.bloodtextureptr[0] = loadTexture("Blood/Blood1.png");
-	decals.bloodtextureptr[1] = loadTexture("Blood/Blood2.png");
-	decals.bloodtextureptr[2] = loadTexture("Blood/Blood3.png");
-	decals.bloodtextureptr[3] = loadTexture("Blood/Blood4.png");
-	decals.bloodtextureptr[4] = loadTexture("Blood/Blood5.png");
-	decals.bloodtextureptr[5] = loadTexture("Blood/Blood6.png");
-	decals.bloodtextureptr[6] = loadTexture("Blood/Blood7.png");
-	decals.bloodtextureptr[7] = loadTexture("Blood/Blood8.png");
-	decals.bloodtextureptr[8] = loadTexture("Blood/Blood9.png");
-	decals.bloodtextureptr[9] = loadTexture("Blood/Blood10.png");
-	decals.bloodtextureptr[10] = loadTexture("Blood/Blood11.png");
+	game->personspritetextureptr = loadTexture("sprites/person.png");
+	game->deadpersonspritetextureptr = loadTexture("sprites/person-dead.png");
+	game->scopetextureptr = loadTexture("scope.png");
+	game->flaretextureptr = loadTexture("flare.png");
+
+	sprites.flaretextureptr = loadTexture("sprites/flash-hit.png");
+	sprites.muzzleflaretextureptr = loadTexture("sprites/flash-muzzle.png");
+	sprites.smoketextureptr = loadTexture("sprites/smoke.png");
+	sprites.bloodtextureptr = loadTexture("sprites/blood.png");
+	sprites.raintextureptr = loadTexture("sprites/white.png");
+	sprites.snowtextureptr = loadTexture("sprites/white.png");
+
+	decals.bulletholetextureptr = loadTexture("black.png");
+	decals.cratertextureptr = loadTexture("black.png");
+	decals.bloodtextureptr[0u] = loadTexture("blood/00.png");
+	decals.bloodtextureptr[1u] = loadTexture("blood/01.png");
+	decals.bloodtextureptr[2u] = loadTexture("blood/02.png");
+	decals.bloodtextureptr[3u] = loadTexture("blood/03.png");
+	decals.bloodtextureptr[4u] = loadTexture("blood/04.png");
+	decals.bloodtextureptr[5u] = loadTexture("blood/05.png");
+	decals.bloodtextureptr[6u] = loadTexture("blood/06.png");
+	decals.bloodtextureptr[7u] = loadTexture("blood/07.png");
+	decals.bloodtextureptr[8u] = loadTexture("blood/08.png");
+	decals.bloodtextureptr[9u] = loadTexture("blood/09.png");
+	decals.bloodtextureptr[10] = loadTexture("blood/10.png");
 }
 
 GLvoid Game::ReSizeGLScene(float fov, float near)
diff --git a/src/main.zig b/src/main.zig
index 5c4e1c2..e6eea7b 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -24,6 +24,11 @@ const gf = @import("gfz");
 const gl = @import("zgl");
 const legacy = @cImport(@cInclude("Game.h"));
 
+comptime {
+    // Work around lazy compilation.
+    @export(@import("misc.zig").loadTexture, .{ .name = "loadTexture" });
+}
+
 var game: *legacy.Game = undefined;
 
 fn resizeWindow(window: ?*gf.Window.Impl,
@@ -75,7 +80,6 @@ pub fn main() !void {
     defer context.deinit() catch unreachable;
     try al.useContext(context);
 
-    _ = @import("misc.zig").loadTexture("Font.png"); // work around laziness
     legacy.initGame(game);
     defer legacy.closeGame(game);
     while (!try window.shouldClose()) {
diff --git a/src/misc.zig b/src/misc.zig
index ff45adc..9015a02 100644
--- a/src/misc.zig
+++ b/src/misc.zig
@@ -24,26 +24,24 @@ usingnamespace @cImport({
 
 const allocator = std.heap.c_allocator;
 const cwd = std.fs.cwd;
-const data_dir = @import("build_options").data_dir;
+const data_dir = @import("build_options").data_dir ++ [_]u8{ sep };
 const free = std.c.free;
 const sep = std.fs.path.sep;
 const maxInt = std.math.maxInt;
 const std = @import("std");
 const span = std.mem.span;
 
-const max_size = maxInt(usize); // don't judge me, take care of me
-const texture_dir = data_dir ++ [_]u8{ sep } ++ "textures";
-
 fn check(errorString: fn (c_uint) callconv(.C) [*c]const u8,
          status: anytype) void {
     if (status != 0)
         @panic(span(errorString(@intCast(c_uint, status))));
 }
 
-pub export fn loadTexture(filename: [*:0]const u8) GLuint {
-    var dir = cwd().openDir(texture_dir, .{}) catch unreachable;
+pub fn loadTexture(filename: [*:0]const u8) callconv(.C) GLuint {
+    var dir = cwd().openDir(data_dir ++ "textures", .{}) catch unreachable;
     defer dir.close();
-    var file = dir.readFileAlloc(allocator, span(filename), max_size)
+    // Don't judge me, take care of me!
+    var file = dir.readFileAlloc(allocator, span(filename), maxInt(usize))
         catch unreachable;
     defer allocator.free(file);