some experimentation

This commit is contained in:
Hartmut Seichter 2019-01-14 09:42:28 +01:00
parent 9773103a18
commit 665a9a4078
8 changed files with 135 additions and 79 deletions

View file

@ -12,6 +12,7 @@ set(srcs
src/script_system.cpp src/script_system.cpp
src/script_scene.hpp src/script_scene.hpp
src/script_scene.cpp src/script_scene.cpp
src/script_visual.cpp
) )
add_library(pwscripting add_library(pwscripting

View file

@ -4,6 +4,9 @@
#include "pw/system/input.hpp" #include "pw/system/input.hpp"
#include "pw/system/display.hpp" #include "pw/system/display.hpp"
// hijacking
#include "pw/visual/pipeline.hpp"
namespace pw { namespace pw {
void script_system::load(sol::table &ns) void script_system::load(sol::table &ns)
@ -29,6 +32,10 @@ void script_system::load(sol::table &ns)
"all",&display::all, "all",&display::all,
"name",sol::readonly_property(&display::name) "name",sol::readonly_property(&display::name)
); );
ns.new_usertype<pipeline>("pipeline",
"create",&pipeline::create
);
} }
} }

View file

View file

@ -80,10 +80,14 @@ end
while w:update() while w:update()
do do
-- somehow works
if (pw.input.get().input_string == 'f') then
w.fullscreen = not w.fullscreen
end
-- just to check
if (pw.input:get().mouse_button == 1) then if (pw.input:get().mouse_button == 1) then
print(pw.input:get().mouse_position.x,pw.input:get().mouse_position.y) print(pw.input:get().mouse_position.x,pw.input:get().mouse_position.y)
-- w.fullscreen = not w.fullscreen
end end
-- print("update") -- print("update")

View file

@ -19,8 +19,6 @@ public:
std::string input_string() const { return _input_string; } std::string input_string() const { return _input_string; }
~input() = default; ~input() = default;
enum mouse_button_state { enum mouse_button_state {

View file

@ -17,25 +17,25 @@
namespace pw { namespace pw {
struct window_context : context //struct window_context : context
{ //{
virtual bool make_current() override; // virtual bool make_current() override;
virtual void resize() override; // virtual void resize() override;
// virtual context::size size() override; // // virtual context::size size() override;
virtual void flush() override; // virtual void flush() override;
}; //};
bool window_context::make_current() //bool window_context::make_current()
{ //{
} //}
void window_context::resize() //void window_context::resize()
{ //{
} //}
void window_context::flush() //void window_context::flush()
{ //{
} //}
struct window::impl { struct window::impl {
@ -264,6 +264,11 @@ struct window::impl {
}; };
//
//
//
window::window() window::window()
: _impl(std::make_unique<window::impl>()) : _impl(std::make_unique<window::impl>())
{ {

View file

@ -1,6 +1,7 @@
#ifndef PW_VISUAL_PIPELINE_HPP #ifndef PW_VISUAL_PIPELINE_HPP
#define PW_VISUAL_PIPELINE_HPP #define PW_VISUAL_PIPELINE_HPP
#include <pw/core/size.hpp>
#include <pw/core/matrix.hpp> #include <pw/core/matrix.hpp>
#include <pw/core/mesh.hpp> #include <pw/core/mesh.hpp>
@ -8,6 +9,22 @@
namespace pw { namespace pw {
class pipeline {
public:
pipeline();
~pipeline() = default;
void draw();
bool create(size s);
protected:
struct impl;
std::unique_ptr<impl> _impl;
};
} }
#endif #endif

View file

@ -1,11 +1,14 @@
#include "pw/core/size.hpp" #include "pw/core/size.hpp"
#include "pw/core/matrix.hpp" #include "pw/core/matrix.hpp"
#include "pw/visual/pipeline.hpp"
#include "glad/glad.h" #include "glad/glad.h"
namespace pw { namespace pw {
struct pipeline { struct pipeline::impl {
sizei _size; sizei _size;
@ -15,7 +18,16 @@ struct pipeline {
GLuint rboColorId; GLuint rboColorId;
GLuint rboDepthId; GLuint rboDepthId;
bool create() bool create(sizei size);
void draw();
impl() = default;
~impl() = default;
};
bool pipeline::impl::create(sizei size)
{ {
int max_msaa; int max_msaa;
@ -60,7 +72,7 @@ struct pipeline {
return true; return true;
} }
void draw() void pipeline::impl::draw()
{ {
/* We are going to blit into the window (default framebuffer) */ /* We are going to blit into the window (default framebuffer) */
glBindFramebuffer (GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer (GL_DRAW_FRAMEBUFFER, 0);
@ -77,8 +89,20 @@ struct pipeline {
GL_NEAREST); GL_NEAREST);
} }
};
//
//
//
pipeline::pipeline()
: _impl(std::make_unique<pipeline::impl>())
{
}
bool pipeline::create(size s)
{
return _impl->create(sizei(s.width,s.height));
}
} }