Browse Source

Abstracted lua bindings for general Texture methods into wrap_Texture.cpp

Alex Szpakowski 11 years ago
parent
commit
510ed6f11e

+ 2 - 0
CMakeLists.txt

@@ -304,6 +304,8 @@ set(LOVE_SRC_MODULE_GRAPHICS_OPENGL
 	src/modules/graphics/opengl/wrap_Shader.h
 	src/modules/graphics/opengl/wrap_SpriteBatch.cpp
 	src/modules/graphics/opengl/wrap_SpriteBatch.h
+	src/modules/graphics/opengl/wrap_Texture.cpp
+	src/modules/graphics/opengl/wrap_Texture.h
 )
 
 set(LOVE_SRC_MODULE_GRAPHICS

+ 8 - 0
platform/macosx/love-framework.xcodeproj/project.pbxproj

@@ -7,6 +7,8 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		FA01BE1E1878E35B00640047 /* wrap_Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA01BE1C1878E35B00640047 /* wrap_Texture.cpp */; };
+		FA01BE1F1878E35B00640047 /* wrap_Texture.h in Headers */ = {isa = PBXBuildFile; fileRef = FA01BE1D1878E35B00640047 /* wrap_Texture.h */; };
 		FA03546C1731F3A700284828 /* simplexnoise1234.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA03546A1731F3A700284828 /* simplexnoise1234.cpp */; };
 		FA03546D1731F3A700284828 /* simplexnoise1234.h in Headers */ = {isa = PBXBuildFile; fileRef = FA03546B1731F3A700284828 /* simplexnoise1234.h */; };
 		FA08F5B016C752F900F007B5 /* Source.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2FB732687B1669402408356D /* Source.cpp */; };
@@ -749,6 +751,8 @@
 		7F575BE9573C654B5ED44CC1 /* wrap_Timer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = wrap_Timer.h; sourceTree = "<group>"; };
 		7F796B7A3362196075C62E61 /* wrap_Fixture.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Fixture.cpp; sourceTree = "<group>"; };
 		7F911CF2107B22F44C5B2542 /* b2Collision.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2Collision.h; sourceTree = "<group>"; };
+		FA01BE1C1878E35B00640047 /* wrap_Texture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Texture.cpp; sourceTree = "<group>"; };
+		FA01BE1D1878E35B00640047 /* wrap_Texture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Texture.h; sourceTree = "<group>"; };
 		FA03546A1731F3A700284828 /* simplexnoise1234.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = simplexnoise1234.cpp; sourceTree = "<group>"; };
 		FA03546B1731F3A700284828 /* simplexnoise1234.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = simplexnoise1234.h; sourceTree = "<group>"; };
 		FA08F5AE16C7525600F007B5 /* Info-Framework.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-Framework.plist"; sourceTree = "<group>"; };
@@ -1700,6 +1704,8 @@
 				FA577A8816C71CF000860150 /* wrap_Shader.h */,
 				02C16FDB537A702F4D42534E /* wrap_SpriteBatch.cpp */,
 				2BE75A693BE206B22DAE1B2E /* wrap_SpriteBatch.h */,
+				FA01BE1C1878E35B00640047 /* wrap_Texture.cpp */,
+				FA01BE1D1878E35B00640047 /* wrap_Texture.h */,
 			);
 			path = opengl;
 			sourceTree = "<group>";
@@ -1971,6 +1977,7 @@
 				FAF6704E18184FF800DBDEEA /* wuff_config.h in Headers */,
 				FA0CDE3D1710F9A50056E8D7 /* FormatHandler.h in Headers */,
 				FA7AA59317F6AC1F00704BE2 /* wrap_Mesh.h in Headers */,
+				FA01BE1F1878E35B00640047 /* wrap_Texture.h in Headers */,
 				FAEC808B1710FEA60057279A /* ImageData.h in Headers */,
 				FAEC808F1711E76C0057279A /* CompressedData.h in Headers */,
 				FA636D8B171B70920065623F /* RandomGenerator.h in Headers */,
@@ -2281,6 +2288,7 @@
 				FAF272A616E3D44400CC193A /* LuaThread.cpp in Sources */,
 				FA0A4BF0182E0C2800E1E4D2 /* b2MotorJoint.cpp in Sources */,
 				FAF272A816E3D44400CC193A /* ThreadModule.cpp in Sources */,
