Refactor render queue management
[lsnes.git] / src / lua / gui-pixel.cpp
blob4089cf81e927e64664880578e72ed60920daff13
1 #include "core/lua-int.hpp"
2 #include "core/render.hpp"
4 namespace
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 void operator()(struct screen& scr) throw()
13 color.set_palette(scr);
14 int32_t _x = x + scr.originx;
15 int32_t _y = y + scr.originy;
16 if(_x < 0 || static_cast<uint32_t>(_x) >= scr.width)
17 return;
18 if(_y < 0 || static_cast<uint32_t>(_y) >= scr.height)
19 return;
20 color.apply(scr.rowptr(_y)[_x]);
22 private:
23 int32_t x;
24 int32_t y;
25 premultiplied_color color;
28 function_ptr_luafun gui_pixel("gui.pixel", [](lua_State* LS, const std::string& fname) -> int {
29 if(!lua_render_ctx)
30 return 0;
31 int64_t color = 0xFFFFFFU;
32 int32_t x = get_numeric_argument<int32_t>(LS, 1, fname.c_str());
33 int32_t y = get_numeric_argument<int32_t>(LS, 2, fname.c_str());
34 get_numeric_argument<int64_t>(LS, 3, color, fname.c_str());
35 premultiplied_color pcolor(color);
36 lua_render_ctx->queue->create_add<render_object_pixel>(x, y, pcolor);
37 return 0;
38 });