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_scene.hpp
src/script_scene.cpp
src/script_visual.cpp
)
add_library(pwscripting

View file

@ -4,6 +4,9 @@
#include "pw/system/input.hpp"
#include "pw/system/display.hpp"
// hijacking
#include "pw/visual/pipeline.hpp"
namespace pw {
void script_system::load(sol::table &ns)
@ -29,6 +32,10 @@ void script_system::load(sol::table &ns)
"all",&display::all,
"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()
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
print(pw.input:get().mouse_position.x,pw.input:get().mouse_position.y)
-- w.fullscreen = not w.fullscreen
end
-- print("update")

View file

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

View file

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

View file

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

View file

@ -1,11 +1,14 @@
#include "pw/core/size.hpp"
#include "pw/core/matrix.hpp"
#include "pw/visual/pipeline.hpp"
#include "glad/glad.h"
namespace pw {
struct pipeline {
struct pipeline::impl {
sizei _size;
@ -15,8 +18,17 @@ struct pipeline {
GLuint rboColorId;
GLuint rboDepthId;
bool create()
{
bool create(sizei size);
void draw();
impl() = default;
~impl() = default;
};
bool pipeline::impl::create(sizei size)
{
int max_msaa;
// query actual maximum MSAA
@ -25,7 +37,7 @@ struct pipeline {
// create a 4x MSAA renderbuffer object for colorbuffer
int msaa = 4;
// msaa = std::clamp(msaa,max_msaa);
// msaa = std::clamp(msaa,max_msaa);
glGenRenderbuffers(1, &rboColorId);
glBindRenderbuffer(GL_RENDERBUFFER, rboColorId);
@ -58,10 +70,10 @@ struct pipeline {
return false;
return true;
}
}
void draw()
{
void pipeline::impl::draw()
{
/* We are going to blit into the window (default framebuffer) */
glBindFramebuffer (GL_DRAW_FRAMEBUFFER, 0);
glDrawBuffer (GL_BACK); /* Use backbuffer as color dst. */
@ -75,10 +87,22 @@ struct pipeline {
0,0, _size.width, _size.height,
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
GL_NEAREST);
}
}
};
//
//
//
pipeline::pipeline()
: _impl(std::make_unique<pipeline::impl>())
{
}
bool pipeline::create(size s)
{
return _impl->create(sizei(s.width,s.height));
}
}