sync to keep working

This commit is contained in:
Hartmut Seichter 2019-01-14 21:48:16 +01:00
parent 236cdd5ef7
commit e267a0d2ed
12 changed files with 154 additions and 89 deletions

View file

@ -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;

View file

@ -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&){})
{
}