Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
08b10d3
More towards error handing with the result monad
Twon Jul 13, 2025
0bb76d0
Render window should have monadic create to handle failures
Twon Jul 13, 2025
9ddec54
Gfx devices are movables. Win32 error codes
Twon Jul 19, 2025
9425897
Correct no discard usage on statics
Twon Jul 19, 2025
b8da081
Enforce getGraphicsApi across render systems
Twon Jul 19, 2025
3506265
Update context tests for monadic interface
Twon Jul 19, 2025
88d8792
Access the visualisation layer
Twon Jul 19, 2025
e200776
Mac os compile fix
Twon Jul 19, 2025
c9be97b
Correct program args
Twon Jul 19, 2025
56c1846
Ensure coverage for graphic API name
Twon Jul 21, 2025
46849a6
Merge branch 'main' into antony/20250712/gfx-win32-monadic-handling
Twon Aug 6, 2025
e77f0b6
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Aug 7, 2025
6a60194
Further formatting applied (#402)
Twon Aug 8, 2025
66bd30a
Twon/20250808/further formatting alignment (#403)
Twon Aug 12, 2025
0f6fd7f
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Aug 12, 2025
7970580
Merge fix
Twon Aug 13, 2025
be58a54
Merge branch 'antony/20250713/gfx-win32-monadic-handling' of github.c…
Twon Aug 13, 2025
38cbcef
Next merge fix
Twon Aug 13, 2025
1fcc174
Add editor config (#404)
Twon Aug 18, 2025
0abd507
Introduce conformance namespace
Twon Aug 31, 2025
7abe371
Introduce conformance namespace (#406)
Twon Sep 1, 2025
35c6585
Fix up conf namespace
Twon Sep 1, 2025
0baff35
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Sep 1, 2025
600b746
Update reference
Twon Sep 1, 2025
8eab13b
Fix typo
Twon Sep 1, 2025
a53e829
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Sep 1, 2025
57d0fc0
Make private
Twon Sep 1, 2025
abacfc8
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Sep 2, 2025
7c32c1f
Merge fix
Twon Sep 2, 2025
7ac4619
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Sep 4, 2025
7b4c4b0
Ignore coverage for tui function
Twon Sep 5, 2025
701a1ea
Test available render sytems across os's
Twon Sep 5, 2025
1a3bb95
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Sep 6, 2025
5ed0961
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Sep 6, 2025
6fe567c
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Sep 6, 2025
dca6e82
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Sep 6, 2025
3b088a4
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Sep 7, 2025
7cdcf63
Correct include order
Twon Sep 7, 2025
0588166
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Sep 7, 2025
edb513e
Remove duplicate
Twon Sep 7, 2025
c92d1ec
Rename func ref conformance namespace
Twon Nov 12, 2025
93b5cb0
Merge branch 'main' into antony/20250713/gfx-win32-monadic-handling
Twon Nov 16, 2025
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
1 change: 1 addition & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class Morpheus(ConanFile):
"unordered_dense/4.5.0",
"boost/1.88.0",
"ctre/3.9.0",
"ftxui/6.0.2",
"magic_enum/0.9.7",
"ms-gsl/4.1.0",
"rapidjson/cci.20230929",
Expand Down
3 changes: 3 additions & 0 deletions examples/gfx/render_triangle/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
add_executable(RenderTriangle main.cpp)

find_package(ftxui)
target_link_libraries(RenderTriangle
PRIVATE
ftxui::ftxui
morpheus::application
morpheus::gfx::platform
morpheus::gfx::gl4
morpheus::vis
)

set_target_properties(RenderTriangle
Expand Down
162 changes: 155 additions & 7 deletions examples/gfx/render_triangle/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include <morpheus/application/application.hpp>
#include <morpheus/application/try_catch.hpp>
#include <morpheus/gfx/gl4/render_system.hpp>
// #include <morpheus/gfx/platform/render_system_factory.hpp>
#include <morpheus/gfx/platform/win32/render_window.hpp>
#include <morpheus/vis/render_system_factory.hpp>

#include <ftxui/component/component.hpp>
#include <ftxui/component/screen_interactive.hpp>

using namespace morpheus::application;
using namespace morpheus::gfx;
Expand Down Expand Up @@ -45,13 +48,158 @@ class RenderTriange : public Application

int main(int argc, char* argv[])
{
// const std::vector<std::string> renders = {
// "Direct X 12",
// "OpenGL 4",
// "Vulkan"
// };

tryCatch(
[&]
{
RenderTriange example(argc, argv);
example.Run();
});
// int selectedRenders = 0;
// ftxui::Component compiler = ftxui::Radiobox(&renders, &selectedRenders);

// auto screen = ftxui::ScreenInteractive::Fullscreen();
////auto testComponent = ftxui::Renderer([]() { return ftxui::text("test Component"); });
// auto testComponent = ftxui::Renderer(compiler, [&]() {
// auto rendererWin = ftxui::window(ftxui::text("Renderer"), compiler->Render() | ftxui::vscroll_indicator | ftxui::frame);
// return rendererWin;
// });
// screen.Loop(testComponent);

morpheus::vis::RenderSystemFactory factory;
factory.runTuiConfiguration();

// tryCatch(
// [&]
// {
// RenderTriange example(argc, argv);
// example.Run();
// });

// render_system_factory renderer_factory;
}

/*
#include <ftxui/component/component.hpp>
#include <ftxui/component/screen_interactive.hpp>
#include <ftxui/dom/elements.hpp>
#include <string>
#include <vector>
#include <map>
#include <memory>

using namespace ftxui;

// Enum to track the current screen state
enum class ScreenStage {
SelectRenderer,
ConfigureRenderer,
};

int main() {
ScreenInteractive screen = ScreenInteractive::TerminalOutput();

// State
ScreenStage current_stage = ScreenStage::SelectRenderer;

std::vector<std::string> renderer_options = {
"DirectX 12", "Vulkan", "OpenGL"
};
int selected_renderer = 0;
auto renderer_selector = Radiobox(&renderer_options, &selected_renderer);

// Settings per renderer
std::map<std::string, std::vector<std::string>> renderer_settings = {
{"DirectX 12", {"Use DXIL", "Enable Tearing"}},
{"Vulkan", {"Validation Layers", "Prefer Integrated GPU"}},
{"OpenGL", {"Core Profile", "Enable Debug Output"}}
};

// Dynamic state for second screen
std::vector<std::string> setting_labels;
std::vector<bool> setting_states; // Real bools for safety
std::vector<Component> setting_checkboxes;
Component settings_container = Container::Vertical({});

// Component placeholders
Component next_button, back_button, finish_button;

// Container that will switch content
Component main_container = Container::Vertical({});

// Renderer root
Component root = Renderer(main_container, [&] {
if (current_stage == ScreenStage::SelectRenderer) {
return vbox({
text("Select Render System:") | bold,
renderer_selector->Render(),
separator(),
next_button->Render(),
}) | border | center;
}
else {
Elements checkbox_elements;
for (auto& cb : setting_checkboxes) {
checkbox_elements.push_back(cb->Render());
}

return vbox({
text("Configure Settings for: ") | bold,
text(renderer_options[selected_renderer]),
separator(),
vbox(std::move(checkbox_elements)),
separator(),
hbox({
back_button->Render(),
finish_button->Render(),
}) | center
}) | border | center;
}
});

// Buttons — defined after root to capture state
next_button = Button("Next", [&] {
current_stage = ScreenStage::ConfigureRenderer;

// Populate setting labels + bools
std::string selected_name = renderer_options[selected_renderer];
setting_labels = renderer_settings[selected_name];
setting_states = std::vector<bool>(setting_labels.size(), false);
setting_checkboxes.clear();

for (size_t i = 0; i < setting_labels.size(); ++i) {
bool local = setting_states[i];
setting_checkboxes.push_back(Checkbox(setting_labels[i], &local));
}

settings_container = Container::Vertical(setting_checkboxes);

// Reconfigure main container
main_container->DetachAllChildren();
//main_container->Add(renderer_selector);
main_container->Add(settings_container);
main_container->Add(back_button);
main_container->Add(finish_button);

screen.PostEvent(Event::Custom); // force re-render
});

back_button = Button("Back", [&] {
current_stage = ScreenStage::SelectRenderer;
main_container->DetachAllChildren();
main_container->Add(renderer_selector);
main_container->Add(next_button);
screen.PostEvent(Event::Custom); // force re-render
});

finish_button = Button("Finish", [&] {
screen.Exit();
});

// Initial container setup
main_container->Add(renderer_selector);
main_container->Add(next_button);

screen.Loop(root);
return 0;
}
*/
3 changes: 2 additions & 1 deletion libraries/core/lib/morpheus/core/base/platform.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once

#include <cstdint>
#include <morpheus/core/base/compiler.hpp>
#include <morpheus/core/base/export.hpp>

#include <cstdint>

/*! \defgroup Platform Morpheus Supported Platforms
The platform group of macros allow for compile time detection of the current platform.
@{
Expand Down
19 changes: 11 additions & 8 deletions libraries/core/lib/morpheus/core/functional/function_ref.hpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
#pragma once

#include <concepts>
#include <functional>
#include <morpheus/core/conformance/version.hpp>
#include <morpheus/core/meta/invocable_traits.hpp>

#include <concepts>
#include <functional>
#include <type_traits>
#include <utility>

#if (__cpp_lib_function_ref >= 202202L)

namespace morpheus::conf
{
namespace func_ref = std;
namespace fr = std;
}

#else

namespace morpheus::conf::func_ref
namespace morpheus::conf::fr
{

/// \struct nontype_t
Expand Down Expand Up @@ -98,7 +99,8 @@ class function_ref<Return(Args...)>
template <class F>
function_ref(F* f) noexcept
requires std::is_function_v<F> and isInvokableWith<F>
: mInvoke([](Storage storage, Args... args) noexcept(isNoexcept) { return invoke(function_ref::get<F>(storage), std::forward<Args>(args)...); })
: mInvoke([](Storage storage, Args... args) noexcept(isNoexcept) -> Return
{ return invoke(function_ref::get<F>(storage), std::forward<Args>(args)...); })
, mStorage(f)
{}

Expand Down Expand Up @@ -180,7 +182,7 @@ class function_ref<Return(Args...)>
template <class F>
requires std::is_function_v<F>
constexpr explicit Storage(F* f) noexcept
: fp(f)
: fp(reinterpret_cast<void (*)()>(f))
{}
};

Expand All @@ -193,7 +195,7 @@ class function_ref<Return(Args...)>
else if constexpr (std::is_object_v<T>)
return static_cast<T*>(storage.p);
else
return static_cast<T*>(storage.fp);
return reinterpret_cast<T*>(storage.fp);
}

using InternalInvocableType = Return(Storage, Args...);
Expand Down Expand Up @@ -226,5 +228,6 @@ function_ref(nontype_t<f>) -> function_ref<std::remove_pointer_t<decltype(f)>>;
function_ref(F) -> function_ref<see below>;
*/

} // namespace morpheus::conf::func_ref
} // namespace morpheus::conf::fr

#endif
6 changes: 3 additions & 3 deletions libraries/core/tests/functional/function_ref.tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace morpheus::functional

TEST_CASE("Propagate constness and noexceptness to function_ref", "[morpheus.functional.function_ref]")
{
using ConcreteFunctionRef = conf::func_ref::function_ref<void()>;
using ConcreteFunctionRef = conf::fr::function_ref<void()>;
STATIC_REQUIRE(std::is_nothrow_copy_constructible_v<ConcreteFunctionRef>);
STATIC_REQUIRE(std::is_nothrow_copy_assignable_v<ConcreteFunctionRef>);
STATIC_REQUIRE(std::is_nothrow_move_constructible_v<ConcreteFunctionRef>);
Expand All @@ -27,7 +27,7 @@ TEST_CASE("Verify construction of function_ref", "[morpheus.functional.function_
{
WHEN("Constructing a function reference to the function")
{
conf::func_ref::function_ref<void()> functionView = testFunction;
conf::fr::function_ref<void()> functionView = testFunction;
THEN("Expect the function to be invocable by the function ref")
{
functionView();
Expand All @@ -45,7 +45,7 @@ TEST_CASE("Verify construction of function_ref", "[morpheus.functional.function_
WHEN("Constructing a function reference to the function")
{
TestForInvocable instance;
conf::func_ref::function_ref<void(int, int)> functionView = {conf::func_ref::nontype<&TestForInvocable::function>, instance};
conf::fr::function_ref<void(int, int)> functionView = {conf::fr::nontype<&TestForInvocable::function>, instance};
THEN("Expect the function to be invocable by the function ref")
{
functionView(0, 1);
Expand Down
Loading
Loading