From 1acf00138a5389e45c38da509a9335d5a8520577 Mon Sep 17 00:00:00 2001 From: Medusa Slockbower Date: Mon, 15 Dec 2025 13:20:08 -0500 Subject: [PATCH] - Setup EGL context for Wayland. Test window now opens as black rectangle. --- CMakeLists.txt | 12 +- cmake/opengl.cmake | 20 ++- cmake/wayland.cmake | 7 +- .../fennec/core/version.h | 36 ++++-- include/fennec/lang/detail/_type_traits.h | 7 ++ include/fennec/lang/type_traits.h | 19 +++ include/fennec/memory/pointers.h | 16 ++- .../platform/interface/display_server.h | 30 ++++- include/fennec/platform/interface/fwd.h | 2 + include/fennec/platform/interface/window.h | 21 +++- .../platform/linux/wayland/egl/context.h | 55 +++++++++ .../platform/linux/wayland/egl/surface.h | 53 ++++++++ include/fennec/platform/linux/wayland/fwd.h | 43 +++++++ .../fennec/platform/linux/wayland/server.h | 9 +- .../fennec/platform/linux/wayland/window.h | 5 +- include/fennec/platform/opengl/egl/context.h | 65 ++++++++++ .../fennec/platform/opengl/egl/fwd.h | 18 ++- include/fennec/platform/opengl/egl/surface.h | 58 +++++++++ .../fennec/renderers/interface/gfxcontext.h | 27 +++-- .../fennec/renderers/interface/gfxsurface.h | 60 +++++++++ include/fennec/renderers/opengl/glcontext.h | 54 +++++++++ include/fennec/rtti/type_registry.h | 10 +- include/fennec/string/string.h | 3 + source/platform/interface/platform.cpp | 2 +- source/platform/interface/window.cpp | 9 ++ source/platform/linux/wayland/egl/context.cpp | 38 ++++++ source/platform/linux/wayland/egl/surface.cpp | 46 +++++++ source/platform/linux/wayland/server.cpp | 42 ++++--- source/platform/linux/wayland/window.cpp | 32 +++-- source/platform/opengl/egl/context.cpp | 114 ++++++++++++++++++ source/platform/opengl/egl/surface.cpp | 55 +++++++++ source/renderers/opengl/glcontext.cpp | 28 +++++ test/CMakeLists.txt | 1 + test/tests/lang/test_metaprogramming.h | 61 ++++++++++ test/tests/test_lang.h | 9 +- test/tests/test_platform.h | 5 +- 36 files changed, 992 insertions(+), 80 deletions(-) rename test/tests/lang/test_sequences.h => include/fennec/core/version.h (66%) create mode 100644 include/fennec/platform/linux/wayland/egl/context.h create mode 100644 include/fennec/platform/linux/wayland/egl/surface.h create mode 100644 include/fennec/platform/linux/wayland/fwd.h create mode 100644 include/fennec/platform/opengl/egl/context.h rename source/core/log.cpp => include/fennec/platform/opengl/egl/fwd.h (84%) create mode 100644 include/fennec/platform/opengl/egl/surface.h create mode 100644 include/fennec/renderers/interface/gfxsurface.h create mode 100644 include/fennec/renderers/opengl/glcontext.h create mode 100644 source/platform/linux/wayland/egl/context.cpp create mode 100644 source/platform/linux/wayland/egl/surface.cpp create mode 100644 source/platform/opengl/egl/context.cpp create mode 100644 source/platform/opengl/egl/surface.cpp create mode 100644 source/renderers/opengl/glcontext.cpp create mode 100644 test/tests/lang/test_metaprogramming.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 784103a..0efe2ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,7 +84,9 @@ add_library(fennec STATIC # CORE ================================================================================================================= include/fennec/core/engine.h source/core/engine.cpp include/fennec/core/event.h source/core/event.cpp + include/fennec/core/logger.h source/core/logger.cpp + include/fennec/core/version.h include/fennec/core/system.h @@ -273,9 +275,9 @@ add_library(fennec STATIC # PLATFORM ============================================================================================================= include/fennec/platform/interface/fwd.h - include/fennec/platform/interface/platform.h source/platform/interface/platform.cpp include/fennec/platform/interface/display_server.h - include/fennec/platform/interface/window.h + include/fennec/platform/interface/platform.h source/platform/interface/platform.cpp + include/fennec/platform/interface/window.h source/platform/interface/window.cpp # GRAPHICS ============================================================================================================= @@ -284,11 +286,7 @@ add_library(fennec STATIC # EXTRA SOURCES ======================================================================================================== ${FENNEC_EXTRA_SOURCES} - source/platform/linux/wayland/window.cpp - source/platform/interface/window.cpp - include/fennec/core/logger.h - source/core/log.cpp - source/core/logger.cpp + ) add_dependencies(fennec metaprogramming fennec-dependencies) diff --git a/cmake/opengl.cmake b/cmake/opengl.cmake index da5e63e..012d7f7 100644 --- a/cmake/opengl.cmake +++ b/cmake/opengl.cmake @@ -16,19 +16,31 @@ # along with this program. If not, see . # ====================================================================================================================== +find_package(OpenGL) + if(FENNEC_GRAPHICS_WANT_EGL) find_package(OpenGL REQUIRED COMPONENTS EGL) - find_package(GLEW REQUIRED) message(STATUS "EGL Requested") -else() - find_package(OpenGL) - find_package(GLEW REQUIRED) + + fennec_add_link_libraries(OpenGL::EGL) + + fennec_add_sources( + include/fennec/platform/opengl/egl/fwd.h + include/fennec/platform/opengl/egl/context.h source/platform/opengl/egl/context.cpp + include/fennec/platform/opengl/egl/surface.h source/platform/opengl/egl/surface.cpp + ) endif() +find_package(GLEW REQUIRED) + if(TARGET OpenGL::GL AND TARGET GLEW::GLEW) message(STATUS "Found OpenGL: ${OPENGL_gl_LIBRARY}") fennec_add_link_libraries(OpenGL::GL GLEW::GLEW) fennec_add_definitions(FENNEC_GRAPHICS_OPENGL=1) + + fennec_add_sources( + include/fennec/renderers/opengl/glcontext.h source/renderers/opengl/glcontext.cpp + ) else() message(FATAL_ERROR "No Suitable OpenGL implementation found.") endif() \ No newline at end of file diff --git a/cmake/wayland.cmake b/cmake/wayland.cmake index 4d1d30b..2fc423d 100644 --- a/cmake/wayland.cmake +++ b/cmake/wayland.cmake @@ -109,8 +109,13 @@ macro(fennec_check_wayland) include/fennec/platform/linux/wayland/lib/loader.h source/platform/linux/wayland/lib/loader.cpp # Fennec Files - include/fennec/platform/linux/wayland/window.h + include/fennec/platform/linux/wayland/fwd.h include/fennec/platform/linux/wayland/server.h source/platform/linux/wayland/server.cpp + include/fennec/platform/linux/wayland/window.h source/platform/linux/wayland/window.cpp + + # EGL + include/fennec/platform/linux/wayland/egl/context.h source/platform/linux/wayland/egl/context.cpp + include/fennec/platform/linux/wayland/egl/surface.h source/platform/linux/wayland/egl/surface.cpp ) fennec_add_definitions( diff --git a/test/tests/lang/test_sequences.h b/include/fennec/core/version.h similarity index 66% rename from test/tests/lang/test_sequences.h rename to include/fennec/core/version.h index 9b213f5..caa39fe 100644 --- a/test/tests/lang/test_sequences.h +++ b/include/fennec/core/version.h @@ -16,23 +16,33 @@ // along with this program. If not, see . // ===================================================================================================================== -#ifndef FENNEC_TEST_LANG_SEQUENCES_H -#define FENNEC_TEST_LANG_SEQUENCES_H +/// +/// \file version.h +/// \brief +/// +/// +/// \details +/// \author Medusa Slockbower +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// -#include -namespace fennec::test +#ifndef FENNEC_CORE_VERSION_H +#define FENNEC_CORE_VERSION_H + +#include +#include + +namespace fennec { - inline void test_sequences() - { - static_assert(fennec::is_same_v, const_index_sequence<0, 1>>); - static_assert(fennec::is_same_v, const_index_sequence<0, 1, 2>>); - static_assert(fennec::is_same_v, const_index_sequence<0, 1, 2, 3>>); - - // TODO - } +struct version { + uint32_t major, minor, patch; + string str; +}; } -#endif // FENNEC_TEST_LANG_SEQUENCES_H +#endif // FENNEC_CORE_VERSION_H \ No newline at end of file diff --git a/include/fennec/lang/detail/_type_traits.h b/include/fennec/lang/detail/_type_traits.h index 183b7b2..3140897 100644 --- a/include/fennec/lang/detail/_type_traits.h +++ b/include/fennec/lang/detail/_type_traits.h @@ -133,6 +133,13 @@ namespace fennec::detail template auto _is_mappable(...) -> false_type; + + + template auto _ptr_conv(const volatile B*) -> true_type; + template auto _ptr_conv(const volatile void*) -> false_type; + + template auto _is_base_of(int) -> decltype(detail::_ptr_conv(static_cast(nullptr))); + template auto _is_base_of(...) -> false_type; } #endif // FENNEC_LANG_DETAIL_TYPE_TRAITS_H diff --git a/include/fennec/lang/type_traits.h b/include/fennec/lang/type_traits.h index d56703f..d1f8de8 100644 --- a/include/fennec/lang/type_traits.h +++ b/include/fennec/lang/type_traits.h @@ -790,6 +790,25 @@ template struct is_same : true_type {}; /// \tparam T1 second type to check template constexpr bool_t is_same_v = is_same {}; + +// fennec::is_base_of ===================================================================================================== + +/// +/// \brief Check if `Derived` has a base type of `Base` +/// +/// \details Checks if `Base` is a base type of `Derived` and stores it in `is_base_of::value` +/// \tparam Base base type to check +/// \tparam Derived derived type to check +template struct is_base_of : bool_constant< + is_class_v and is_class_v and decltype(detail::_is_base_of(0))::value +> {}; + +/// +/// \brief Shorthand for ```is_base_of::value``` +/// \tparam Base base type to check +/// \tparam Derived derived type to check +template constexpr bool_t is_base_of_v = is_base_of {}; + // fennec::is_complete ============================================================================================== /// diff --git a/include/fennec/memory/pointers.h b/include/fennec/memory/pointers.h index 866f8da..edbbdf4 100644 --- a/include/fennec/memory/pointers.h +++ b/include/fennec/memory/pointers.h @@ -128,7 +128,7 @@ public: /// /// \brief Default Constructor, if it owns a resource, it deletes it using `delete_t` constexpr ~unique_ptr() { - if(_handle) _delete(_handle); + reset(); } constexpr unique_ptr& operator=(const unique_ptr&) = delete; @@ -140,6 +140,20 @@ public: return *this; } + void reset(pointer_t ptr) { + if(_handle) { + _delete(_handle); + _handle = ptr; + } + } + + void reset(nullptr_t = nullptr) { + if(_handle) { + _delete(_handle); + _handle = nullptr; + } + } + pointer_t release() { pointer_t retval = _handle; _handle = nullptr; diff --git a/include/fennec/platform/interface/display_server.h b/include/fennec/platform/interface/display_server.h index 653d8b0..a46fd25 100644 --- a/include/fennec/platform/interface/display_server.h +++ b/include/fennec/platform/interface/display_server.h @@ -40,6 +40,16 @@ namespace fennec { +class display_server; + +/// +/// \brief Interface resembling the API for a display server of an operating system, e.g. Linux X11/Wayland +/// +/// \details An implementation for a display server should inherit `display_server_base` and note the following: +/// +/// For a server type `DisplayT`; any `gfxcontext` implementation that wishes to implement `DisplayT` +/// must provide a constructor that accepts a `DisplayT*`. `DisplayT::ctx_registry::register_type` must then be +/// called for the `gfxcontext` implementation. class display_server : public type_registry { // Typedefs/Constants/Enums ============================================================================================ public: @@ -99,6 +109,9 @@ enum feature_ : uint32_t { return features.test(feature); } + gfxcontext* get_gfx_context() { + return gfx_context; + } virtual window* create_window(const window::config& conf) = 0; @@ -110,16 +123,31 @@ enum feature_ : uint32_t { virtual void disconnect() = 0; virtual bool connected() const = 0; + virtual void dispatch() = 0; + + virtual void* get_native_handle() = 0; + protected: featureset_t features; object_pool windows; + gfxcontext* gfx_context; FENNEC_RTTI_CLASS_ENABLE() { - } }; +template +class display_server_base : public display_server, public type_registry { +public: + display_server_base(fennec::platform* p) + : display_server(p) { + } + + using ctx_registry = type_registry; + using window_t = WindowT; +}; + } #endif // FENNEC_PLATFORM_INTERFACE_DISPLAY_SERVER_H \ No newline at end of file diff --git a/include/fennec/platform/interface/fwd.h b/include/fennec/platform/interface/fwd.h index 07d4151..e387921 100644 --- a/include/fennec/platform/interface/fwd.h +++ b/include/fennec/platform/interface/fwd.h @@ -25,7 +25,9 @@ namespace fennec class platform; class display_server; // The display server used by the OS, e.g. WDM, Wayland, X11, etc. +class gfxcontext; // Handles the GFX API context of a display server, e.g. OpenGL, Vulkan, etc. class window; // Handles window surfaces of the display protocol +class gfxsurface; // Handles the GFX surface of a window for a specific gfxcontext } diff --git a/include/fennec/platform/interface/window.h b/include/fennec/platform/interface/window.h index 9c96c14..843f712 100644 --- a/include/fennec/platform/interface/window.h +++ b/include/fennec/platform/interface/window.h @@ -105,6 +105,10 @@ public: window* get_parent() const; + const ivec2& get_size() const { return cfg.size; } + int get_width() const { return cfg.size.x; } + int get_height() const { return cfg.size.y; } + bool get_flag(uint8_t flag) const { return cfg.flags.test(flag); } bool is_always_on_top() const { return get_flag(flag_always_on_top); } @@ -120,6 +124,7 @@ public: bool is_running() const { return get_flag(flag_running); } bool is_no_focus() const { return get_flag(flag_no_focus); } + virtual bool set_flag(uint8_t flag, bool val) = 0; bool set_always_on_top(bool val) { return set_flag(flag_always_on_top, val); } @@ -135,13 +140,27 @@ public: virtual void show() = 0; virtual void hide() = 0; - virtual void dispatch() = 0; + virtual void begin_frame(); + virtual void end_frame(); + + virtual void* get_native_handle() = 0; protected: display_server* const server; const size_t id; config cfg; window* root; + gfxsurface* gfx_surface; +}; + +template +class window_base : public window { +public: + window_base(display_server* display, size_t id, const config& conf) + : window(display, id, conf) { + } + + using display_t = DisplayT; }; } diff --git a/include/fennec/platform/linux/wayland/egl/context.h b/include/fennec/platform/linux/wayland/egl/context.h new file mode 100644 index 0000000..7fc588f --- /dev/null +++ b/include/fennec/platform/linux/wayland/egl/context.h @@ -0,0 +1,55 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +/// +/// \file context.h +/// \brief +/// +/// +/// \details +/// \author Medusa Slockbower +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// + + +#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_EGL_CONTEXT_H +#define FENNEC_PLATFORM_LINUX_WAYLAND_EGL_CONTEXT_H + +#include + +namespace fennec +{ + +class wayland_eglcontext : public eglcontext { +public: + explicit wayland_eglcontext(display_server* display); + ~wayland_eglcontext(); + + gfxsurface* create_surface(window* window) override; + +private: + FENNEC_RTTI_CLASS_ENABLE(eglcontext) { + wayland_server::ctx_registry::register_type(); + } +}; + +} + +#endif // FENNEC_PLATFORM_LINUX_WAYLAND_EGL_CONTEXT_H diff --git a/include/fennec/platform/linux/wayland/egl/surface.h b/include/fennec/platform/linux/wayland/egl/surface.h new file mode 100644 index 0000000..d605fef --- /dev/null +++ b/include/fennec/platform/linux/wayland/egl/surface.h @@ -0,0 +1,53 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +/// +/// \file surface.h +/// \brief +/// +/// +/// \details +/// \author Medusa Slockbower +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// + + +#ifndef LATFORM_LINUX_WAYLAND_EGL_SURFACE_H +#define LATFORM_LINUX_WAYLAND_EGL_SURFACE_H + +#include +#include + +namespace fennec +{ + +class wayland_eglsurface : public eglsurface { +public: + wayland_eglsurface(wayland_window* win, eglcontext* ctx); + ~wayland_eglsurface(); + + void resize(const ivec2& size) override; + +private: +}; + +} + +#endif // LATFORM_LINUX_WAYLAND_EGL_SURFACE_H \ No newline at end of file diff --git a/include/fennec/platform/linux/wayland/fwd.h b/include/fennec/platform/linux/wayland/fwd.h new file mode 100644 index 0000000..5b871a5 --- /dev/null +++ b/include/fennec/platform/linux/wayland/fwd.h @@ -0,0 +1,43 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +/// +/// \file fwd.h +/// \brief +/// +/// +/// \details +/// \author Medusa Slockbower +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// + + +#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H +#define FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H + +namespace fennec +{ + +class wayland_server; +class wayland_window; + +} + +#endif // FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H \ No newline at end of file diff --git a/include/fennec/platform/linux/wayland/server.h b/include/fennec/platform/linux/wayland/server.h index 63c0215..afa8319 100644 --- a/include/fennec/platform/linux/wayland/server.h +++ b/include/fennec/platform/linux/wayland/server.h @@ -31,6 +31,7 @@ #ifndef FENNEC_PLATFORM_LINUX_WAYLAND_SERVER_H #define FENNEC_PLATFORM_LINUX_WAYLAND_SERVER_H +#include #include // forward defs to avoid flooding global namespace @@ -46,7 +47,9 @@ struct xdg_wm_base; namespace fennec { -class wayland_server : public display_server { +/// +/// \brief Class for handling the Wayland Display Server +class wayland_server : public display_server_base { public: explicit wayland_server(fennec::platform* p); ~wayland_server() override; @@ -55,8 +58,12 @@ public: void disconnect() override; bool connected() const override; + void dispatch() override; + window* create_window(const window::config& conf) override; + void* get_native_handle() override { return display; } + private: wl_display* display; wl_registry* registry; diff --git a/include/fennec/platform/linux/wayland/window.h b/include/fennec/platform/linux/wayland/window.h index a2eac44..cb1ef7a 100644 --- a/include/fennec/platform/linux/wayland/window.h +++ b/include/fennec/platform/linux/wayland/window.h @@ -31,6 +31,7 @@ #ifndef FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H #define FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H +#include #include struct wl_array; @@ -44,7 +45,7 @@ struct xdg_toplevel; namespace fennec { -class wayland_window : public window { +class wayland_window : public window_base { public: wayland_window(display_server* server, uint32_t id, const config& cfg); ~wayland_window(); @@ -52,7 +53,7 @@ public: void show() override; void hide() override; - void dispatch() override; + void* get_native_handle() override; bool set_flag(uint8_t flag, bool val) override; diff --git a/include/fennec/platform/opengl/egl/context.h b/include/fennec/platform/opengl/egl/context.h new file mode 100644 index 0000000..db4f9ba --- /dev/null +++ b/include/fennec/platform/opengl/egl/context.h @@ -0,0 +1,65 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +/// +/// \file context.h +/// \brief +/// +/// +/// \details +/// \author Medusa Slockbower +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// + + +#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_OPENGL_EGLCONTEXT_H +#define FENNEC_PLATFORM_LINUX_WAYLAND_OPENGL_EGLCONTEXT_H + +#include + +#include +#include + +namespace fennec +{ + +class eglcontext : public glcontext { +public: + eglcontext(display_server* display); + ~eglcontext(); + + bool is_valid() override; + +private: + EGLDisplay _egldisplay; + EGLContext _eglcontext; + EGLConfig _eglconfig; + EGLint _eglvmajor, _eglvminor, _eglctype; + cstring _extensions; + + FENNEC_RTTI_CLASS_ENABLE(glcontext) { + } + + friend class eglsurface; +}; + +} + +#endif // FENNEC_PLATFORM_LINUX_WAYLAND_OPENGL_EGLCONTEXT_H diff --git a/source/core/log.cpp b/include/fennec/platform/opengl/egl/fwd.h similarity index 84% rename from source/core/log.cpp rename to include/fennec/platform/opengl/egl/fwd.h index 89ce690..1a01ced 100644 --- a/source/core/log.cpp +++ b/include/fennec/platform/opengl/egl/fwd.h @@ -17,7 +17,7 @@ // ===================================================================================================================== /// -/// \file log.h +/// \file fwd.h /// \brief /// /// @@ -26,4 +26,18 @@ /// /// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) /// -/// \ No newline at end of file +/// + + +#ifndef FENNEC_PLATFORM_OPENGL_EGL_FWD_H +#define FENNEC_PLATFORM_OPENGL_EGL_FWD_H + +namespace fennec +{ + +class eglcontext; +class eglsurface; + +} + +#endif // FENNEC_PLATFORM_OPENGL_EGL_FWD_H \ No newline at end of file diff --git a/include/fennec/platform/opengl/egl/surface.h b/include/fennec/platform/opengl/egl/surface.h new file mode 100644 index 0000000..a9c0a80 --- /dev/null +++ b/include/fennec/platform/opengl/egl/surface.h @@ -0,0 +1,58 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +/// +/// \file surface.h +/// \brief +/// +/// +/// \details +/// \author Medusa Slockbower +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// + + +#ifndef FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H +#define FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H + +#include + +#include +#include + +namespace fennec +{ + +class eglsurface : public gfxsurface { +public: + eglsurface(fennec::window* win, eglcontext* ctx, EGLNativeWindowType eglwindow); + ~eglsurface(); + + void make_current() override; + void swap() override; + +protected: + EGLNativeWindowType _eglwindow; + EGLSurface _eglsurface; +}; + +} // fennec + +#endif // FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H \ No newline at end of file diff --git a/include/fennec/renderers/interface/gfxcontext.h b/include/fennec/renderers/interface/gfxcontext.h index 8356208..1b064ff 100644 --- a/include/fennec/renderers/interface/gfxcontext.h +++ b/include/fennec/renderers/interface/gfxcontext.h @@ -31,7 +31,9 @@ #ifndef FENNEC_RENDERERS_INTERFACE_GFXCONTEXT_H #define FENNEC_RENDERERS_INTERFACE_GFXCONTEXT_H +#include #include +#include #include #include #include @@ -55,22 +57,31 @@ public: using handle_t = uint32_t; - struct version_t { - uint8_t major, minor, patch; - string str; - }; - - const version_t version; gfxresourcepool resources; + gfxcontext(display_server* display) + : display(display) + , version(0, 0, 0, string("")) { + } + + virtual ~gfxcontext() = default; + gfxcontext& operator=(const gfxcontext&) = delete; gfxcontext& operator=(gfxcontext&&) = delete; - virtual gfxpass* create_pass() = 0; + virtual bool is_valid() = 0; + + virtual gfxsurface* create_surface(window* window) = 0; + + virtual gfxpass* create_pass() = 0; + virtual const version& get_version() const { return version; }; protected: + display_server* display; + version version; -private: + FENNEC_RTTI_CLASS_ENABLE() { + } }; } diff --git a/include/fennec/renderers/interface/gfxsurface.h b/include/fennec/renderers/interface/gfxsurface.h new file mode 100644 index 0000000..6cbbfd6 --- /dev/null +++ b/include/fennec/renderers/interface/gfxsurface.h @@ -0,0 +1,60 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +/// +/// \file gfxcontext.h +/// \brief +/// +/// +/// \details +/// \author Medusa Slockbower +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// + + +#ifndef FENNEC_RENDERERS_INTERFACE_GFXSURFACE_H +#define FENNEC_RENDERERS_INTERFACE_GFXSURFACE_H + +#include + +namespace fennec +{ + +class gfxsurface { +public: + virtual ~gfxsurface() = default; + + gfxsurface(window* win, gfxcontext* ctx) + : window(win), context(ctx) { + } + + virtual void make_current() = 0; + virtual void swap() = 0; + + virtual void resize(const ivec2& size) = 0; + +protected: + window* window; + gfxcontext* context; +}; + +} + +#endif // FENNEC_RENDERERS_INTERFACE_GFXSURFACE_H \ No newline at end of file diff --git a/include/fennec/renderers/opengl/glcontext.h b/include/fennec/renderers/opengl/glcontext.h new file mode 100644 index 0000000..b16e352 --- /dev/null +++ b/include/fennec/renderers/opengl/glcontext.h @@ -0,0 +1,54 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +/// +/// \file glcontext.h +/// \brief +/// +/// +/// \details +/// \author Medusa Slockbower +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// + + +#ifndef FENNEC_RENDERERS_OPENGL_GLCONTEXT_H +#define FENNEC_RENDERERS_OPENGL_GLCONTEXT_H +#include + +namespace fennec +{ + +class glcontext : public gfxcontext { +public: + explicit glcontext(display_server* display) + : gfxcontext(display) { + } + + gfxpass* create_pass() override; + +private: + FENNEC_RTTI_CLASS_ENABLE(gfxcontext) { + } +}; + +} + +#endif // FENNEC_RENDERERS_OPENGL_GLCONTEXT_H diff --git a/include/fennec/rtti/type_registry.h b/include/fennec/rtti/type_registry.h index 719e2ec..4203d3c 100644 --- a/include/fennec/rtti/type_registry.h +++ b/include/fennec/rtti/type_registry.h @@ -30,7 +30,11 @@ #ifndef FENNEC_RTTI_TYPE_REGISTRY_H #define FENNEC_RTTI_TYPE_REGISTRY_H + #include + +#include + #include namespace fennec @@ -89,12 +93,12 @@ public: using entrylist_t = priority_queue; - template + template requires(is_base_of_v) static void register_type(size_t priority = 0) { _global_list().emplace( priority, - type::get(), - _constructor_helper + type::get(), + _constructor_helper ); } diff --git a/include/fennec/string/string.h b/include/fennec/string/string.h index c877348..934b4b5 100644 --- a/include/fennec/string/string.h +++ b/include/fennec/string/string.h @@ -84,6 +84,9 @@ public: /// \brief Buffer Constructor, wraps the provided C-Style string, appending a null-terminator if not present /// \param str the buffer to wrap /// \tparam n the number of characters in the buffer including the null-terminator, if present + /// + /// \details This constructor is explicit because we want to be explicit about when we are allocating memory for + /// a string. template explicit constexpr _string(const char (&str)[n]) : _str(str[n - 1] != '\0' ? n + 1 : n) { diff --git a/source/platform/interface/platform.cpp b/source/platform/interface/platform.cpp index 65696e3..31e9e20 100644 --- a/source/platform/interface/platform.cpp +++ b/source/platform/interface/platform.cpp @@ -46,7 +46,7 @@ void platform::initialize() { } void platform::shutdown() { - + display.reset(); } } diff --git a/source/platform/interface/window.cpp b/source/platform/interface/window.cpp index c2d2d2f..6713043 100644 --- a/source/platform/interface/window.cpp +++ b/source/platform/interface/window.cpp @@ -30,6 +30,7 @@ #include #include +#include namespace fennec { @@ -38,4 +39,12 @@ window* window::get_parent() const { return server->get_window(cfg.parent); } +void window::begin_frame() { + gfx_surface->make_current(); +} + +void window::end_frame() { + gfx_surface->swap(); +} + } diff --git a/source/platform/linux/wayland/egl/context.cpp b/source/platform/linux/wayland/egl/context.cpp new file mode 100644 index 0000000..2b26186 --- /dev/null +++ b/source/platform/linux/wayland/egl/context.cpp @@ -0,0 +1,38 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + + +#include +#include +#include + +namespace fennec +{ + +wayland_eglcontext::wayland_eglcontext(display_server* display) + : eglcontext(display) { +} + +wayland_eglcontext::~wayland_eglcontext() { +} + +gfxsurface* wayland_eglcontext::create_surface(window* window) { + return new wayland_eglsurface(static_cast(window), this); +} + +} diff --git a/source/platform/linux/wayland/egl/surface.cpp b/source/platform/linux/wayland/egl/surface.cpp new file mode 100644 index 0000000..ac4cbdd --- /dev/null +++ b/source/platform/linux/wayland/egl/surface.cpp @@ -0,0 +1,46 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + + +#include +#include +#include + +namespace fennec +{ + +wayland_eglsurface::wayland_eglsurface(wayland_window* win, eglcontext* ctx) + : eglsurface(win, ctx, + reinterpret_cast( + wl_egl_window_create( + static_cast(win->get_native_handle()), win->get_size().x, win->get_size().y + ) + ) + ) { + +} + +wayland_eglsurface::~wayland_eglsurface() { + wl_egl_window_destroy(reinterpret_cast(_eglwindow)); +} + +void wayland_eglsurface::resize(const ivec2& size) { + wl_egl_window_resize(reinterpret_cast(_eglwindow), size.x, size.y, 0, 0); +} + +} diff --git a/source/platform/linux/wayland/server.cpp b/source/platform/linux/wayland/server.cpp index 3475f62..cf32573 100644 --- a/source/platform/linux/wayland/server.cpp +++ b/source/platform/linux/wayland/server.cpp @@ -16,30 +16,19 @@ // along with this program. If not, see . // ===================================================================================================================== -/// -/// \file wayland_server.h -/// \brief -/// -/// -/// \details -/// \author Medusa Slockbower -/// -/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) -/// -/// - #include #include #include #include #include #include +#include namespace fennec { wayland_server::wayland_server(fennec::platform* p) - : display_server(p) + : display_server_base(p) , display(nullptr), registry(nullptr), compositor(nullptr), seat(nullptr), fifo(false) { // load shared lib @@ -91,6 +80,22 @@ void wayland_server::connect() { disconnect(); return; } + + auto contexts = ctx_registry::get_type_list(); + while (not contexts.empty()) { + const auto& ctx = contexts.front(); + gfx_context = ctx.ctor(this); + + if (gfx_context->is_valid()) { + break; + } else { + delete gfx_context; + gfx_context = nullptr; + contexts.pop(); + } + } + + assertf(gfx_context != nullptr, "Failed to create graphics context."); } void wayland_server::disconnect() { @@ -100,6 +105,10 @@ void wayland_server::disconnect() { return; } + // delete the gfx context + delete gfx_context; + + // check compositor if (compositor) { wl_compositor_destroy(compositor); @@ -115,7 +124,8 @@ void wayland_server::disconnect() { wl_display_disconnect(display); // clear vars - display = nullptr; + gfx_context = nullptr; + display = nullptr; registry = nullptr; compositor = nullptr; seat = nullptr; @@ -126,6 +136,10 @@ bool wayland_server::connected() const { return display != nullptr; } +void wayland_server::dispatch() { + wl_display_dispatch_pending(display); +} + window* wayland_server::create_window(const window::config& conf) { size_t id = windows.insert(new wayland_window(this, windows.next_id(), conf)); return windows[id]; diff --git a/source/platform/linux/wayland/window.cpp b/source/platform/linux/wayland/window.cpp index 95fe10e..2c02fb7 100644 --- a/source/platform/linux/wayland/window.cpp +++ b/source/platform/linux/wayland/window.cpp @@ -16,29 +16,18 @@ // along with this program. If not, see . // ===================================================================================================================== -/// -/// \file window.h -/// \brief -/// -/// -/// \details -/// \author Medusa Slockbower -/// -/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) -/// -/// - #include #include #include #include #include +#include using namespace fennec; wayland_window::wayland_window(display_server* server, uint32_t id, const config& cfg) - : window(server, id, cfg) + : window_base(server, id, cfg) , surface(nullptr) , xdgsurface(nullptr) { @@ -99,10 +88,12 @@ void wayland_window::show() { cfg.flags.set(flag_visible); cfg.flags.set(flag_running); + + gfx_surface = wl_server->get_gfx_context()->create_surface(this); } void wayland_window::hide() { - if (not is_visible()) { + if (not is_running()) { return; } @@ -134,9 +125,8 @@ void wayland_window::hide() { cfg.flags.clear(flag_running); } -void wayland_window::dispatch() { - wayland_server* wl_server = static_cast(server); - wl_display_dispatch(wl_server->display); +void* wayland_window::get_native_handle() { + return surface; } bool wayland_window::set_flag(uint8_t, bool) { @@ -156,5 +146,11 @@ void wayland_window::listen_xdg_surface_configure(void*, xdg_surface* xdg, uint3 void wayland_window::listen_xdg_toplevel_configure(void*, xdg_toplevel*, int32_t, int32_t, wl_array*) {} void wayland_window::listen_xdg_toplevel_configure_bounds(void*, xdg_toplevel*, int32_t, int32_t) {} -void wayland_window::listen_xdg_toplevel_close(void*, xdg_toplevel*) {} + +void wayland_window::listen_xdg_toplevel_close(void* data, xdg_toplevel*) { + wayland_window* window = static_cast(data); + window->hide(); + +} + void wayland_window::listen_xdg_toplevel_capabilities(void*, xdg_toplevel*, wl_array*) {} diff --git a/source/platform/opengl/egl/context.cpp b/source/platform/opengl/egl/context.cpp new file mode 100644 index 0000000..e6d02b6 --- /dev/null +++ b/source/platform/opengl/egl/context.cpp @@ -0,0 +1,114 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +#include +#include + +#include + +namespace fennec +{ + +static const cstring& egl_translate_type(EGLint type) { + static constexpr cstring opengl = "OpenGL"; + static constexpr cstring gles = "GLES"; + static constexpr cstring openvg = "OpenVG"; // this should never be used + switch (type) { + default: + case EGL_OPENGL_API: return opengl; + case EGL_OPENGL_ES_API: return gles; + case EGL_OPENVG_API: return openvg; + } + +} + +eglcontext::eglcontext(display_server* display) + : glcontext(display) { + + EGLint config_attrs[] = { + EGL_SURFACE_TYPE, + EGL_WINDOW_BIT, + + EGL_RENDERABLE_TYPE, + EGL_OPENGL_BIT, // 4 + EGL_NONE + }; + + EGLint context_attrs[] = { + EGL_NONE + }; + + // Get the EGL display from the display server + _egldisplay = eglGetDisplay(display->get_native_handle()); + assertf(_egldisplay, "Failed to connect to egl display."); + + // Initialize EGL + assertf(eglInitialize(_egldisplay, &_eglvmajor, &_eglvminor), "Failed to initialize egl."); + + // Attempt to bind to OpenGL or GLES + if (not eglBindAPI(EGL_OPENGL_API)) { + config_attrs[4] = EGL_OPENGL_ES_BIT; + assertf(eglBindAPI(EGL_OPENGL_ES_API), "Failed to find suitable OpenGL API."); + } + + // Select a configuration + EGLint n; + assertf(eglChooseConfig(_egldisplay, config_attrs, &_eglconfig, 1, &n), "Failed to find suitable OpenGL configuration."); + + // Create a context from the configuration and display + _eglcontext = eglCreateContext(_egldisplay, _eglconfig, EGL_NO_CONTEXT, context_attrs); + assertf(_eglcontext, "Failed to create OpenGL Context."); + + // Make the created context the current context to query some info + eglMakeCurrent(_egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, _eglcontext); + + // Query version information + eglQueryContext(_egldisplay, _eglcontext, EGL_CONTEXT_CLIENT_TYPE, &_eglctype); + glGetIntegerv(GL_MAJOR_VERSION, &_eglvmajor); + glGetIntegerv(GL_MINOR_VERSION, &_eglvminor); + + // Set the version fields + version.major = _eglvmajor; + version.minor = _eglvminor; + version.patch = 0; + version.str = format("{} v{}.{}", egl_translate_type(_eglctype), _eglvmajor, _eglvminor); +} + +eglcontext::~eglcontext() { + eglMakeCurrent(_egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroyContext(_egldisplay, _eglcontext); + eglTerminate(_egldisplay); + eglReleaseThread(); + + _egldisplay = nullptr; + _eglconfig = nullptr; + _eglcontext = nullptr; + _eglvmajor = 0; + _eglvminor = 0; + + version.major = 0; + version.minor = 0; + version.patch = 0; + version.str = ""; +} + +bool eglcontext::is_valid() { + return _egldisplay != nullptr; +} + +} diff --git a/source/platform/opengl/egl/surface.cpp b/source/platform/opengl/egl/surface.cpp new file mode 100644 index 0000000..06a3889 --- /dev/null +++ b/source/platform/opengl/egl/surface.cpp @@ -0,0 +1,55 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +#include +#include + +namespace fennec { + +eglsurface::eglsurface(fennec::window* win, eglcontext* ctx, EGLNativeWindowType eglwindow) + : gfxsurface(win, ctx) + , _eglwindow(eglwindow) + , _eglsurface(nullptr) { + + assertf(_eglwindow, "Failed to acquire EGL window!"); + + _eglsurface = eglCreateWindowSurface( + ctx->_egldisplay, + ctx->_eglconfig, + _eglwindow, + nullptr + ); + assertf(_eglsurface, "Failed to create EGL surface!"); +} + +eglsurface::~eglsurface() { + eglcontext* ctx = static_cast(context); + eglDestroySurface(ctx->_egldisplay, _eglsurface); +} + +void eglsurface::make_current() { + eglcontext* ctx = static_cast(context); + eglMakeCurrent(ctx->_egldisplay, _eglsurface, _eglsurface, ctx->_eglcontext); +} + +void eglsurface::swap() { + eglcontext* ctx = static_cast(context); + eglSwapBuffers(ctx->_egldisplay, _eglsurface); +} + +} // fennec \ No newline at end of file diff --git a/source/renderers/opengl/glcontext.cpp b/source/renderers/opengl/glcontext.cpp new file mode 100644 index 0000000..9c92492 --- /dev/null +++ b/source/renderers/opengl/glcontext.cpp @@ -0,0 +1,28 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +#include + +namespace fennec +{ + +gfxpass* glcontext::create_pass() { + return nullptr; +} + +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3a6ac09..ca0d23a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,6 +6,7 @@ set(CMAKE_C_STANDARD 23) add_executable(fennec-test main.cpp + tests/lang/test_metaprogramming.h ) target_compile_definitions(fennec-test PUBLIC FENNEC_TEST_CWD="${CMAKE_SOURCE_DIR}/bin/${FENNEC_BUILD_NAME}" diff --git a/test/tests/lang/test_metaprogramming.h b/test/tests/lang/test_metaprogramming.h new file mode 100644 index 0000000..407f324 --- /dev/null +++ b/test/tests/lang/test_metaprogramming.h @@ -0,0 +1,61 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +/// +/// \file test_metaprogramming.h +/// \brief +/// +/// +/// \details +/// \author Medusa Slockbower +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// + + +#ifndef FENNEC_TEST_LANG_METAPROGRAMMING_H +#define FENNEC_TEST_LANG_METAPROGRAMMING_H + +#include "../../test.h" + +namespace fennec::test +{ + +struct metaprogramming_test { + +}; + +struct metaprogramming_test_base { + +}; + +struct metaprogramming_test_derived : metaprogramming_test_base { + +}; + +inline void fennec_test_lang_metaprogramming() { + + fennec_test_run((is_base_of_v), true); + fennec_test_run((is_base_of_v), false); + +} + +} + +#endif // FENNEC_TEST_LANG_METAPROGRAMMING_H \ No newline at end of file diff --git a/test/tests/test_lang.h b/test/tests/test_lang.h index 0b4cfb3..146ce20 100644 --- a/test/tests/test_lang.h +++ b/test/tests/test_lang.h @@ -22,12 +22,12 @@ #include "lang/test_bits.h" #include "lang/test_conditional_types.h" #include "lang/test_hashing.h" +#include "lang/test_metaprogramming.h" namespace fennec::test { - inline void fennec_test_lang() - { + inline void fennec_test_lang() { fennec_test_subheader("bit tests"); fennec_test_spacer(2); fennec_test_lang_bits(); @@ -36,6 +36,11 @@ namespace fennec::test fennec_test_subheader("hashing tests"); fennec_test_spacer(2); fennec_test_lang_hashing(); + fennec_test_spacer(3); + + fennec_test_subheader("metaprogramming tests"); + fennec_test_spacer(2); + fennec_test_lang_metaprogramming(); // TODO } diff --git a/test/tests/test_platform.h b/test/tests/test_platform.h index 397b3dd..3650732 100644 --- a/test/tests/test_platform.h +++ b/test/tests/test_platform.h @@ -48,7 +48,10 @@ inline void fennec_test_platform() { window->show(); while (window->is_running()) { - window->dispatch(); + window->begin_frame(); + window->end_frame(); + + display->dispatch(); } window->hide();