Skip to content

Commit

Permalink
Disable screenshot extension in headless mode (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
JCash authored Oct 19, 2020
1 parent 9424c01 commit f066f19
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions screenshot/src/screenshot.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// copyright britzl

#if !defined(DM_HEADLESS)

// Extension lib defines
#define LIB_NAME "Screenshot"
#define MODULE_NAME "screenshot"
Expand Down Expand Up @@ -249,16 +252,16 @@ static int HTML5_screenshot(lua_State* L) {
h = luaL_checkint(L, 4);
fn_num = 5;
}

cbk.m_L = dmScript::GetMainThread(L);
luaL_checktype(L, fn_num, LUA_TFUNCTION);
lua_pushvalue(L, fn_num);
cbk.m_Callback = dmScript::Ref(L, LUA_REGISTRYINDEX);
dmScript::GetInstance(L);
cbk.m_Self = dmScript::Ref(L, LUA_REGISTRYINDEX);

screenshot_on_the_next_frame(JsToCCallback, x, y, w, h);

assert(top == lua_gettop(L));
return 0;
}
Expand Down Expand Up @@ -310,3 +313,10 @@ dmExtension::Result FinalizeScreenshotExtension(dmExtension::Params* params) {
// DM_DECLARE_EXTENSION(symbol, name, app_init, app_final, init, update, on_event, final)

DM_DECLARE_EXTENSION(Screenshot, LIB_NAME, AppInitializeScreenshotExtension, AppFinalizeScreenshotExtension, InitializeScreenshotExtension, 0, 0, FinalizeScreenshotExtension)

#else

// dummy implementation
extern "C" void Screenshot() {}

#endif

0 comments on commit f066f19

Please sign in to comment.