Browse Source

Added love.graphics.getMaxImageSize

Alex Szpakowski 12 years ago
parent
commit
57aa632841

+ 5 - 0
src/modules/graphics/opengl/Graphics.cpp

@@ -394,6 +394,11 @@ unsigned char Graphics::getAlphaTestRef()
 	return ref * 255;
 	return ref * 255;
 }
 }
 
 
+int Graphics::getMaxImageSize() const
+{
+	return gl.getMaxTextureSize();
+}
+
 Image *Graphics::newImage(love::image::ImageData *data)
 Image *Graphics::newImage(love::image::ImageData *data)
 {
 {
 	// Create the image.
 	// Create the image.

+ 6 - 0
src/modules/graphics/opengl/Graphics.h

@@ -216,6 +216,12 @@ public:
 	 */
 	 */
 	unsigned char getAlphaTestRef();
 	unsigned char getAlphaTestRef();
 
 
+	/**
+	 * Gets the maximum supported width or height of Images and Canvases on this
+	 * system.
+	 **/
+	int getMaxImageSize() const;
+
 	/**
 	/**
 	 * Creates an Image object with padding and/or optimization.
 	 * Creates an Image object with padding and/or optimization.
 	 **/
 	 **/

+ 7 - 0
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -175,6 +175,12 @@ int w_getAlphaTest(lua_State *L)
 	return 2;
 	return 2;
 }
 }
 
 
+int w_getMaxImageSize(lua_State *L)
+{
+	lua_pushinteger(L, instance->getMaxImageSize());
+	return 1;
+}
+
 int w_newImage(lua_State *L)
 int w_newImage(lua_State *L)
 {
 {
 	love::image::ImageData *data = 0;
 	love::image::ImageData *data = 0;
@@ -1544,6 +1550,7 @@ static const luaL_Reg functions[] =
 	{ "getPointSize", w_getPointSize },
 	{ "getPointSize", w_getPointSize },
 	{ "getPointStyle", w_getPointStyle },
 	{ "getPointStyle", w_getPointStyle },
 	{ "getMaxPointSize", w_getMaxPointSize },
 	{ "getMaxPointSize", w_getMaxPointSize },
+	{ "getMaxImageSize", w_getMaxImageSize },
 	{ "newScreenshot", w_newScreenshot },
 	{ "newScreenshot", w_newScreenshot },
 	{ "setCanvas", w_setCanvas },
 	{ "setCanvas", w_setCanvas },
 	{ "setCanvases", w_setCanvases },
 	{ "setCanvases", w_setCanvases },

+ 1 - 0
src/modules/graphics/opengl/wrap_Graphics.h

@@ -50,6 +50,7 @@ int w_getScissor(lua_State *L);
 int w_setStencil(lua_State *L);
 int w_setStencil(lua_State *L);
 int w_setAlphaTest(lua_State *L);
 int w_setAlphaTest(lua_State *L);
 int w_getAlphaTest(lua_State *L);
 int w_getAlphaTest(lua_State *L);
+int w_getMaxImageSize(lua_State *L);
 int w_newImage(lua_State *L);
 int w_newImage(lua_State *L);
 int w_newGeometry(lua_State *L);
 int w_newGeometry(lua_State *L);
 int w_newQuad(lua_State *L);
 int w_newQuad(lua_State *L);