feat: on frame listener

This commit is contained in:
2026-02-13 13:53:47 +01:00
parent 7f9de651d4
commit 2912ebb91c
5 changed files with 40 additions and 12 deletions

View File

@@ -3,6 +3,7 @@
#define H_WINDOW_
#include <cstddef>
#include <functional>
#include <EGL/egl.h>
#include <EGL/eglext.h>
@@ -10,6 +11,8 @@
#define UNUSED(x) (void)(x)
typedef std::function<void()> IFrameListener;
class WindowImpl {
public:
WindowImpl() = default;
@@ -19,6 +22,7 @@ public:
WindowImpl(WindowImpl&&) = delete;
protected:
virtual bool Dispatch() = 0;
virtual void OnFrame(IFrameListener fn) = 0;
virtual size_t GetWidth() const = 0;
virtual size_t GetHeight() const = 0;
@@ -39,6 +43,10 @@ public:
size_t GetWidth() const;
size_t GetHeight() const;
public:
void Run();
void OnFrame(IFrameListener fn);
private:
WindowImpl* m_impl;

View File

@@ -10,6 +10,7 @@ public:
public:
bool Dispatch() override;
void OnFrame(IFrameListener fn) override;
size_t GetWidth() const override;
size_t GetHeight() const override;
@@ -45,5 +46,7 @@ private:
bool m_running = false;
size_t m_width, m_height;
IFrameListener m_on_frame;
};