From a0f016a0117bf99f4ea9619fcc06f0e2fd13b31d Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Wed, 23 Nov 2022 23:29:50 +0000 Subject: [PATCH] Use CC for general compiling; get rid of more printfs; display opengl version on load --- .gitignore | 2 ++ Makefile | 47 ++++++++++++++---------------- assets/scripts/engine.rb | 62 ---------------------------------------- source/engine/engine.c | 3 +- source/engine/render.h | 1 + source/engine/timer.c | 3 +- source/engine/window.c | 7 ++++- source/scripts/engine.rb | 58 +++++++++++++++++++++++++++++-------- 8 files changed, 80 insertions(+), 103 deletions(-) delete mode 100644 assets/scripts/engine.rb diff --git a/.gitignore b/.gitignore index a5d43e5..8403822 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ +.git/ bin/ build/ *.o *.a engine tags +Jenkinsfile diff --git a/Makefile b/Makefile index 90121b2..fbe14f4 100755 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ UNAME_P != uname -m CCACHE = ccache -CC = $(CCACHE) clang +CC = $(CCACHE) cc ifeq ($(DEBUG), 1) DEFFALGS += -DDEBUG @@ -44,15 +44,15 @@ define findindir endef # All other sources -edirs != find ./source/engine -type d -name include +edirs != find ./source -type d -name include edirs += ./source/engine ehead != $(call findindir,./source/engine,*.h) eobjects != $(call make_objs, ./source/engine) eobjects != $(call rm,$(eobjects),sqlite pl_mpeg_extract_frames pl_mpeg_player yugine nuklear) edirs += ./source/engine/thirdparty/Chipmunk2D/include ./source/engine/thirdparty/enet/include ./source/engine/thirdparty/Nuklear -includeflag != $(call prefix,$(edirs) $(eddirs),-I) -COMPINCLUDE = $(edirs) $(eddirs) +includeflag != $(call prefix,$(edirs),-I) +COMPINCLUDE = $(edirs) WARNING_FLAGS = -Wno-everything #-Wno-incompatible-function-pointer-types -Wall -Wwrite-strings -Wunsupported -Wall -Wextra -Wwrite-strings -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -Wno-incompatible-function-pointer-types -Wno-gnu-statement-expression -Wno-complex-component-init -pedantic @@ -63,22 +63,22 @@ LIBPATH = -L./bin -L/usr/local/lib ALLFILES != find source/ -name '*.[ch]' -type f ifeq ($(UNAME), Windows_NT) - LINKER_FLAGS = -static -DSDL_MAIN_HANDLED + LINKER_FLAGS = -DSDL_MAIN_HANDLED ELIBS = engine editor mingw32 SDL2main SDL2 m dinput8 dxguid dxerr8 user32 gdi32 winmm imm32 ole32 oleaut32 shell32 version uuid setupapi opengl32 stdc++ winpthread ELIBS += SDL2_mixer FLAC vorbis vorbisenc vorbisfile mpg123 out123 syn123 opus opusurl opusfile ogg ssp shlwapi CLIBS = glew32 EXT = .exe else LINKER_FLAGS = -g - ELIBS = engine glfw3 pthread yughc mruby portaudio m - CLIBS = asound jack c + ELIBS = engine glfw3 pthread yughc mruby portaudio asound c m dl + CLIBS = EXT = endif CLIBS != $(call prefix, $(CLIBS), -l) ELIBS != $(call prefix, $(ELIBS), -l) -LELIBS = -Wl,-Bdynamic $(ELIBS) -Wl,-Bdynamic $(CLIBS) +LELIBS = $(ELIBS) objects = $(eobjects) DEPENDS = $(objects:.o=.d) @@ -91,22 +91,23 @@ INCLUDE = $(BIN)include LINK = $(LIBPATH) $(LINKER_FLAGS) $(LELIBS) -engine: $(yuginec:.%.c=$(objprefix)%.o) $(ENGINE) tags $(BIN)libportaudio.a $(BIN)libglfw3.a - @echo Linking engine - $(CC) $< $(LINK) -o $@ +.PHONY: yugine + +yugine: $(yuginec:.%.c=$(objprefix)%.o) $(ENGINE) $(BIN)libportaudio.a $(BIN)libglfw3.a + @echo Linking yugine + $(CC) $< $(LINK) -o yugine @echo Finished build -bs: engine - cp engine brainstorm +install: yugine + cp yugine ~/.local/bin -pin: engine - cp -rf source/shaders pinball - cp -rf assets/fonts pinball - cp -f assets/scripts/* pinball/scripts - cp engine pinball - -pal: engine - cp engine paladin +pin: yugine + cp yugine pinball + mkdir -p pinball/fonts pinball/scripts pinball/shaders + cp -f assets/fonts/* pinball/fonts + cp -f source/scripts/* pinball/scripts + cp -rf source/shaders/* pinball/shaders + $(ENGINE): $(eobjects) @echo Making library engine.a @@ -138,10 +139,6 @@ $(objprefix)/%.o:%.c @echo Making C object $@ @$(CC) $(COMPILER_FLAGS) -tags: $(ALLFILES) - @echo Making tags - @ctags -x -R source > tags - clean: @echo Cleaning project @find $(BIN) -type f -delete diff --git a/assets/scripts/engine.rb b/assets/scripts/engine.rb deleted file mode 100644 index e88bf55..0000000 --- a/assets/scripts/engine.rb +++ /dev/null @@ -1,62 +0,0 @@ -class Method - def source(n=5) - loc = source_location - puts `sed -n "#{loc[1]},#{loc[1]+n}p;#{loc[1]+6}q" #{loc[0]}` - end -end - -class Music - - def initialize(mpath = "") - load(mpath); - end - - - def load(mpath) - #@music = load(path); - end - - def play - - end -end - -class Sound - def initialize(path = "") - load(path); - end - - def load(path) - #@sound = - end - - def play - - end -end - -def checknewer - $maketimes ||= {} - file = caller[0].split(":")[0] - if $maketimes[file].nil? - $maketimes[file] = `stat --printf '%Y' #{file}` - return - end - - newtime = `stat --printf '%Y' #{file}` - if newtime > $maketimes[file] - load(file) - end -end - -def set_renderms(val) - settings_cmd(0, val); -end - -def set_updatems(val) - settings_cmd(1, val); -end - -def set_physms(val) - settings_cmd(2, val); -end \ No newline at end of file diff --git a/source/engine/engine.c b/source/engine/engine.c index 6cbc317..0fba6e2 100644 --- a/source/engine/engine.c +++ b/source/engine/engine.c @@ -50,7 +50,8 @@ void engine_init() glfwSetErrorCallback(error_callback); /* Initialize GLFW */ if (!glfwInit()) { - printf("Could not init GLFW\n"); + YughError("Could not init GLFW. Exiting."); + exit(1); } diff --git a/source/engine/render.h b/source/engine/render.h index 89763e1..32dccf0 100644 --- a/source/engine/render.h +++ b/source/engine/render.h @@ -1,6 +1,7 @@ #ifndef RENDER_H #define RENDER_H +#define GLFW_INCLUDE_NONE #include #include diff --git a/source/engine/timer.c b/source/engine/timer.c index f6b0bc1..143de72 100644 --- a/source/engine/timer.c +++ b/source/engine/timer.c @@ -1,5 +1,4 @@ #include "timer.h" -#include #include #include ; @@ -100,4 +99,4 @@ void arrwalk(void *arr, void (*fn)(void *data)) { for (int i = 0; i < arrlen(arr); i++) fn(&arr[i]); -} \ No newline at end of file +} diff --git a/source/engine/window.c b/source/engine/window.c index 18d785b..29c61fb 100644 --- a/source/engine/window.c +++ b/source/engine/window.c @@ -89,7 +89,12 @@ struct window *MakeSDLWindow(const char *name, int width, int height, uint32_t f } glfwMakeContextCurrent(w.window); - gladLoadGL(glfwGetProcAddress); + int version = gladLoadGL(glfwGetProcAddress); + if (!version) { + YughError("Failed to initialize OpenGL context."); + exit(1); + } + YughInfo("Loaded OpenGL %d.%d", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version)); glfwSwapInterval(1); // Set callbacks diff --git a/source/scripts/engine.rb b/source/scripts/engine.rb index 5f21e24..e88bf55 100644 --- a/source/scripts/engine.rb +++ b/source/scripts/engine.rb @@ -1,28 +1,62 @@ -class Component - +class Method + def source(n=5) + loc = source_location + puts `sed -n "#{loc[1]},#{loc[1]+n}p;#{loc[1]+6}q" #{loc[0]}` + end end -class Sprite +class Music + def initialize(mpath = "") + load(mpath); + end + + + def load(mpath) + #@music = load(path); + end + + def play + + end end -class CircleCollider2D +class Sound + def initialize(path = "") + load(path); + end + def load(path) + #@sound = + end + + def play + + end end -class Segment2D +def checknewer + $maketimes ||= {} + file = caller[0].split(":")[0] + if $maketimes[file].nil? + $maketimes[file] = `stat --printf '%Y' #{file}` + return + end + newtime = `stat --printf '%Y' #{file}` + if newtime > $maketimes[file] + load(file) + end end -class Box2D - - +def set_renderms(val) + settings_cmd(0, val); end -class Polygon2D - +def set_updatems(val) + settings_cmd(1, val); end -class Edge2D - +def set_physms(val) + settings_cmd(2, val); end \ No newline at end of file