further cleanup
This commit is contained in:
parent
075d18b4b8
commit
05dea19436
8 changed files with 54 additions and 25 deletions
|
@ -40,6 +40,9 @@ private:
|
|||
int _mouse_button;
|
||||
bool _mouse_pressed;
|
||||
|
||||
int _key_code;
|
||||
bool _key_pressed;
|
||||
|
||||
std::string _input_string;
|
||||
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ public:
|
|||
|
||||
void set_on_update(on_update_t f) { _on_update = f; }
|
||||
|
||||
bool visible() const;
|
||||
void set_visible(bool is_visible);
|
||||
protected:
|
||||
|
||||
on_update_t _on_update;
|
||||
|
|
|
@ -70,12 +70,15 @@ struct window::impl {
|
|||
|
||||
static void cursor_pos_callback(GLFWwindow* window, double xpos, double ypos)
|
||||
{
|
||||
input::get()._mouse_position = point(xpos,ypos);
|
||||
input::get()._mouse_position = pointd(xpos,ypos).cast<float>();
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow *window,int key, int scancode, int action, int mods)
|
||||
{
|
||||
std::cout << __FUNCTION__ << std::endl;
|
||||
input::get()._key_code = scancode;
|
||||
input::get()._key_pressed = action;
|
||||
// action 0,1,2
|
||||
// std::cout << __FUNCTION__ << action << std::endl;
|
||||
}
|
||||
|
||||
// static void character_callback(GLFWwindow* window, unsigned int codepoint)
|
||||
|
@ -167,7 +170,7 @@ struct window::impl {
|
|||
|
||||
glfwSetWindowUserPointer(_window,this);
|
||||
|
||||
glfwSetFramebufferSizeCallback(_window, window::impl::framebuffer_size_callback);
|
||||
//glfwSetFramebufferSizeCallback(_window, window::impl::framebuffer_size_callback);
|
||||
glfwSetKeyCallback(_window, window::impl::key_callback);
|
||||
// glfwSetCharCallback(_window, character_callback);
|
||||
glfwSetCharModsCallback(_window, charmods_callback);
|
||||
|
@ -200,13 +203,6 @@ struct window::impl {
|
|||
|
||||
_parent._on_update(_parent);
|
||||
|
||||
|
||||
// do other stuff
|
||||
#if 0
|
||||
glClearColor(1,0,0,1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
#endif
|
||||
|
||||
glfwSwapBuffers(_window);
|
||||
|
||||
return true;
|
||||
|
@ -280,6 +276,14 @@ struct window::impl {
|
|||
bool fullscreen() const {
|
||||
return glfwGetWindowMonitor(_window) != nullptr;
|
||||
}
|
||||
|
||||
void set_visible(bool show) {
|
||||
(show) ? glfwShowWindow(_window) : glfwHideWindow(_window);
|
||||
}
|
||||
|
||||
bool visible() const {
|
||||
return glfwGetWindowAttrib(_window, GLFW_VISIBLE) > 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -343,6 +347,15 @@ void window::set_fullscreen(bool use_fullscreen)
|
|||
_impl->set_fullscreen(use_fullscreen);
|
||||
}
|
||||
|
||||
bool window::visible() const
|
||||
{
|
||||
return _impl->visible();
|
||||
}
|
||||
|
||||
void window::set_visible(bool is_visible)
|
||||
{
|
||||
_impl->set_visible(is_visible);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue