build(deps): replace SOIL2 with stb for image and vorbis decoding

This commit is contained in:
2026-07-21 10:51:47 +08:00
parent 48300b0acc
commit 5018ebe247
12 changed files with 8009 additions and 19 deletions

View File

@@ -39,6 +39,8 @@ add_subdirectory(third_party/imgui)
add_subdirectory(third_party/dr_libs) add_subdirectory(third_party/dr_libs)
add_subdirectory(third_party/stb)
add_executable(${PROJECT_NAME}) add_executable(${PROJECT_NAME})
add_subdirectory(src) add_subdirectory(src)
@@ -131,12 +133,12 @@ target_link_libraries(${PROJECT_NAME}
SDL3::SDL3 SDL3::SDL3
glad glad
OpenGL::GL OpenGL::GL
soil2
Freetype::Freetype Freetype::Freetype
tomlplusplus::tomlplusplus tomlplusplus::tomlplusplus
imgui imgui
dr_libs dr_libs
tbb tbb
stb
protobuf::libprotobuf protobuf::libprotobuf
absl::log absl::log
absl::check absl::check

View File

@@ -13,13 +13,6 @@ find_package(Opus REQUIRED)
# Third-party libraries # Third-party libraries
FetchContent_Declare(
soil2
GIT_REPOSITORY https://github.com/SpartanJ/SOIL2.git
GIT_TAG 1.31
)
FetchContent_MakeAvailable(soil2)
FetchContent_Declare( FetchContent_Declare(
tomlplusplus tomlplusplus
GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git

View File

@@ -1,6 +1,5 @@
#pragma once #pragma once
#include <SOIL2.h>
#include <glad/glad.h> #include <glad/glad.h>
#include <string> #include <string>
#include <utility> #include <utility>

View File

@@ -1,2 +0,0 @@
DisableFormat: true
SortIncludes: false

View File

@@ -2,12 +2,10 @@
#include "Cubed/tools/log.hpp" #include "Cubed/tools/log.hpp"
#define STB_VORBIS_IMPLEMENTATION
#include "stb/stb_vorbis.h"
#include <dr_flac.h> #include <dr_flac.h>
#include <dr_mp3.h> #include <dr_mp3.h>
#include <dr_wav.h> #include <dr_wav.h>
#include <stb_vorbis.h>
namespace fs = std::filesystem; namespace fs = std::filesystem;
namespace Cubed { namespace Cubed {

View File

@@ -5,6 +5,7 @@
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <stb_image.h>
#include <unordered_set> #include <unordered_set>
namespace Cubed { namespace Cubed {
@@ -171,7 +172,7 @@ void delete_image_data(unsigned char* data) {
if (data == nullptr) { if (data == nullptr) {
return; return;
} }
SOIL_free_image_data(data); stbi_image_free(data);
} }
ImageData load_image_data(const std::string& tex_image_path, bool check_exist) { ImageData load_image_data(const std::string& tex_image_path, bool check_exist) {
@@ -181,9 +182,8 @@ ImageData load_image_data(const std::string& tex_image_path, bool check_exist) {
} }
unsigned char* data = nullptr; unsigned char* data = nullptr;
int width, height, channels; int width, height, channels;
data = data = stbi_load(path.string().c_str(), &width, &height, &channels,
SOIL_load_image(path.string().c_str(), &width, &height, &channels, STBI_rgb_alpha); // Materials are all RGBA; must force
SOIL_LOAD_RGBA); // Materials are all RGBA; must force
// RGBA, otherwise sampling will fail. // RGBA, otherwise sampling will fail.
if (check_exist) { if (check_exist) {
if (!data) { if (!data) {

View File

@@ -50,7 +50,6 @@ void CreditsUI::init() {
add_text("Libraries Used", 0.8f); add_text("Libraries Used", 0.8f);
add_text("GLAD MIT / Apache-2.0"); add_text("GLAD MIT / Apache-2.0");
add_text("SDL3 zlib"); add_text("SDL3 zlib");
add_text("SOIL2 MIT-0");
add_text("GLM MIT"); add_text("GLM MIT");
add_text("FreeType FTL / GPL-2.0+"); add_text("FreeType FTL / GPL-2.0+");
add_text("toml++ MIT"); add_text("toml++ MIT");
@@ -65,6 +64,7 @@ void CreditsUI::init() {
add_text("nlohmann/json MIT"); add_text("nlohmann/json MIT");
add_text("HarfBuzz Old-MIT / GPL-2.0+"); add_text("HarfBuzz Old-MIT / GPL-2.0+");
add_text("utf8cpp BSL-1.0"); add_text("utf8cpp BSL-1.0");
add_text("stb - public domain / MIT licensed");
add_text("Music", 0.8f); add_text("Music", 0.8f);
add_text("'Find a Peaceful Place' by ROZKOL (Free Music Archive), CC " add_text("'Find a Peaceful Place' by ROZKOL (Free Music Archive), CC "
"BY 4.0."); "BY 4.0.");

8
third_party/stb/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,8 @@
add_library(stb STATIC
stb_vorbis.cpp
stb_image.cpp
)
target_include_directories(stb PUBLIC
${CMAKE_SOURCE_DIR}/third_party/stb
)

2
third_party/stb/stb_image.cpp vendored Normal file
View File

@@ -0,0 +1,2 @@
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

7988
third_party/stb/stb_image.h vendored Normal file

File diff suppressed because it is too large Load Diff

2
third_party/stb/stb_vorbis.cpp vendored Normal file
View File

@@ -0,0 +1,2 @@
#define STB_VORBIS_IMPLEMENTATION
#include "stb_vorbis.h"