+				FA01BE1E1878E35B00640047 /* wrap_Texture.cpp in Sources */,
 				FAF272AA16E3D44400CC193A /* wrap_Channel.cpp in Sources */,
 				FAF272AC16E3D44400CC193A /* wrap_LuaThread.cpp in Sources */,
 				FAF272AE16E3D44400CC193A /* wrap_ThreadModule.cpp in Sources */,

+ 9 - 103
src/modules/graphics/opengl/wrap_Canvas.cpp

@@ -79,80 +79,6 @@ int w_Canvas_getPixel(lua_State * L)
 	return 4;
 }
 
-int w_Canvas_setFilter(lua_State *L)
-{
-	Canvas *canvas = luax_checkcanvas(L, 1);
-
-	Texture::Filter f;
-
-	const char *minstr = luaL_checkstring(L, 2);
-	const char *magstr = luaL_optstring(L, 3, minstr);
-
-	if (!Texture::getConstant(minstr, f.min))
-		return luaL_error(L, "Invalid filter mode: %s", minstr);
-	if (!Texture::getConstant(magstr, f.mag))
-		return luaL_error(L, "Invalid filter mode: %s", magstr);
-
-	f.anisotropy = (float) luaL_optnumber(L, 4, 1.0);
-
-	canvas->setFilter(f);
-
-	return 0;
-
-}
-
-int w_Canvas_getFilter(lua_State *L)
-{
-	Canvas *canvas = luax_checkcanvas(L, 1);
-	const Texture::Filter f = canvas->getFilter();
-
-	const char *minstr;
-	const char *magstr;
-	Texture::getConstant(f.min, minstr);
-	Texture::getConstant(f.mag, magstr);
-
-	lua_pushstring(L, minstr);
-	lua_pushstring(L, magstr);
-	lua_pushnumber(L, f.anisotropy);
-
-	return 3;
-}
-
-int w_Canvas_setWrap(lua_State *L)
-{
-	Canvas *canvas = luax_checkcanvas(L, 1);
-
-	Texture::Wrap w;
-
-	const char *sstr = luaL_checkstring(L, 2);
-	const char *tstr = luaL_optstring(L, 3, sstr);
-
-	if (!Texture::getConstant(sstr, w.s))
-		return luaL_error(L, "Invalid wrap mode: %s", sstr);
-	if (!Texture::getConstant(tstr, w.t))
-		return luaL_error(L, "Invalid wrap mode, %s", tstr);
-
-	canvas->setWrap(w);
-
-	return 0;
-}
-
-int w_Canvas_getWrap(lua_State *L)
-{
-	Canvas *canvas = luax_checkcanvas(L, 1);
-	const Texture::Wrap w = canvas->getWrap();
-
-	const char *wrap_s;
-	const char *wrap_t;
-	Texture::getConstant(w.s, wrap_s);
-	Texture::getConstant(w.t, wrap_t);
-
-	lua_pushstring(L, wrap_s);
-	lua_pushstring(L, wrap_t);
-
-	return 2;
-}
-
 int w_Canvas_clear(lua_State *L)
 {
 	Canvas *canvas = luax_checkcanvas(L, 1);
@@ -185,28 +111,6 @@ int w_Canvas_clear(lua_State *L)
 	return 0;
 }
 
