initial checkin

This commit is contained in:
Hartmut Seichter 2017-06-27 23:20:14 +02:00
commit 8c67b1f632
474 changed files with 145799 additions and 0 deletions

20
src/core/CMakeLists.txt Normal file
View file

@ -0,0 +1,20 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../deps/glfw-3.2.1/include
${CMAKE_CURRENT_SOURCE_DIR}/../deps/lua-5.3.4/src
)
add_library(pw
STATIC
binding.hpp
binding.cpp
context.hpp
context.cpp
core.hpp
core.cpp
window.hpp
window.cpp
)
target_link_libraries(pw lualib glfw)

0
src/core/binding.cpp Normal file
View file

11
src/core/binding.hpp Normal file
View file

@ -0,0 +1,11 @@
#ifndef PW_BINDING_HPP
#define PW_BINDING_HPP
#include <lua.hpp>
namespace pw {
}
#endif

37
src/core/context.cpp Normal file
View file

@ -0,0 +1,37 @@
#include "context.hpp"
#include "window.hpp"
pw::context::context()
: _running(true)
{
_lua.open_libraries();
sol::table pw = _lua.create_named_table("pw");
window::load(pw);
// luaL_openlibs(_state);
}
pw::context::~context()
{
// lua_close(_state);
}
bool pw::context::update()
{
return _running;
}
void pw::context::yield()
{
}
void pw::context::script(const char *s)
{
_lua.script("w = pw.window.new()");
_lua.script("while w:update() do end");
// luaL_loadstring(_state,s);
// int r = lua_pcall(_state,0,LUA_MULTRET,0);
}

36
src/core/context.hpp Normal file
View file

@ -0,0 +1,36 @@
#ifndef PW_CONTEXT_HPP
#define PW_CONTEXT_HPP
#include <lua.hpp>
#include <memory>
#include <sol.hpp>
namespace pw {
class context {
sol::state _lua;
bool _running;
public:
context();
~context();
bool update();
void yield();
void set_running(bool s) { _running = s; }
bool is_running() const { return _running; }
void script(const char* s);
};
}
#endif

8
src/core/core.cpp Normal file
View file

@ -0,0 +1,8 @@
#include <GLFW/glfw3.h>
#include <lua.hpp>
#include <lualib.h>
#include "core.hpp"

7
src/core/core.hpp Normal file
View file

@ -0,0 +1,7 @@
#ifndef PW_CORE_HPP
#define PW_CORE_HPP
#include "context.hpp"
#endif

33
src/core/window.cpp Normal file
View file

@ -0,0 +1,33 @@
#include "window.hpp"
pw::window::window() {
_window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
}
pw::window::~window() {
glfwDestroyWindow(_window);
}
bool pw::window::update()
{
if (!glfwWindowShouldClose(_window)) {
glfwSwapBuffers(_window);
glfwPollEvents();
return true;
}
return false;
}
void pw::window::load(sol::table &ns) {
{
glfwInit();
ns.new_usertype<window>("window",
"update",&window::update
);
}
}

28
src/core/window.hpp Normal file
View file

@ -0,0 +1,28 @@
#ifndef PW_WINDOW_HPP
#define PW_WINDOW_HPP
#include "GLFW/glfw3.h"
#include "sol.hpp"
namespace pw {
class window {
GLFWwindow* _window;
public:
window();
~window();
bool update();
static void load(sol::table &ns);
};
}
#endif