some cleanup
This commit is contained in:
parent
b25ab14587
commit
67ae8daef3
10 changed files with 46 additions and 46 deletions
|
@ -216,12 +216,12 @@ void register_core_function(sol::state& lua,sol::table& ns)
|
|||
|
||||
|
||||
auto image_type = ns.new_usertype<image>("image"
|
||||
, sol::constructors<image()>()
|
||||
,"create",&image::create
|
||||
,"size",sol::readonly_property(&image::size)
|
||||
,"generate_noise",&image::generate_noise
|
||||
,"change_count",sol::property(&image::change_count,&image::set_change_count)
|
||||
);
|
||||
,sol::call_constructor,sol::constructors<image(),image(const size&,image::pixel_layout pl,const void*)>()
|
||||
,"create",&image::create
|
||||
,"size",sol::readonly_property(&image::size)
|
||||
,"generate_noise",&image::generate_noise
|
||||
,"change_count",sol::property(&image::change_count,&image::set_change_count)
|
||||
);
|
||||
|
||||
ns.create_named("pixel_layout"
|
||||
,"rgb8", image::RGB8
|
||||
|
@ -239,8 +239,9 @@ void register_core_function(sol::state& lua,sol::table& ns)
|
|||
,sol::call_constructor,sol::constructors<rectangle(),rectangle(const point_<float>&,const size_<float>&)>()
|
||||
);
|
||||
|
||||
auto mathf_table = ns.create_named("mathf");
|
||||
mathf_table.set_function("ping_pong",ping_pong<real_t>);
|
||||
// some math function
|
||||
ns.create_named("mathf")
|
||||
.set_function("ping_pong",ping_pong<real_t>);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace pw {
|
|||
void register_io_function(sol::state&,sol::table& ns)
|
||||
{
|
||||
ns.new_usertype<image_io>("image_io"
|
||||
,"new", sol::no_constructor
|
||||
,"new",sol::no_constructor
|
||||
,"get",&image_io::get
|
||||
,"read",&image_io::read
|
||||
,"write",&image_io::write
|
||||
|
|
|
@ -17,14 +17,14 @@ void register_scene_function(sol::state&,sol::table &ns)
|
|||
{
|
||||
|
||||
ns.new_usertype<scene>("scene",
|
||||
sol::constructors<scene()>()
|
||||
sol::call_constructor,sol::constructors<scene()>()
|
||||
,"count_all_entities",sol::readonly_property(&scene::count_all_enties)
|
||||
,"count_alive_entities",sol::readonly_property(&scene::count_alive_enties)
|
||||
);
|
||||
|
||||
|
||||
ns.new_usertype<entity>("entity"
|
||||
,sol::constructors<entity(),entity(const entity&),entity(scene&)>()
|
||||
,sol::call_constructor,sol::constructors<entity(),entity(const entity&),entity(scene&)>()
|
||||
,"add_child",&entity::add_child
|
||||
,"remove_child",&entity::remove_child
|
||||
,"child_count",sol::readonly_property(&entity::child_count)
|
||||
|
|
|
@ -42,7 +42,7 @@ void register_system_function(sol::state&, sol::table &ns)
|
|||
);
|
||||
|
||||
ns.new_usertype<path>("path"
|
||||
,"new", sol::no_constructor
|
||||
,"new",sol::no_constructor
|
||||
,"get",&path::get
|
||||
,"separator",sol::readonly_property(&path::separator)
|
||||
,"resource_paths",sol::readonly_property(&path::resource_paths)
|
||||
|
|
|
@ -16,13 +16,13 @@ namespace pw {
|
|||
void register_visual_function(sol::state& lua,sol::table &ns)
|
||||
{
|
||||
|
||||
ns.new_usertype<pipeline>("pipeline"
|
||||
,"create",&pipeline::create
|
||||
,"draw",&pipeline::draw
|
||||
);
|
||||
// ns.new_usertype<pipeline>("pipeline"
|
||||
// ,"create",&pipeline::create
|
||||
// ,"draw",&pipeline::draw
|
||||
// );
|
||||
|
||||
ns.new_usertype<shader>("shader"
|
||||
,sol::constructors<shader()>()
|
||||
,sol::call_constructor,sol::constructors<shader()>()
|
||||
,"ready",sol::readonly_property(&shader::ready)
|
||||
,"use",&shader::use
|
||||
,"build",&shader::build
|
||||
|
@ -54,7 +54,7 @@ void register_visual_function(sol::state& lua,sol::table &ns)
|
|||
|
||||
|
||||
ns.new_usertype<renderer>("renderer"
|
||||
,sol::constructors<renderer(),renderer(const geometry&)>()
|
||||
,sol::call_constructor,sol::constructors<renderer(),renderer(const geometry&)>()
|
||||
,"create",&renderer::create
|
||||
,"ready",sol::readonly_property(&renderer::ready)
|
||||
,"release",&renderer::release
|
||||
|
@ -62,14 +62,14 @@ void register_visual_function(sol::state& lua,sol::table &ns)
|
|||
);
|
||||
|
||||
ns.new_usertype<framebuffer>("framebuffer"
|
||||
,sol::constructors<framebuffer()>()
|
||||
,sol::call_constructor,sol::constructors<framebuffer()>()
|
||||
,"create",&framebuffer::create
|
||||
,"bind",&framebuffer::bind
|
||||
,"unbind",&framebuffer::unbind
|
||||
,"blit",&framebuffer::blit);
|
||||
|
||||
ns.new_usertype<texture>("texture"
|
||||
,sol::constructors<texture()>()
|
||||
,sol::call_constructor,sol::constructors<texture()>()
|
||||
,"create",&texture::create
|
||||
,"update",&texture::update
|
||||
,"bind",&texture::bind
|
||||
|
@ -78,7 +78,7 @@ void register_visual_function(sol::state& lua,sol::table &ns)
|
|||
);
|
||||
|
||||
ns.new_usertype<context>("context"
|
||||
,sol::constructors<context()>()
|
||||
,sol::call_constructor,sol::constructors<context()>()
|
||||
,"clear",&context::clear
|
||||
,"set_viewport",&context::set_viewport
|
||||
,"get_error",&context::get_error
|
||||
|
|
|
@ -15,13 +15,13 @@ local w = pw.window.new()
|
|||
w.title = "pixwerx - bare rendering"
|
||||
|
||||
-- set size
|
||||
w.size = pw.size.new(640,480)
|
||||
w.size = pw.size(640,480)
|
||||
|
||||
-- move window
|
||||
w.position = pw.point.new(100,100)
|
||||
w.position = pw.point(100,100)
|
||||
|
||||
-- create a new geometry
|
||||
local g = pw.geometry:new()
|
||||
local g = pw.geometry()
|
||||
|
||||
g.primitive_topology = pw.primitive_topology_type.triangle_list -- meh
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ pw.script:load_all()
|
|||
print("executable path:",pw.path.get().executable_path)
|
||||
print("resource path:",pw.path.get().resource_path)
|
||||
|
||||
local img = pw.image.new()
|
||||
if not img:create(pw.size(64,64),pw.pixel_layout.rgb8) then
|
||||
local img = pw.image()
|
||||
if not img:create(pw.size(512,512),pw.pixel_layout.rgb8) then
|
||||
|
||||
print("image couldnt be created")
|
||||
|
||||
|
@ -42,10 +42,10 @@ g.primitive_topology = pw.primitive_topology_type.triangle_list -- meh
|
|||
|
||||
-- create texture coordinates
|
||||
g.texture_coordinates = { {
|
||||
{ 0.0, 0.0 },
|
||||
{ 1.0, 1.0 },
|
||||
{ 1.0, 0.0 },
|
||||
{ 0.0, 1.0 },
|
||||
{ 0.0, 0.0 }
|
||||
{ 0.0, 1.0 }
|
||||
} }
|
||||
|
||||
z = -5.0
|
||||
|
@ -79,7 +79,7 @@ local mm = pw.matrix4x4.identity
|
|||
local mv = pw.matrix4x4()
|
||||
local mp = pw.matrix4x4()
|
||||
|
||||
local s = pw.shader:new()
|
||||
local s = pw.shader()
|
||||
|
||||
s:set_source(pw.shader_type.vertex,[[
|
||||
#version 400
|
||||
|
@ -122,7 +122,7 @@ if not s:build() then
|
|||
end
|
||||
|
||||
-- the renderer for a geometry
|
||||
local renderer = pw.renderer:new()
|
||||
local renderer = pw.renderer()
|
||||
|
||||
if not renderer:create(g) then
|
||||
print("couldn't create renderer")
|
||||
|
@ -134,9 +134,9 @@ local cam_pos = pw.vector3(0,0,0)
|
|||
local model_pos = pw.vector3(0,0,0)
|
||||
|
||||
|
||||
local ctx = pw.context:new()
|
||||
local ctx = pw.context()
|
||||
|
||||
local tx = pw.texture:new()
|
||||
local tx = pw.texture()
|
||||
tx:create(img)
|
||||
|
||||
w.on_resize = function(self)
|
||||
|
@ -171,23 +171,17 @@ w.on_update = function(self)
|
|||
|
||||
-- update the uniforms, currently the slow path
|
||||
s:set_uniform_mat4("model",mm)
|
||||
|
||||
|
||||
|
||||
s:set_uniform_mat4("view",mv)
|
||||
s:set_uniform_mat4("projection",mp)
|
||||
s:set_uniform_vec4("color",cl)
|
||||
|
||||
s:set_uniform_int("tex_color",0)
|
||||
|
||||
|
||||
tx:bind()
|
||||
|
||||
-- draw
|
||||
renderer:draw()
|
||||
|
||||
-- tx:unbind()
|
||||
|
||||
local e = ctx:get_error()
|
||||
if e ~= 0 then
|
||||
print("OpenGL error",e)
|
||||
|
|
|
@ -31,6 +31,8 @@ namespace pw {
|
|||
class path {
|
||||
public:
|
||||
|
||||
using path_list = std::vector<std::string>;
|
||||
|
||||
static path& get();
|
||||
~path();
|
||||
|
||||
|
@ -38,19 +40,15 @@ public:
|
|||
|
||||
std::string executable_path() const;
|
||||
|
||||
std::string resource_path() const;
|
||||
|
||||
typedef std::vector<std::string> path_list;
|
||||
|
||||
std::string find_file(const std::string &filename) const;
|
||||
|
||||
path_list resource_paths() const { return _resource_paths; }
|
||||
void set_resource_paths(path_list pl);
|
||||
|
||||
std::string find_file(const std::string &filename) const;
|
||||
|
||||
std::string get_filename(const std::string &filepath, bool with_extension = true) const;
|
||||
|
||||
protected:
|
||||
|
||||
path_list _plugin_paths;
|
||||
path_list _resource_paths;
|
||||
|
||||
path();
|
||||
|
|
|
@ -81,7 +81,12 @@ std::string path::executable_path() const
|
|||
#endif
|
||||
result.assign(buf.data());
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
void path::set_resource_paths(path::path_list pl)
|
||||
{
|
||||
_resource_paths = pl;
|
||||
}
|
||||
|
||||
std::string path::find_file(const std::string&) const
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include "glad/glad.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace pw {
|
||||
|
||||
// TODO stencil buffer?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue