Browse Source

love.graphics.getScissor now has a proper C++ module method

Alex Szpakowski 11 years ago
parent
commit
fda005c5ff

+ 1 - 1
src/common/Module.cpp

@@ -78,7 +78,7 @@ Module::~Module()
 void Module::registerInstance(Module *instance)
 {
 	if (instance == nullptr)
-		throw Exception("Module instance is NULL");
+		throw Exception("Module instance is null");
 
 	std::string name(instance->getName());
 

+ 0 - 1
src/common/Module.h

@@ -22,7 +22,6 @@
 #define LOVE_MODULE_H
 
 // LOVE
-#include "runtime.h"
 #include "Exception.h"
 #include "Object.h"
 

+ 1 - 0
src/modules/filesystem/physfs/Filesystem.h

@@ -31,6 +31,7 @@
 #include "common/Module.h"
 #include "common/config.h"
 #include "common/int.h"
+#include "common/runtime.h"
 #include "filesystem/FileData.h"
 #include "File.h"
 

+ 6 - 9
src/modules/graphics/opengl/Graphics.cpp

@@ -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()

+ 4 - 4
src/modules/graphics/opengl/Graphics.h

@@ -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

+ 10 - 1
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -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)

+ 1 - 0
src/modules/joystick/sdl/wrap_JoystickModule.h

@@ -23,6 +23,7 @@
 
 // LOVE
 #include "common/config.h"
+#include "common/runtime.h"
 #include "JoystickModule.h"
 
 namespace love

+ 1 - 0
src/modules/keyboard/wrap_Keyboard.h

@@ -22,6 +22,7 @@
 #define LOVE_KEYBOARD_WRAP_KEYBOARD_H
 
 // LOVE
+#include "common/runtime.h"
 #include "Keyboard.h"
 
 namespace love

+ 1 - 0
src/modules/timer/wrap_Timer.h

@@ -22,6 +22,7 @@
 #define LOVE_TIMER_WRAP_TIMER_H
 
 // LOVE
+#include "common/runtime.h"
 #include "Timer.h"
 
 namespace love