1
0
Fork 0
mirror of https://github.com/ctruLua/ctruLua.git synced 2025-10-27 16:39:29 +00:00

Added gfx.scissor

Note: doesn't work on citra but it does on real hardware.
This commit is contained in:
Reuh 2016-03-09 16:13:06 +01:00
parent acd41db805
commit 9db21c7831

View file

@ -377,6 +377,33 @@ static int gfx_getTextSize(lua_State *L) {
return 1; return 1;
} }
/***
Enables or disable the scissor test.
When the scissor test is enabled, the drawing area will be limited to a specific rectangle, every pixel drawn outside will be discarded.
Calls this function without argument to disable the scissor test.
@function scissor
@tparam integer x scissor rectangle origin horizontal coordinate, in pixels
@tparam integer y scissor rectangle origin vertical coordinate, in pixels
@tparam integer width scissor rectangle width, in pixels
@tparam integer height scissor rectangle height, in pixels
@tparam[opt=false] boolean invert if true the scissor will be inverted (will draw only outside of the rectangle)
*/
static int gfx_scissor(lua_State *L) {
if (lua_gettop(L) == 0) {
sf2d_set_scissor_test(GPU_SCISSOR_DISABLE, 0, 0, 0, 0);
} else {
int x = luaL_checkinteger(L, 1);
int y = luaL_checkinteger(L, 2);
int width = luaL_checkinteger(L, 3);
int height = luaL_checkinteger(L, 4);
bool invert = lua_toboolean(L, 5);
sf2d_set_scissor_test(invert ? GPU_SCISSOR_INVERT : GPU_SCISSOR_NORMAL, x, y, width, height);
}
return 0;
}
// Functions // Functions
static const struct luaL_Reg gfx_lib[] = { static const struct luaL_Reg gfx_lib[] = {
{ "start", gfx_start }, { "start", gfx_start },
@ -397,6 +424,7 @@ static const struct luaL_Reg gfx_lib[] = {
{ "calcBoundingBox", gfx_calcBoundingBox }, { "calcBoundingBox", gfx_calcBoundingBox },
{ "setTextSize", gfx_setTextSize }, { "setTextSize", gfx_setTextSize },
{ "getTextSize", gfx_getTextSize }, { "getTextSize", gfx_getTextSize },
{ "scissor", gfx_scissor },
{ NULL, NULL } { NULL, NULL }
}; };