this is basically a design document version - it sets the scenery for upcoming additions

This commit is contained in:
Hartmut Seichter 2018-04-02 01:06:50 +02:00
parent 32aac45162
commit 550d27273f
1504 changed files with 1051518 additions and 127 deletions

1
src/ui/CMakeLists.txt Normal file
View file

@ -0,0 +1 @@
add_subdirectory(src)

View file

@ -0,0 +1,43 @@
#ifndef PW_WINDOW_HPP
#define PW_WINDOW_HPP
//#include "glad/glad.h"
#include "GLFW/glfw3.h"
#include "sol.hpp"
namespace pw {
class window;
class context {
GLFWwindow* _window;
public:
context(window& other);
~context();
};
class window {
GLFWwindow* _window;
public:
window();
~window();
bool update();
void set_title(const char* t);
void set_size(int w, int h);
context* get_context();
static void load(sol::table &ns);
};
}
#endif

22
src/ui/src/CMakeLists.txt Normal file
View file

@ -0,0 +1,22 @@
set(hdrs
../include/pw/ui/window.hpp
)
set(srcs
window.cpp
)
add_library(pwui
STATIC
${hdrs}
${srcs}
)
target_include_directories(
pwui
PUBLIC
../include
)
target_link_libraries(pwui pwcore glfw glad)

61
src/ui/src/window.cpp Normal file
View file

@ -0,0 +1,61 @@
#include "pw/ui/window.hpp"
//#include "glad/glad.h"
pw::window::window() {
_window = glfwCreateWindow(640, 480, "pixwerxs", NULL, NULL);
#if 0
glfwMakeContextCurrent(_window);
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
#endif
}
pw::window::~window() {
glfwDestroyWindow(_window);
}
bool pw::window::update()
{
if (!glfwWindowShouldClose(_window)) {
// do other stuff
#if 0
glClearColor(1,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
#endif
glfwSwapBuffers(_window);
glfwPollEvents();
return true;
}
return false;
}
void pw::window::set_title(const char *t)
{
glfwSetWindowTitle(_window,t);
}
void pw::window::set_size(int w,int h) {
glfwSetWindowSize(_window,w,h);
}
void pw::window::load(sol::table &ns)
{
glfwInit();
ns.new_usertype<window>("window",
"update",&window::update,
"set_title",&window::set_title,
"set_size",&window::set_size
);
}