- Refactor on platform implementation. See comment in interface/platform.h for more info

This commit is contained in:
2025-07-27 22:44:32 -04:00
parent d02a51fd8d
commit 8124ea2ae5
45 changed files with 4650 additions and 826 deletions

View File

@@ -56,6 +56,7 @@ add_library(fennec STATIC
# CORE ================================================================================================================= # CORE =================================================================================================================
include/fennec/core/engine.h source/core/engine.cpp include/fennec/core/engine.h source/core/engine.cpp
include/fennec/core/event.h source/core/event.cpp
# CONTAINERS =========================================================================================================== # CONTAINERS ===========================================================================================================
@@ -83,6 +84,7 @@ add_library(fennec STATIC
include/fennec/lang/limits.h include/fennec/lang/limits.h
include/fennec/lang/numeric_transforms.h include/fennec/lang/numeric_transforms.h
include/fennec/lang/sequences.h include/fennec/lang/sequences.h
include/fennec/lang/startup.h
include/fennec/lang/type_identity.h include/fennec/lang/type_identity.h
include/fennec/lang/type_operators.h include/fennec/lang/type_operators.h
include/fennec/lang/type_sequences.h include/fennec/lang/type_sequences.h
@@ -117,6 +119,11 @@ add_library(fennec STATIC
include/fennec/memory/detail/_ptr_traits.h include/fennec/memory/detail/_ptr_traits.h
# CONCURRENCY ==========================================================================================================
include/fennec/concurrency/thread.h
include/fennec/concurrency/mutex.h
include/fennec/concurrency/atomic.h
# DEBUG ================================================================================================================ # DEBUG ================================================================================================================
source/debug/assert_impl.cpp source/debug/assert_impl.cpp
@@ -156,6 +163,7 @@ add_library(fennec STATIC
include/fennec/math/detail/_types.h include/fennec/math/detail/_types.h
include/fennec/math/detail/_vector_traits.h include/fennec/math/detail/_vector_traits.h
# FPROC ================================================================================================================ # FPROC ================================================================================================================
# Strings # Strings
@@ -169,23 +177,18 @@ add_library(fennec STATIC
include/fennec/fproc/filesystem/file.h source/fproc/filesystem/file.cpp include/fennec/fproc/filesystem/file.h source/fproc/filesystem/file.cpp
include/fennec/fproc/filesystem/path.h source/fproc/filesystem/path.cpp include/fennec/fproc/filesystem/path.h source/fproc/filesystem/path.cpp
# PLATFORM =============================================================================================================
include/fennec/platform/interface/fwd.h
include/fennec/platform/interface/dialog.h # PLATFORM =============================================================================================================
include/fennec/platform/interface/displaydev.h source/platform/interface/displaydev.cpp
include/fennec/platform/interface/gfxcontext.h source/platform/interface/gfxcontext.cpp include/fennec/platform/interface/fwd.h
include/fennec/platform/interface/gfxsurface.h source/platform/interface/gfxsurface.cpp
include/fennec/platform/interface/platform.h source/platform/interface/platform.cpp include/fennec/platform/interface/platform.h source/platform/interface/platform.cpp
include/fennec/platform/interface/window.h source/platform/interface/window.cpp include/fennec/platform/interface/display.h
include/fennec/platform/interface/gfxcontext.h
# EXTRA SOURCES ========================================================================================================
${FENNEC_EXTRA_SOURCES} ${FENNEC_EXTRA_SOURCES}
include/fennec/platform/interface/inputdevice.h
include/fennec/core/event.h
source/core/event.cpp
include/fennec/concurrency/thread.h
include/fennec/concurrency/mutex.h
include/fennec/concurrency/atomic.h
) )
add_dependencies(fennec metaprogramming) add_dependencies(fennec metaprogramming)

View File

@@ -42,7 +42,5 @@ if(FENNEC_GRAPHICS_WANT_EGL)
list(APPEND FENNEC_LINK_LIBRARIES OpenGL::EGL) list(APPEND FENNEC_LINK_LIBRARIES OpenGL::EGL)
list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_GRAPHICS_EGL=1) list(APPEND FENNEC_COMPILE_DEFINITIONS FENNEC_GRAPHICS_EGL=1)
list(APPEND FENNEC_EXTRA_SOURCES list(APPEND FENNEC_EXTRA_SOURCES
include/fennec/platform/opengl/egl/context.h
include/fennec/platform/opengl/egl/surface.h
) )
endif() endif()

View File

@@ -22,3 +22,8 @@
list(APPEND FENNEC_COMPILE_DEFINITIONS list(APPEND FENNEC_COMPILE_DEFINITIONS
FENNEC_PLATFORM_UNIX=1 FENNEC_PLATFORM_UNIX=1
) )
# extra source files
list(APPEND FENNEC_EXTRA_SOURCES
include/fennec/platform/unix/platform.h source/platform/unix/platform.cpp
)

View File

@@ -43,6 +43,11 @@ macro(fennec_check_wayland)
if( (WAYLAND_CLIENT_INCLUDE_DIR AND WAYLAND_CLIENT_LIBRARY) if( (WAYLAND_CLIENT_INCLUDE_DIR AND WAYLAND_CLIENT_LIBRARY)
AND (WAYLAND_EGL_INCLUDE_DIR AND WAYLAND_EGL_LIBRARY)) AND (WAYLAND_EGL_INCLUDE_DIR AND WAYLAND_EGL_LIBRARY))
message(STATUS "Found Wayland: ${WAYLAND_CLIENT_LIBRARY}")
include("${FENNEC_SOURCE_DIR}/cmake/xkb.cmake")
fennec_check_xkb()
get_filename_component( get_filename_component(
WAYLAND_CLIENT_LIBRARY WAYLAND_CLIENT_LIBRARY
${WAYLAND_CLIENT_LIBRARY} ${WAYLAND_CLIENT_LIBRARY}
@@ -64,11 +69,10 @@ macro(fennec_check_wayland)
include/fennec/platform/linux/wayland/lib/sym.h include/fennec/platform/linux/wayland/lib/sym.h
include/fennec/platform/linux/wayland/lib/wayland-client.h include/fennec/platform/linux/wayland/lib/wayland-client.h
include/fennec/platform/linux/wayland/lib/wayland-util.h include/fennec/platform/linux/wayland/lib/wayland-util.h
include/fennec/platform/linux/wayland/lib/dyn.h source/platform/linux/wayland/lib/dyn.cpp include/fennec/platform/linux/wayland/lib/loader.h source/platform/linux/wayland/lib/loader.cpp
# Fennec Files # Fennec Files
include/fennec/platform/linux/wayland/displaydev.h source/platform/linux/wayland/displaydev.cpp include/fennec/platform/linux/wayland/display.h source/platform/linux/wayland/display.cpp
include/fennec/platform/linux/wayland/window.h source/platform/linux/wayland/window.cpp
) )
list(APPEND FENNEC_COMPILE_DEFINITIONS list(APPEND FENNEC_COMPILE_DEFINITIONS

59
cmake/xkb.cmake Normal file
View File

@@ -0,0 +1,59 @@
# ======================================================================================================================
# 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 <https://www.gnu.org/licenses/>.
# ======================================================================================================================
# this script finds libxkbcommon and dependencies
macro(fennec_check_xkb)
set(XKB_FOUND 0)
find_path(
XKB_INCLUDE_DIR
NAMES xkbcommon/xkbcommon.h
)
find_library(
XKB_LIBRARY
NAMES xkbcommon libxkbcommon
)
if(XKB_INCLUDE_DIR AND XKB_LIBRARY)
message(STATUS "Found XKB: ${XKB_LIBRARY}")
get_filename_component(
XKB_LIBRARY
${XKB_LIBRARY}
NAME
)
set(XKB_FOUND 1)
list(APPEND FENNEC_EXTRA_SOURCES
# Dynamic Library Files
include/fennec/platform/linux/xkb/lib/fwd.h
include/fennec/platform/linux/xkb/lib/sym.h
include/fennec/platform/linux/xkb/lib/xkbcommon.h
include/fennec/platform/linux/xkb/lib/loader.h source/platform/linux/xkb/lib/loader.cpp
# Fennec files
)
list(APPEND FENNEC_COMPILE_DEFINITIONS
FENNEC_HAS_XKB=1
FENNEC_LIB_XKB="${XKB_LIBRARY}"
)
endif()
endmacro()

View File

@@ -42,9 +42,13 @@ namespace fennec
/// ///
/// \brief wrapper for fixed size arrays /// \brief wrapper for fixed size arrays
/// ///
/// \details | | | /// \details
/// |-|-| /// | Property | Value |
/// | | | /// |----------|-------------------------|
/// | stable | \emoji heavy_check_mark |
/// | access | \f$O(1)\f$ |
/// | space | \f$O(N)\f$ |
///
/// \tparam ValueT value type /// \tparam ValueT value type
/// \tparam ElemV number of elements /// \tparam ElemV number of elements
template<typename ValueT, size_t ElemV> template<typename ValueT, size_t ElemV>

View File

@@ -38,6 +38,19 @@
namespace fennec namespace fennec
{ {
///
///
/// \brief wrapper for dynamically sized arrays
/// \details
/// | Property | Value |
/// |-----------|--------------|
/// | stable | \emoji anger |
/// | access | \f$O(1)\f$ |
/// | insertion | \f$O(N)\f$ |
/// | deletion | \f$O(N)\f$ |
/// | space | \f$O(N)\f$ |
///
/// \tparam TypeT value type
template<class TypeT, class Alloc = allocator<TypeT>> template<class TypeT, class Alloc = allocator<TypeT>>
class dynarray { class dynarray {
public: public:
@@ -123,12 +136,14 @@ public:
return _size == 0; return _size == 0;
} }
constexpr TypeT& operator[](size_t i) { constexpr TypeT& operator[](int i) {
assertd(i < _size, "Array Out of Bounds"); return _alloc.data()[i]; assertd(i >= 0 and size_t(i) < _size, "Array Out of Bounds");
return _alloc.data()[i];
} }
constexpr const TypeT& operator[](size_t i) const { constexpr const TypeT& operator[](int i) const {
assertd(i < _size, "Array Out of Bounds"); return _alloc.data()[i]; assertd(i >= 0 and size_t(i) < _size, "Array Out of Bounds");
return _alloc.data()[i];
} }
constexpr TypeT* begin() { return _alloc.data(); } constexpr TypeT* begin() { return _alloc.data(); }

View File

@@ -16,6 +16,18 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
///
/// \file list.h
/// \brief List of elements
///
///
/// \details
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///
#ifndef FENNEC_CONTAINERS_LIST_H #ifndef FENNEC_CONTAINERS_LIST_H
#define FENNEC_CONTAINERS_LIST_H #define FENNEC_CONTAINERS_LIST_H
@@ -26,11 +38,22 @@
#include <fennec/math/common.h> #include <fennec/math/common.h>
#include <fennec/platform/interface/window.h>
namespace fennec namespace fennec
{ {
///
///
/// \brief wrapper for lists of elements
/// \details
/// | Property | Value |
/// |-----------|--------------|
/// | stable | \emoji anger |
/// | access | \f$O(1)\f$ |
/// | insertion | \f$O(1)\f$ |
/// | deletion | \f$O(1)\f$ |
/// | space | \f$O(N)\f$ |
///
/// \tparam TypeT value type
template<class TypeT, class Alloc = allocator<TypeT>> template<class TypeT, class Alloc = allocator<TypeT>>
struct list { struct list {
public: public:
@@ -41,63 +64,7 @@ public:
class iterator; class iterator;
private: private:
struct node { struct node;
optional<value_t> data;
size_t prev, next;
constexpr node()
: data()
, prev(npos)
, next(npos) {
}
constexpr node(size_t p, size_t n)
: data()
, prev(p)
, next(n) {
}
constexpr node(size_t p, size_t n, value_t&& val)
: data(fennec::forward<value_t>(val))
, prev(p)
, next(n) {
}
constexpr ~node() = default;
constexpr void clear() {
data = nullopt;
prev = npos;
next = npos;
}
};
size_t _next(size_t n) {
return _table[n].next;
}
size_t _prev(size_t n) {
return _table[n].prev;
}
size_t _walk(size_t i) {
size_t n = _root;
if (n == npos) return n;
while (i > 0 && n != npos) {
n = _next(n); --i;
}
return n;
}
size_t _next_free() {
if (not _freed.empty()) {
size_t n = _freed.back();
_freed.pop_back();
return n;
}
_table[_size];
return _size;
}
public: public:
using elem_t = node; using elem_t = node;
@@ -113,19 +80,45 @@ public:
constexpr bool empty() const { return _root == npos; } constexpr bool empty() const { return _root == npos; }
constexpr value_t& operator[](int i) { constexpr value_t& operator[](int i) {
assertd(i >= 0, "Index out of Bounds"); assertd(i >= 0 && size_t(i) < _size, "Index out of Bounds");
size_t n = _walk(i); size_t n = _walk(i);
assertd(n != npos, "Index out of Bounds"); assertd(n != npos, "Index out of Bounds");
return *_table[n].data; return *_table[n].data;
} }
constexpr const value_t& operator[](int i) const { constexpr const value_t& operator[](int i) const {
assertd(i >= 0, "Index out of Bounds"); assertd(i >= 0 && size_t(i) < _size, "Index out of Bounds");
size_t n = _walk(i); size_t n = _walk(i);
assertd(n != npos, "Index out of Bounds"); assertd(n != npos, "Index out of Bounds");
return *_table[n].data; return *_table[n].data;
} }
void insert(const iterator& it, value_t&& x) {
if (size() == capacity()) {
_expand();
}
size_t n = it._n;
size_t p = _next_free();
_table[p].data = fennec::forward<value_t>(x);
if (n == npos) {
if (empty()) {
_root = p;
_table[p].next = npos;
_table[p].prev = npos;
} else {
_table[p].prev = n;
_table[p].next = npos;
_last = n;
}
return;
}
_table[p].next = n;
_table[p].prev = _prev(n);
_table[n].prev = p;
++_size;
}
void insert(size_t i, value_t&& x) { void insert(size_t i, value_t&& x) {
assert(i <= size(), "Index out of Bounds"); assert(i <= size(), "Index out of Bounds");
if (size() == capacity()) { if (size() == capacity()) {
@@ -142,13 +135,14 @@ public:
} }
_table[p].data = fennec::forward<value_t>(x); _table[p].data = fennec::forward<value_t>(x);
if (i == size()) { if (i == size()) {
_table[p].prev = n;
_last = n;
}
else {
_table[p].next = n; _table[p].next = n;
_table[p].prev = _prev(n); _table[p].prev = _prev(n);
_table[n].prev = p; _table[n].prev = p;
} }
else {
_table[p].prev = n;
}
++_size; ++_size;
} }
@@ -239,6 +233,10 @@ public:
return *(_list->_table[_n].data); return *(_list->_table[_n].data);
} }
constexpr value_t* operator->() {
return &*(_list->_table[_n].data);
}
constexpr bool operator==(const iterator& it) { constexpr bool operator==(const iterator& it) {
return _list == it._list and _n == it._n; return _list == it._list and _n == it._n;
} }
@@ -274,7 +272,65 @@ private:
friend class iterator; friend class iterator;
constexpr void _expand() { constexpr void _expand() {
_table.reallocate(_table.capacity() * 2); _table.reallocate(fennec::max(_table.capacity(), size_t(1)) * 2);
}
struct node {
optional<value_t> data;
size_t prev, next;
constexpr node()
: data()
, prev(npos)
, next(npos) {
}
constexpr node(size_t p, size_t n)
: data()
, prev(p)
, next(n) {
}
constexpr node(size_t p, size_t n, value_t&& val)
: data(fennec::forward<value_t>(val))
, prev(p)
, next(n) {
}
constexpr ~node() = default;
constexpr void clear() {
data = nullopt;
prev = npos;
next = npos;
}
};
size_t _next(size_t n) {
return _table[n].next;
}
size_t _prev(size_t n) {
return _table[n].prev;
}
size_t _walk(size_t i) {
size_t n = _root;
if (n == npos) return n;
while (i > 0 && n != npos) {
n = _next(n); --i;
}
return n;
}
size_t _next_free() {
if (not _freed.empty()) {
size_t n = _freed.back();
_freed.pop_back();
return n;
}
_table[_size];
return _size;
} }
}; };

View File

@@ -16,15 +16,13 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H #ifndef FENNEC_LANG_STARTUP_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H #define FENNEC_LANG_STARTUP_H
namespace fennec // Helper for running a function before main()
{ #define STATIC_CONSTRUCTOR(f) \
inline static void f(void); \
struct f##_t_ { inline f##_t_(void) { f(); } }; inline static f##_t_ f##_; \
inline static void f(void)
class wayland_display; #endif // FENNEC_LANG_STARTUP_H
class wayland_window;
}
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H

View File

@@ -1,22 +0,0 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_PLATFORM_INTERFACE_DIALOG_H
#define FENNEC_PLATFORM_INTERFACE_DIALOG_H
#endif // FENNEC_PLATFORM_INTERFACE_DIALOG_H

View File

@@ -16,18 +16,16 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
#ifndef FENNEC_PLATFORM_INTERFACE_DISPLAYDEV_H #ifndef FENNEC_PLATFORM_INTERFACE_DISPLAY_H
#define FENNEC_PLATFORM_INTERFACE_DISPLAYDEV_H #define FENNEC_PLATFORM_INTERFACE_DISPLAY_H
#include <fennec/lang/types.h>
#include <fennec/platform/interface/fwd.h> #include <fennec/platform/interface/fwd.h>
#include <fennec/platform/interface/window.h>
namespace fennec namespace fennec
{ {
/// class display
/// \brief Interface for display management
class displaydev
{ {
public: public:
struct pixel_format { struct pixel_format {
@@ -40,7 +38,7 @@ public:
}; };
virtual bool connected() const = 0; virtual bool connected() const = 0;
virtual ~displaydev() = default; virtual ~display() = default;
virtual window* create_window() = 0; virtual window* create_window() = 0;
@@ -63,9 +61,20 @@ protected:
gfxcontext* _context; gfxcontext* _context;
config _config; config _config;
displaydev(platform* platform); explicit display(platform* platform)
: _platform(platform)
, _context(nullptr)
, _config {
.format = {
.depth = 24,
.r = 8,
.g = 8,
.b = 8,
}
} {
}
}; };
} }
#endif // FENNEC_PLATFORM_INTERFACE_DISPLAYDEV_H #endif // FENNEC_PLATFORM_INTERFACE_DISPLAY_H

View File

@@ -16,18 +16,19 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
#ifndef FENNEC_PLATFORM_INTERFACE_FORWARD_H #ifndef FENNEC_PLATFORM_INTERFACE_FWD_H
#define FENNEC_PLATFORM_INTERFACE_FORWARD_H #define FENNEC_PLATFORM_INTERFACE_FWD_H
namespace fennec namespace fennec
{ {
class platform; class platform; // Handles OS level functionality
class window; class display; // Handles display protocols
class displaydev; class window; // Handles window surfaces of the display protocol
class gfxcontext; class inputdevice; // Handles input devices
class gfxsurface; class gfxcontext; // Handle Driver Contexts, i.e. EGL, WGL, VkWayland, etc.
class gfxsurface; // Handle
} }
#endif // FENNEC_PLATFORM_INTERFACE_FORWARD_H #endif // FENNEC_PLATFORM_INTERFACE_FWD_H

View File

@@ -19,25 +19,4 @@
#ifndef FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H #ifndef FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H
#define FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H #define FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H
#include <fennec/platform/interface/fwd.h>
namespace fennec
{
class gfxcontext {
public:
template<typename TypeT>
TypeT* get_device() {
return static_cast<TypeT*>(_device);
}
protected:
gfxcontext(displaydev* device);
private:
displaydev* _device;
};
}
#endif // FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H #endif // FENNEC_PLATFORM_INTERFACE_GFXCONTEXT_H

View File

@@ -19,50 +19,118 @@
#ifndef FENNEC_PLATFORM_INTERFACE_PLATFORM_H #ifndef FENNEC_PLATFORM_INTERFACE_PLATFORM_H
#define FENNEC_PLATFORM_INTERFACE_PLATFORM_H #define FENNEC_PLATFORM_INTERFACE_PLATFORM_H
#include <fennec/containers/list.h>
#include <fennec/fproc/strings/cstring.h>
#include <fennec/fproc/strings/string.h> #include <fennec/fproc/strings/string.h>
#include <fennec/platform/interface/fwd.h> #include <fennec/platform/interface/fwd.h>
/*
* This class should resemble the target platform as a whole. By itself, it will represent the OS, i.e. Linux, Windows,
* etc.
*
* We want everything to be type agnostic from the top level down
*
* The general structure is:
* Platform -> Display Protocol -> GFX API -> GFX Context
* -> Window -> GFX Surface
* -> Input Protocol
*
* For example, let's say we are on Linux, using Wayland and OpenGL with EGL
* EGL will know that we are using OpenGL, but won't know we are using Wayland
* OpenGL won't know or care that Linux, EGL, or Wayland is being used
* Wayland won't know or care that OpenGL or EGL is being used
* Linux won't know or care that OpenGL, Wayland, or EGL are in use
*
* Why do we want everything to be type agnostic?
* Let's say someone wants to add a DirectX extension for Windows. They shouldn't have to touch the
* Windows platform class or Win32 display manager class at all to write the implementation. This
* allows the extension to remain entirely independent of the engine which allows you to just drop
* it into your project, and it will work as expected. This should also keep version compatibility
* issues to the absolute minimum.
*
* We can allow this by notifying the platform of all available drivers at startup and give them priorities.
* Then, the platform will load the highest priority first, only falling back when a driver fails to load or is
* deemed incompatible for whatever reason.
*
*
*/
namespace fennec namespace fennec
{ {
class platform { class platform {
public: public:
using shared_object = struct shared_object; using shared_object = struct shared_object;
using function_pointer = void (*)(void); using symbol = void*;
using global = void*;
struct shared_lib { const string name;
shared_object* _lib;
const cstring _name;
};
struct config {
};
// Functions with default implementations
virtual string get_environment_variable(const cstring& var);
// Pure Virtual Functions
virtual displaydev* get_display() = 0;
virtual shared_object* load_object(const cstring& file) = 0;
virtual void unload_object(shared_object* obj) = 0;
virtual function_pointer find_symbol(shared_object* hndl, const cstring& name) = 0;
virtual global find_global(shared_object* hndl, const cstring& name) = 0;
protected:
platform();
virtual ~platform() = default; virtual ~platform() = default;
// Dynamically linked objects
virtual shared_object* load_object(const cstring& file) = 0;
virtual void unload_object(shared_object* obj) = 0;
virtual symbol find_symbol(shared_object* obj, const cstring& name) = 0;
virtual void initialize(); // Initialize Drivers and Contexts
virtual void shutdown(); // Close Drivers and Contexts
display* get_display() { return _display; }
protected:
explicit platform(const cstring& name)
: name(name) {
auto& globals = _get_globals();
assertf(globals.singleton == nullptr, "Conflicting Platform Definitions.");
globals.singleton = this;
}
virtual void load_display();
display* _display;
private: private:
config _config; platform(const platform&) = delete;
// Static Stuff ========================================================================================================
public:
using display_ctor = display* (*)(platform*);
using input_ctor = inputdevice* (*)(display*);
using gfxctx_ctor = gfxcontext* (*)(display*);
template<typename ctor>
struct driver {
int priority;
ctor constructor;
};
static void add_driver(display_ctor ctor, int priority);
static void add_driver(input_ctor ctor, int priority);
static void add_driver(gfxctx_ctor ctor, int priority);
private:
struct global_context {
platform* singleton;
list<driver<display_ctor>> displays;
list<driver<input_ctor>> inputs;
list<driver<gfxctx_ctor>> graphics;
global_context()
: singleton(nullptr) {
}
};
static global_context& _get_globals();
public:
static const global_context& get_globals() {
return _get_globals();
}
static platform* instance() {
return _get_globals().singleton;
}
}; };
} }

View File

@@ -22,7 +22,6 @@
#include <fennec/containers/optional.h> #include <fennec/containers/optional.h>
#include <fennec/fproc/strings/string.h> #include <fennec/fproc/strings/string.h>
#include <fennec/platform/interface/fwd.h> #include <fennec/platform/interface/fwd.h>
#include <fennec/platform/interface/gfxsurface.h>
namespace fennec namespace fennec
{ {
@@ -84,11 +83,11 @@ public:
return _config->flags & flags_modal; return _config->flags & flags_modal;
} }
displaydev* get_display() { display* get_display() {
return _display; return _display;
} }
const displaydev* get_display() const { const display* get_display() const {
return _display; return _display;
} }
@@ -139,9 +138,9 @@ public:
protected: protected:
virtual ~window() = default; virtual ~window() = default;
window(displaydev* display, window* parent); window(display* display, window* parent);
displaydev* _display; display* _display;
window* _parent; window* _parent;
optional<config> _config; optional<config> _config;
gfxsurface* _context; gfxsurface* _context;

View File

@@ -18,42 +18,20 @@
#ifndef FENNEC_PLATFORM_LINUX_PLATFORM_H #ifndef FENNEC_PLATFORM_LINUX_PLATFORM_H
#define FENNEC_PLATFORM_LINUX_PLATFORM_H #define FENNEC_PLATFORM_LINUX_PLATFORM_H
#include <fennec/platform/unix/platform.h>
#include <fennec/containers/set.h>
#include <fennec/platform/interface/displaydev.h>
#include <fennec/platform/interface/platform.h>
namespace fennec namespace fennec
{ {
class linux_platform : public platform { class linux_platform : public unix_platform {
public: public:
enum display_ : int_t { linux_platform()
display_none = -1, : unix_platform("linux") {
display_x11 = 0, }
display_wayland,
};
linux_platform(); void initialize() override;
~linux_platform() override;
shared_object* load_object(const cstring& file) override; void shutdown() override;
void unload_object(shared_object* obj) override;
function_pointer find_symbol(shared_object* hndl, const cstring& name) override;
global find_global(shared_object* hndl, const cstring& name) override;
displaydev* get_display() override;
private:
displaydev* _display;
int_t _display_driver;
void _runtime_client_checks();
void _find_display_driver();
void _runtime_server_checks();
}; };
} }

View File

@@ -19,47 +19,31 @@
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H #ifndef FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H #define FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
#include <fennec/containers/list.h> #include <fennec/platform/interface/display.h>
#include <fennec/fproc/strings/cstring.h> #include <fennec/platform/linux/wayland/lib/fwd.h>
#include <fennec/platform/interface/displaydev.h>
#include <fennec/platform/linux/platform.h>
#include <fennec/platform/linux/wayland/fwd.h>
#include <fennec/platform/linux/wayland/lib/wayland-client.h>
namespace fennec namespace fennec
{ {
class wayland_display : public displaydev { class wayland_display : public display {
public: public:
wayland_display(linux_platform* platform); explicit wayland_display(platform* platform);
wayland_display(linux_platform* platform, const cstring& drv);
~wayland_display() override; ~wayland_display() override;
bool connected() const override; bool connected() const override;
window* create_window() override; window* create_window() override;
inline wl_display* get_handle() { return _handle; }
inline wl_registry* get_registry() { return _registry; }
inline wl_compositor* get_compositor() { return _compositor; }
inline wl_shell* get_shell() { return _shell; }
inline wl_seat* get_seat() { return _seat; }
inline wl_pointer* get_pointer() { return _pointer; }
inline wl_keyboard* get_keyboard() { return _keyboard; }
inline wl_shm* get_shm() { return _shm; }
private: private:
wl_display* _handle; wl_display* _handle;
wl_registry* _registry; wl_registry* _registry;
wl_compositor* _compositor; wl_compositor* _compositor;
wl_shell* _shell; wl_shell* _shell;
wl_seat* _seat; wl_seat* _seat;
wl_pointer* _pointer;
wl_keyboard* _keyboard;
wl_shm* _shm; wl_shm* _shm;
list<wayland_window*> _windows; bool _fifo;
void cleanup();
static void listen_global(void*, wl_registry*, uint32_t, const char*, uint32_t); static void listen_global(void*, wl_registry*, uint32_t, const char*, uint32_t);
static void listen_global_remove(void*, wl_registry*, uint32_t); static void listen_global_remove(void*, wl_registry*, uint32_t);

View File

@@ -19,6 +19,31 @@
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_LIB_FWD_H #ifndef FENNEC_PLATFORM_LINUX_WAYLAND_LIB_FWD_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_LIB_FWD_H #define FENNEC_PLATFORM_LINUX_WAYLAND_LIB_FWD_H
/*
* Copyright © 2008 Kristian Høgsberg
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <fennec/lang/types.h> #include <fennec/lang/types.h>
#include <stdarg.h> #include <stdarg.h>

View File

@@ -19,7 +19,7 @@
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_DYN_H #ifndef FENNEC_PLATFORM_LINUX_WAYLAND_DYN_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_DYN_H #define FENNEC_PLATFORM_LINUX_WAYLAND_DYN_H
#include <fennec/platform/linux/platform.h> #include <fennec/platform/interface/platform.h>
namespace fennec namespace fennec
{ {
@@ -27,8 +27,8 @@ namespace fennec
namespace libwayland namespace libwayland
{ {
bool load_symbols(linux_platform* platform); bool load_symbols(platform* platform);
void unload_symbols(linux_platform* platform); void unload_symbols(platform* platform);
} }

View File

@@ -19,6 +19,31 @@
#include <fennec/lang/types.h> #include <fennec/lang/types.h>
#include <fennec/platform/linux/wayland/lib/fwd.h> #include <fennec/platform/linux/wayland/lib/fwd.h>
/*
* Copyright © 2008 Kristian Høgsberg
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef FENNEC_LIB #ifndef FENNEC_LIB
#define FENNEC_LIB(...) #define FENNEC_LIB(...)
#endif #endif

View File

@@ -19,10 +19,10 @@
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_SYM_DEF_H #ifndef FENNEC_PLATFORM_LINUX_WAYLAND_SYM_DEF_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_SYM_DEF_H #define FENNEC_PLATFORM_LINUX_WAYLAND_SYM_DEF_H
#define FENNEC_LIB(name) inline bool FENNEC_HAS_LIB_##name = false; #define FENNEC_LIB(name) extern bool FENNEC_HAS_LIB_##name;
#define FENNEC_SYMBOL(ret, fn, ...) using sym_##fn = ret(*)(__VA_ARGS__); \ #define FENNEC_SYMBOL(ret, fn, ...) using sym_##fn = ret(*)(__VA_ARGS__); \
inline sym_##fn fn = nullptr; extern sym_##fn fn;
#define FENNEC_GLOBAL(type, name) inline type* name = nullptr; #define FENNEC_GLOBAL(type, name) extern type* name;
#include <fennec/platform/linux/wayland/lib/sym.h> #include <fennec/platform/linux/wayland/lib/sym.h>
#include <stdint.h> #include <stdint.h>

View File

@@ -1,60 +0,0 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
#define FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
#include <fennec/platform/interface/window.h>
#include <fennec/platform/linux/wayland/fwd.h>
#include <fennec/platform/linux/wayland/lib/fwd.h>
namespace fennec
{
class wayland_window : window {
public:
bool running() override;
void configure(const config& config) override;
bool initialize(bool modal) override;
bool shutdown() override;
bool set_title(const cstring& title) override;
bool set_title(const string& title) override;
bool set_width(size_t w) override;
bool set_height(size_t h) override;
bool set_size(size_t w, size_t h) override;
bool set_fullscreen_mode(fullscreen_mode mode) override;
bool set_resizable(bool e) override;
bool grab_keyboard(bool e) override;
bool grab_mouse(bool e) override;
bool block_screensaver(bool e) override;
wayland_window(wayland_display* display, wayland_window* parent);
~wayland_window() override;
private:
wl_surface* _surface;
wl_shell_surface* _shell;
wl_callback* _callback;
gfxcontext* _context;
};
}
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H

View File

@@ -0,0 +1,215 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_PLATFORM_LINUX_XKB_LIB_FWD_H
#define FENNEC_PLATFORM_LINUX_XKB_LIB_FWD_H
#include <fennec/lang/types.h>
/*
* Copyright © 2009-2012 Daniel Stone
* Copyright © 2012 Intel Corporation
* Copyright © 2012 Ran Benita
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Author: Daniel Stone <daniel@fooishbar.org>
*/
struct xkb_context;
struct xkb_keymap;
struct xkb_state;
struct xkb_rule_names;
typedef uint32_t xkb_keycode_t;
typedef uint32_t xkb_keysym_t;
typedef uint32_t xkb_layout_index_t;
typedef uint32_t xkb_layout_mask_t;
typedef uint32_t xkb_level_index_t;
typedef uint32_t xkb_mod_index_t;
typedef uint32_t xkb_mod_mask_t;
typedef uint32_t xkb_led_index_t;
typedef uint32_t xkb_led_mask_t;
/**
* The iterator used by xkb_keymap_key_for_each().
*
* @sa xkb_keymap_key_for_each
* @memberof xkb_keymap
* @since 0.3.1
*/
typedef void
(*xkb_keymap_key_iter_t)(struct xkb_keymap *keymap, xkb_keycode_t key,
void *data);
/** Flags for xkb_keysym_from_name(). */
enum xkb_keysym_flags {
/** Do not apply any flags. */
XKB_KEYSYM_NO_FLAGS = 0,
/** Find keysym by case-insensitive search. */
XKB_KEYSYM_CASE_INSENSITIVE = (1 << 0)
};
/** Flags for context creation. */
enum xkb_context_flags {
/** Do not apply any context flags. */
XKB_CONTEXT_NO_FLAGS = 0,
/** Create this context with an empty include path. */
XKB_CONTEXT_NO_DEFAULT_INCLUDES = (1 << 0),
/**
* Don't take RMLVO names from the environment.
*
* @since 0.3.0
*/
XKB_CONTEXT_NO_ENVIRONMENT_NAMES = (1 << 1),
/**
* Disable the use of secure_getenv for this context, so that privileged
* processes can use environment variables. Client uses at their own risk.
*
* @since 1.5.0
*/
XKB_CONTEXT_NO_SECURE_GETENV = (1 << 2)
};
/** Specifies a logging level. */
enum xkb_log_level {
XKB_LOG_LEVEL_CRITICAL = 10, /**< Log critical internal errors only. */
XKB_LOG_LEVEL_ERROR = 20, /**< Log all errors. */
XKB_LOG_LEVEL_WARNING = 30, /**< Log warnings and errors. */
XKB_LOG_LEVEL_INFO = 40, /**< Log information, warnings, and errors. */
XKB_LOG_LEVEL_DEBUG = 50 /**< Log everything. */
};
/** Flags for keymap compilation. */
enum xkb_keymap_compile_flags {
/** Do not apply any flags. */
XKB_KEYMAP_COMPILE_NO_FLAGS = 0
};
/** The possible keymap formats. */
enum xkb_keymap_format {
/** The current/classic XKB text format, as generated by xkbcomp -xkb. */
XKB_KEYMAP_FORMAT_TEXT_V1 = 1
};
/** Specifies the direction of the key (press / release). */
enum xkb_key_direction {
XKB_KEY_UP, /**< The key was released. */
XKB_KEY_DOWN /**< The key was pressed. */
};
/**
* Modifier and layout types for state objects. This enum is bitmaskable,
* e.g. (XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED) is valid to
* exclude locked modifiers.
*
* In XKB, the DEPRESSED components are also known as 'base'.
*/
enum xkb_state_component {
/** Depressed modifiers, i.e. a key is physically holding them. */
XKB_STATE_MODS_DEPRESSED = (1 << 0),
/** Latched modifiers, i.e. will be unset after the next non-modifier
* key press. */
XKB_STATE_MODS_LATCHED = (1 << 1),
/** Locked modifiers, i.e. will be unset after the key provoking the
* lock has been pressed again. */
XKB_STATE_MODS_LOCKED = (1 << 2),
/** Effective modifiers, i.e. currently active and affect key
* processing (derived from the other state components).
* Use this unless you explicitly care how the state came about. */
XKB_STATE_MODS_EFFECTIVE = (1 << 3),
/** Depressed layout, i.e. a key is physically holding it. */
XKB_STATE_LAYOUT_DEPRESSED = (1 << 4),
/** Latched layout, i.e. will be unset after the next non-modifier
* key press. */
XKB_STATE_LAYOUT_LATCHED = (1 << 5),
/** Locked layout, i.e. will be unset after the key provoking the lock
* has been pressed again. */
XKB_STATE_LAYOUT_LOCKED = (1 << 6),
/** Effective layout, i.e. currently active and affects key processing
* (derived from the other state components).
* Use this unless you explicitly care how the state came about. */
XKB_STATE_LAYOUT_EFFECTIVE = (1 << 7),
/** LEDs (derived from the other state components). */
XKB_STATE_LEDS = (1 << 8)
};
/**
* Match flags for xkb_state_mod_indices_are_active() and
* xkb_state_mod_names_are_active(), specifying the conditions for a
* successful match. XKB_STATE_MATCH_NON_EXCLUSIVE is bitmaskable with
* the other modes.
*/
enum xkb_state_match {
/** Returns true if any of the modifiers are active. */
XKB_STATE_MATCH_ANY = (1 << 0),
/** Returns true if all of the modifiers are active. */
XKB_STATE_MATCH_ALL = (1 << 1),
/** Makes matching non-exclusive, i.e. will not return false if a
* modifier not specified in the arguments is active. */
XKB_STATE_MATCH_NON_EXCLUSIVE = (1 << 16)
};
enum xkb_consumed_mode {
/**
* This is the mode defined in the XKB specification and used by libX11.
*
* A modifier is consumed if and only if it *may affect* key translation.
*
* For example, if `Control+Alt+<Backspace>` produces some assigned keysym,
* then when pressing just `<Backspace>`, `Control` and `Alt` are consumed,
* even though they are not active, since if they *were* active they would
* have affected key translation.
*/
XKB_CONSUMED_MODE_XKB,
/**
* This is the mode used by the GTK+ toolkit.
*
* The mode consists of the following two independent heuristics:
*
* - The currently active set of modifiers, excluding modifiers which do
* not affect the key (as described for @ref XKB_CONSUMED_MODE_XKB), are
* considered consumed, if the keysyms produced when all of them are
* active are different from the keysyms produced when no modifiers are
* active.
*
* - A single modifier is considered consumed if the keysyms produced for
* the key when it is the only active modifier are different from the
* keysyms produced when no modifiers are active.
*/
XKB_CONSUMED_MODE_GTK
};
#endif // FENNEC_PLATFORM_LINUX_XKB_LIB_FWD_H

View File

@@ -16,15 +16,22 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
#include <fennec/platform/interface/gfxcontext.h> #ifndef FENNEC_PLATFORM_LINUX_XKB_DYN_H
#define FENNEC_PLATFORM_LINUX_XKB_DYN_H
#include <fennec/platform/interface/platform.h>
namespace fennec namespace fennec
{ {
gfxcontext::gfxcontext(displaydev* device) namespace libxkbcommon
: _device(device) { {
bool load_symbols(platform* platform);
void unload_symbols(platform* platform);
} }
} }
#endif // FENNEC_PLATFORM_LINUX_XKB_DYN_H

View File

@@ -0,0 +1,142 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
/*
* Copyright © 2009-2012 Daniel Stone
* Copyright © 2012 Intel Corporation
* Copyright © 2012 Ran Benita
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Author: Daniel Stone <daniel@fooishbar.org>
*/
#include <stdio.h>
#include <fennec/platform/linux/xkb/lib/fwd.h>
#ifndef FENNEC_LIB
#define FENNEC_LIB(...)
#endif
#ifndef FENNEC_SYMBOL
#define FENNEC_SYMBOL(...)
#endif
#ifndef FENNEC_GLOBAL
#define FENNEC_GLOBAL(...)
#endif
FENNEC_LIB(XKB);
FENNEC_SYMBOL(int, xkb_keysym_get_name, xkb_keysym_t keysym, char *buffer, size_t size);
FENNEC_SYMBOL(xkb_keysym_t, xkb_keysym_from_name, const char *name, enum xkb_keysym_flags flags);
FENNEC_SYMBOL(int, xkb_keysym_to_utf8, xkb_keysym_t keysym, char *buffer, size_t size);
FENNEC_SYMBOL(uint32_t, xkb_keysym_to_utf32, xkb_keysym_t keysym);
FENNEC_SYMBOL(xkb_keysym_t, xkb_utf32_to_keysym, uint32_t ucs);
FENNEC_SYMBOL(xkb_keysym_t, xkb_keysym_to_upper, xkb_keysym_t ks);
FENNEC_SYMBOL(xkb_keysym_t, xkb_keysym_to_lower, xkb_keysym_t ks);
FENNEC_SYMBOL(struct xkb_context*, xkb_context_new, enum xkb_context_flags flags);
FENNEC_SYMBOL(struct xkb_context*, xkb_context_ref, struct xkb_context *context);
FENNEC_SYMBOL(void, xkb_context_unref, struct xkb_context *context);
FENNEC_SYMBOL(void, xkb_context_set_user_data, struct xkb_context *context, void *user_data);
FENNEC_SYMBOL(void*, xkb_context_get_user_data, struct xkb_context *context);
FENNEC_SYMBOL(int, xkb_context_include_path_append, struct xkb_context *context, const char *path);
FENNEC_SYMBOL(int, xkb_context_include_path_append_default, struct xkb_context *context);
FENNEC_SYMBOL(int, xkb_context_include_path_reset_defaults, struct xkb_context *context);
FENNEC_SYMBOL(void, xkb_context_include_path_clear, struct xkb_context *context);
FENNEC_SYMBOL(unsigned int, xkb_context_num_include_paths, struct xkb_context *context);
FENNEC_SYMBOL(const char*, xkb_context_include_path_get, struct xkb_context *context, unsigned int index);
FENNEC_SYMBOL(void, xkb_context_set_log_level, struct xkb_context *context, enum xkb_log_level level);
FENNEC_SYMBOL(enum xkb_log_level, xkb_context_get_log_level, struct xkb_context *context);
FENNEC_SYMBOL(void, xkb_context_set_log_verbosity, struct xkb_context *context, int verbosity);
FENNEC_SYMBOL(int, xkb_context_get_log_verbosity, struct xkb_context *context);
FENNEC_SYMBOL(void, xkb_context_set_log_fn, struct xkb_context *context, void (*log_fn)(struct xkb_context *context, enum xkb_log_level level, const char *format, va_list args));
FENNEC_SYMBOL(struct xkb_keymap*, xkb_keymap_new_from_names, struct xkb_context *context, const struct xkb_rule_names *names, enum xkb_keymap_compile_flags flags);
FENNEC_SYMBOL(struct xkb_keymap*, xkb_keymap_new_from_file, struct xkb_context *context, FILE *file, enum xkb_keymap_format format, enum xkb_keymap_compile_flags flags);
FENNEC_SYMBOL(struct xkb_keymap*, xkb_keymap_new_from_string, struct xkb_context *context, const char *string, enum xkb_keymap_format format, enum xkb_keymap_compile_flags flags);
FENNEC_SYMBOL(struct xkb_keymap*, xkb_keymap_new_from_buffer, struct xkb_context *context, const char *buffer, size_t length, enum xkb_keymap_format format, enum xkb_keymap_compile_flags flags);
FENNEC_SYMBOL(struct xkb_keymap*, xkb_keymap_ref, struct xkb_keymap *keymap);
FENNEC_SYMBOL(void, xkb_keymap_unref, struct xkb_keymap *keymap);
FENNEC_SYMBOL(char*, xkb_keymap_get_as_string, struct xkb_keymap *keymap, enum xkb_keymap_format format);
FENNEC_SYMBOL(xkb_keycode_t, xkb_keymap_min_keycode, struct xkb_keymap *keymap);
FENNEC_SYMBOL(xkb_keycode_t, xkb_keymap_max_keycode, struct xkb_keymap *keymap);
FENNEC_SYMBOL(void, xkb_keymap_key_for_each, struct xkb_keymap *keymap, xkb_keymap_key_iter_t iter, void *data);
FENNEC_SYMBOL(const char*, xkb_keymap_key_get_name, struct xkb_keymap *keymap, xkb_keycode_t key);
FENNEC_SYMBOL(xkb_keycode_t, xkb_keymap_key_by_name, struct xkb_keymap *keymap, const char *name);
FENNEC_SYMBOL(xkb_mod_index_t, xkb_keymap_num_mods, struct xkb_keymap *keymap);
FENNEC_SYMBOL(const char*, xkb_keymap_mod_get_name, struct xkb_keymap *keymap, xkb_mod_index_t idx);
FENNEC_SYMBOL(xkb_mod_index_t, xkb_keymap_mod_get_index, struct xkb_keymap *keymap, const char *name);
FENNEC_SYMBOL(xkb_layout_index_t, xkb_keymap_num_layouts, struct xkb_keymap *keymap);
FENNEC_SYMBOL(const char*, xkb_keymap_layout_get_name, struct xkb_keymap *keymap, xkb_layout_index_t idx);
FENNEC_SYMBOL(xkb_layout_index_t, xkb_keymap_layout_get_index, struct xkb_keymap *keymap, const char *name);
FENNEC_SYMBOL(xkb_led_index_t, xkb_keymap_num_leds, struct xkb_keymap *keymap);
FENNEC_SYMBOL(const char*, xkb_keymap_led_get_name, struct xkb_keymap *keymap, xkb_led_index_t idx);
FENNEC_SYMBOL(xkb_led_index_t, xkb_keymap_led_get_index, struct xkb_keymap *keymap, const char *name);
FENNEC_SYMBOL(xkb_layout_index_t, xkb_keymap_num_layouts_for_key, struct xkb_keymap *keymap, xkb_keycode_t key);
FENNEC_SYMBOL(xkb_level_index_t, xkb_keymap_num_levels_for_key, struct xkb_keymap *keymap, xkb_keycode_t key, xkb_layout_index_t layout);
FENNEC_SYMBOL(size_t, xkb_keymap_key_get_mods_for_level, struct xkb_keymap *keymap, xkb_keycode_t key, xkb_layout_index_t layout, xkb_level_index_t level, xkb_mod_mask_t *masks_out, size_t masks_size);
FENNEC_SYMBOL(int, xkb_keymap_key_get_syms_by_level, struct xkb_keymap *keymap, xkb_keycode_t key, xkb_layout_index_t layout, xkb_level_index_t level, const xkb_keysym_t **syms_out);
FENNEC_SYMBOL(int, xkb_keymap_key_repeats, struct xkb_keymap *keymap, xkb_keycode_t key);
FENNEC_SYMBOL(struct xkb_state*, xkb_state_new, struct xkb_keymap *keymap);
FENNEC_SYMBOL(struct xkb_state*, xkb_state_ref, struct xkb_state *state);
FENNEC_SYMBOL(void, xkb_state_unref, struct xkb_state *state);
FENNEC_SYMBOL(struct xkb_keymap*, xkb_state_get_keymap, struct xkb_state *state);
FENNEC_SYMBOL(enum xkb_state_component, xkb_state_update_key, struct xkb_state *state, xkb_keycode_t key, enum xkb_key_direction direction);
FENNEC_SYMBOL(enum xkb_state_component, xkb_state_update_mask, struct xkb_state *state, xkb_mod_mask_t depressed_mods, xkb_mod_mask_t latched_mods, xkb_mod_mask_t locked_mods, xkb_layout_index_t depressed_layout, xkb_layout_index_t latched_layout, xkb_layout_index_t locked_layout);
FENNEC_SYMBOL(int, xkb_state_key_get_syms, struct xkb_state *state, xkb_keycode_t key, const xkb_keysym_t **syms_out);
FENNEC_SYMBOL(int, xkb_state_key_get_utf8, struct xkb_state *state, xkb_keycode_t key, char *buffer, size_t size);
FENNEC_SYMBOL(uint32_t, xkb_state_key_get_utf32, struct xkb_state *state, xkb_keycode_t key);
FENNEC_SYMBOL(xkb_keysym_t, xkb_state_key_get_one_sym, struct xkb_state *state, xkb_keycode_t key);
FENNEC_SYMBOL(xkb_layout_index_t, xkb_state_key_get_layout, struct xkb_state *state, xkb_keycode_t key);
FENNEC_SYMBOL(xkb_level_index_t, xkb_state_key_get_level, struct xkb_state *state, xkb_keycode_t key, xkb_layout_index_t layout);
FENNEC_SYMBOL(xkb_mod_mask_t, xkb_state_serialize_mods, struct xkb_state *state, enum xkb_state_component components);
FENNEC_SYMBOL(xkb_layout_index_t, xkb_state_serialize_layout, struct xkb_state *state, enum xkb_state_component components);
FENNEC_SYMBOL(int, xkb_state_mod_name_is_active, struct xkb_state *state, const char *name, enum xkb_state_component type);
FENNEC_SYMBOL(int, xkb_state_mod_names_are_active, struct xkb_state *state, enum xkb_state_component type, enum xkb_state_match match, ...);
FENNEC_SYMBOL(int, xkb_state_mod_index_is_active, struct xkb_state *state, xkb_mod_index_t idx, enum xkb_state_component type);
FENNEC_SYMBOL(int, xkb_state_mod_indices_are_active, struct xkb_state *state, enum xkb_state_component type, enum xkb_state_match match, ...);
FENNEC_SYMBOL(xkb_mod_mask_t, xkb_state_key_get_consumed_mods2, struct xkb_state *state, xkb_keycode_t key, enum xkb_consumed_mode mode);
FENNEC_SYMBOL(xkb_mod_mask_t, xkb_state_key_get_consumed_mods, struct xkb_state *state, xkb_keycode_t key);
FENNEC_SYMBOL(int, xkb_state_mod_index_is_consumed2, struct xkb_state *state, xkb_keycode_t key, xkb_mod_index_t idx, enum xkb_consumed_mode mode);
FENNEC_SYMBOL(int, xkb_state_mod_index_is_consumed, struct xkb_state *state, xkb_keycode_t key, xkb_mod_index_t idx);
FENNEC_SYMBOL(xkb_mod_mask_t, xkb_state_mod_mask_remove_consumed, struct xkb_state *state, xkb_keycode_t key, xkb_mod_mask_t mask);
FENNEC_SYMBOL(int, xkb_state_layout_name_is_active, struct xkb_state *state, const char *name, enum xkb_state_component type);
FENNEC_SYMBOL(int, xkb_state_layout_index_is_active, struct xkb_state *state, xkb_layout_index_t idx, enum xkb_state_component type);
FENNEC_SYMBOL(int, xkb_state_led_name_is_active, struct xkb_state *state, const char *name);
FENNEC_SYMBOL(int, xkb_state_led_index_is_active, struct xkb_state *state, xkb_led_index_t idx);
#undef FENNEC_LIB
#undef FENNEC_SYMBOL
#undef FENNEC_GLOBAL

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,45 @@
/*
* Copyright © 2012 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Author: Daniel Stone <daniel@fooishbar.org>
*/
#ifndef _XKBCOMMON_NAMES_H
#define _XKBCOMMON_NAMES_H
/**
* @file
* @brief Predefined names for common modifiers and LEDs.
*/
#define XKB_MOD_NAME_SHIFT "Shift"
#define XKB_MOD_NAME_CAPS "Lock"
#define XKB_MOD_NAME_CTRL "Control"
#define XKB_MOD_NAME_ALT "Mod1"
#define XKB_MOD_NAME_NUM "Mod2"
#define XKB_MOD_NAME_LOGO "Mod4"
#define XKB_LED_NAME_CAPS "Caps Lock"
#define XKB_LED_NAME_NUM "Num Lock"
#define XKB_LED_NAME_SCROLL "Scroll Lock"
#endif

View File

@@ -0,0 +1,157 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_PLATFORM_LINUX_XKB_LIB_XKBCOMMON_H
#define FENNEC_PLATFORM_LINUX_XKB_LIB_XKBCOMMON_H
#define FENNEC_LIB(name) extern bool FENNEC_HAS_LIB_##name;
#define FENNEC_SYMBOL(ret, fn, ...) using sym_##fn = ret(*)(__VA_ARGS__); \
extern sym_##fn fn;
#define FENNEC_GLOBAL(type, name) extern type* name;
#include <fennec/platform/linux/xkb/lib/sym.h>
/*
* Copyright © 2009-2012 Daniel Stone
* Copyright © 2012 Intel Corporation
* Copyright © 2012 Ran Benita
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Author: Daniel Stone <daniel@fooishbar.org>
*/
#include <fennec/platform/linux/xkb/lib/xkbcommon-names.h>
#include <fennec/platform/linux/xkb/lib/xkbcommon-keysyms.h>
#define XKB_KEYCODE_INVALID (0xffffffff)
#define XKB_LAYOUT_INVALID (0xffffffff)
#define XKB_LEVEL_INVALID (0xffffffff)
#define XKB_MOD_INVALID (0xffffffff)
#define XKB_LED_INVALID (0xffffffff)
#define XKB_KEYCODE_MAX (0xffffffff - 1)
/**
* Maximum keysym value
*
* @since 1.6.0
* @sa xkb_keysym_t
* @ingroup keysyms
*/
#define XKB_KEYSYM_MAX 0x1fffffff
/**
* Test whether a value is a valid extended keycode.
* @sa xkb_keycode_t
**/
#define xkb_keycode_is_legal_ext(key) (key <= XKB_KEYCODE_MAX)
/**
* Test whether a value is a valid X11 keycode.
* @sa xkb_keycode_t
*/
#define xkb_keycode_is_legal_x11(key) (key >= 8 && key <= 255)
/**
* Names to compile a keymap with, also known as RMLVO.
*
* The names are the common configuration values by which a user picks
* a keymap.
*
* If the entire struct is NULL, then each field is taken to be NULL.
* You should prefer passing NULL instead of choosing your own defaults.
*/
struct xkb_rule_names {
/**
* The rules file to use. The rules file describes how to interpret
* the values of the model, layout, variant and options fields.
*
* If NULL or the empty string "", a default value is used.
* If the XKB_DEFAULT_RULES environment variable is set, it is used
* as the default. Otherwise the system default is used.
*/
const char *rules;
/**
* The keyboard model by which to interpret keycodes and LEDs.
*
* If NULL or the empty string "", a default value is used.
* If the XKB_DEFAULT_MODEL environment variable is set, it is used
* as the default. Otherwise the system default is used.
*/
const char *model;
/**
* A comma separated list of layouts (languages) to include in the
* keymap.
*
* If NULL or the empty string "", a default value is used.
* If the XKB_DEFAULT_LAYOUT environment variable is set, it is used
* as the default. Otherwise the system default is used.
*/
const char *layout;
/**
* A comma separated list of variants, one per layout, which may
* modify or augment the respective layout in various ways.
*
* Generally, should either be empty or have the same number of values
* as the number of layouts. You may use empty values as in "intl,,neo".
*
* If NULL or the empty string "", and a default value is also used
* for the layout, a default value is used. Otherwise no variant is
* used.
* If the XKB_DEFAULT_VARIANT environment variable is set, it is used
* as the default. Otherwise the system default is used.
*/
const char *variant;
/**
* A comma separated list of options, through which the user specifies
* non-layout related preferences, like which key combinations are used
* for switching layouts, or which key is the Compose key.
*
* If NULL, a default value is used. If the empty string "", no
* options are used.
* If the XKB_DEFAULT_OPTIONS environment variable is set, it is used
* as the default. Otherwise the system default is used.
*/
const char *options;
};
/**
* Get the keymap as a string in the format from which it was created.
* @sa xkb_keymap_get_as_string()
**/
#define XKB_KEYMAP_USE_ORIGINAL_FORMAT ((enum xkb_keymap_format) -1)
#endif // FENNEC_PLATFORM_LINUX_XKB_LIB_XKBCOMMON_H

View File

@@ -1,44 +0,0 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_PLATFORM_EGL_CONTEXT_H
#define FENNEC_PLATFORM_EGL_CONTEXT_H
#include <EGL/egl.h>
#include <fennec/platform/interface/displaydev.h>
#include <fennec/platform/interface/gfxcontext.h>
#if FENNEC_HAS_WAYLAND
#include <fennec/platform/linux/wayland/fwd.h>
#endif
namespace fennec
{
class eglcontext : gfxcontext {
public:
eglcontext(displaydev* device);
EGLDisplay display;
EGLContext context;
EGLConfig config;
};
}
#endif // FENNEC_PLATFORM_EGL_CONTEXT_H

View File

@@ -1,43 +0,0 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H
#define FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H
#include <EGL/egl.h>
#include <fennec/platform/interface/gfxsurface.h>
#include <fennec/platform/opengl/egl/context.h>
#if FENNEC_HAS_WAYLAND
#endif
namespace fennec
{
class eglsurface : gfxsurface {
public:
eglsurface(eglcontext* context);
EGLSurface surface;
};
}
#endif // FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H

View File

@@ -16,21 +16,27 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
#ifndef FENNEC_PLATFORM_INTERFACE_INPUTDEVICE_H #ifndef FENNEC_PLATFORM_UNIX_UNIX_PLATFORM_H
#define FENNEC_PLATFORM_INTERFACE_INPUTDEVICE_H #define FENNEC_PLATFORM_UNIX_UNIX_PLATFORM_H
#include <fennec/platform/interface/platform.h>
namespace fennec namespace fennec
{ {
class inputdevice { class unix_platform : public platform {
public: public:
virtual bool has_keyboard() = 0; explicit unix_platform(const cstring& name)
virtual bool has_mouse() = 0; : platform(name) {
virtual bool has_touch() = 0; }
shared_object* load_object(const cstring& file) override;
void unload_object(shared_object* obj) override;
symbol find_symbol(shared_object* obj, const cstring& name) override;
private: private:
}; };
} }
#endif // FENNEC_PLATFORM_INTERFACE_INPUTDEVICE_H #endif // FENNEC_PLATFORM_UNIX_UNIX_PLATFORM_H

View File

@@ -1,37 +0,0 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#include <fennec/platform/interface/displaydev.h>
namespace fennec
{
displaydev::displaydev(platform* platform)
: _platform(platform)
, _context(nullptr)
, _config {
.format = {
.depth = 24,
.r = 8,
.g = 8,
.b = 8
}
} {
}
}

View File

@@ -1,28 +0,0 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#include <fennec/platform/interface/gfxsurface.h>
namespace fennec
{
gfxsurface::gfxsurface(window* window, gfxcontext* context)
: _window(window), _context(context) {
}
}

View File

@@ -16,18 +16,62 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
#include <cstdlib> #include <fennec/platform/interface/display.h>
#include <fennec/platform/interface/platform.h> #include <fennec/platform/interface/platform.h>
namespace fennec namespace fennec
{ {
string platform::get_environment_variable(const cstring& var) { template<typename CtorT>
const char* val = getenv(var); static constexpr void insert_driver(list<platform::driver<CtorT>>& list, CtorT ctor, int priority) {
return string(val, strlen(val)); using list_t = fennec::list<platform::driver<CtorT>>;
using iter_t = typename list_t::iterator;
iter_t it = list.begin();
while (it != list.end()) {
if (priority > it->priority) {
break;
}
}
list.insert(it, { priority, ctor });
} }
platform::platform() { void platform::initialize() {
load_display();
}
void platform::shutdown() {
delete _display;
}
void platform::load_display() {
auto& globals = _get_globals();
for (auto it : globals.displays) {
_display = it.constructor(this);
if (_display != nullptr) {
return;
}
}
}
void platform::add_driver(display_ctor ctor, int priority) {
auto& globals = _get_globals();
insert_driver(globals.displays, ctor, priority);
}
void platform::add_driver(input_ctor ctor, int priority) {
auto& globals = _get_globals();
insert_driver(globals.inputs, ctor, priority);
}
void platform::add_driver(gfxctx_ctor ctor, int priority) {
auto& globals = _get_globals();
insert_driver(globals.graphics, ctor, priority);
}
platform::global_context& platform::_get_globals() {
static global_context ctx;
return ctx;
} }
} }

View File

@@ -1,31 +0,0 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#include <fennec/platform/interface/window.h>
namespace fennec
{
window::window(displaydev* display, window* parent)
: _display(display)
, _parent(parent)
, _config() {
}
}

View File

@@ -16,89 +16,24 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
#include <fennec/fproc/filesystem/file.h>
#include <fennec/platform/linux/platform.h> #include <fennec/platform/linux/platform.h>
#include <dlfcn.h> #include <fennec/lang/startup.h>
#ifdef FENNEC_LIB_WAYLAND
#include <fennec/platform/linux/wayland/lib/dyn.h>
#include <fennec/platform/linux/wayland/displaydev.h>
#endif
namespace fennec namespace fennec
{ {
linux_platform::linux_platform() STATIC_CONSTRUCTOR(_init_linux) {
: platform() static linux_platform* platform = new linux_platform();
, _display_driver(display_none) { file::cout().write(platform, sizeof(platform), 1);
#if FENNEC_BUILD_SERVER
_runtime_server_checks();
#else
_runtime_client_checks();
#endif
} }
linux_platform::~linux_platform() { void linux_platform::initialize() {
if (_display) { platform::initialize();
delete _display;
_display = nullptr;
}
} }
shared_object* linux_platform::load_object(const cstring& file) { void linux_platform::shutdown() {
void* handle = dlopen(file, RTLD_NOW | RTLD_LOCAL);
const char* load_error = dlerror();
assert(handle != nullptr, load_error);
return static_cast<shared_object*>(handle);
}
void linux_platform::unload_object(shared_object* obj) {
if (obj) {
dlclose(obj);
}
}
platform::function_pointer linux_platform::find_symbol(shared_object* hndl, const cstring& name) {
string _name = name;
void* symbol = dlsym(hndl, _name);
if (symbol == nullptr) {
_name = '_' + _name;
symbol = dlsym(hndl, _name);
}
return (function_pointer)symbol;
}
platform::global linux_platform::find_global(shared_object* hndl, const cstring& name) {
string _name = name;
void* symbol = dlsym(hndl, _name);
if (symbol == nullptr) {
_name = '_' + _name;
symbol = dlsym(hndl, _name);
}
return symbol;
}
displaydev* linux_platform::get_display() {
return _display;
}
void linux_platform::_runtime_client_checks() {
#ifdef FENNEC_LIB_WAYLAND
if (libwayland::load_symbols(this)) {
_display_driver = display_wayland;
_display = new wayland_display(this);
libwayland::unload_symbols(this); // Doesn't actually unload symbols, just resets ref counter to only consider
// the created display
}
#endif
assertf(_display != nullptr, "failed to find suitable display driver");
}
void linux_platform::_find_display_driver() {
}
void linux_platform::_runtime_server_checks() {
} }

View File

@@ -16,47 +16,71 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
#include <fennec/platform/linux/wayland/displaydev.h> #include <fennec/platform/linux/wayland/display.h>
#include <fennec/platform/linux/wayland/window.h> #include <fennec/platform/linux/wayland/lib/loader.h>
#include <fennec/platform/linux/wayland/lib/dyn.h>
#include <fennec/platform/linux/wayland/lib/wayland-client.h> #include <fennec/platform/linux/wayland/lib/wayland-client.h>
#include <fennec/lang/startup.h>
namespace fennec namespace fennec
{ {
wayland_display::wayland_display(linux_platform* platform) static display* _create_wayland_display(platform* platform) {
: wayland_display(platform, nullptr) { wayland_display* display = new wayland_display(platform);
if (not display->connected()) {
delete display, display = nullptr;
}
return display;
} }
wayland_display::wayland_display(linux_platform* platform, const cstring& drv) STATIC_CONSTRUCTOR(_wayland_init) {
: displaydev(platform) platform::add_driver(_create_wayland_display, 1);
}
wayland_display::wayland_display(platform* platform)
: display(platform)
, _handle(nullptr) , _handle(nullptr)
, _registry(nullptr) , _registry(nullptr)
, _compositor(nullptr) { , _compositor(nullptr)
, _shell(nullptr)
, _seat(nullptr)
, _shm(nullptr)
, _fifo(false) {
static constexpr wl_registry_listener listener = { static constexpr wl_registry_listener listener = {
listen_global, listen_global_remove listen_global, listen_global_remove
}; };
// Load libwayland.so // Load libwayland.so
libwayland::load_symbols(get_platform<linux_platform>()); libwayland::load_symbols(_platform);
// Get handles // Get handles
_handle = wl_display_connect(drv); _handle = wl_display_connect(nullptr);
if (not _handle) {
cleanup();
return;
}
_registry = wl_display_get_registry(_handle); _registry = wl_display_get_registry(_handle);
if (not _registry) {
cleanup();
return;
}
wl_registry_add_listener(_registry, &listener, this); wl_registry_add_listener(_registry, &listener, this);
wl_display_roundtrip(_handle);
if (not _fifo) {
assert(_fifo, "Compositor does not support fifo-v1 protocol, falling back to other display protocols.");
cleanup();
}
} }
wayland_display::~wayland_display() { wayland_display::~wayland_display() {
wl_registry_destroy(_registry); if (_handle) {
wl_display_flush(_handle); cleanup();
wl_display_disconnect(_handle);
libwayland::unload_symbols(get_platform<linux_platform>());
_handle = nullptr;
_platform = nullptr;
for (const auto it : _windows) {
delete it;
} }
} }
@@ -65,8 +89,26 @@ bool wayland_display::connected() const {
} }
window* wayland_display::create_window() { window* wayland_display::create_window() {
_windows.push_back(new wayland_window(this, nullptr)); return nullptr;
return (window*)(_windows.back()); }
void wayland_display::cleanup() {
// Cleanup members
if (_shell) wl_shell_destroy(_shell);
if (_compositor) wl_compositor_destroy(_compositor);
if (_registry) wl_registry_destroy(_registry);
if (_handle) {
wl_display_flush(_handle);
wl_display_disconnect(_handle);
}
_shell = nullptr;
_compositor = nullptr;
_registry = nullptr;
_handle = nullptr;
libwayland::unload_symbols(_platform);
} }
void wayland_display::listen_global(void* data, wl_registry* registry, uint32_t name, const char* itfc, uint32_t version) { void wayland_display::listen_global(void* data, wl_registry* registry, uint32_t name, const char* itfc, uint32_t version) {
@@ -84,6 +126,8 @@ void wayland_display::listen_global(void* data, wl_registry* registry, uint32_t
} else if (interface == "wl_seat") { } else if (interface == "wl_seat") {
device->_seat = static_cast<wl_seat*>(wl_registry_bind(registry, name, wl_seat_interface, version)); device->_seat = static_cast<wl_seat*>(wl_registry_bind(registry, name, wl_seat_interface, version));
wl_seat_add_listener(device->_seat, &seat_listener, device); wl_seat_add_listener(device->_seat, &seat_listener, device);
} else if (interface == "wp_fifo_manager_v1") {
device->_fifo = true;
} }
} }

View File

@@ -17,7 +17,13 @@
// ===================================================================================================================== // =====================================================================================================================
#include <fennec/platform/linux/wayland/lib/wayland-client.h> #include <fennec/platform/linux/wayland/lib/wayland-client.h>
#include <fennec/platform/linux/wayland/lib/dyn.h> #include <fennec/platform/linux/wayland/lib/loader.h>
#define FENNEC_LIB(name) bool FENNEC_HAS_LIB_##name;
#define FENNEC_SYMBOL(ret, fn, ...) using sym_##fn = ret(*)(__VA_ARGS__); \
sym_##fn fn;
#define FENNEC_GLOBAL(type, name) type* name;
#include <fennec/platform/linux/wayland/lib/sym.h>
namespace fennec namespace fennec
{ {
@@ -25,7 +31,12 @@ namespace fennec
namespace libwayland namespace libwayland
{ {
using shared_lib = platform::shared_lib; using shared_object = platform::shared_object;
struct shared_lib {
shared_object* obj;
const cstring name;
};
static int _load_count = 0; static int _load_count = 0;
@@ -33,37 +44,37 @@ static int _load_count = 0;
#define FENNEC_LIB(lib) static shared_lib _FENNEC_LIB_##lib = { nullptr, FENNEC_LIB_##lib }; #define FENNEC_LIB(lib) static shared_lib _FENNEC_LIB_##lib = { nullptr, FENNEC_LIB_##lib };
#include <fennec/platform/linux/wayland/lib/sym.h> #include <fennec/platform/linux/wayland/lib/sym.h>
bool load_symbols(linux_platform* platform) { bool load_symbols(platform* platform) {
if (_load_count++ != 0) { if (_load_count++ != 0) {
return true; return true;
} }
shared_lib* current_lib = nullptr; shared_lib* current_lib = nullptr;
#define FENNEC_LIB(lib) _FENNEC_LIB_##lib._lib = platform->load_object(_FENNEC_LIB_##lib._name); \ #define FENNEC_LIB(lib) _FENNEC_LIB_##lib.obj = platform->load_object(_FENNEC_LIB_##lib.name); \
FENNEC_HAS_LIB_##lib = _FENNEC_LIB_##lib._lib != nullptr; \ FENNEC_HAS_LIB_##lib = _FENNEC_LIB_##lib.obj != nullptr; \
if(not FENNEC_HAS_LIB_##lib) { \ if(not FENNEC_HAS_LIB_##lib) { \
unload_symbols(platform); \ unload_symbols(platform); \
return false; \ return false; \
} \ } \
current_lib = &_FENNEC_LIB_##lib; current_lib = &_FENNEC_LIB_##lib;
#define FENNEC_SYMBOL(ret, fn, ...) fn = (sym_##fn)(platform->find_symbol(current_lib->_lib, #fn)); \ #define FENNEC_SYMBOL(ret, fn, ...) fn = (sym_##fn)(platform->find_symbol(current_lib->obj, #fn)); \
assertf(fn != nullptr, "Failed to find symbol: " #fn); assertf(fn != nullptr, "Failed to find symbol: " #fn);
#define FENNEC_GLOBAL(type, name) name = (type*)(platform->find_symbol(current_lib->_lib, #name)); \ #define FENNEC_GLOBAL(type, name) name = (type*)(platform->find_symbol(current_lib->obj, #name)); \
assertf(name != nullptr, "Failed to find global: " #name); assertf(name != nullptr, "Failed to find global: " #name);
#include <fennec/platform/linux/wayland/lib/sym.h> #include <fennec/platform/linux/wayland/lib/sym.h>
return true; return true;
} }
void unload_symbols(linux_platform* platform) { void unload_symbols(platform* platform) {
if (--_load_count != 0) { if (--_load_count != 0) {
return; return;
} }
#define FENNEC_LIB(lib) platform->unload_object(_FENNEC_LIB_##lib._lib); \ #define FENNEC_LIB(lib) platform->unload_object(_FENNEC_LIB_##lib.obj); \
_FENNEC_LIB_##lib._lib = nullptr; _FENNEC_LIB_##lib.obj = nullptr;
#define FENNEC_SYMBOL(ret, fn, ...) fn = nullptr; #define FENNEC_SYMBOL(ret, fn, ...) fn = nullptr;
#define FENNEC_GLOBAL(type, name) name = nullptr; #define FENNEC_GLOBAL(type, name) name = nullptr;
#include <fennec/platform/linux/wayland/lib/sym.h> #include <fennec/platform/linux/wayland/lib/sym.h>

View File

@@ -1,86 +0,0 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#include <fennec/platform/linux/wayland/displaydev.h>
#include <fennec/platform/linux/wayland/window.h>
#include <EGL/egl.h>
namespace fennec
{
bool wayland_window::running() {
return false;
}
void wayland_window::configure(const config& config) {
assertf(running() == false, "Attempted to Configure Running Window.");
_config = config;
}
bool wayland_window::initialize(bool modal) {
assertf(_config, "Attempted to Initialize a Window Without Configuration");
if (not _config) {
return true;
}
_config->flags &= ~flags_modal & ~flags_child;
if (_parent != nullptr) {
_config->flags |= flags_child;
if (modal) {
_config->flags |= flags_modal;
}
}
_surface = wl_compositor_create_surface(get_display<wayland_display>()->get_compositor());
_shell = wl_shell_get_shell_surface(get_display<wayland_display>()->get_shell(), _surface);
return false;
}
bool wayland_window::shutdown() {
wl_shell_surface_destroy(_shell);
wl_surface_destroy(_surface);
return false;
}
bool wayland_window::set_title(const cstring&) { return true; }
bool wayland_window::set_title(const string&) { return true; }
bool wayland_window::set_width(size_t) { return true; }
bool wayland_window::set_height(size_t) { return true; }
bool wayland_window::set_size(size_t, size_t) { return true; }
bool wayland_window::set_fullscreen_mode(fullscreen_mode) { return true; }
bool wayland_window::set_resizable(bool) { return true; }
bool wayland_window::grab_keyboard(bool) { return true; }
bool wayland_window::grab_mouse(bool) { return true; }
bool wayland_window::block_screensaver(bool) { return true; }
wayland_window::wayland_window(wayland_display* display, wayland_window* parent)
: window(display, parent)
, _surface(nullptr)
, _shell(nullptr)
, _callback(nullptr) {
}
wayland_window::~wayland_window() {
}
}

View File

@@ -0,0 +1,87 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#define FENNEC_LIB(name) bool FENNEC_HAS_LIB_##name;
#define FENNEC_SYMBOL(ret, fn, ...) using sym_##fn = ret(*)(__VA_ARGS__); \
sym_##fn fn;
#define FENNEC_GLOBAL(type, name) type* name;
#include <fennec/platform/linux/xkb/lib/sym.h>
#include <fennec/platform/linux/xkb/lib/xkbcommon.h>
#include <fennec/platform/linux/xkb/lib/loader.h>
#include <fennec/platform/interface/platform.h>
namespace fennec
{
namespace libxkbcommon
{
using shared_object = platform::shared_object;
struct shared_lib {
shared_object* obj;
const cstring name;
};
static int _load_count = 0;
// Create private variables
#define FENNEC_LIB(lib) static shared_lib _FENNEC_LIB_##lib = { nullptr, FENNEC_LIB_##lib };
#include <fennec/platform/linux/xkb/lib/sym.h>
bool load_symbols(platform* platform) {
if (_load_count++ != 0) {
return true;
}
shared_lib* current_lib = nullptr;
#define FENNEC_LIB(lib) _FENNEC_LIB_##lib.obj = platform->load_object(_FENNEC_LIB_##lib.name); \
FENNEC_HAS_LIB_##lib = _FENNEC_LIB_##lib.obj != nullptr; \
if(not FENNEC_HAS_LIB_##lib) { \
unload_symbols(platform); \
return false; \
} \
current_lib = &_FENNEC_LIB_##lib;
#define FENNEC_SYMBOL(ret, fn, ...) fn = (sym_##fn)(platform->find_symbol(current_lib->obj, #fn)); \
assertf(fn != nullptr, "Failed to find symbol: " #fn);
#define FENNEC_GLOBAL(type, name) name = (type*)(platform->find_symbol(current_lib->obj, #name)); \
assertf(name != nullptr, "Failed to find global: " #name);
#include <fennec/platform/linux/xkb/lib/sym.h>
return true;
}
void unload_symbols(platform* platform) {
if (--_load_count != 0) {
return;
}
#define FENNEC_LIB(lib) platform->unload_object(_FENNEC_LIB_##lib.obj); \
_FENNEC_LIB_##lib.obj = nullptr;
#define FENNEC_SYMBOL(ret, fn, ...) fn = nullptr;
#define FENNEC_GLOBAL(type, name) name = nullptr;
#include <fennec/platform/linux/xkb/lib/sym.h>
}
}
}

View File

@@ -16,33 +16,34 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// ===================================================================================================================== // =====================================================================================================================
#ifndef FENNEC_PLATFORM_INTERFACE_GFXSURFACE_H #include <fennec/platform/unix/platform.h>
#define FENNEC_PLATFORM_INTERFACE_GFXSURFACE_H
#include <fennec/platform/interface/fwd.h> #include <dlfcn.h>
namespace fennec namespace fennec
{ {
class gfxsurface { shared_object* unix_platform::load_object(const cstring& file) {
template<typename ContextT> void* handle = dlopen(file, RTLD_NOW | RTLD_LOCAL);
ContextT* get_context() { const char* load_error = dlerror();
return static_cast<ContextT*>(_context); assert(handle != nullptr, load_error);
return static_cast<shared_object*>(handle);
} }
template<typename WindowT> void unix_platform::unload_object(shared_object* obj) {
WindowT* get_window() { if (obj) {
return static_cast<WindowT*>(_window); dlclose(obj);
}
} }
protected: platform::symbol unix_platform::find_symbol(shared_object* obj, const cstring& name) {
gfxsurface(window* window, gfxcontext* context); string _name = name;
void* symbol = dlsym(obj, _name);
private: if (symbol == nullptr) {
window* _window; _name = '_' + _name;
gfxcontext* _context; symbol = dlsym(obj, _name);
}; }
return symbol;
} }
#endif // FENNEC_PLATFORM_INTERFACE_GFXSURFACE_H }

View File

@@ -27,8 +27,6 @@ add_executable(fennec-test main.cpp
printing.h printing.h
tests/math/test_ext.h tests/math/test_ext.h
tests/math/ext/test_quaternion.h tests/math/ext/test_quaternion.h
tests/platform/linux/test_wayland.h
tests/platform/test_linux.h
tests/test_platform.h tests/test_platform.h
tests/lang/test_hashing.h tests/lang/test_hashing.h
tests/containers/test_array.h tests/containers/test_array.h
@@ -41,5 +39,7 @@ target_compile_definitions(fennec-test PUBLIC FENNEC_TEST_CWD="${CMAKE_SOURCE_DI
) )
target_link_libraries(fennec-test PRIVATE target_link_libraries(fennec-test PRIVATE
-Wl,--whole-archive
fennec fennec
-Wl,--no-whole-archive
) )

View File

@@ -1,36 +0,0 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_TEST_PLATFORM_LINUX_WAYLAND_H
#define FENNEC_TEST_PLATFORM_LINUX_WAYLAND_H
#include "../../../test.h"
#include <fennec/platform/linux/wayland/displaydev.h>
namespace fennec::test
{
inline void fennec_test_platform_linux_wayland(linux_platform& platform) {
wayland_display* display = static_cast<wayland_display*>(platform.get_display());
fennec_test_run(display != nullptr, true);
}
}
#endif // FENNEC_TEST_PLATFORM_LINUX_WAYLAND_H

View File

@@ -1,46 +0,0 @@
// =====================================================================================================================
// 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 <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_TEST_PLATFORM_LINUX_H
#define FENNEC_TEST_PLATFORM_LINUX_H
#include "../../test.h"
#ifdef FENNEC_LIB_WAYLAND
#include "linux/test_wayland.h"
#endif
namespace fennec::test
{
inline void fennec_test_platform_linux() {
linux_platform platform;
#ifdef FENNEC_LIB_WAYLAND
fennec_test_section("wayland tests");
fennec_test_spacer(2);
fennec_test_platform_linux_wayland(platform);
fennec_test_spacer(3);
#endif
// TODO
}
}
#endif // FENNEC_TEST_PLATFORM_LINUX_H

View File

@@ -18,22 +18,20 @@
#ifndef FENNEC_TEST_PLATFORM_H #ifndef FENNEC_TEST_PLATFORM_H
#define FENNEC_TEST_PLATFORM_H #define FENNEC_TEST_PLATFORM_H
#include "../test.h" #include <fennec/platform/interface/platform.h>
#if FENNEC_PLATFORM_LINUX
#include "./platform/test_linux.h"
#endif
namespace fennec::test namespace fennec::test
{ {
inline void fennec_test_platform() { inline void fennec_test_platform() {
#if FENNEC_PLATFORM_LINUX
fennec_test_subheader("linux"); platform* instance = platform::instance();
fennec_test_spacer(2); instance->initialize();
fennec_test_platform_linux();
fennec_test_spacer(3); fennec_test_run(instance->get_display() != nullptr, true);
#endif
instance->shutdown();
} }
} }