1 #include "lua/internal.hpp"
2 #include "library/framebuffer.hpp"
6 struct render_object_pixel
: public render_object
8 render_object_pixel(int32_t _x
, int32_t _y
, premultiplied_color _color
) throw()
9 : x(_x
), y(_y
), color(_color
) {}
10 ~render_object_pixel() throw() {}
11 template<bool X
> void op(struct framebuffer
<X
>& scr
) throw()
13 color
.set_palette(scr
);
14 int32_t _x
= x
+ scr
.get_origin_x();
15 int32_t _y
= y
+ scr
.get_origin_y();
16 if(_x
< 0 || static_cast<uint32_t>(_x
) >= scr
.get_width())
18 if(_y
< 0 || static_cast<uint32_t>(_y
) >= scr
.get_height())
20 color
.apply(scr
.rowptr(_y
)[_x
]);
22 void operator()(struct framebuffer
<true>& scr
) throw() { op(scr
); }
23 void operator()(struct framebuffer
<false>& scr
) throw() { op(scr
); }
24 void clone(render_queue
& q
) const throw(std::bad_alloc
) { q
.clone_helper(this); }
28 premultiplied_color color
;
31 function_ptr_luafun
gui_pixel(LS
, "gui.pixel", [](lua_state
& L
, const std::string
& fname
) -> int {
34 int64_t color
= 0xFFFFFFU
;
35 int32_t x
= L
.get_numeric_argument
<int32_t>(1, fname
.c_str());
36 int32_t y
= L
.get_numeric_argument
<int32_t>(2, fname
.c_str());
37 L
.get_numeric_argument
<int64_t>(3, color
, fname
.c_str());
38 premultiplied_color
pcolor(color
);
39 lua_render_ctx
->queue
->create_add
<render_object_pixel
>(x
, y
, pcolor
);