-int w_Canvas_getWidth(lua_State *L)
-{
-	Canvas *canvas = luax_checkcanvas(L, 1);
-	lua_pushnumber(L, canvas->getWidth());
-	return 1;
-}
-
-int w_Canvas_getHeight(lua_State *L)
-{
-	Canvas *canvas = luax_checkcanvas(L, 1);
-	lua_pushnumber(L, canvas->getHeight());
-	return 1;
-}
-
-int w_Canvas_getDimensions(lua_State *L)
-{
-	Canvas *canvas = luax_checkcanvas(L, 1);
-	lua_pushnumber(L, canvas->getWidth());
-	lua_pushnumber(L, canvas->getHeight());
-	return 2;
-}
-
 int w_Canvas_getType(lua_State *L)
 {
 	Canvas *canvas = luax_checkcanvas(L, 1);
@@ -219,17 +123,19 @@ int w_Canvas_getType(lua_State *L)
 
 static const luaL_Reg functions[] =
 {
+	// From wrap_Texture.
+	{ "getWidth", w_Texture_getWidth },
+	{ "getHeight", w_Texture_getHeight },
+	{ "getDimensions", w_Texture_getDimensions },
+	{ "setFilter", w_Texture_setFilter },
+	{ "getFilter", w_Texture_getFilter },
+	{ "setWrap", w_Texture_setWrap },
+	{ "getWrap", w_Texture_getWrap },
+
 	{ "renderTo", w_Canvas_renderTo },
 	{ "getImageData", w_Canvas_getImageData },
 	{ "getPixel", w_Canvas_getPixel },
-	{ "setFilter", w_Canvas_setFilter },
-	{ "getFilter", w_Canvas_getFilter },
-	{ "setWrap", w_Canvas_setWrap },
-	{ "getWrap", w_Canvas_getWrap },
 	{ "clear", w_Canvas_clear },
-	{ "getWidth", w_Canvas_getWidth },
-	{ "getHeight", w_Canvas_getHeight },
-	{ "getDimensions", w_Canvas_getDimensions },
 	{ "getType", w_Canvas_getType },
 	{ 0, 0 }
 };

+ 1 - 7
src/modules/graphics/opengl/wrap_Canvas.h

@@ -24,6 +24,7 @@
 // LOVE
 #include "common/runtime.h"
 #include "Canvas.h"
+#include "wrap_Texture.h"
 
 namespace love
 {
@@ -37,14 +38,7 @@ Canvas *luax_checkcanvas(lua_State *L, int idx);
 int w_Canvas_renderTo(lua_State *L);
 int w_Canvas_getImageData(lua_State *L);
 int w_Canvas_getPixel(lua_State * L);
-int w_Canvas_setFilter(lua_State *L);
-int w_Canvas_getFilter(lua_State *L);
-int w_Canvas_setWrap(lua_State *L);
-int w_Canvas_getWrap(lua_State *L);
 int w_Canvas_clear(lua_State *L);
-int w_Canvas_getWidth(lua_State *L);
-int w_Canvas_getHeight(lua_State *L);
-int w_Canvas_getDimensions(lua_State *L);
 int w_Canvas_getType(lua_State *L);
 extern "C" int luaopen_canvas(lua_State *L);
 

+ 4 - 4
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -277,7 +277,7 @@ int w_newImageFont(lua_State *L)
 
 int w_newSpriteBatch(lua_State *L)
 {
-	Texture *texture = luax_checktype<Texture>(L, 1, "Texture", GRAPHICS_TEXTURE_T);
+	Texture *texture = luax_checktexture(L, 1);
 	int size = luaL_optint(L, 2, 1000);
 	SpriteBatch::UsageHint usage = SpriteBatch::USAGE_DYNAMIC;
 	if (lua_gettop(L) > 2)
@@ -296,7 +296,7 @@ int w_newSpriteBatch(lua_State *L)
 
 int w_newParticleSystem(lua_State *L)
 {
-	Texture *texture = luax_checktype<Texture>(L, 1, "Texture", GRAPHICS_TEXTURE_T);
+	Texture *texture = luax_checktexture(L, 1);
 	lua_Number size = luaL_optnumber(L, 2, 1000);
 	ParticleSystem *t = 0;
 	if (size < 1.0 || size > ParticleSystem::MAX_PARTICLES)
@@ -437,7 +437,7 @@ int w_newMesh(lua_State *L)
 	// Second argument: optional texture.
 	Texture *tex = nullptr;
 	if (!lua_isnoneornil(L, 2))
-		tex = luax_checktype<Texture>(L, 2, "Texture", GRAPHICS_TEXTURE_T);
+		tex = luax_checktexture(L, 2);
 
 	// Third argument: optional draw mode.
 	const char *str = 0;
@@ -1011,7 +1011,7 @@ int w_draw(lua_State *L)
 
 	if (luax_istype(L, 2, GRAPHICS_QUAD_T))
 	{
-		texture = luax_checktype<Texture>(L, 1, "Texture", GRAPHICS_TEXTURE_T);
+		texture = luax_checktexture(L, 1);
 		quad = luax_totype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
 		startidx = 3;
 	}

+ 9 - 93
src/modules/graphics/opengl/wrap_Image.cpp

@@ -33,61 +33,6 @@ Image *luax_checkimage(lua_State *L, int idx)
 	return luax_checktype<Image>(L, idx, "Image", GRAPHICS_IMAGE_T);
 }
 
-int w_Image_getWidth(lua_State *L)
-{
-	Image *t = luax_checkimage(L, 1);
-	lua_pushnumber(L, t->getWidth());
-	return 1;
-}
-
-int w_Image_getHeight(lua_State *L)
-{
-	Image *t = luax_checkimage(L, 1);
-	lua_pushnumber(L, t->getHeight());
-	return 1;
-}
-
-int w_Image_getDimensions(lua_State *L)
-{
-	Image *t = luax_checkimage(L, 1);
-	lua_pushnumber(L, t->getWidth());
-	lua_pushnumber(L, t->getHeight());
-	return 2;
-}
-
-int w_Image_setFilter(lua_State *L)
-{
-	Image *t = luax_checkimage(L, 1);
-	Texture::Filter f = t->getFilter();
-
-	const char *minstr = luaL_checkstring(L, 2);
-	const char *magstr = luaL_optstring(L, 3, minstr);
-
-	if (!Texture::getConstant(minstr, f.min))
-		return luaL_error(L, "Invalid filter mode: %s", minstr);
-	if (!Texture::getConstant(magstr, f.mag))
-		return luaL_error(L, "Invalid filter mode: %s", magstr);
-
-	f.anisotropy = (float) luaL_optnumber(L, 4, 1.0);
-
-	EXCEPT_GUARD(t->setFilter(f);)
-	return 0;
-}
-
-int w_Image_getFilter(lua_State *L)
-{
-	Image *t = luax_checkimage(L, 1);
-	const Texture::Filter f = t->getFilter();
-	const char *minstr;
-	const char *magstr;
-	Texture::getConstant(f.min, minstr);
-	Texture::getConstant(f.mag, magstr);
-	lua_pushstring(L, minstr);
-	lua_pushstring(L, magstr);
-	lua_pushnumber(L, f.anisotropy);
-	return 3;
-}
-
 int w_Image_setMipmapFilter(lua_State *L)
 {
 	Image *t = luax_checkimage(L, 1);
@@ -126,37 +71,6 @@ int w_Image_getMipmapFilter(lua_State *L)
 	return 2;
 }
 
-int w_Image_setWrap(lua_State *L)
-{
-	Image *i = luax_checkimage(L, 1);
-
-	Texture::Wrap w;
-
-	const char *sstr = luaL_checkstring(L, 2);
-	const char *tstr = luaL_optstring(L, 3, sstr);
-
-	if (!Texture::getConstant(sstr, w.s))
-		return luaL_error(L, "Invalid wrap mode: %s", sstr);
-	if (!Texture::getConstant(tstr, w.t))
-		return luaL_error(L, "Invalid wrap mode, %s", tstr);
-
-	i->setWrap(w);
-	return 0;
-}
-
-int w_Image_getWrap(lua_State *L)
-{
-	Image *i = luax_checkimage(L, 1);
-	const Texture::Wrap w = i->getWrap();
-	const char *sstr;
-	const char *tstr;
-	Texture::getConstant(w.s, sstr);
-	Texture::getConstant(w.t, tstr);
-	lua_pushstring(L, sstr);
-	lua_pushstring(L, tstr);
-	return 2;
-}
-
 int w_Image_isCompressed(lua_State *L)
 {
 	Image *i = luax_checkimage(L, 1);
@@ -203,13 +117,15 @@ int w_Image_getData(lua_State *L)
 
 static const luaL_Reg functions[] =
 {
-	{ "getWidth", w_Image_getWidth },
-	{ "getHeight", w_Image_getHeight },
-	{ "getDimensions", w_Image_getDimensions },
-	{ "setFilter", w_Image_setFilter },
-	{ "getFilter", w_Image_getFilter },
-	{ "setWrap", w_Image_setWrap },
-	{ "getWrap", w_Image_getWrap },
+	// From wrap_Texture.
+	{ "getWidth", w_Texture_getWidth },
+	{ "getHeight", w_Texture_getHeight },
+	{ "getDimensions", w_Texture_getDimensions },
+	{ "setFilter", w_Texture_setFilter },
+	{ "getFilter", w_Texture_getFilter },
+	{ "setWrap", w_Texture_setWrap },
+	{ "getWrap", w_Texture_getWrap },
+
 	{ "setMipmapFilter", w_Image_setMipmapFilter },
 	{ "getMipmapFilter", w_Image_getMipmapFilter },
 	{ "isCompressed", w_Image_isCompressed },

+ 1 - 7
src/modules/graphics/opengl/wrap_Image.h

@@ -24,6 +24,7 @@
 // LOVE
 #include "common/runtime.h"
 #include "Image.h"
+#include "wrap_Texture.h"
 
 namespace love
 {
@@ -33,15 +34,8 @@ namespace opengl
 {
 
 Image *luax_checkimage(lua_State *L, int idx);
-int w_Image_getWidth(lua_State *L);
-int w_Image_getHeight(lua_State *L);
-int w_Image_getDimensions(lua_State *L);
-int w_Image_setFilter(lua_State *L);
-int w_Image_getFilter(lua_State *L);
 int w_Image_setMipmapFilter(lua_State *L);
 int w_Image_getMipmapFilter(lua_State *L);
-int w_Image_setWrap(lua_State *L);
-int w_Image_getWrap(lua_State *L);
 int w_Image_isCompressed(lua_State *L);
 int w_Image_refresh(lua_State *L);
 int w_Image_getData(lua_State *L);

+ 2 - 1
src/modules/graphics/opengl/wrap_Mesh.cpp

@@ -22,6 +22,7 @@
 #include "wrap_Mesh.h"
 #include "Image.h"
 #include "Canvas.h"
+#include "wrap_Texture.h"
 
 // C++
 #include <typeinfo>
@@ -243,7 +244,7 @@ int w_Mesh_setTexture(lua_State *L)
 		t->setTexture();
 	else
 	{
-		Texture *tex = luax_checktype<Texture>(L, 2, "Texture", GRAPHICS_TEXTURE_T);
+		Texture *tex = luax_checktexture(L, 2);
 		t->setTexture(tex);
 	}
 

+ 2 - 1
src/modules/graphics/opengl/wrap_ParticleSystem.cpp

@@ -24,6 +24,7 @@
 
 #include "Image.h"
 #include "Canvas.h"
+#include "wrap_Texture.h"
 
 // C
 #include <cstring>
@@ -57,7 +58,7 @@ int w_ParticleSystem_clone(lua_State *L)
 int w_ParticleSystem_setTexture(lua_State *L)
 {
 	ParticleSystem *t = luax_checkparticlesystem(L, 1);
-	Texture *tex = luax_checktype<Texture>(L, 2, "Texture", GRAPHICS_TEXTURE_T);
+	Texture *tex = luax_checktexture(L, 2);
 	t->setTexture(tex);
 	return 0;
 }

+ 2 - 3
src/modules/graphics/opengl/wrap_Shader.cpp

@@ -19,8 +19,7 @@
  **/
 
 #include "wrap_Shader.h"
-#include "wrap_Image.h"
-#include "wrap_Canvas.h"
+#include "wrap_Texture.h"
 #include <string>
 #include <iostream>
 
@@ -257,7 +256,7 @@ int w_Shader_sendTexture(lua_State *L)
 {
 	Shader *shader = luax_checkshader(L, 1);
 	const char *name = luaL_checkstring(L, 2);
-	Texture *texture = luax_checktype<Texture>(L, 3, "Texture", GRAPHICS_TEXTURE_T);
+	Texture *texture = luax_checktexture(L, 3);
 
 	EXCEPT_GUARD(shader->sendTexture(name, texture);)
 	return 0;

+ 2 - 1
src/modules/graphics/opengl/wrap_SpriteBatch.cpp

@@ -22,6 +22,7 @@
 #include "wrap_SpriteBatch.h"
 #include "Image.h"
 #include "Canvas.h"
+#include "wrap_Texture.h"
 
 // C++
 #include <typeinfo>
@@ -134,7 +135,7 @@ int w_SpriteBatch_unbind(lua_State *L)
 int w_SpriteBatch_setTexture(lua_State *L)
 {
 	SpriteBatch *t = luax_checkspritebatch(L, 1);
-	Texture *tex = luax_checktype<Texture>(L, 2, "Texture", GRAPHICS_TEXTURE_T);
+	Texture *tex = luax_checktexture(L, 2);
 	t->setTexture(tex);
 	return 0;
 }

+ 133 - 0
src/modules/graphics/opengl/wrap_Texture.cpp

@@ -0,0 +1,133 @@
+/**
+ * Copyright (c) 2006-2014 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#include "wrap_Texture.h"
+
+namespace love
+{
+namespace graphics
+{
+namespace opengl
+{
+
+Texture *luax_checktexture(lua_State *L, int idx)
+{
+	return luax_checktype<Texture>(L, idx, "Texture", GRAPHICS_TEXTURE_T);
+}
+
+int w_Texture_getWidth(lua_State *L)
+{
+	Texture *t = luax_checktexture(L, 1);
+	lua_pushnumber(L, t->getWidth());
+	return 1;
+}
+
+int w_Texture_getHeight(lua_State *L)
+{
+	Texture *t = luax_checktexture(L, 1);
+	lua_pushnumber(L, t->getHeight());
+	return 1;
+}
+
+int w_Texture_getDimensions(lua_State *L)
+{
+	Texture *t = luax_checktexture(L, 1);
+	lua_pushnumber(L, t->getWidth());
+	lua_pushnumber(L, t->getHeight());
+	return 2;
+}
+
+int w_Texture_setFilter(lua_State *L)
+{
+	Texture *t = luax_checktexture(L, 1);
+	Texture::Filter f = t->getFilter();
+
+	const char *minstr = luaL_checkstring(L, 2);
+	const char *magstr = luaL_optstring(L, 3, minstr);
+
+	if (!Texture::getConstant(minstr, f.min))
+		return luaL_error(L, "Invalid filter mode: %s", minstr);
+	if (!Texture::getConstant(magstr, f.mag))
+		return luaL_error(L, "Invalid filter mode: %s", magstr);
+
+	f.anisotropy = (float) luaL_optnumber(L, 4, 1.0);
+
+	EXCEPT_GUARD(t->setFilter(f);)
+	return 0;
+}
+
+int w_Texture_getFilter(lua_State *L)
+{
+	Texture *t = luax_checktexture(L, 1);
+	const Texture::Filter f = t->getFilter();
+
+	const char *minstr = nullptr;
+	const char *magstr = nullptr;
+
+	if (!Texture::getConstant(f.min, minstr))
+		return luaL_error(L, "Unknown filter mode.");
+	if (!Texture::getConstant(f.mag, magstr))
+		return luaL_error(L, "Unknown filter mode.");
+
+	lua_pushstring(L, minstr);
+	lua_pushstring(L, magstr);
+	lua_pushnumber(L, f.anisotropy);
+	return 3;
+}
+
+int w_Texture_setWrap(lua_State *L)
+{
+	Texture *t = luax_checktexture(L, 1);
+	Texture::Wrap w;
+
+	const char *sstr = luaL_checkstring(L, 2);
+	const char *tstr = luaL_optstring(L, 3, sstr);
+
+	if (!Texture::getConstant(sstr, w.s))
+		return luaL_error(L, "Invalid wrap mode: %s", sstr);
+	if (!Texture::getConstant(tstr, w.t))
+		return luaL_error(L, "Invalid wrap mode, %s", tstr);
+
+	t->setWrap(w);
+	return 0;
+}
+
+int w_Texture_getWrap(lua_State *L)
+{
+	Texture *t = luax_checktexture(L, 1);
+	const Texture::Wrap w = t->getWrap();
+
+	const char *sstr = nullptr;
+	const char *tstr = nullptr;
+
+	if (!Texture::getConstant(w.s, sstr))
+		return luaL_error(L, "Unknown wrap mode.");
+	if (!Texture::getConstant(w.t, tstr))
+		return luaL_error(L, "Unknown wrap mode.");
+
+	lua_pushstring(L, sstr);
+	lua_pushstring(L, tstr);
+	return 2;
+}
+
+
+} // opengl
+} // graphics
+} // love

+ 47 - 0
src/modules/graphics/opengl/wrap_Texture.h

@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) 2006-2014 LOVE Development Team
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.  In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ *    claim that you wrote the original software. If you use this software
+ *    in a product, an acknowledgment in the product documentation would be
+ *    appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ *    misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ **/
+
+#ifndef LOVE_GRAPHICS_OPENGL_WRAP_TEXTURE_H
+#define LOVE_GRAPHICS_OPENGL_WRAP_TEXTURE_H
+
+#include "Texture.h"
+#include "common/runtime.h"
+
+namespace love
+{
+namespace graphics
+{
+namespace opengl
+{
+
+Texture *luax_checktexture(lua_State *L, int idx);
+int w_Texture_getWidth(lua_State *L);
+int w_Texture_getHeight(lua_State *L);
+int w_Texture_getDimensions(lua_State *L);
+int w_Texture_setFilter(lua_State *L);
+int w_Texture_getFilter(lua_State *L);
+int w_Texture_setWrap(lua_State *L);
+int w_Texture_getWrap(lua_State *L);
+
+} // opengl
+} // graphics
+} // love
+
+#endif // LOVE_GRAPHICS_OPENGL_WRAP_TEXTURE_H