mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
love.graphics.getScissor now has a proper C++ module method
This commit is contained in:
@@ -273,19 +273,16 @@ void Graphics::setScissor()
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
int Graphics::getScissor(lua_State *L) const
|
||||
bool Graphics::getScissor(int &x, int &y, int &width, int &height) const
|
||||
{
|
||||
if (glIsEnabled(GL_SCISSOR_TEST) == GL_FALSE)
|
||||
return 0;
|
||||
|
||||
OpenGL::Viewport scissor = gl.getScissor();
|
||||
|
||||
lua_pushinteger(L, scissor.x);
|
||||
lua_pushinteger(L, scissor.y);
|
||||
lua_pushinteger(L, scissor.w);
|
||||
lua_pushinteger(L, scissor.h);
|
||||
x = scissor.x;
|
||||
y = scissor.y;
|
||||
width = scissor.w;
|
||||
height = scissor.h;
|
||||
|
||||
return 4;
|
||||
return glIsEnabled(GL_SCISSOR_TEST) == GL_TRUE;
|
||||
}
|
||||
|
||||
void Graphics::defineStencil()
|
||||
|
||||
@@ -163,10 +163,10 @@ public:
|
||||
void setScissor();
|
||||
|
||||
/**
|
||||
* This native Lua function gets the current scissor box in the order of:
|
||||
* x, y, width, height
|
||||
**/
|
||||
int getScissor(lua_State *L) const;
|
||||
* Gets the current scissor box.
|
||||
* @return Whether the scissor is enabled.
|
||||
*/
|
||||
bool getScissor(int &x, int &y, int &width, int &height) const;
|
||||
|
||||
/**
|
||||
* Enables the stencil buffer and set stencil function to fill it
|
||||
|
||||
@@ -104,7 +104,16 @@ int w_setScissor(lua_State *L)
|
||||
|
||||
int w_getScissor(lua_State *L)
|
||||
{
|
||||
return instance->getScissor(L);
|
||||
int x, y, w, h;
|
||||
if (!instance->getScissor(x, y, w, h))
|
||||
return 0;
|
||||
|
||||
lua_pushinteger(L, x);
|
||||
lua_pushinteger(L, y);
|
||||
lua_pushinteger(L, w);
|
||||
lua_pushinteger(L, h);
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
static int setStencil(lua_State *L, bool invert)
|
||||
|
||||
Reference in New Issue
Block a user