sync to keep working
This commit is contained in:
parent
236cdd5ef7
commit
e267a0d2ed
12 changed files with 154 additions and 89 deletions
|
@ -5,11 +5,15 @@
|
|||
#include <pw/core/size.hpp>
|
||||
#include <pw/core/point.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace pw {
|
||||
|
||||
class window {
|
||||
public:
|
||||
|
||||
typedef std::function<void(window&)> on_update_t;
|
||||
|
||||
window();
|
||||
~window();
|
||||
|
||||
|
@ -28,9 +32,12 @@ public:
|
|||
bool fullscreen() const;
|
||||
void set_fullscreen(bool use_fullscreen);
|
||||
|
||||
void set_on_update(on_update_t f) { _on_update = f; }
|
||||
|
||||
protected:
|
||||
|
||||
on_update_t _on_update;
|
||||
|
||||
struct impl;
|
||||
std::unique_ptr<impl> _impl;
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ namespace pw {
|
|||
|
||||
struct window::impl {
|
||||
|
||||
window& _parent;
|
||||
|
||||
GLFWwindow *_window = nullptr;
|
||||
|
||||
sizei _old_size;
|
||||
|
@ -125,7 +127,8 @@ struct window::impl {
|
|||
|
||||
}
|
||||
|
||||
impl()
|
||||
impl(window& w)
|
||||
: _parent(w)
|
||||
{
|
||||
// initialize
|
||||
glfwInit();
|
||||
|
@ -190,6 +193,9 @@ struct window::impl {
|
|||
// get new events
|
||||
glfwPollEvents();
|
||||
|
||||
_parent._on_update(_parent);
|
||||
|
||||
|
||||
// do other stuff
|
||||
#if 0
|
||||
glClearColor(1,0,0,1);
|
||||
|
@ -270,7 +276,8 @@ struct window::impl {
|
|||
|
||||
|
||||
window::window()
|
||||
: _impl(std::make_unique<window::impl>())
|
||||
: _impl(std::make_unique<window::impl>(*this))
|
||||
, _on_update([](window&){})
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue