1 #include "lua/internal.hpp"
2 #include "library/framebuffer.hpp"
3 #include "library/lua-framebuffer.hpp"
7 struct render_object_pixel
: public framebuffer::object
9 render_object_pixel(int32_t _x
, int32_t _y
, framebuffer::color _color
) throw()
10 : x(_x
), y(_y
), color(_color
) {}
11 ~render_object_pixel() throw() {}
12 template<bool X
> void op(struct framebuffer::fb
<X
>& scr
) throw()
14 color
.set_palette(scr
);
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
)
35 framebuffer::color pcolor
;
37 if(!lua_render_ctx
) return 0;
39 P(x
, y
, P
.optional(pcolor
, 0xFFFFFFU
));
41 lua_render_ctx
->queue
->create_add
<render_object_pixel
>(x
, y
, pcolor
);
45 lua::functions
pixel_fns(lua_func_misc
, "gui", {