From b2a45fcfdd5c2a0ee3e45c5691ef5127183c77cc Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Wed, 29 May 2024 20:21:19 -0500 Subject: [PATCH] fix linux opengl render; windows ucrt --- Makefile | 46 +++++++++++++++++-------------------------- scripts/engine.js | 9 ++++----- scripts/physics.js | 2 ++ scripts/render.js | 2 +- source/engine/jsffi.c | 6 +++--- source/engine/log.c | 5 ++--- 6 files changed, 30 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index abd62b38..2984c47a 100755 --- a/Makefile +++ b/Makefile @@ -78,34 +78,27 @@ CPPFLAGS += -DCONFIG_VERSION=\"2024-02-14\" -DCONFIG_BIGNUM #for quickjs # ENABLE_SINC_[BEST|FAST|MEDIUM]_CONVERTER # default, fast and medium available in game at runtime; best available in editor -PKGCMD = tar --directory --exclude="./*.a" --exclude="./obj" -czf $(DISTDIR)/$(DIST) . -ZIP = .tar.gz -UNZIP = cp $(DISTDIR)/$(DIST) $(DESTDIR) && tar xzf $(DESTDIR)/$(DIST) -C $(DESTDIR) && rm $(DESTDIR)/$(DIST) - INFO := $(INFO)_$(ARCH) ifeq ($(OS), Windows_NT) # then WINDOWS - PLATFORM := win64 + PLATFORM := win64 DEPS += resource.o STEAMAPI := steam_api64 LDFLAGS += -mwin32 -static CPPFLAGS += -mwin32 LDLIBS += mingw32 kernel32 d3d11 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m pthread - PKGCMD = zip -q -r $(MAKEDIR)/$(DISTDIR)/$(DIST) . -x \*.a ./obj/\* - ZIP = .zip - UNZIP = unzip -o -q $(DISTDIR)/$(DIST) -d $(DESTDIR) - INFO :=$(INFO)_win - EXT = .exe + INFO :=$(INFO)_win + EXT = .exe else ifeq ($(OS), IOS) CC = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - SDK = iphoneos - SDK_PATH = /Applications/Xcode.app/Contents/Developer/Platforms/$(SDK).platform/Developer/SDKs/$(SDK).sdk - CFLAGS += -isysroot $(SDK_PATH) -miphoneos-version-min=13.0 - LDFLAGS += -isysroot $(SDK_PATH) -miphoneos-version-min=13.0 - LDFLAGS += -framework Foundation -framework UIKit -framework AudioToolbox -framework Metal -framework MetalKit -framework AVFoundation - CXXFLAGS += -std=c++11 - CFLAGS += -x objective-c -DIOS - INFO :=$(INFO)_ios + SDK = iphoneos + SDK_PATH = /Applications/Xcode.app/Contents/Developer/Platforms/$(SDK).platform/Developer/SDKs/$(SDK).sdk + CFLAGS += -isysroot $(SDK_PATH) -miphoneos-version-min=13.0 + LDFLAGS += -isysroot $(SDK_PATH) -miphoneos-version-min=13.0 + LDFLAGS += -framework Foundation -framework UIKit -framework AudioToolbox -framework Metal -framework MetalKit -framework AVFoundation + CXXFLAGS += -std=c++11 + CFLAGS += -x objective-c -DIOS + INFO :=$(INFO)_ios else ifeq ($(OS), wasm) # Then WEB OS := Web LDFLAGS += -sUSE_WEBGPU @@ -131,8 +124,8 @@ else CFLAGS += -x objective-c CXXFLAGS += -std=c++11 LDFLAGS += -framework Cocoa -framework QuartzCore -framework AudioToolbox -framework Metal -framework MetalKit - INFO :=$(INFO)_macos - STEAMAPI := steam_api + INFO :=$(INFO)_macos + STEAMAPI := steam_api endif endif @@ -161,9 +154,11 @@ includeflag := $(addprefix -I, $(includeflag)) WARNING_FLAGS = -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types +# For vanilla compilation, remove _ ifeq ($(INFO),_) - INFO := + INFO := endif + APP = prosperon NAME = $(APP)$(INFO)$(EXT) SEM != git describe --tags --abbrev=0 @@ -183,17 +178,12 @@ all: $(NAME) prereqs: source/engine/core.cdb.h -DESTDIR ?= ~/.bin -install: $(NAME) - @echo Copying to destination - cp -f $(NAME) $(DESTDIR)/$(APP) - $(NAME): $(OBJS) $(DEPS) @echo Linking $(NAME) $(CROSS)$(LD) $^ $(CPPFLAGS) $(LDFLAGS) -L. $(LDPATHS) $(LDLIBS) -o $@ @echo Finished build -%$(INFO).o: %.c +%$(INFO).o: %.c prereqs @echo Making C object $@ $(CROSS)$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ @@ -257,7 +247,7 @@ crossmac: Prosperon.icns cp Prosperon.icns Prosperon.app/Contents/Resources crosswin: - make CROSS=x86_64-w64-mingw32- OS=Windows_NT CC=gcc + make CROSS=x86_64-w64-mingw32ucrt- OS=Windows_NT CC=gcc crossweb: make CC=emcc OS=wasm diff --git a/scripts/engine.js b/scripts/engine.js index c05f498e..1e4e68fd 100644 --- a/scripts/engine.js +++ b/scripts/engine.js @@ -269,7 +269,6 @@ global.mixin("scripts/render"); global.mixin("scripts/debug"); var frame_t = profile.secs(profile.now()); -var phys_step = 1/240; var sim = {}; sim.mode = "play"; @@ -344,11 +343,11 @@ function process() physlag += dt; - while (physlag > phys_step) { - physlag -= phys_step; + while (physlag > physics.delta) { + physlag -= physics.delta; var st = profile.now(); - prosperon.phys2d_step(phys_step*game.timescale); - prosperon.physupdate(phys_step*game.timescale); + prosperon.phys2d_step(physics.delta*game.timescale); + prosperon.physupdate(physics.delta*game.timescale); profile.addreport(profcache, "physics step", st); } } diff --git a/scripts/physics.js b/scripts/physics.js index 2af9d049..6406c5f8 100644 --- a/scripts/physics.js +++ b/scripts/physics.js @@ -53,6 +53,8 @@ physics.gravity.strength = 500; physics.damp = physics.make_damp(); physics.damp.mask = ~1; +physics.delta = 1/240; + return { physics } diff --git a/scripts/render.js b/scripts/render.js index 4457bdec..322e5863 100644 --- a/scripts/render.js +++ b/scripts/render.js @@ -6,7 +6,7 @@ render.doc = { var shaderlang = { macos: "metal_macos", - windows: "hlsl4", + windows: "hlsl5", linux: "glsl430", web: "wgsl", ios: "metal_ios", diff --git a/source/engine/jsffi.c b/source/engine/jsffi.c index 2dd91efc..6dbac7e1 100644 --- a/source/engine/jsffi.c +++ b/source/engine/jsffi.c @@ -793,9 +793,9 @@ sg_shader js2shader(JSValue v) int atin = js_arrlen(attrs); for (int i = 0; i < atin; i++) { JSValue u = js_getpropidx(attrs, i); - desc.attrs[i].name = js2strdup(js_getpropstr(u, "name")); - desc.attrs[i].sem_name = js2strdup(js_getpropstr(u,"sem_name")); - desc.attrs[i].sem_index = js2number(js_getpropstr(u, "sem_index")); + int slot = js2number(js_getpropstr(u, "slot")); + desc.attrs[slot].sem_name = js2strdup(js_getpropstr(u,"sem_name")); + desc.attrs[slot].sem_index = js2number(js_getpropstr(u, "sem_index")); } JSValue vsu = js_getpropstr(vs, "uniform_blocks"); diff --git a/source/engine/log.c b/source/engine/log.c index ff64aed1..a439166b 100644 --- a/source/engine/log.c +++ b/source/engine/log.c @@ -29,7 +29,7 @@ #define CYAN 36 #define WHITE 37 -#define COLOR(TXT, _C) ESC #_C "m" #TXT ESC "0m" +#define COLOR(TXT, _C) ESC "22;" #_C "m" #TXT ESC "0m" char *logstr[] = { "spam", "debug", "info", "warn", "error", "panic"}; char *logcolor[] = { COLOR(spam,37), COLOR(debug,32), COLOR(info,36), COLOR(warn,33), COLOR(error,31), COLOR(panic,45) }; @@ -47,7 +47,6 @@ void log_init() if (!fexists(".prosperon")) { logout = tmpfile(); dump = tmpfile(); - writeout = stdout; } else { logout = fopen(".prosperon/log.txt", "w"); @@ -93,7 +92,7 @@ void mYughLog(int category, int priority, int line, const char *file, const char printf("\n"); } - if (priority >= LOG_PANIC) { + if (priority >= LOG_ERROR) { js_stacktrace(); #ifdef __WIN32 DebugBreak();