Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 71 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ add_library(cmp_core STATIC
dep/compressonator/cmp_core/shaders/bc3_encode_kernel.cpp
dep/compressonator/cmp_core/shaders/bc7_encode_kernel.cpp
)
set_target_properties(cmp_core PROPERTIES POSITION_INDEPENDENT_CODE ON)

target_include_directories(cmp_core PRIVATE
dep/compressonator/applications/_libs/cmp_math
Expand Down Expand Up @@ -168,20 +169,26 @@ add_library(imgui STATIC
dep/imgui/misc/cpp/imgui_stdlib.h
)

target_compile_definitions(imgui PUBLIC
"IMGUI_IMPL_OPENGL_ES2"
)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
# On Linux: use system GLES3 via EGL (same context as engine/glad), not ANGLE.
# IMGUI_IMPL_OPENGL_ES3 uses <GLES3/gl3.h> declarations resolved through glad at link time.
target_compile_definitions(imgui PUBLIC "IMGUI_IMPL_OPENGL_ES3")
else()
target_compile_definitions(imgui PUBLIC "IMGUI_IMPL_OPENGL_ES2")
endif()

target_include_directories(imgui PUBLIC
dep/imgui
dep/imgui/backends
dep/imgui/misc/cpp
)

target_link_libraries(imgui PUBLIC
unofficial::angle::libGLESv2
glfw
)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
target_link_libraries(imgui PUBLIC glfw GLESv2)
else()
target_link_libraries(imgui PUBLIC unofficial::angle::libGLESv2 glfw)
endif()
set_target_properties(imgui PROPERTIES POSITION_INDEPENDENT_CODE ON)

target_include_directories(SimpleGraphic
PRIVATE
Expand All @@ -194,6 +201,10 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux")
PRIVATE
"-export-dynamic"
)
target_compile_options(SimpleGraphic
PRIVATE
"-Wno-template-body"
)
endif ()

if (WIN32)
Expand Down Expand Up @@ -240,11 +251,11 @@ target_link_libraries(SimpleGraphic
Threads::Threads
WebP::webpdecoder
ZLIB::ZLIB
zstd::libzstd_shared
$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>
)

install(FILES $<TARGET_RUNTIME_DLLS:SimpleGraphic> DESTINATION ".")
install(TARGETS SimpleGraphic RUNTIME DESTINATION ".")
install(TARGETS SimpleGraphic RUNTIME DESTINATION "." LIBRARY DESTINATION ".")

if (WIN32)
set(DEPS_DIR "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}")
Expand Down Expand Up @@ -282,29 +293,47 @@ endif ()
set(LCURL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/Lua-cURLv3)
file(GLOB LCURL_SOURCES ${LCURL_SOURCE_DIR}/src/**.c)
add_library(lcurl SHARED ${LCURL_SOURCES})
if (NOT WIN32)
set_target_properties(lcurl PROPERTIES PREFIX "")
endif()

target_include_directories(lcurl
PRIVATE
${LCURL_SOURCE_DIR}/src
)

if (NOT WIN32)
# LuaJIT 2.1 already provides luaL_setfuncs; l52util.c also defines it as a Lua 5.1 compat shim
target_link_options(lcurl PRIVATE "-Wl,--allow-multiple-definition")
endif()

target_link_libraries(lcurl
PRIVATE
CURL::libcurl
LuaJIT::LuaJIT
)

install(TARGETS lcurl RUNTIME DESTINATION ".")
install(TARGETS lcurl RUNTIME DESTINATION "." LIBRARY DESTINATION ".")
install(FILES $<TARGET_RUNTIME_DLLS:lcurl> DESTINATION ".")

# luautf8 module

add_library(lua-utf8 SHARED libs/luautf8/lutf8lib.c)
if (NOT WIN32)
set_target_properties(lua-utf8 PROPERTIES OUTPUT_NAME "lua-utf8" PREFIX "")
endif()

target_compile_definitions(lua-utf8
PRIVATE
LUA_BUILD_AS_DLL
)
if (WIN32)
target_compile_definitions(lua-utf8
PRIVATE
LUA_BUILD_AS_DLL
)
else()
target_compile_options(lua-utf8
PRIVATE
"-include" "limits.h"
)
endif()

target_include_directories(lua-utf8
PRIVATE
Expand All @@ -315,11 +344,18 @@ target_link_libraries(lua-utf8
LuaJIT::LuaJIT
)

install(TARGETS lua-utf8 RUNTIME DESTINATION ".")
install(TARGETS lua-utf8 RUNTIME DESTINATION "." LIBRARY DESTINATION ".")
install(FILES $<TARGET_RUNTIME_DLLS:lua-utf8> DESTINATION ".")

# luasocket module

set(LUASOCKET_PLATFORM_SOURCES)
if (WIN32)
set(LUASOCKET_PLATFORM_SOURCES "libs/luasocket/src/wsocket.c")
else()
set(LUASOCKET_PLATFORM_SOURCES "libs/luasocket/src/usocket.c")
endif()

add_library(luasocket SHARED
"libs/luasocket/src/auxiliar.c"
"libs/luasocket/src/buffer.c"
Expand All @@ -333,28 +369,35 @@ add_library(luasocket SHARED
"libs/luasocket/src/tcp.c"
"libs/luasocket/src/timeout.c"
"libs/luasocket/src/udp.c"
"libs/luasocket/src/wsocket.c"
${LUASOCKET_PLATFORM_SOURCES}
)

target_include_directories(luasocket
PRIVATE
${LSOCKET_SOURCE_DIR}/src
)

set(LUASOCKET_PLATFORM_LIBS)
if (WIN32)
set(LUASOCKET_PLATFORM_LIBS wsock32 ws2_32)
endif()

target_link_libraries(luasocket
PRIVATE
LuaJIT::LuaJIT
wsock32
ws2_32
${LUASOCKET_PLATFORM_LIBS}
)

set_target_properties( luasocket PROPERTIES OUTPUT_NAME "socket" )
install(TARGETS luasocket RUNTIME DESTINATION ".")
set_target_properties(luasocket PROPERTIES OUTPUT_NAME "socket" PREFIX "")
install(TARGETS luasocket RUNTIME DESTINATION "." LIBRARY DESTINATION ".")
install(FILES $<TARGET_RUNTIME_DLLS:luasocket> DESTINATION ".")

# lzip module

add_library(lzip SHARED libs/LZip/lzip.cpp)
if (NOT WIN32)
set_target_properties(lzip PROPERTIES PREFIX "")
endif()

target_include_directories(lzip
PRIVATE
Expand All @@ -366,5 +409,12 @@ target_link_libraries(lzip
ZLIB::ZLIB
)

install(TARGETS lzip RUNTIME DESTINATION ".")
install(TARGETS lzip RUNTIME DESTINATION "." LIBRARY DESTINATION ".")
install(FILES $<TARGET_RUNTIME_DLLS:lzip> DESTINATION ".")

# Linux launcher
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_executable(PathOfBuilding linux/launcher.c)
target_link_libraries(PathOfBuilding PRIVATE ${CMAKE_DL_LIBS})
install(TARGETS PathOfBuilding RUNTIME DESTINATION ".")
endif()
6 changes: 3 additions & 3 deletions cmake/FindLuaJIT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ if (DEFINED VCPKG_INSTALLED_DIR AND DEFINED VCPKG_TARGET_TRIPLET)

find_path(LuaJIT_INCLUDE_DIR luajit.h
PATHS ${LuaJIT_SEARCH_ROOT}/include
PATH_SUFFIXES luajit
PATH_SUFFIXES luajit luajit-2.1 luajit-2.0
NO_DEFAULT_PATH)

find_library(LuaJIT_LIBRARY_RELEASE NAMES lua51
find_library(LuaJIT_LIBRARY_RELEASE NAMES lua51 luajit-5.1
PATHS ${LuaJIT_SEARCH_ROOT}
PATH_SUFFIXES lib
NO_DEFAULT_PATH)

find_library(LuaJIT_LIBRARY_DEBUG NAMES lua51
find_library(LuaJIT_LIBRARY_DEBUG NAMES lua51 luajit-5.1
PATHS ${LuaJIT_SEARCH_ROOT}
PATH_SUFFIXES debug/lib
NO_DEFAULT_PATH)
Expand Down
7 changes: 4 additions & 3 deletions engine/common/base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "base64.h"

#include <stdlib.h>
#include <string.h>

/* ---- Base64 Encoding/Decoding Table --- */
/* Padding character string starts at offset 64. */
Expand All @@ -47,7 +48,7 @@ static const unsigned char decodetable[] =
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51 };
/*
* Base64Decode() née Curl_base64_decode()
* Base64Decode() n�e Curl_base64_decode()
*
* Given a base64 NUL-terminated string at src, decode it and return a
* pointer in *outptr to a newly allocated memory area holding decoded
Expand Down Expand Up @@ -235,7 +236,7 @@ static bool base64_encode(const char* table64,
}

/*
* Base64Encode() née Curl_base64_encode()
* Base64Encode() n�e Curl_base64_encode()
*
* Given a pointer to an input buffer and an input size, encode it and
* return a pointer in *outptr to a newly allocated memory area holding
Expand All @@ -256,7 +257,7 @@ bool Base64Encode(const char* inputbuff, size_t insize,
}

/*
* Base64UrlEncode() née Curl_base64url_encode()
* Base64UrlEncode() n�e Curl_base64url_encode()
*
* Given a pointer to an input buffer and an input size, encode it and
* return a pointer in *outptr to a newly allocated memory area holding
Expand Down
1 change: 1 addition & 0 deletions engine/common/base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// Modified for standalone inclusion in SimpleGraphic.

#include <stdbool.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
Expand Down
3 changes: 2 additions & 1 deletion engine/common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ char* NarrowUTF8String(const wchar_t* str)
return NarrowCodepageString(str, CP_UTF8);
}

#endif

IndexedUTF32String IndexUTF8ToUTF32(std::string_view input)
{
IndexedUTF32String ret{};
Expand Down Expand Up @@ -494,4 +496,3 @@ IndexedUTF32String IndexUTF8ToUTF32(std::string_view input)
return ret;
}

#endif
1 change: 1 addition & 0 deletions engine/core/core_compress.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "core_compress.h"
#include <cstring>

std::optional<std::vector<char>> CompressZstandard(gsl::span<const std::byte> src, std::optional<int> level)
{
Expand Down
1 change: 1 addition & 0 deletions engine/render/r_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "r_local.h"

#include <algorithm>
#include <fmt/format.h>
#include <iostream>
#include <fstream>
Expand Down
6 changes: 4 additions & 2 deletions engine/render/r_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@

#include <algorithm>
#include <array>
#include <chrono>
#include <filesystem>
#include <fmt/chrono.h>
#include <future>
#include <map>
#include <numeric>
#include <random>
#include <sstream>
#include <thread>
#include <vector>

#include <imgui_impl_glfw.h>
Expand Down Expand Up @@ -1084,7 +1086,7 @@ void r_renderer_c::Init(r_featureFlag_e features)
ImGui::SetCurrentContext(imguiCtx);

ImGui_ImplGlfw_InitForOpenGL((GLFWwindow*)sys->video->GetWindowHandle(), true);
ImGui_ImplOpenGL3_Init("#version 100");
ImGui_ImplOpenGL3_Init(nullptr);

fonts[F_FIXED] = new r_font_c(this, "Bitstream Vera Sans Mono");
fonts[F_VAR] = new r_font_c(this, "Liberation Sans");
Expand Down Expand Up @@ -1640,7 +1642,7 @@ void r_renderer_c::GetShaderImageSize(r_shaderHnd_c* hnd, int& width, int& heigh
if (hnd)
{
while (hnd->sh->tex->status < r_tex_c::SIZE_KNOWN) {
Sleep(1);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
width = hnd->sh->tex->fileWidth;
height = hnd->sh->tex->fileHeight;
Expand Down
6 changes: 4 additions & 2 deletions engine/render/r_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
// Module: Render Texture
//

#include <algorithm>
#include <mutex>
#include <thread>
#include <vector>
#include <atomic>
#include "r_local.h"
Expand Down Expand Up @@ -504,7 +506,7 @@ static gli::texture2d_array TranscodeTexture(gli::texture2d_array src, gli::form

for (size_t blockRow = 0; blockRow < srcBlocksPerRow; ++blockRow) {
const size_t rowBase = blockRow * srcBlockSize.y;
const size_t rowsLeft = (std::min)(4ull, dstExtent.y - rowBase);
const size_t rowsLeft = (std::min)(size_t{4}, dstExtent.y - rowBase);

for (size_t blockCol = 0; blockCol < srcBlocksPerColumn; ++blockCol) {
// Read source 4x4 texel block, no branching needed.
Expand All @@ -524,7 +526,7 @@ static gli::texture2d_array TranscodeTexture(gli::texture2d_array src, gli::form

// Here we work off that dstData points at the top left pixel of the block row in the destination.
const size_t colBase = blockCol * srcBlockSize.x;
const size_t colsLeft = (std::min)(4ull, dstExtent.x - colBase);
const size_t colsLeft = (std::min)(size_t{4}, dstExtent.x - colBase);
const size_t colBytesLeft = colsLeft * 4;
for (size_t innerRow = 0; innerRow < rowsLeft; ++innerRow) {
auto* dstPtr = dstData + dstRowStride * innerRow + colBase * 4;
Expand Down
Loading
Loading