1 #include "core/instance.hpp"
2 #include "lua/internal.hpp"
3 #include "library/framebuffer.hpp"
4 #include "library/lua-framebuffer.hpp"
8 struct render_object_pixel
: public framebuffer::object
10 render_object_pixel(int32_t _x
, int32_t _y
, framebuffer::color _color
) throw()
11 : x(_x
), y(_y
), color(_color
) {}
12 ~render_object_pixel() throw() {}
13 template<bool X
> void op(struct framebuffer::fb
<X
>& scr
) throw()
15 int32_t _x
= x
+ scr
.get_origin_x();
16 int32_t _y
= y
+ scr
.get_origin_y();
17 if(_x
< 0 || static_cast<uint32_t>(_x
) >= scr
.get_width())
19 if(_y
< 0 || static_cast<uint32_t>(_y
) >= scr
.get_height())
21 color
.apply(scr
.rowptr(_y
)[_x
]);
23 void operator()(struct framebuffer::fb
<true>& scr
) throw() { op(scr
); }
24 void operator()(struct framebuffer::fb
<false>& scr
) throw() { op(scr
); }
25 void clone(framebuffer::queue
& q
) const throw(std::bad_alloc
) { q
.clone_helper(this); }
29 framebuffer::color color
;
32 int pixel(lua::state
& L
, lua::parameters
& P
)
36 framebuffer::color pcolor
;
38 if(!core
.lua2
->render_ctx
) return 0;
40 P(x
, y
, P
.optional(pcolor
, 0xFFFFFFU
));
42 core
.lua2
->render_ctx
->queue
->create_add
<render_object_pixel
>(x
, y
, pcolor
);
46 lua::functions
LUA_pixel_fns(lua_func_misc
, "gui", {