From ff52b8546c5982313bb47b7bf8aed33fef21e77d Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Fri, 31 Mar 2023 05:49:29 +0300 Subject: [PATCH] GNU makefile and procdata --- GNUmakefile | 32 ++++++++++++++++++++++++++++++++ src/scr_game.c | 12 +++++++++++- tools/procdata | 4 ++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 GNUmakefile create mode 100644 libs/unix/.keepdir create mode 100755 tools/procdata diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..d847936 --- /dev/null +++ b/GNUmakefile @@ -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 index 0000000..e69de29 diff --git a/src/scr_game.c b/src/scr_game.c index 112b6ff..5b9f4bf 100644 --- a/src/scr_game.c +++ b/src/scr_game.c @@ -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 index 0000000..fb50f7a --- /dev/null +++ b/tools/procdata @@ -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 -- 1.7.10.4