15 Commits

Author SHA1 Message Date
9b173c64a6 add pkg-config fallback and imported target to sdl find module 2023-10-31 17:06:11 +01:00
3a885ee250 update entt to v3.12.2 2023-09-07 01:51:33 +02:00
00e48f9967 update spdlog to v1.12.0 2023-09-05 11:56:50 +02:00
c791f4c6a1 fix print formatter 2023-09-04 23:46:12 +02:00
7a3823db78 update ImGui to v1.89.9
and reenable obsolte bc of text editor (temp, will be replaced)
2023-09-04 20:57:00 +02:00
1722f61250 negative_bloom 2023-05-11 02:12:05 +02:00
0abb860185 update tracy to v0.9.1 2023-03-05 00:11:16 +01:00
22dc949cc5 update stb to latest, reenable perlin noise 2023-03-05 00:04:31 +01:00
196ea7b93b update imgui to v1.89.3 2023-03-04 23:47:18 +01:00
f655da82d5 silence more conversion warnings 2023-03-04 19:38:13 +01:00
d672f8a52c update github ci emscripten to 3.1.32 2023-03-04 19:14:26 +01:00
6df865de3e fix warning for release builds for opengl es / webgl 2023-03-04 18:57:44 +01:00
e9c62f9201 add small helper to scalar range 2023-03-04 02:35:06 +01:00
7bce78167b mark data const in net interface 2022-12-07 18:42:11 +01:00
a45da5c2b0 remove questionable assert in s6zer 2022-12-07 18:40:12 +01:00
25 changed files with 197 additions and 139 deletions

View File

@ -9,12 +9,12 @@ on:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Debug
EM_VERSION: 2.0.24
EM_VERSION: 3.1.32
EM_CACHE_FOLDER: 'emsdk-cache'
jobs:
linux:
timeout-minutes: 10
timeout-minutes: 15
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.

View File

