GNU makefile and procdata
authorJohn Tsiombikas <nuclear@member.fsf.org>
Fri, 31 Mar 2023 02:49:29 +0000 (05:49 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Fri, 31 Mar 2023 02:49:29 +0000 (05:49 +0300)
GNUmakefile [new file with mode: 0644]
libs/unix/.keepdir [new file with mode: 0644]
src/scr_game.c
tools/procdata [new file with mode: 0755]

diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644 (file)
index 0000000..d847936
--- /dev/null
@@ -0,0 +1,32 @@
+src = $(wildcard src/*.c)
+obj = $(src:.c=.o)
+dep = $(src:.c=.d)
+bin = game
+
+warn = -pedantic -Wall
+dbg = -g
+opt = -O3
+def = -DMINIGLUT_USE_LIBC
+inc = -Ilibs -Ilibs/imago -Ilibs/treestor/include -Ilibs/goat3d/include
+libs = libs/unix/imago.a libs/unix/goat3d.a libs/unix/treestor.a
+
+CFLAGS = $(warn) $(dbg) $(opt) $(inc) $(def)
+LDFLAGS = $(libs) -lGL -lGLU -lX11 -lm
+
+$(bin): $(obj) libs
+       $(CC) -o $@ $(obj) $(LDFLAGS)
+
+.c.o:
+       $(CC) $(CFLAGS) -c $< -o $@
+
+.PHONY: clean
+clean:
+       rm -f $(obj) $(bin)
+
+.PHONY: libs
+libs:
+       $(MAKE) -C libs
+
+.PHONY: clean-libs
+clean-libs:
+       $(MAKE) -C libs clean
diff --git a/libs/unix/.keepdir b/libs/unix/.keepdir
new file mode 100644 (file)
index 0000000..e69de29
index 112b6ff..5b9f4bf 100644 (file)
@@ -51,11 +51,21 @@ static int ginit(void)
                        glEnableClientState(GL_VERTEX_ARRAY);
                        glVertexPointer(3, GL_FLOAT, 0, goat3d_get_mesh_attribs(mesh, GOAT3D_MESH_ATTR_VERTEX));
 
+                       if(goat3d_get_mesh_attrib_count(mesh, GOAT3D_MESH_ATTR_NORMAL)) {
+                               glEnableClientState(GL_NORMAL_ARRAY);
+                               glNormalPointer(GL_FLOAT, 0, goat3d_get_mesh_attribs(mesh, GOAT3D_MESH_ATTR_NORMAL));
+                       }
+                       if(goat3d_get_mesh_attrib_count(mesh, GOAT3D_MESH_ATTR_TEXCOORD)) {
+                               glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+                               glTexCoordPointer(2, GL_FLOAT, 0, goat3d_get_mesh_attribs(mesh, GOAT3D_MESH_ATTR_TEXCOORD));
+                       }
+
                        nfaces = goat3d_get_mesh_face_count(mesh) / 3;
                        glDrawElements(GL_TRIANGLES, nfaces * 3, GL_UNSIGNED_INT, goat3d_get_mesh_faces(mesh));
 
                        glDisableClientState(GL_VERTEX_ARRAY);
-
+                       glDisableClientState(GL_NORMAL_ARRAY);
+                       glDisableClientState(GL_TEXTURE_COORD_ARRAY);
                }
        }
        glEndList();
diff --git a/tools/procdata b/tools/procdata
new file mode 100755 (executable)
index 0000000..fb50f7a
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+[ ! -e data/track1.g3d -o datasrc/track1.gltf -nt data/track1.g3d ] && \
+       ass2goat datasrc/track1.gltf && mv datasrc/track1.goat3d data/track1.g3d