output render callback accepts { : output : renderer }
This commit is contained in:
parent
b804bb1c1f
commit
7c061624c7
@ -230,7 +230,8 @@ output_frame_notify(struct wl_listener *listener, void *data)
|
|||||||
wl_signal_emit(&view->events.post_render, &rdata);
|
wl_signal_emit(&view->events.post_render, &rdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_signal_emit(&output->events.render, output);
|
rdata.data = NULL;
|
||||||
|
wl_signal_emit(&output->events.render, &rdata);
|
||||||
|
|
||||||
render_layer(&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &rdata);
|
render_layer(&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &rdata);
|
||||||
render_layer(&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &rdata);
|
render_layer(&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &rdata);
|
||||||
|
@ -305,10 +305,13 @@ kiwmi_output_on_render_notify(struct wl_listener *listener, void *data)
|
|||||||
struct kiwmi_lua_callback *lc = wl_container_of(listener, lc, listener);
|
struct kiwmi_lua_callback *lc = wl_container_of(listener, lc, listener);
|
||||||
struct kiwmi_server *server = lc->server;
|
struct kiwmi_server *server = lc->server;
|
||||||
lua_State *L = server->lua->L;
|
lua_State *L = server->lua->L;
|
||||||
struct kiwmi_output *output = data;
|
struct kiwmi_render_data *rdata = data;
|
||||||
|
struct kiwmi_output *output = rdata->output->data;
|
||||||
|
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, lc->callback_ref);
|
lua_rawgeti(L, LUA_REGISTRYINDEX, lc->callback_ref);
|
||||||
|
|
||||||
|
lua_newtable(L);
|
||||||
|
|
||||||
lua_pushcfunction(L, luaK_kiwmi_output_new);
|
lua_pushcfunction(L, luaK_kiwmi_output_new);
|
||||||
lua_pushlightuserdata(L, server->lua);
|
lua_pushlightuserdata(L, server->lua);
|
||||||
lua_pushlightuserdata(L, output);
|
lua_pushlightuserdata(L, output);
|
||||||
@ -318,6 +321,20 @@ kiwmi_output_on_render_notify(struct wl_listener *listener, void *data)
|
|||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
lua_setfield(L, -2, "output");
|
||||||
|
|
||||||
|
lua_pushcfunction(L, luaK_kiwmi_renderer_new);
|
||||||
|
lua_pushlightuserdata(L, server->lua);
|
||||||
|
lua_pushlightuserdata(L, rdata->renderer);
|
||||||
|
lua_pushlightuserdata(L, output);
|
||||||
|
|
||||||
|
if (lua_pcall(L, 3, 1, 0)) {
|
||||||
|
wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1));
|
||||||
|
lua_pop(L, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_setfield(L, -2, "renderer");
|
||||||
|
|
||||||
if (lua_pcall(L, 1, 0, 0)) {
|
if (lua_pcall(L, 1, 0, 0)) {
|
||||||
wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1));
|
wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1));
|
||||||
|
31
rc.fnl
31
rc.fnl
@ -1,4 +1,33 @@
|
|||||||
(kiwmi:on "output" #(doto $1 (: :set_mode 360 720 0)))
|
(local { : GdkPixbuf } (require :lgi))
|
||||||
|
(local { : view } (require :fennel))
|
||||||
|
|
||||||
|
(var texture nil)
|
||||||
|
|
||||||
|
(local pixels
|
||||||
|
(let [(buf err) (GdkPixbuf.Pixbuf.new_from_file "globe.png")]
|
||||||
|
(if (not buf) (print :err err))
|
||||||
|
buf))
|
||||||
|
|
||||||
|
(kiwmi:on
|
||||||
|
"output"
|
||||||
|
(fn [output]
|
||||||
|
(output:set_mode 360 720 0)
|
||||||
|
(let [r (output:renderer)]
|
||||||
|
(set texture (r:texture_from_pixels
|
||||||
|
pixels.rowstride
|
||||||
|
pixels.width
|
||||||
|
pixels.height
|
||||||
|
(pixels:get_pixels)))
|
||||||
|
(output:on "render"
|
||||||
|
(fn [{: output : renderer}]
|
||||||
|
(renderer:draw_texture
|
||||||
|
texture
|
||||||
|
[1 0 0
|
||||||
|
0 1 0
|
||||||
|
0 0 1]
|
||||||
|
150 150 0.7)))
|
||||||
|
(print :texture texture))))
|
||||||
|
|
||||||
(kiwmi:on "view"
|
(kiwmi:on "view"
|
||||||
(fn [view]
|
(fn [view]
|
||||||
(let [(w h) (: (kiwmi:active_output) :size)]
|
(let [(w h) (: (kiwmi:active_output) :size)]
|
||||||
|
Loading…
Reference in New Issue
Block a user