diff --git a/OTRExporter/OTRExporter/Makefile b/OTRExporter/OTRExporter/Makefile index d25f9930f..893828845 100644 --- a/OTRExporter/OTRExporter/Makefile +++ b/OTRExporter/OTRExporter/Makefile @@ -1,6 +1,6 @@ # Only used for standalone compilation, usually inherits these from the main makefile -CXX := g++-mp-devel +CXX := g++-12 AR := ar FORMAT := clang-format-11 diff --git a/ZAPDTR/Makefile b/ZAPDTR/Makefile index 6182b20b1..673ff6934 100644 --- a/ZAPDTR/Makefile +++ b/ZAPDTR/Makefile @@ -7,15 +7,9 @@ DEBUG ?= 0 COPYCHECK_ARGS ?= LLD ?= 0 WERROR ?= 0 +UNAME := $(shell uname) -# Use clang++ if available, else use g++ -ifeq ($(shell command -v clang++ >/dev/null 2>&1; echo $$?),0) - CXX := clang++ -else - CXX := g++ -endif - -CXX := g++-mp-devel +CXX := g++-12 INC := -I ZAPD -I lib/elfio -I lib/libgfxd -I lib/tinyxml2 -I ZAPDUtils CXXFLAGS := -fpic -std=c++17 -Wall -Wextra -fno-omit-frame-pointer @@ -47,10 +41,13 @@ endif # CXXFLAGS += -DTEXTURE_DEBUG LDFLAGS := -lm -ldl -lpng \ - -L../external -L../libultraship -lz -lbz2 -pthread -lpulse -lultraship -lstorm $(shell pkg-config --libs glew x11 libpng) $(shell sdl2-config --libs) - - + -L../external -L../libultraship -lz -lbz2 -pthread -lpulse -lultraship -lstorm -lSDL2 -lGLEW -lX11 +ifeq ($(UNAME), Darwin) + LDFLAGS += $(shell pkg-config --libs glew x11 libpng) $(shell sdl2-config --libs) -framework OpenGL +else + LDFLAGS += -lGL +endif # Use LLD if available. Set LLD=0 to not use it ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0) @@ -61,7 +58,6 @@ ifneq ($(LLD),0) LDFLAGS += -fuse-ld=lld endif -UNAME := $(shell uname) UNAMEM := $(shell uname -m) ifneq ($(UNAME), Darwin) LDFLAGS += -Wl,-export-dynamic -lstdc++fs @@ -69,8 +65,8 @@ ifneq ($(UNAME), Darwin) else EXPORTERS := -Wl,-force_load ../OTRExporter/OTRExporter/OTRExporter.a ifeq ($(UNAMEM),arm64) - LDFLAGS += $(shell pkg-config --libs libpng) - INC += $(shell pkg-config --cflags libpng) + LDFLAGS += $(shell pkg-config --libs libpng) + INC += $(shell pkg-config --cflags libpng) endif endif diff --git a/ZAPDTR/ZAPDUtils/Makefile b/ZAPDTR/ZAPDUtils/Makefile index 01dac2a22..503197373 100644 --- a/ZAPDTR/ZAPDUtils/Makefile +++ b/ZAPDTR/ZAPDUtils/Makefile @@ -1,5 +1,5 @@ # Only used for standalone compilation, usually inherits these from the main makefile -CXX := g++-mp-devel +CXX := g++-12 CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17 SRC_DIRS := $(shell find . -type d -not -path "*build*") diff --git a/ZAPDTR/lib/libgfxd/Makefile b/ZAPDTR/lib/libgfxd/Makefile index a184cc80c..ba06fdb2a 100644 --- a/ZAPDTR/lib/libgfxd/Makefile +++ b/ZAPDTR/lib/libgfxd/Makefile @@ -1,4 +1,4 @@ -CC := gcc-mp-devel +CC := gcc-12 CFLAGS = -Wall -O2 -g UC_OBJ = uc_f3d.o uc_f3db.o uc_f3dex.o uc_f3dexb.o uc_f3dex2.o OBJ = gfxd.o $(UC_OBJ) diff --git a/libultraship/Makefile b/libultraship/Makefile index d967bf7f3..6ba3d0373 100644 --- a/libultraship/Makefile +++ b/libultraship/Makefile @@ -1,9 +1,10 @@ # Only used for standalone compilation, usually inherits these from the main makefile -CXX := g++-mp-devel -CC := gcc-mp-devel +CXX := g++-12 +CC := gcc-12 AR := ar FORMAT := clang-format-11 +UNAME := $(shell uname) ASAN ?= 0 DEBUG ?= 1 @@ -18,9 +19,20 @@ WARN := -Wall -Wextra -Werror \ -Wno-narrowing \ -Wno-missing-field-initializers -CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 -Wno-deprecated-enum-enum-conversion +CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 -CPPFLAGS := -MMD $(shell pkg-config --cflags sdl2 glew) +CPPFLAGS := -MMD + +ifeq ($(UNAME), Linux) #LINUX + CXXFLAGS += -m32 + CFLAGS += -m32 +endif + +ifeq ($(UNAME), Darwin) #APPLE + CXXFLAGS += -Wno-deprecated-enum-enum-conversion + CPPFLAGS += -framework OpenGL + CPPFLAGS += $(shell pkg-config --cflags sdl2 glew) +endif ifneq ($(DEBUG),0) CXXFLAGS += -g -D_DEBUG diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp index bfdcea748..110903681 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp @@ -105,7 +105,7 @@ static bool current_depth_mask; static uint32_t frame_count; -static vector framebuffers; +static std::vector framebuffers; static size_t current_framebuffer; static float current_noise_scale; static FilteringMode current_filter_mode = THREE_POINT; @@ -637,7 +637,7 @@ static uint32_t gfx_cm_to_opengl(uint32_t val) { static void gfx_opengl_set_sampler_parameters(int tile, bool linear_filter, uint32_t cms, uint32_t cmt) { const GLint filter = linear_filter && current_filter_mode == LINEAR ? GL_LINEAR : GL_NEAREST; - GL_CHECK(glActiveTexture(GL_TEXTURE0 + tile)); + glActiveTexture(GL_TEXTURE0 + tile); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, gfx_cm_to_opengl(cms)); @@ -750,6 +750,7 @@ static int gfx_opengl_create_framebuffer() { glGenFramebuffers(1, &fbo); size_t i = framebuffers.size(); + printf("framebuffers size %ld\n", i); framebuffers.resize(i + 1); framebuffers[i].fbo = fbo; @@ -892,7 +893,7 @@ static std::map, uint16_t> gfx_opengl_get_pixel_depth(in } glBindFramebuffer(GL_READ_FRAMEBUFFER, pixel_depth_fb); - vector depth_stencil_values(coordinates.size()); + std::vector depth_stencil_values(coordinates.size()); glReadPixels(0, 0, coordinates.size(), 1, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, depth_stencil_values.data()); { diff --git a/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_sdl.cpp b/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_sdl.cpp index 61e6d99ac..0681a268b 100644 --- a/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_sdl.cpp +++ b/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_sdl.cpp @@ -66,11 +66,15 @@ // SDL // (the multi-viewports feature requires SDL features supported from SDL 2.0.4+. SDL 2.0.5+ is highly recommended) +#if defined(__APPLE__) +#include "SDL.h" +#include "SDL_syswm.h" +#include "SDL_stdinc.h" +#include +#else #include #include #include -#if defined(__APPLE__) -#include #endif #if SDL_VERSION_ATLEAST(2,0,4) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS) @@ -865,7 +869,11 @@ static void ImGui_ImplSDL2_SwapBuffers(ImGuiViewport* viewport, void*) // Vulkan support (the Vulkan renderer needs to call a platform-side support function to create the surface) // SDL is graceful enough to _not_ need so we can safely include this. #if SDL_HAS_VULKAN +#if defined(__APPLE__) +#include "SDL_vulkan.h" +#else #include +#endif static int ImGui_ImplSDL2_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_instance, const void* vk_allocator, ImU64* out_vk_surface) { ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData; diff --git a/libultraship/libultraship/SDLAudioPlayer.h b/libultraship/libultraship/SDLAudioPlayer.h index 05e4befd3..0bb6d3665 100644 --- a/libultraship/libultraship/SDLAudioPlayer.h +++ b/libultraship/libultraship/SDLAudioPlayer.h @@ -1,6 +1,10 @@ #pragma once #include "AudioPlayer.h" +#if __APPLE__ +#include +#else #include +#endif namespace Ship { class SDLAudioPlayer : public AudioPlayer { diff --git a/libultraship/libultraship/SDLController.h b/libultraship/libultraship/SDLController.h index fbffa478f..2493efbbc 100644 --- a/libultraship/libultraship/SDLController.h +++ b/libultraship/libultraship/SDLController.h @@ -1,6 +1,10 @@ #pragma once #include "Controller.h" +#if __APPLE__ +#include +#else #include +#endif #define INVALID_SDL_CONTROLLER_GUID (std::string("00000000000000000000000000000000")) diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index 0df1b6f3f..8e4becaab 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -153,11 +153,7 @@ namespace SohImGui { void ImGuiBackendInit() { switch (impl.backend) { case Backend::SDL: -#if __APPLE__ - ImGui_ImplOpenGL3_Init("#version 420"); -#else ImGui_ImplOpenGL3_Init("#version 120"); -#endif break; #if defined(ENABLE_DX11) || defined(ENABLE_DX12) diff --git a/libultraship/libultraship/Window.cpp b/libultraship/libultraship/Window.cpp index 588e3af50..7a8cb094c 100644 --- a/libultraship/libultraship/Window.cpp +++ b/libultraship/libultraship/Window.cpp @@ -18,7 +18,11 @@ #include "Lib/Fast3D/gfx_sdl.h" #include "Lib/Fast3D/gfx_opengl.h" #include "stox.h" +#if __APPLE__ +#include +#else #include +#endif #include #include #include diff --git a/soh/Makefile b/soh/Makefile index 3e99950f8..946731c5c 100644 --- a/soh/Makefile +++ b/soh/Makefile @@ -1,9 +1,10 @@ -CXX := g++-mp-devel -CC := gcc-mp-devel +CXX := g++-12 +CC := gcc-12 LD := lld AR := ar FORMAT := clang-format-11 ZAPD := ../ZAPDTR/ZAPD.out +UNAME := $(shell uname) LIBULTRASHIP := ../libultraship/libultraship.a ZAPDUTILS := ../ZAPDTR/ZAPDUtils/ZAPDUtils.a @@ -18,9 +19,21 @@ WARN := \ -funsigned-char \ -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -fno-toplevel-reorder -ffreestanding -fwrapv \ -CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib $(shell pkg-config --cflags sdl2 x11) -CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib $(shell pkg-config --cflags sdl2 x11) +CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib +CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib LDFLAGS := + +ifeq ($(UNAME), Linux) #LINUX + CXXFLAGS += -march=i386 -m32 -mhard-float + CFLAGS += $(WARN) -march=i386 + LDFLAGS += -m32 +endif + +ifeq ($(UNAME), Darwin) #APPLE + CXXFLAGS += $(shell pkg-config --cflags sdl2 x11) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew) -framework OpenGL + CFLAGS += $(shell pkg-config --cflags sdl2 x11) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew) -framework OpenGL +endif + CPPFLAGS := -MMD ifneq ($(DEBUG),0) @@ -28,9 +41,6 @@ ifneq ($(DEBUG),0) CFLAGS += -g endif -CXXFLAGS += -g -CFLAGS += -g - ifneq ($(ASAN),0) CXXFLAGS += -fsanitize=address LDFLAGS += -fsanitize=address @@ -43,6 +53,14 @@ endif TARGET := soh.arm64 +# ifeq ($(UNAME), Linux) #LINUX +# TARGET := soh.elf +# endif + +# ifeq ($(UNAME), Darwin) #APPLE +# TARGET := soh.arm64 +# endif + INC_DIRS := $(addprefix -I, \ . \ assets \ @@ -54,18 +72,37 @@ INC_DIRS := $(addprefix -I, \ ../libultraship/libultraship/Lib/spdlog/include \ ../libultraship/libultraship/Lib/Fast3D/U64 \ ../libultraship/libultraship/Lib/Fast3D/U64/PR \ - /opt/X11/include \ ) -CFLAGS := $(CFLAGS) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew) -CXXFLAGS := $(CXXFLAGS) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew) +ifeq ($(UNAME), Linux) #LINUX + INC_DIRS += $(addprefix -I, \ + /opt/X11/include \ +) +endif + +ifeq ($(UNAME), Darwin) #APPLE + INC_DIRS += $(addprefix -I, \ + /opt/homebrew/Cellar/libx11/1.8/include \ +) +endif LDDIRS := $(addprefix -L, \ ../external \ ../libultraship/ \ - /opt/X11/lib \ ) +ifeq ($(UNAME), Linux) #LINUX + LDDIRS += $(addprefix -L, \ + /opt/X11/lib \ +) +endif + +ifeq ($(UNAME), Darwin) #APPLE + LDDIRS += $(addprefix -L, \ + /opt/homebrew/Cellar/libx11/1.8/lib \ +) +endif + LDLIBS := \ $(ZAPDUTILS) \ $(addprefix -l, \ @@ -75,12 +112,26 @@ LDLIBS := \ z \ pthread \ atomic \ - GL \ storm \ ultraship \ -) \ +) -LDLIBS := $(LDLIBS) $(shell sdl2-config --libs) $(shell pkg-config --libs glew) +ifeq ($(UNAME), Linux) #LINUX +LDLIBS += \ + $(addprefix -l, \ + GL \ + pulse \ +) +endif + +ifeq ($(UNAME), Darwin) #APPLE +LDLIBS += \ + $(addprefix -framework, \ + OpenGL \ + CoreFoundation \ +) \ + $(shell sdl2-config --libs) $(shell pkg-config --libs glew) +endif ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*") ASSET_FILES_XML := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.xml))