- Setup EGL context for Wayland. Test window now opens as black rectangle.
This commit is contained in:
@@ -40,6 +40,16 @@
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class display_server;
|
||||
|
||||
///
|
||||
/// \brief Interface resembling the API for a display server of an operating system, e.g. Linux X11/Wayland
|
||||
///
|
||||
/// \details An implementation for a display server should inherit `display_server_base` and note the following:
|
||||
///
|
||||
/// For a server type `DisplayT`; any `gfxcontext` implementation that wishes to implement `DisplayT`
|
||||
/// must provide a constructor that accepts a `DisplayT*`. `DisplayT::ctx_registry::register_type` must then be
|
||||
/// called for the `gfxcontext` implementation.
|
||||
class display_server : public type_registry<display_server, platform*> {
|
||||
// Typedefs/Constants/Enums ============================================================================================
|
||||
public:
|
||||
@@ -99,6 +109,9 @@ enum feature_ : uint32_t {
|
||||
return features.test(feature);
|
||||
}
|
||||
|
||||
gfxcontext* get_gfx_context() {
|
||||
return gfx_context;
|
||||
}
|
||||
|
||||
virtual window* create_window(const window::config& conf) = 0;
|
||||
|
||||
@@ -110,16 +123,31 @@ enum feature_ : uint32_t {
|
||||
virtual void disconnect() = 0;
|
||||
virtual bool connected() const = 0;
|
||||
|
||||
virtual void dispatch() = 0;
|
||||
|
||||
virtual void* get_native_handle() = 0;
|
||||
|
||||
|
||||
protected:
|
||||
featureset_t features;
|
||||
object_pool<window*> windows;
|
||||
gfxcontext* gfx_context;
|
||||
|
||||
FENNEC_RTTI_CLASS_ENABLE() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
template<typename DisplayT, typename WindowT>
|
||||
class display_server_base : public display_server, public type_registry<gfxcontext, DisplayT*> {
|
||||
public:
|
||||
display_server_base(fennec::platform* p)
|
||||
: display_server(p) {
|
||||
}
|
||||
|
||||
using ctx_registry = type_registry<gfxcontext, DisplayT*>;
|
||||
using window_t = WindowT;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_INTERFACE_DISPLAY_SERVER_H
|
||||
@@ -25,7 +25,9 @@ namespace fennec
|
||||
class platform;
|
||||
|
||||
class display_server; // The display server used by the OS, e.g. WDM, Wayland, X11, etc.
|
||||
class gfxcontext; // Handles the GFX API context of a display server, e.g. OpenGL, Vulkan, etc.
|
||||
class window; // Handles window surfaces of the display protocol
|
||||
class gfxsurface; // Handles the GFX surface of a window for a specific gfxcontext
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,10 @@ public:
|
||||
|
||||
window* get_parent() const;
|
||||
|
||||
const ivec2& get_size() const { return cfg.size; }
|
||||
int get_width() const { return cfg.size.x; }
|
||||
int get_height() const { return cfg.size.y; }
|
||||
|
||||
bool get_flag(uint8_t flag) const { return cfg.flags.test(flag); }
|
||||
|
||||
bool is_always_on_top() const { return get_flag(flag_always_on_top); }
|
||||
@@ -120,6 +124,7 @@ public:
|
||||
bool is_running() const { return get_flag(flag_running); }
|
||||
bool is_no_focus() const { return get_flag(flag_no_focus); }
|
||||
|
||||
|
||||
virtual bool set_flag(uint8_t flag, bool val) = 0;
|
||||
|
||||
bool set_always_on_top(bool val) { return set_flag(flag_always_on_top, val); }
|
||||
@@ -135,13 +140,27 @@ public:
|
||||
virtual void show() = 0;
|
||||
virtual void hide() = 0;
|
||||
|
||||
virtual void dispatch() = 0;
|
||||
virtual void begin_frame();
|
||||
virtual void end_frame();
|
||||
|
||||
virtual void* get_native_handle() = 0;
|
||||
|
||||
protected:
|
||||
display_server* const server;
|
||||
const size_t id;
|
||||
config cfg;
|
||||
window* root;
|
||||
gfxsurface* gfx_surface;
|
||||
};
|
||||
|
||||
template<typename DisplayT>
|
||||
class window_base : public window {
|
||||
public:
|
||||
window_base(display_server* display, size_t id, const config& conf)
|
||||
: window(display, id, conf) {
|
||||
}
|
||||
|
||||
using display_t = DisplayT;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
55
include/fennec/platform/linux/wayland/egl/context.h
Normal file
55
include/fennec/platform/linux/wayland/egl/context.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file context.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_EGL_CONTEXT_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_EGL_CONTEXT_H
|
||||
|
||||
#include <fennec/platform/opengl/egl/context.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_eglcontext : public eglcontext {
|
||||
public:
|
||||
explicit wayland_eglcontext(display_server* display);
|
||||
~wayland_eglcontext();
|
||||
|
||||
gfxsurface* create_surface(window* window) override;
|
||||
|
||||
private:
|
||||
FENNEC_RTTI_CLASS_ENABLE(eglcontext) {
|
||||
wayland_server::ctx_registry::register_type<wayland_eglcontext>();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_EGL_CONTEXT_H
|
||||
53
include/fennec/platform/linux/wayland/egl/surface.h
Normal file
53
include/fennec/platform/linux/wayland/egl/surface.h
Normal file
@@ -0,0 +1,53 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file surface.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
|
||||
#ifndef LATFORM_LINUX_WAYLAND_EGL_SURFACE_H
|
||||
#define LATFORM_LINUX_WAYLAND_EGL_SURFACE_H
|
||||
|
||||
#include <fennec/platform/opengl/egl/surface.h>
|
||||
#include <fennec/platform/linux/wayland/fwd.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_eglsurface : public eglsurface {
|
||||
public:
|
||||
wayland_eglsurface(wayland_window* win, eglcontext* ctx);
|
||||
~wayland_eglsurface();
|
||||
|
||||
void resize(const ivec2& size) override;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // LATFORM_LINUX_WAYLAND_EGL_SURFACE_H
|
||||
43
include/fennec/platform/linux/wayland/fwd.h
Normal file
43
include/fennec/platform/linux/wayland/fwd.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file fwd.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_server;
|
||||
class wayland_window;
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_FWD_H
|
||||
@@ -31,6 +31,7 @@
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_SERVER_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_SERVER_H
|
||||
|
||||
#include <fennec/platform/linux/wayland/fwd.h>
|
||||
#include <fennec/platform/interface/display_server.h>
|
||||
|
||||
// forward defs to avoid flooding global namespace
|
||||
@@ -46,7 +47,9 @@ struct xdg_wm_base;
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_server : public display_server {
|
||||
///
|
||||
/// \brief Class for handling the Wayland Display Server
|
||||
class wayland_server : public display_server_base<wayland_server, wayland_window> {
|
||||
public:
|
||||
explicit wayland_server(fennec::platform* p);
|
||||
~wayland_server() override;
|
||||
@@ -55,8 +58,12 @@ public:
|
||||
void disconnect() override;
|
||||
bool connected() const override;
|
||||
|
||||
void dispatch() override;
|
||||
|
||||
window* create_window(const window::config& conf) override;
|
||||
|
||||
void* get_native_handle() override { return display; }
|
||||
|
||||
private:
|
||||
wl_display* display;
|
||||
wl_registry* registry;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_WINDOW_H
|
||||
|
||||
#include <fennec/platform/linux/wayland/fwd.h>
|
||||
#include <fennec/platform/interface/window.h>
|
||||
|
||||
struct wl_array;
|
||||
@@ -44,7 +45,7 @@ struct xdg_toplevel;
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class wayland_window : public window {
|
||||
class wayland_window : public window_base<wayland_server> {
|
||||
public:
|
||||
wayland_window(display_server* server, uint32_t id, const config& cfg);
|
||||
~wayland_window();
|
||||
@@ -52,7 +53,7 @@ public:
|
||||
void show() override;
|
||||
void hide() override;
|
||||
|
||||
void dispatch() override;
|
||||
void* get_native_handle() override;
|
||||
|
||||
bool set_flag(uint8_t flag, bool val) override;
|
||||
|
||||
|
||||
65
include/fennec/platform/opengl/egl/context.h
Normal file
65
include/fennec/platform/opengl/egl/context.h
Normal file
@@ -0,0 +1,65 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file context.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
|
||||
#ifndef FENNEC_PLATFORM_LINUX_WAYLAND_OPENGL_EGLCONTEXT_H
|
||||
#define FENNEC_PLATFORM_LINUX_WAYLAND_OPENGL_EGLCONTEXT_H
|
||||
|
||||
#include <EGL/egl.h>
|
||||
|
||||
#include <fennec/platform/linux/wayland/server.h>
|
||||
#include <fennec/renderers/opengl/glcontext.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class eglcontext : public glcontext {
|
||||
public:
|
||||
eglcontext(display_server* display);
|
||||
~eglcontext();
|
||||
|
||||
bool is_valid() override;
|
||||
|
||||
private:
|
||||
EGLDisplay _egldisplay;
|
||||
EGLContext _eglcontext;
|
||||
EGLConfig _eglconfig;
|
||||
EGLint _eglvmajor, _eglvminor, _eglctype;
|
||||
cstring _extensions;
|
||||
|
||||
FENNEC_RTTI_CLASS_ENABLE(glcontext) {
|
||||
}
|
||||
|
||||
friend class eglsurface;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_LINUX_WAYLAND_OPENGL_EGLCONTEXT_H
|
||||
43
include/fennec/platform/opengl/egl/fwd.h
Normal file
43
include/fennec/platform/opengl/egl/fwd.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file fwd.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
|
||||
#ifndef FENNEC_PLATFORM_OPENGL_EGL_FWD_H
|
||||
#define FENNEC_PLATFORM_OPENGL_EGL_FWD_H
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class eglcontext;
|
||||
class eglsurface;
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_PLATFORM_OPENGL_EGL_FWD_H
|
||||
58
include/fennec/platform/opengl/egl/surface.h
Normal file
58
include/fennec/platform/opengl/egl/surface.h
Normal file
@@ -0,0 +1,58 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
///
|
||||
/// \file surface.h
|
||||
/// \brief
|
||||
///
|
||||
///
|
||||
/// \details
|
||||
/// \author Medusa Slockbower
|
||||
///
|
||||
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
||||
///
|
||||
///
|
||||
|
||||
|
||||
#ifndef FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H
|
||||
#define FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H
|
||||
|
||||
#include <EGL/egl.h>
|
||||
|
||||
#include <fennec/platform/opengl/egl/fwd.h>
|
||||
#include <fennec/renderers/interface/gfxsurface.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
class eglsurface : public gfxsurface {
|
||||
public:
|
||||
eglsurface(fennec::window* win, eglcontext* ctx, EGLNativeWindowType eglwindow);
|
||||
~eglsurface();
|
||||
|
||||
void make_current() override;
|
||||
void swap() override;
|
||||
|
||||
protected:
|
||||
EGLNativeWindowType _eglwindow;
|
||||
EGLSurface _eglsurface;
|
||||
};
|
||||
|
||||
} // fennec
|
||||
|
||||
#endif // FENNEC_PLATFORM_OPENGL_EGL_SURFACE_H
|
||||
Reference in New Issue
Block a user