WiP
This commit is contained in:
parent
62281699ea
commit
7037abbcb6
11 changed files with 114 additions and 31 deletions
|
@ -58,6 +58,8 @@ public:
|
|||
|
||||
typedef shared_ptr<image> ptr;
|
||||
|
||||
sizei size() const;
|
||||
|
||||
protected:
|
||||
|
||||
sizei _size;
|
||||
|
|
|
@ -48,6 +48,11 @@ uint32_t image::bytes_per_pixel(image::pixel_layout t)
|
|||
return std::numeric_limits<uint32_t>::max();
|
||||
}
|
||||
|
||||
sizei image::size() const
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
image::pixel_layout image::layout() const
|
||||
{
|
||||
return _layout;
|
||||
|
|
|
@ -5,6 +5,7 @@ set(scripts_demo
|
|||
|
||||
set(scripts_test
|
||||
${CMAKE_SOURCE_DIR}/src/scripts/tests/test_core.lua
|
||||
${CMAKE_SOURCE_DIR}/src/scripts/tests/test_io.lua
|
||||
)
|
||||
|
||||
add_executable(pixwerx WIN32 MACOSX_BUNDLE
|
||||
|
|
|
@ -37,13 +37,15 @@ public:
|
|||
|
||||
bool write(const std::string& uri,uint32_t flags = 0);
|
||||
|
||||
~image_io();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
struct impl;
|
||||
std::unique_ptr<impl> _impl;
|
||||
|
||||
image_io() = default;
|
||||
~image_io() = default;
|
||||
image_io();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "pw/io/image_io.hpp"
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
#include "stb_image_write.h"
|
||||
// #include "stb_image_write.h"
|
||||
|
||||
|
||||
namespace pw {
|
||||
|
@ -26,6 +27,11 @@ struct image_io::impl
|
|||
return image();
|
||||
}
|
||||
|
||||
bool write(const std::string& uri, uint32_t flags)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -40,4 +46,22 @@ image image_io::read(const std::string &uri, uint32_t flags)
|
|||
return _impl->read_impl(uri,flags);
|
||||
}
|
||||
|
||||
bool image_io::write(const std::string &uri, uint32_t flags)
|
||||
{
|
||||
return _impl->write(uri,flags);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
image_io::image_io()
|
||||
{
|
||||
_impl = make_unique<impl>();
|
||||
}
|
||||
|
||||
image_io::~image_io()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,13 +5,10 @@ set(hdrs
|
|||
|
||||
set(srcs
|
||||
src/script.cpp
|
||||
# src/script_core.hpp
|
||||
src/script_core.cpp
|
||||
# src/script_system.hpp
|
||||
src/script_system.cpp
|
||||
# src/script_scene.hpp
|
||||
src/script_io.cpp
|
||||
src/script_scene.cpp
|
||||
# src/script_visual.hpp
|
||||
src/script_visual.cpp
|
||||
src/runtime_lua.hpp
|
||||
src/runtime_lua.cpp
|
||||
|
@ -33,4 +30,10 @@ target_include_directories(
|
|||
include
|
||||
)
|
||||
|
||||
target_link_libraries(pwscripting lualib pwcore pwsystem pwscene pwvisual)
|
||||
target_link_libraries(pwscripting
|
||||
lualib
|
||||
pwcore
|
||||
pwsystem
|
||||
pwio
|
||||
pwscene
|
||||
pwvisual)
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace pw {
|
|||
|
||||
PW_REGISTER_DECL_LUA(core)
|
||||
PW_REGISTER_DECL_LUA(system)
|
||||
PW_REGISTER_DECL_LUA(io)
|
||||
PW_REGISTER_DECL_LUA(scene)
|
||||
PW_REGISTER_DECL_LUA(visual)
|
||||
|
||||
|
@ -89,6 +90,7 @@ void script::initialize()
|
|||
|
||||
PW_REGISTER_USE_LUA(core)
|
||||
PW_REGISTER_USE_LUA(system)
|
||||
PW_REGISTER_USE_LUA(io)
|
||||
PW_REGISTER_USE_LUA(scene)
|
||||
PW_REGISTER_USE_LUA(visual)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "pw/core/point.hpp"
|
||||
#include "pw/core/timer.hpp"
|
||||
#include "pw/core/mesh.hpp"
|
||||
#include "pw/core/image.hpp"
|
||||
|
||||
#include "runtime_lua.hpp"
|
||||
|
||||
|
@ -75,6 +76,12 @@ void register_core_function(sol::state& lua,sol::table& ns)
|
|||
, "height",&size::height
|
||||
);
|
||||
|
||||
ns.new_usertype<sizei>("sizei"
|
||||
, sol::constructors<sizei(),sizei(int,int)>()
|
||||
, "width",&sizei::width
|
||||
, "height",&sizei::height
|
||||
);
|
||||
|
||||
ns.new_usertype<point>("point",
|
||||
sol::constructors<point(),point(Scalar,Scalar)>(),
|
||||
"x",&point::x,
|
||||
|
@ -109,6 +116,17 @@ void register_core_function(sol::state& lua,sol::table& ns)
|
|||
, "line_strip", mesh::topology_type::line_strip
|
||||
);
|
||||
|
||||
ns.new_usertype<image>("image"
|
||||
,"create",&image::create
|
||||
,"size",sol::readonly_property(&image::size)
|
||||
,"change_count",sol::property(&image::change_count,&image::set_change_count)
|
||||
|
||||
).new_enum("layout"
|
||||
,"rgb8", image::RGB8
|
||||
,"rgb32", image::RGBA8
|
||||
,"gray", image::LUM);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
21
src/scripting/src/script_io.cpp
Normal file
21
src/scripting/src/script_io.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include "pw/io/image_io.hpp"
|
||||
#include "runtime_lua.hpp"
|
||||
|
||||
|
||||
|
||||
namespace pw {
|
||||
|
||||
|
||||
void register_io_function(sol::state& lua,sol::table& ns)
|
||||
{
|
||||
ns.new_usertype<image_io>("imageio"
|
||||
,"new", sol::no_constructor
|
||||
,"get",&image_io::get
|
||||
,"read",&image_io::read
|
||||
, "write",&image_io::write
|
||||
);
|
||||
}
|
||||
|
||||
PW_REGISTER_LUA(io)
|
||||
|
||||
}
|
11
src/scripts/tests/test_io.lua
Normal file
11
src/scripts/tests/test_io.lua
Normal file
|
@ -0,0 +1,11 @@
|
|||
--
|
||||
-- pixwerx - test - io
|
||||
--
|
||||
|
||||
-- loading our libraries
|
||||
pw.script:load_all()
|
||||
|
||||
local img = pw.imageio:get():read("/home/hartmut/Development/pixwerx/share/assets/textures/checkerboard-512-32.png",0)
|
||||
|
||||
print(img.size.width,img.size.height)
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
|
||||
#include "pw/core/size.hpp"
|
||||
#include "pw/core/matrix.hpp"
|
||||
#include "pw/core/mesh.hpp"
|
||||
#include "pw/core/timer.hpp"
|
||||
|
||||
|
||||
#include "pw/core/debug.hpp"
|
||||
#include "pw/visual/pipeline.hpp"
|
||||
#include "pw/visual/shader.hpp"
|
||||
|
@ -19,7 +17,6 @@ class queue {
|
|||
// vector<commands> ...
|
||||
};
|
||||
|
||||
|
||||
struct triangle_renderer
|
||||
{
|
||||
GLuint vbo = 0;
|
||||
|
@ -35,11 +32,8 @@ struct triangle_renderer
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
|
||||
mesh::vertex3array_t vertices = {
|
||||
{ 0.0f, 0.5f, 0.0f}
|
||||
,{ 0.5f, -0.5f, 0.0f}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue