63 lines
1.0 KiB
C++
63 lines
1.0 KiB
C++
#pragma once
|
|
#ifndef H_WINDOW_
|
|
#define H_WINDOW_
|
|
|
|
#include <cstddef>
|
|
#include <functional>
|
|
|
|
#include <EGL/egl.h>
|
|
#include <EGL/eglext.h>
|
|
#include <GLES2/gl2.h>
|
|
|
|
#define UNUSED(x) (void)(x)
|
|
|
|
typedef std::function<void()> IFrameListener;
|
|
|
|
class WindowImpl {
|
|
public:
|
|
WindowImpl() = default;
|
|
virtual ~WindowImpl() = default;
|
|
|
|
WindowImpl(const WindowImpl&) = delete;
|
|
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;
|
|
|
|
friend class Window;
|
|
};
|
|
|
|
class Window {
|
|
public:
|
|
Window(size_t width, size_t height);
|
|
virtual ~Window();
|
|
|
|
static void Init();
|
|
|
|
Window(const Window &) = delete;
|
|
Window(Window &&) = delete;
|
|
|
|
public:
|
|
bool Running() const;
|
|
size_t GetWidth() const;
|
|
size_t GetHeight() const;
|
|
|
|
public:
|
|
void Run();
|
|
void OnFrame(IFrameListener fn);
|
|
|
|
private:
|
|
WindowImpl* m_impl;
|
|
|
|
private: // app logic
|
|
uint32_t m_last_time;
|
|
size_t m_width;
|
|
size_t m_height;
|
|
bool m_running;
|
|
};
|
|
|
|
#endif // H_WINDOW_
|