renamed logger into debug and start of piping through the GLFW input system to the script system

This commit is contained in:
Hartmut Seichter 2019-01-09 11:34:19 +01:00
parent 24154087ba
commit b8f5681131
9 changed files with 193 additions and 169 deletions

View file

@ -1,23 +1,25 @@
set(hdrs
include/pw/system/window.hpp
)
include/pw/system/window.hpp
include/pw/system/input.hpp
)
set(srcs
src/window.cpp
)
src/window.cpp
src/input.cpp
)
add_library(pwsystem
STATIC
${hdrs}
${srcs}
)
STATIC
${hdrs}
${srcs}
)
target_include_directories(
pwsystem
PUBLIC
include
)
pwsystem
PUBLIC
include
)
target_link_libraries(pwsystem pwcore pwvisual glfw glad)

View file

@ -1,7 +1,8 @@
#ifndef PW_WINDOW_HPP
#define PW_WINDOW_HPP
#ifndef PW_SYSTEM_WINDOW_HPP
#define PW_SYSTEM_WINDOW_HPP
#include <pw/core/globals.hpp>
#include <pw/core/size.hpp>
namespace pw {
@ -14,12 +15,12 @@ public:
bool update();
void set_title(const std::string& title);
void set_size(int w, int h);
size get_size() const;
// context* get_context();
typedef void drop_callback;
int get_heigth();
int get_width();
protected:

View file

@ -4,6 +4,7 @@
//#include "glad/glad.h"
#include "pw/visual/context.hpp"
#include "pw/system/input.hpp"
#include <iostream>
@ -34,10 +35,18 @@ struct window::impl {
// window_context _context;
static void key_callback(GLFWwindow *window,int key, int scancode, int action, int mods)
{
}
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
window::impl* impl = static_cast<window::impl*>(glfwGetWindowUserPointer(window));
// impl->on_resize(width,height);
// impl->on_resize(width,height);
// std::cout << "framebuffer " << width << "x" << height << std::endl;
// glViewport(0, 0, width, height);
@ -50,7 +59,9 @@ struct window::impl {
_window = glfwCreateWindow(640, 480, "pixwerxs", nullptr, nullptr);
glfwSetWindowUserPointer(_window,this);
glfwSetFramebufferSizeCallback(_window, window::impl::framebuffer_size_callback);
glfwSetKeyCallback(_window, window::impl::key_callback);
#if 0
@ -70,6 +81,7 @@ struct window::impl {
{
if (!glfwWindowShouldClose(_window)) {
glfwPollEvents();
// do other stuff
@ -97,6 +109,14 @@ struct window::impl {
glfwSetWindowSize(_window,w,h);
}
::pw::size size() const {
int w,h;
glfwGetWindowSize(_window,&w,&h);
return ::pw::size(w,h);
}
};
@ -125,19 +145,11 @@ void window::set_size(int w,int h)
_impl->set_size(w,h);
}
int window::get_width()
size window::get_size() const
{
// int w,h;
// glfwGetWindowSize(_window,&w,&h);
// return w;
}
int window::get_heigth()
{
// int w,h;
// glfwGetWindowSize(_window,&w,&h);
// return h;
return _impl->size();
}
}