- Separated Platform and Compiler Dependent Behaviour into CMake scripts
- Implemented Basic Platform Interfaces
- Implemented partial Linux platform and Wayland Display.
- Implemented Dependencies for the above
- map
- set
- optional
- pair
TODO: threading
This commit is contained in:
22
include/fennec/platform/interface/dialog.h
Normal file
22
include/fennec/platform/interface/dialog.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// =====================================================================================================================
|
||||
// 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
|
||||
47
include/fennec/platform/interface/display.h
Normal file
47
include/fennec/platform/interface/display.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// =====================================================================================================================
|
||||
// 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_DISPLAY_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_DISPLAY_H
|
||||
|
||||
#include <fennec/platform/interface/fwd.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
///
|
||||
/// \brief Interface for display management
|
||||
class display
|
||||
{
|
||||
public:
|
||||
struct config {
|
||||
|
||||
};
|
||||
|
||||
virtual bool connected() const = 0;
|
||||
|
||||
protected:
|
||||
virtual ~display() = default;
|
||||
|
||||
private:
|
||||
config _config;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_DISPLAY_H
|
||||
30
include/fennec/platform/interface/fwd.h
Normal file
30
include/fennec/platform/interface/fwd.h
Normal file
@@ -0,0 +1,30 @@
|
||||
// =====================================================================================================================
|
||||
// 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_FORWARD_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_FORWARD_H
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class window;
|
||||
class display;
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_FORWARD_H
|
||||
74
include/fennec/platform/interface/platform.h
Normal file
74
include/fennec/platform/interface/platform.h
Normal file
@@ -0,0 +1,74 @@
|
||||
// =====================================================================================================================
|
||||
// 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_PLATFORM_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_PLATFORM_H
|
||||
|
||||
#include <fennec/fproc/strings/string.h>
|
||||
#include <fennec/platform/interface/fwd.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class platform {
|
||||
public:
|
||||
using shared_object = struct shared_object;
|
||||
using function_pointer = void (*)(void);
|
||||
|
||||
struct shared_lib {
|
||||
shared_object* _lib;
|
||||
const cstring _name;
|
||||
};
|
||||
|
||||
enum class user {
|
||||
client,
|
||||
server
|
||||
};
|
||||
|
||||
struct config {
|
||||
user type;
|
||||
};
|
||||
|
||||
// Functions with default implementations
|
||||
|
||||
virtual string get_environment_variable(const cstring& var);
|
||||
|
||||
|
||||
|
||||
// Pure Virtual Functions
|
||||
|
||||
virtual display* 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;
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
platform(user t);
|
||||
virtual ~platform() = default;
|
||||
|
||||
private:
|
||||
config _config;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_PLATFORM_H
|
||||
137
include/fennec/platform/interface/window.h
Normal file
137
include/fennec/platform/interface/window.h
Normal file
@@ -0,0 +1,137 @@
|
||||
// =====================================================================================================================
|
||||
// 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_WINDOW_H
|
||||
#define FENNEC_PLATFORM_INTERFACE_WINDOW_H
|
||||
|
||||
#include <fennec/fproc/strings/string.h>
|
||||
#include <fennec/platform/interface/fwd.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
///
|
||||
/// \brief interface for handling windows
|
||||
/// \details the interface makes no guarantees about the bit-depth and is completely dependent on the implementation.
|
||||
class window {
|
||||
public:
|
||||
enum class fullscreen_mode {
|
||||
windowed = 0,
|
||||
borderless,
|
||||
fullscreen
|
||||
};
|
||||
|
||||
enum flags_ : uint32_t {
|
||||
flags_none = 0,
|
||||
flags_child = 0x1 << 0,
|
||||
flags_modal = 0x1 << 1,
|
||||
flags_grab_mouse = 0x1 << 2,
|
||||
flags_grab_keyboard = 0x1 << 3,
|
||||
flags_block_screensaver = 0x1 << 4,
|
||||
};
|
||||
|
||||
union bits {
|
||||
uint32_t depth;
|
||||
uint8_t r, g, b, a;
|
||||
};
|
||||
|
||||
struct config {
|
||||
string title;
|
||||
uint32_t flags;
|
||||
size_t width, height;
|
||||
fullscreen_mode fullscreen;
|
||||
bits bit_depth;
|
||||
};
|
||||
|
||||
virtual bool set_title(const cstring& title) = 0;
|
||||
virtual bool set_title(const string& title) = 0;
|
||||
|
||||
virtual bool set_width(size_t w) = 0;
|
||||
virtual bool set_height(size_t h) = 0;
|
||||
virtual bool set_size(size_t w, size_t h) = 0;
|
||||
|
||||
virtual bool set_fullscreen_mode(fullscreen_mode mode) = 0;
|
||||
|
||||
virtual bool set_resizable(bool e) = 0;
|
||||
|
||||
virtual bool grab_keyboard(bool e) = 0;
|
||||
virtual bool grab_mouse(bool e) = 0;
|
||||
virtual bool block_screensaver(bool e) = 0;
|
||||
|
||||
bool is_child() const {
|
||||
return _config.flags & flags_child;
|
||||
}
|
||||
|
||||
bool is_modal() const {
|
||||
return _config.flags & flags_modal;
|
||||
}
|
||||
|
||||
display* get_display() {
|
||||
return _display;
|
||||
}
|
||||
|
||||
const display* get_display() const {
|
||||
return _display;
|
||||
}
|
||||
|
||||
|
||||
const string& get_title() const {
|
||||
return _config.title;
|
||||
}
|
||||
|
||||
|
||||
size_t get_width() const {
|
||||
return _config.width;
|
||||
}
|
||||
|
||||
size_t get_height() const {
|
||||
return _config.height;
|
||||
}
|
||||
|
||||
|
||||
fullscreen_mode get_fullscreen_mode() const {
|
||||
return _config.fullscreen;
|
||||
}
|
||||
|
||||
|
||||
bool is_keyboard_grabbed() const {
|
||||
return _config.flags & flags_grab_keyboard;
|
||||
}
|
||||
|
||||
bool is_mouse_grabbed() const {
|
||||
return _config.flags & flags_grab_mouse;
|
||||
}
|
||||
|
||||
bool is_screensaver_blocked() const {
|
||||
return _config.flags & flags_block_screensaver;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~window() = default;
|
||||
window(display* display, window* parent, bool modal);
|
||||
|
||||
display* _display;
|
||||
window* _parent;
|
||||
config _config;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_WINDOW_H
|
||||
59
include/fennec/platform/linux/platform.h
Normal file
59
include/fennec/platform/linux/platform.h
Normal 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/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_PLATFORM_H
|
||||
#define FENNEC_PLATFORM_LINUX_PLATFORM_H
|
||||
|
||||
#include <fennec/containers/set.h>
|
||||
#include <fennec/platform/interface/display.h>
|
||||
#include <fennec/platform/interface/platform.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class linux_platform : public platform {
|
||||
public:
|
||||
enum display_ : int_t {
|
||||
display_none = -1,
|
||||
display_x11 = 0,
|
||||
display_wayland,
|
||||
};
|
||||
|
||||
linux_platform(user type);
|
||||
~linux_platform() override;
|
||||
|
||||
shared_object* load_object(const cstring& file) override;
|
||||
void unload_object(shared_object* obj) override;
|
||||
function_pointer find_symbol(shared_object* hndl, const cstring& name) override;
|
||||
|
||||
display* get_display() override;
|
||||
|
||||
|
||||
private:
|
||||
display* _display;
|
||||
int_t _display_driver;
|
||||
|
||||
void _runtime_client_checks();
|
||||
void _find_display_driver();
|
||||
|
||||
void _runtime_server_checks();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_PLATFORM_H
|
||||
51
include/fennec/platform/linux/wayland/display.h
Normal file
51
include/fennec/platform/linux/wayland/display.h
Normal file
@@ -0,0 +1,51 @@
|
||||
// =====================================================================================================================
|
||||
// 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_DISPLAY_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
|
||||
#include <fennec/fproc/strings/cstring.h>
|
||||
#include <fennec/platform/interface/display.h>
|
||||
|
||||
#include <fennec/platform/linux/platform.h>
|
||||
#include <fennec/platform/linux/wayland/lib/fwd.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
namespace wayland
|
||||
{
|
||||
|
||||
class wayland_display : public display {
|
||||
public:
|
||||
wayland_display(linux_platform* platform);
|
||||
wayland_display(linux_platform* platform, const cstring& drv);
|
||||
~wayland_display() override;
|
||||
|
||||
bool connected() const override;
|
||||
|
||||
private:
|
||||
struct wl_display* _handle;
|
||||
linux_platform* _platform;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_DISPLAY_H
|
||||
37
include/fennec/platform/linux/wayland/lib/dyn.h
Normal file
37
include/fennec/platform/linux/wayland/lib/dyn.h
Normal file
@@ -0,0 +1,37 @@
|
||||
// =====================================================================================================================
|
||||
// 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_DYN_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_DYN_H
|
||||
|
||||
#include <fennec/platform/linux/platform.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
namespace wayland
|
||||
{
|
||||
|
||||
bool load_symbols(linux_platform* platform);
|
||||
void unload_symbols(linux_platform* platform);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_DYN_H
|
||||
24
include/fennec/platform/linux/wayland/lib/fwd.h
Normal file
24
include/fennec/platform/linux/wayland/lib/fwd.h
Normal file
@@ -0,0 +1,24 @@
|
||||
// =====================================================================================================================
|
||||
// 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_FWD_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
|
||||
struct wl_display;
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
37
include/fennec/platform/linux/wayland/lib/sym.h
Normal file
37
include/fennec/platform/linux/wayland/lib/sym.h
Normal file
@@ -0,0 +1,37 @@
|
||||
// =====================================================================================================================
|
||||
// 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/lib/fwd.h>
|
||||
|
||||
#ifndef FENNEC_LIB
|
||||
#define FENNEC_LIB(...)
|
||||
#endif
|
||||
|
||||
#ifndef FENNEC_SYMBOL
|
||||
#define FENNEC_SYMBOL(...)
|
||||
#endif
|
||||
|
||||
FENNEC_LIB(WAYLAND);
|
||||
|
||||
FENNEC_SYMBOL(struct wl_display*, wl_display_connect, const char* name);
|
||||
FENNEC_SYMBOL(void, wl_display_disconnect, wl_display* name);
|
||||
|
||||
#undef FENNEC_LIB
|
||||
#undef FENNEC_SYMBOL
|
||||
|
||||
|
||||
27
include/fennec/platform/linux/wayland/lib/sym_def.h
Normal file
27
include/fennec/platform/linux/wayland/lib/sym_def.h
Normal file
@@ -0,0 +1,27 @@
|
||||
// =====================================================================================================================
|
||||
// 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_SYM_DEF_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_SYM_DEF_H
|
||||
|
||||
#define FENNEC_LIB(name) inline bool FENNEC_HAS_LIB_##name = false;
|
||||
#define FENNEC_SYMBOL(ret, fn, ...) using sym_##fn = ret(*)(__VA_ARGS__); \
|
||||
inline sym_##fn fn = nullptr;
|
||||
#include <fennec/platform/linux/wayland/lib/sym.h>
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_SYM_DEF_H
|
||||
Reference in New Issue
Block a user