summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-07-16 06:35:02 +0200
committerkdx <kikoodx@paranoici.org>2023-07-16 06:35:48 +0200
commit0f2975883ee34df042dbd25dbce2d5a385b9df18 (patch)
treee5b9e12343637ab29039a6541cd709c6cf2ae727
parentd76287cd9c0db1176c59740b5d1e17b168746bef (diff)
downloadfld-0f2975883ee34df042dbd25dbce2d5a385b9df18.tar.gz
soloud integration
-rw-r--r--.gitmodules3
-rw-r--r--Makefile12
-rw-r--r--compile_flags.txt2
-rwxr-xr-xcreate_FLD.cpp.sh4
-rw-r--r--src/FLD.hpp3
-rw-r--r--src/destructor.cpp1
-rw-r--r--src/init.cpp14
m---------vendors/soloud0
8 files changed, 33 insertions, 6 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..02c5a12
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "vendors/soloud"]
+ path = vendors/soloud
+ url = https://github.com/jarikomppa/soloud
diff --git a/Makefile b/Makefile
index bada565..bc8c029 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,12 @@
-CFLAGS = -O3 -std=c++20 -Wall -Wextra -Wno-c99-designator -iquotesrc
+SOLOUD = vendors/soloud
+CFLAGS = -O3 -std=c++20 \
+ -iquotesrc -iquote$(SOLOUD)/include -iquote/usr/include/SDL2 \
+ -DWITH_SDL2_STATIC= # -Wall -Wextra -Wno-c99-designator
LIBS = -lSDL2
-SRC = FLD.cpp demo.cpp
+SRC = FLD.cpp demo.cpp \
+ $(wildcard $(SOLOUD)/src/core/*.c*) \
+ $(wildcard $(SOLOUD)/src/audiosource/wav/*.c*) \
+ $(wildcard $(SOLOUD)/src/backend/sdl2_static/*.c*)
all: demo
@@ -8,7 +14,7 @@ FLD.cpp:
./create_FLD.cpp.sh
demo: $(SRC)
- clang++ $(CFLAGS) -o $@ $(SRC) $(LIBS)
+ g++ $(CFLAGS) -o $@ $(SRC) $(LIBS)
clean:
rm -rf FLD.cpp demo build_FLD.cpp
diff --git a/compile_flags.txt b/compile_flags.txt
index 24c61c8..b339b18 100644
--- a/compile_flags.txt
+++ b/compile_flags.txt
@@ -4,3 +4,5 @@
-std=c++20
-fprebuilt-module-path=.
-iquotesrc
+-iquotevendors/soloud/include
+-DWITH_SDL2_STATIC=
diff --git a/create_FLD.cpp.sh b/create_FLD.cpp.sh
index e6bce11..f08f33d 100755
--- a/create_FLD.cpp.sh
+++ b/create_FLD.cpp.sh
@@ -3,8 +3,8 @@ BUILDDIR=build_FLD.cpp
rm -Rf "$BUILDDIR"
mkdir -p "$BUILDDIR"
-for FILE in src/FLD.hpp src/*.cpp; do
- grep "^#include <" "$FILE" >>"$BUILDDIR/includes"
+for FILE in src/*.cpp; do
+ grep "^#include " "$FILE" >>"$BUILDDIR/includes"
printf '/* %s */\n' "$FILE" >>"$BUILDDIR/sources"
grep -v '^#include' "$FILE" \
| grep -v "^#pragma" \
diff --git a/src/FLD.hpp b/src/FLD.hpp
index 329cc72..1a08a72 100644
--- a/src/FLD.hpp
+++ b/src/FLD.hpp
@@ -4,6 +4,7 @@
#include <map>
#include <optional>
#include <climits>
+#include "soloud.h"
#define READONLY(T, X, V) private: T _##X = V; public: decltype(_##X) const& X = _##X
@@ -78,6 +79,7 @@ public:
Point viewport = {0, 0};
const Config config;
+ SoLoud::Soloud soloud = {};
READONLY(SDL_Window *, window, nullptr);
READONLY(SDL_Renderer *, renderer, nullptr);
READONLY(SDL_Texture *, target, nullptr);
@@ -120,5 +122,6 @@ private:
[[nodiscard]] Error initWindow();
[[nodiscard]] Error initRenderer();
[[nodiscard]] Error initTarget();
+ [[nodiscard]] Error initSoloud();
void cycleEvents();
};
diff --git a/src/destructor.cpp b/src/destructor.cpp
index 1adcb65..4ee6549 100644
--- a/src/destructor.cpp
+++ b/src/destructor.cpp
@@ -3,6 +3,7 @@
FLD::~FLD()
{
+ soloud.deinit();
for (auto [_, e] : images)
if (e.ptr != nullptr)
SDL_DestroyTexture(e.ptr);
diff --git a/src/init.cpp b/src/init.cpp
index 2cd1b2f..062f9b5 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -14,7 +14,7 @@ FLD::init(MainLoop main_loop, void *udata)
FLD::Error
FLD::init()
{
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0)
return sdlError();
if (auto err = initBasepath())
return err;
@@ -24,6 +24,8 @@ FLD::init()
return err;
if (auto err = initTarget())
return err;
+ if (auto err = initSoloud())
+ return err;
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
@@ -93,3 +95,13 @@ FLD::initTarget()
return sdlError();
return 0;
}
+
+FLD::Error
+FLD::initSoloud()
+{
+ if (auto err = soloud.init()) {
+ SDL_Log("soloud runtime error: %s", soloud.getErrorString(err));
+ return err;
+ }
+ return 0;
+}
diff --git a/vendors/soloud b/vendors/soloud
new file mode 160000
+Subproject 1157475881da0d7f76102578255b937c7d4e8f5