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/cimport.zig1
-rw-r--r--src/misc.zig16
3 files changed, 33 insertions, 36 deletions
diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp
index 4182c24..4ae9971 100644
--- a/src/GameInitDispose.cpp
+++ b/src/GameInitDispose.cpp
@@ -1018,33 +1018,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.qoi");
 	game->text.BuildFont();
-	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");
+	game->personspritetextureptr = loadTexture("sprites/person.qoi");
+	game->deadpersonspritetextureptr = loadTexture("sprites/person-dead.qoi");
+	game->scopetextureptr = loadTexture("scope.qoi");
+	game->flaretextureptr = loadTexture("flare.qoi");
+
+	sprites.flaretextureptr = loadTexture("sprites/flash-hit.qoi");
+	sprites.muzzleflaretextureptr = loadTexture("sprites/flash-muzzle.qoi");
+	sprites.smoketextureptr = loadTexture("sprites/smoke.qoi");
+	sprites.bloodtextureptr = loadTexture("sprites/blood.qoi");
+	sprites.raintextureptr = loadTexture("sprites/white.qoi");
+	sprites.snowtextureptr = loadTexture("sprites/white.qoi");
+
+	decals.bulletholetextureptr = loadTexture("black.qoi");
+	decals.cratertextureptr = loadTexture("black.qoi");
+	decals.bloodtextureptr[0u] = loadTexture("blood/00.qoi");
+	decals.bloodtextureptr[1u] = loadTexture("blood/01.qoi");
+	decals.bloodtextureptr[2u] = loadTexture("blood/02.qoi");
+	decals.bloodtextureptr[3u] = loadTexture("blood/03.qoi");
+	decals.bloodtextureptr[4u] = loadTexture("blood/04.qoi");
+	decals.bloodtextureptr[5u] = loadTexture("blood/05.qoi");
+	decals.bloodtextureptr[6u] = loadTexture("blood/06.qoi");
+	decals.bloodtextureptr[7u] = loadTexture("blood/07.qoi");
+	decals.bloodtextureptr[8u] = loadTexture("blood/08.qoi");
+	decals.bloodtextureptr[9u] = loadTexture("blood/09.qoi");
+	decals.bloodtextureptr[10] = loadTexture("blood/10.qoi");
 }
 
 struct Scores getScores(Game* game)
diff --git a/src/cimport.zig b/src/cimport.zig
index 88061db..05f9537 100644
--- a/src/cimport.zig
+++ b/src/cimport.zig
@@ -2,7 +2,6 @@ usingnamespace @cImport({
     @cInclude("AL/al.h");
     @cInclude("GL/gl.h");
     @cInclude("GL/glu.h");
-    @cInclude("lodepng.h");
 
     @cInclude("Game.h");
     @cInclude("Constants.h");
diff --git a/src/misc.zig b/src/misc.zig
index 3e1ece0..3307713 100644
--- a/src/misc.zig
+++ b/src/misc.zig
@@ -39,6 +39,7 @@ const tokenize = std.mem.tokenize;
 const al = @import("zeal");
 const gf = @import("gfz");
 const ini = @import("ini");
+const qoi = @import("qoi");
 
 const data_dir = @import("build_options").data_dir ++ [_]u8{ sep };
 const c = @import("cimport.zig");
@@ -322,12 +323,9 @@ export fn loadTexture(filename: [*:0]const u8) c.GLuint {
     }) catch unreachable;
     defer allocator.free(file);
 
-    var data: [*c]u8 = undefined;
-    var w: c_uint = undefined;
-    var h: c_uint = undefined;
-    check(c.lodepng_error_text,
-          c.lodepng_decode32(&data, &w, &h, file.ptr, file.len));
-    defer free(data);
+    var image = qoi.decodeBuffer(allocator, file) catch unreachable;
+    defer image.deinit(allocator);
+    const data = @ptrCast([*c]const u8, image.pixels.ptr);
 
     var texture: c.GLuint = undefined;
     c.glGenTextures(1, &texture);
@@ -337,11 +335,11 @@ export fn loadTexture(filename: [*:0]const u8) c.GLuint {
     c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_MAG_FILTER, c.GL_LINEAR);
     c.glTexParameteri(c.GL_TEXTURE_2D, c.GL_TEXTURE_MIN_FILTER, c.GL_LINEAR);
 
-    const width = @intCast(c.GLint, w);
-    const height = @intCast(c.GLint, h);
+    const width = @intCast(c.GLint, image.width);
+    const height = @intCast(c.GLint, image.height);
     c.glPixelStorei(c.GL_UNPACK_ALIGNMENT, 1);
     c.glTexImage2D(c.GL_TEXTURE_2D, 0, 4, width, height,
-                 0, c.GL_RGBA, c.GL_UNSIGNED_BYTE, data);
+                   0, c.GL_RGBA, c.GL_UNSIGNED_BYTE, data);
     check(c.gluErrorString,
           c.gluBuild2DMipmaps(c.GL_TEXTURE_2D, 4, width, height,
                               c.GL_RGBA, c.GL_UNSIGNED_BYTE, data));