@ -105,7 +105,7 @@
if(NOT EMSCRIPTEN)
FIND_PATH(SDL2_INCLUDE_DIR SDL.h
FIND_PATH(SDL2_INCLUDE_DIR_TEMP SDL.h
HINTS
$ENV{SDL2}
PATH_SUFFIXES include/SDL2 include SDL2
@ -153,7 +153,7 @@ ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
IF(NOT SDL2_BUILDING_LIBRARY)
IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
IF(NOT "${SDL2_INCLUDE_DIR_TEMP}" MATCHES ".framework")
# Non-OS X framework versions expect you to also dynamically link to
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
# seem to provide SDL2main for compatibility even though they don't
@ -189,7 +189,7 @@ IF(NOT SDL2_BUILDING_LIBRARY)
/opt
)
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
ENDIF(NOT "${SDL2_INCLUDE_DIR_TEMP}" MATCHES ".framework")
ENDIF(NOT SDL2_BUILDING_LIBRARY)
# SDL2 may require threads on your system.
@ -208,58 +208,67 @@ IF(MINGW)
ENDIF(MINGW)
SET(SDL2_FOUND "NO")
IF(SDL2_LIBRARY_TEMP)
# For SDL2main
IF(NOT SDL2_BUILDING_LIBRARY)
IF(SDL2MAIN_LIBRARY)
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
ENDIF(SDL2MAIN_LIBRARY)
ENDIF(NOT SDL2_BUILDING_LIBRARY)
IF(SDL2_LIBRARY_TEMP)
# For SDL2main
IF(NOT SDL2_BUILDING_LIBRARY)
IF(SDL2MAIN_LIBRARY)
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
ENDIF(SDL2MAIN_LIBRARY)
ENDIF(NOT SDL2_BUILDING_LIBRARY)
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
# CMake doesn't display the -framework Cocoa string in the UI even
# though it actually is there if I modify a pre-used variable.
# I think it has something to do with the CACHE STRING.
# So I use a temporary variable until the end so I can set the
# "real" variable in one-shot.
IF(APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
ENDIF(APPLE)
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
# CMake doesn't display the -framework Cocoa string in the UI even
# though it actually is there if I modify a pre-used variable.
# I think it has something to do with the CACHE STRING.
# So I use a temporary variable until the end so I can set the
# "real" variable in one-shot.
IF(APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
ENDIF(APPLE)
# For threads, as mentioned Apple doesn't need this.
# In fact, there seems to be a problem if I used the Threads package
# and try using this line, so I'm just skipping it entirely for OS X.
IF(NOT APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
ENDIF(NOT APPLE)
# For threads, as mentioned Apple doesn't need this.
# In fact, there seems to be a problem if I used the Threads package
# and try using this line, so I'm just skipping it entirely for OS X.
IF(NOT APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
ENDIF(NOT APPLE)
# For MinGW library
IF(MINGW)
SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
ENDIF(MINGW)
# For MinGW library
IF(MINGW)
SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
ENDIF(MINGW)
# Set the final string here so the GUI reflects the final state.
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
# Set the final string here so the GUI reflects the final state.
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
############add_library(SDL UNKNOWN IMPORTED)
#target_link_libraries(SDL INTERFACE ${SDL2_LIBRARY})
#target_include_directories(SDL INTERFACE ${SDL2_INCLUDE_DIR})
#set_target_properties(SDL PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${SDL2_LIBRARY}")
set(SDL2_INCLUDE_DIR ${SDL2_INCLUDE_DIR_TEMP} CACHE STRING "Where the SDL2 Headers can be found")
SET(SDL2_INCLUDE_DIR_TEMP "${SDL2_INCLUDE_DIR_TEMP}" CACHE INTERNAL "")
#set_target_properties(SDL PROPERTIES
#INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}")
SET(SDL2_FOUND "YES")
else() # SDL2_LIBRARY_TEMP
# try to pkg-config fallback
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PKG_C_SDL2 QUIET sdl2)
if (PKG_C_SDL2_FOUND)
SET(SDL2_LIBRARY_TEMP ${PKG_C_SDL2_LIBRARIES})
SET(SDL2_INCLUDE_DIR_TEMP ${PKG_C_SDL2_INCLUDE_DIRS})
#set_target_properties(SDL PROPERTIES
#IMPORTED_LINK_INTERFACE_LANGUAGES "C"
#IMPORTED_LINK_INTERFACE_LIBRARIES "${SDL2_LIBRARY}"
#LINK_INTERFACE_LIBRARIES "${SDL2_LIBRARY}")
# Set the final string here so the GUI reflects the final state.
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
#IMPORTED_LOCATION "${SDL2_LIBRARY}")
set(SDL2_INCLUDE_DIR ${SDL2_INCLUDE_DIR_TEMP} CACHE STRING "Where the SDL2 Headers can be found")
SET(SDL2_INCLUDE_DIR_TEMP "${SDL2_INCLUDE_DIR_TEMP}" CACHE INTERNAL "")
#message("II set include dir to ${SDL2_INCLUDE_DIR}")
SET(SDL2_FOUND "YES")
SET(SDL2_FOUND "YES")
endif()
endif()
ENDIF(SDL2_LIBRARY_TEMP)
else() #emsripten
@ -288,4 +297,11 @@ INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
if (SDL2_FOUND)
if (NOT TARGET SDL2::SDL2)
add_library(SDL2::SDL2 INTERFACE IMPORTED)
target_include_directories(SDL2::SDL2 INTERFACE ${SDL2_INCLUDE_DIR})
target_link_libraries(SDL2::SDL2 INTERFACE ${SDL2_LIBRARY})
endif()
endif()

2
external/entt vendored

View File

@ -2,43 +2,31 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project(imgui C CXX)
set(CPP_FILES
add_library(imgui
"imgui/imgui.h"
"imgui/imgui.cpp"
"imgui/imgui_draw.cpp"
"imgui/imgui_widgets.cpp"
"imgui/imgui_tables.cpp"
"imgui/imgui_demo.cpp"
"imgui/misc/cpp/imgui_stdlib.cpp"
"imgui_plot_var.cpp"
#"imgui_impl_sdl_gl3.cpp" # very old
#"imgui_impl_sdl.cpp" # old
#"imgui_impl_opengl3.cpp" # old
"imgui/backends/imgui_impl_sdl.cpp"
"imgui/backends/imgui_impl_opengl3.cpp"
)
set(HPP_FILES
"imgui/imgui.h"
"imgui/imstb_rectpack.h"
"imgui/imstb_textedit.h"
"imgui/imstb_truetype.h"
"imgui/misc/cpp/imgui_stdlib.h"
"imgui/misc/cpp/imgui_stdlib.cpp"
"imgui_plot_var.hpp"
"imgui_plot_var.cpp"
#"imgui_impl_sdl_gl3.h" # very old
#"imgui_impl_sdl.h" # old
#"imgui_impl_opengl3.h" # old
"imgui/backends/imgui_impl_sdl.h"
# TODO: seperate backends into libs
"imgui/backends/imgui_impl_sdl2.h"
"imgui/backends/imgui_impl_sdl2.cpp"
"imgui/backends/imgui_impl_opengl3.h"
"imgui/backends/imgui_impl_opengl3.cpp"
)
add_library(imgui ${CPP_FILES} ${HPP_FILES})
target_compile_features(imgui PUBLIC cxx_std_11)
if(MM_OPENGL_3_GLES)
@ -53,7 +41,7 @@ target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
#target_include_directories(imgui PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/imgui")
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/imgui") # im sad
target_compile_definitions(imgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1)
#target_compile_definitions(imgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1) # more sad
if(EMSCRIPTEN)
target_compile_options(imgui PUBLIC -sUSE_SDL=2)

View File

@ -11,9 +11,8 @@ target_link_libraries(stb_image stb)
add_library(stb_image_write "stb/stb_image_write.h" "stb_image_write.cpp")
target_link_libraries(stb_image_write stb)
# lel TODO: add back in when patent expires
#add_library(stb_perlin "stb/stb_perlin.h" "stb_perlin.cpp")
#target_link_libraries(stb_perlin stb)
add_library(stb_perlin "stb/stb_perlin.h" "stb_perlin.cpp")
target_link_libraries(stb_perlin stb)
add_library(stb_rect_pack "stb/stb_rect_pack.h" "stb_rect_pack.cpp")
target_link_libraries(stb_rect_pack stb)

View File

@ -10,6 +10,8 @@ if(NOT EMSCRIPTEN)
"${CMAKE_CURRENT_LIST_DIR}/tracy/public/TracyClient.cpp"
)
option(TRACY_ENABLE "Enable tracy profiling" OFF)
if(TRACY_ENABLE)
target_compile_definitions(tracy_client PUBLIC TRACY_ENABLE)
#target_compile_definitions(tracy_client PUBLIC TRACY_NO_SYSTEM_TRACING)

View File

@ -50,11 +50,11 @@ namespace MM::Services {
public: // send/recv
// sends a packet of max getMaxPacketSize() bytes
virtual bool sendPacket(peer_id peer, channel_id channel, uint8_t* data, size_t data_size) = 0;
virtual bool sendPacket(peer_id peer, channel_id channel, const uint8_t* data, size_t data_size) = 0;
// sends a packet, automatically split if too big
// !! only on lossless channels
virtual bool sendPacketLarge(peer_id peer, channel_id channel, uint8_t* data, size_t data_size) = 0;
virtual bool sendPacketLarge(peer_id peer, channel_id channel, const uint8_t* data, size_t data_size) = 0;
// TODO: broadcast?
// has any?

View File

@ -134,10 +134,10 @@ public:
e = registry.create();
// create a copy of an entity component by component
for (auto &&curr: registry.storage()) {
if (auto &storage = curr.second; storage.contains(old_e)) {
for(auto &&curr: registry.storage()) {
if(auto &storage = curr.second; storage.contains(old_e)) {
// TODO: do something with the return value. returns false on failure.
storage.emplace(e, storage.get(old_e));
storage.push(e, storage.value(old_e));
}
}
}
@ -237,11 +237,11 @@ public:
if (comp_list.empty()) {
ImGui::Text("Orphans:");
registry.each([&registry](auto e){
for (EntityType e : registry.template storage<EntityType>()) {
if (registry.orphan(e)) {
MM_IEEE_ENTITY_WIDGET(e, registry, false);
}
});
}
} else {
entt::runtime_view view{};
for (const auto type : comp_list) {
@ -264,17 +264,6 @@ public:
}
}
[[deprecated("Use renderEditor() instead. And manage the window yourself.")]]
void render(Registry& registry, EntityType& e)
{
if (show_window) {
if (ImGui::Begin("Entity Editor", &show_window)) {
renderEditor(registry, e);
}
ImGui::End();
}
}
// displays both, editor and list
// uses static internally, use only as a quick way to get going!
void renderSimpleCombo(Registry& registry, EntityType& e)

View File

@ -4,6 +4,7 @@
#include <imgui.h>
#include <nlohmann/json.hpp>
#include <imgui/misc/cpp/imgui_stdlib.h>
#include <cinttypes>
namespace MM::ImGuiWidgets {
@ -55,16 +56,16 @@ void JsonViewerSimple(const char* name, const JsonObjectType& json) {
}
break;
case JsonObjectType::value_t::number_integer:
ImGui::TextColored(int_color, "%ld", json.template get<int64_t>());
ImGui::TextColored(int_color, "%" PRId64, json.template get<int64_t>());
break;
case JsonObjectType::value_t::number_unsigned:
ImGui::TextColored(unsigned_color, "%lu", json.template get<uint64_t>());
ImGui::TextColored(unsigned_color, "%" PRIu64, json.template get<uint64_t>());
break;
case JsonObjectType::value_t::number_float:
ImGui::TextColored(float_color, "%f", json.template get<float>());
break;
case JsonObjectType::value_t::object:
ImGui::TextDisabled("{%d}", json.size());
ImGui::TextDisabled("{%zu}", json.size());
ImGui::Indent();
for (auto& [key, value] : json.items()) {
@ -74,7 +75,7 @@ void JsonViewerSimple(const char* name, const JsonObjectType& json) {
break;
case JsonObjectType::value_t::array:
ImGui::TextDisabled("[%d]", json.size());
ImGui::TextDisabled("[%zu]", json.size());
ImGui::Indent();
for (auto& [key, value] : json.items()) {
@ -103,9 +104,9 @@ void JsonViewerTree(const char* name, const JsonObjectType& json) {
ImGui::SameLine();
if (json.is_object()) {
ImGui::TextDisabled("{%d}", json.size());
ImGui::TextDisabled("{%zu}", json.size());
} else { // is_array()
ImGui::TextDisabled("[%d]", json.size());
ImGui::TextDisabled("[%zu]", json.size());
}
if (tree_open) {
@ -143,10 +144,10 @@ void JsonViewerTree(const char* name, const JsonObjectType& json) {
}
break;
case JsonObjectType::value_t::number_integer:
ImGui::TextColored(int_color, "%ld", json.template get<int64_t>());
ImGui::TextColored(int_color, "%" PRId64, json.template get<int64_t>());
break;
case JsonObjectType::value_t::number_unsigned:
ImGui::TextColored(unsigned_color, "%lu", json.template get<uint64_t>());
ImGui::TextColored(unsigned_color, "%" PRIu64, json.template get<uint64_t>());
break;
case JsonObjectType::value_t::number_float:
ImGui::TextColored(float_color, "%f", json.template get<float>());
@ -200,9 +201,9 @@ void JsonEditor(const char* name, JsonObjectType& json) {
ImGui::SameLine();
if (json.is_object()) {
ImGui::TextDisabled("{%d}", json.size());
ImGui::TextDisabled("{%zu}", json.size());
} else { // is_array()
ImGui::TextDisabled("[%d]", json.size());
ImGui::TextDisabled("[%zu]", json.size());
}
if (tree_open) {

View File

@ -1,7 +1,7 @@
#include "./imgui_s.hpp"
#include <imgui/imgui.h>
#include <imgui/backends/imgui_impl_sdl.h>
#include <imgui/backends/imgui_impl_sdl2.h>
#ifdef MM_OPENGL_3
#include <imgui/backends/imgui_impl_opengl3.h>

View File

@ -1,4 +1,5 @@
#include "./scene_tools.hpp"
#include "mm/engine_fwd.hpp"
#include <mm/engine.hpp>
@ -109,16 +110,19 @@ namespace MM::Services {
if (_show_scene_metrics) {
if (ImGui::Begin("Scene Metrics##ImGuiSceneToolsService", &_show_scene_metrics)) {
ImGui::Text("capacity: %lu", scene.capacity());
ImGui::Text("size: %lu", scene.size());
ImGui::Text("alive: %lu", scene.alive());
size_t orphans = 0;
scene.each([&orphans, &scene](auto entity) {
if (scene.orphan(entity)) {
orphans++;
ImGui::Text("capacity: %zu", scene.storage<::MM::Entity>().capacity());
ImGui::Text("size: %zu", scene.storage<::MM::Entity>().size());
ImGui::Text("alive: %zu", scene.storage<::MM::Entity>().in_use());
if (ImGui::CollapsingHeader("orphans")) {
// iterating all entities is expensive
size_t orphans = 0;
for (const auto it : scene.storage<MM::Entity>().each()) {
if (scene.orphan(std::get<0>(it))) {
orphans++;
}
}
});
ImGui::Text("orphans: %lu", orphans);
ImGui::Text("orphans: %lu", orphans);
}
}
ImGui::End();
}

View File

@ -97,6 +97,7 @@ Texture::handle_t Texture::createEmptyMultiSampled(int32_t internalFormat, int32
(void)height;
(void)samples;
assert(false && "GLES has no multisampling support");
return nullptr;
#endif
}

View File

@ -29,14 +29,20 @@ void setup_bloom(
const auto bloom_internal_format = GL_RGB565; // prolly fine. NOPE its not. it causes green pixely halos
const auto bloom_format_type = GL_UNSIGNED_BYTE;
#else
//const auto bloom_internal_format = GL_RGBA16F;
const auto bloom_internal_format = GL_R11F_G11F_B10F;
const auto bloom_format_type = GL_FLOAT;
const auto bloom_format_type = GL_RGBA;
const auto bloom_internal_format = GL_RGBA16F;
//const auto bloom_internal_format = GL_R11F_G11F_B10F;
const auto bloom_data_type = GL_FLOAT;
//const auto bloom_format_type = GL_RGBA_INTEGER;
//const auto bloom_internal_format = GL_RGBA16I;
//const auto bloom_data_type = GL_SHORT;
#endif
#else
//const auto bloom_internal_format = GL_RGB16F;
const auto bloom_internal_format = GL_R11F_G11F_B10F;
const auto bloom_format_type = GL_FLOAT;
const auto bloom_format_type = GL_RGB;
const auto bloom_internal_format = GL_RGB16F; // opengl silently upgrades to RGBA
//const auto bloom_internal_format = GL_R11F_G11F_B10F; // no sign
const auto bloom_data_type = GL_FLOAT;
#endif
{ // bloom in (bloom extraction)
@ -44,7 +50,7 @@ void setup_bloom(
"bloom_in",
bloom_internal_format,
w * bloom_in_scale, h * bloom_in_scale,
GL_RGB, bloom_format_type
bloom_format_type, bloom_data_type
);
{ // filter
rm_t.get("bloom_in"_hs)->bind(0);
@ -72,7 +78,7 @@ void setup_bloom(
tex_out_id,
bloom_internal_format,
w * bloom_in_scale * glm::pow(bloom_phase_scale, i), h * bloom_in_scale * glm::pow(bloom_phase_scale, i),
GL_RGB, bloom_format_type
bloom_format_type, bloom_data_type
);
{ // filter
rm_t.get(tex_out_id)->bind(0);
@ -89,7 +95,7 @@ void setup_bloom(
tex_tmp_id,
bloom_internal_format,
w * bloom_in_scale * glm::pow(bloom_phase_scale, i), h * bloom_in_scale * glm::pow(bloom_phase_scale, i),
GL_RGB, bloom_format_type
bloom_format_type, bloom_data_type
);
{ // filter
rm_t.get(tex_tmp_id)->bind(0);

View File

@ -106,7 +106,15 @@ void main() {
vec3 color = texture(color_tex, _uv).rgb;
// TODO: expose threshold
_out_color = max(vec3(0.0), color - vec3(1.0));
//_out_color = max(vec3(0.0), color - vec3(1.0));
//_out_color = mix(
//color, // < 0.0
//max(vec3(0.0), color - vec3(1.0)), // > 0.0
//step(vec3(0.0), color)
//);
_out_color = max(min(color, vec3(0.0)), color - vec3(1.0));
})")
}

View File

@ -141,7 +141,7 @@ void main() {
vec3 color = texture(color_tex, _uv).rgb;
vec3 bloom = texture(bloom_tex, _uv).rgb;
vec3 comp = color + bloom * vec3(bloom_factor);
vec3 comp = max(vec3(0.0), color + bloom * vec3(bloom_factor));
#if 0
const vec3 tint = vec3(1.5, 0.8, 1.1);

View File

@ -129,8 +129,9 @@ static void setup_fbos(MM::Engine& engine) {
assert(rs.targets["game_view"]);
}
static MM::Engine engine;
TEST(hdr_bloom_pipeline, it) {
MM::Engine engine;
auto& sdl_ss = engine.addService<MM::Services::SDLService>();
ASSERT_TRUE(engine.enableService<MM::Services::SDLService>());
@ -228,7 +229,7 @@ TEST(hdr_bloom_pipeline, it) {
col.color = {3.f, 3.f, 3.f, 1.f};
}
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 5; i++) {
auto e = scene.create();
auto& p = scene.emplace<MM::Components::Position2D>(e);
p.pos.x = i * 9.f - 40;
@ -247,7 +248,43 @@ TEST(hdr_bloom_pipeline, it) {
col.color = {rng.zeroToOne()*2.f, rng.zeroToOne()*2.f, rng.zeroToOne()*2.f, 1.f};
}
for (int i = 5; i < 10; i++) {
auto e = scene.create();
auto& p = scene.emplace<MM::Components::Position2D>(e);
p.pos.x = i * 9.f - 40;
// zoffset is created by event
auto& s = scene.emplace<MM::Components::Scale2D>(e);
s.scale = {5,5};
scene.emplace<MM::Components::Rotation2D>(e);
auto& v = scene.emplace<MM::Components::Velocity2DRotation>(e);
v.rot_vel = i * 0.3f;
auto& col = scene.emplace<MM::Components::Color>(e);
col.color = {rng.zeroToOne()*-2.f, rng.zeroToOne()*-2.f, rng.zeroToOne()*-2.f, 1.f};
}
{ // white background for negatives
auto e = scene.create();
auto& p = scene.emplace<MM::Components::Position2D>(e);
p.pos.y = 30.f;
p.pos.x = 25.f;
auto& s = scene.emplace<MM::Components::Scale2D>(e);
s.scale = {50,150};
auto& col = scene.emplace<MM::Components::Color>(e);
col.color = {1.f, 1.f, 1.f, 1.f};
}
engine.run();
#ifndef __EMSCRIPTEN__
engine.cleanup();
#endif
}
int main(int argc, char** argv) {

View File

@ -7,7 +7,7 @@ namespace MM::Random {
// Seeded (Pseudo-) Random Number Generator
struct SRNG {
// make shuffle compat
// make shuffle compat
// TODO: add more type info
using result_type = uint32_t;
@ -35,7 +35,7 @@ struct SRNG {
}
bool roll(float prob) {
return zeroToOne() <= prob;
return zeroToOne() <= prob; // TODO: just < ?
}
// more advanced

View File

@ -194,10 +194,6 @@ struct StreamWriter {
}
[[nodiscard]] size_t bytesWritten(void) noexcept {
// TODO: is this assert valid?
assert(_scratch_bits == 0);
//return _bits_written/8 + ((_bits_written % 8) ? 1 : 0);
return (_bits_written+7) / 8;
}

View File

@ -391,7 +391,7 @@ struct TestStruct {
double f64 {0.};
// float compressed [0; 1] range
constexpr static float c0_f32_resolution = 0.001;
constexpr static float c0_f32_resolution = 0.001f;
constexpr static MM::ScalarRange2<float> c0_f32_r{0.f, 1.f};
float c0_f32_0 {0.f};
float c0_f32_1 {0.f};
@ -399,7 +399,7 @@ struct TestStruct {
float c0_f32_3 {0.f};
// float compressed [-1; 1] range
constexpr static float c1_f32_resolution = 0.05;
constexpr static float c1_f32_resolution = 0.05f;
constexpr static MM::ScalarRange2<float> c1_f32_r{-1.f, 1.f};
float c1_f32_0 {0.f};
float c1_f32_1 {0.f};
@ -407,7 +407,7 @@ struct TestStruct {
float c1_f32_3 {0.f};
// float compressed [-1000; 1000] range
constexpr static float c2_f32_resolution = 0.01;
constexpr static float c2_f32_resolution = 0.01f;
constexpr static MM::ScalarRange2<float> c2_f32_r{-1000.f, 1000.f};
float c2_f32_0 {0.f};
float c2_f32_1 {0.f};

View File

@ -31,9 +31,10 @@ namespace MM::Services {
SDLService::SDLService(uint32_t _sdl_init_flags) {
MM::Logger::initSectionLogger("SDLService");
//#ifdef __EMSCRIPTEN__
//_sdl_init_flags &= ~SDL_INIT_HAPTIC;
//#endif
#ifdef __EMSCRIPTEN__
_sdl_init_flags &= ~SDL_INIT_HAPTIC;
#endif
#if 1 // hack for mingw + wine
_sdl_init_flags &= ~SDL_INIT_SENSOR;
#endif

View File

@ -60,6 +60,16 @@ struct ScalarRange2 {
[[nodiscard]] constexpr bool inRange(T&& value) const {
return value >= min() && value <= max();
}
// lerp between min and max
[[nodiscard]] constexpr T map(const float a) const {
return min() * (1.f-a) + max() * a;
}
// reverse map
[[nodiscard]] constexpr float unmap(const T& v) const {
return (v - min()) / static_cast<float>(max() - min());
}
};
} // MM