Browse Source

Removed unnecessary tabs in empty lines, fixed texture filtering when the minification and mipmap filter are the same

Alexander Szpakowski 12 years ago
parent
commit
eb98e8cc48

+ 1 - 1
src/modules/graphics/Image.h

@@ -77,7 +77,7 @@ public:
 	static bool getConstant(WrapMode in, const char  *&out);
 	static bool getConstant(WrapMode in, const char  *&out);
 
 
 private:
 private:
-	
+
 	// The default image filter
 	// The default image filter
 	static Filter defaultFilter;
 	static Filter defaultFilter;
 
 

+ 5 - 5
src/modules/graphics/opengl/Canvas.cpp

@@ -97,9 +97,9 @@ struct FramebufferStrategyGL3 : public FramebufferStrategy
 
 
 		glGenTextures(1, &img);
 		glGenTextures(1, &img);
 		bindTexture(img);
 		bindTexture(img);
-		
+
 		setTextureFilter(Image::getDefaultFilter());
 		setTextureFilter(Image::getDefaultFilter());
-		
+
 		glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height,
 		glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height,
 			0, GL_RGBA, format, NULL);
 			0, GL_RGBA, format, NULL);
 		bindTexture(0);
 		bindTexture(0);
@@ -165,7 +165,7 @@ struct FramebufferStrategyPackedEXT : public FramebufferStrategy
 
 
 		glGenTextures(1, &img);
 		glGenTextures(1, &img);
 		bindTexture(img);
 		bindTexture(img);
-		
+
 		setTextureFilter(Image::getDefaultFilter());
 		setTextureFilter(Image::getDefaultFilter());
 
 
 		glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height,
 		glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height,
@@ -232,9 +232,9 @@ struct FramebufferStrategyEXT : public FramebufferStrategyPackedEXT
 
 
 		glGenTextures(1, &img);
 		glGenTextures(1, &img);
 		bindTexture(img);
 		bindTexture(img);
-		
+
 		setTextureFilter(Image::getDefaultFilter());
 		setTextureFilter(Image::getDefaultFilter());
-		
+
 		glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height,
 		glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height,
 			0, GL_RGBA, format, NULL);
 			0, GL_RGBA, format, NULL);
 		bindTexture(0);
 		bindTexture(0);

+ 17 - 17
src/modules/graphics/opengl/Image.cpp

@@ -147,26 +147,26 @@ void Image::checkMipmapsCreated() const
 {
 {
 	if (filter.mipmap != FILTER_NEAREST && filter.mipmap != FILTER_LINEAR)
 	if (filter.mipmap != FILTER_NEAREST && filter.mipmap != FILTER_LINEAR)
 		return;
 		return;
-	
+
 	if (!hasMipmapSupport())
 	if (!hasMipmapSupport())
 		throw love::Exception("Mipmap filtering is not supported on this system!");
 		throw love::Exception("Mipmap filtering is not supported on this system!");
-	
+
 	// some old GPUs/systems claim support for NPOT textures, but fail when generating mipmaps
 	// some old GPUs/systems claim support for NPOT textures, but fail when generating mipmaps
 	// we can't detect which systems will do this, so we fail gracefully for all NPOT images
 	// we can't detect which systems will do this, so we fail gracefully for all NPOT images
 	int w = int(width), h = int(height);
 	int w = int(width), h = int(height);
 	if (w != next_p2(w) || h != next_p2(h))
 	if (w != next_p2(w) || h != next_p2(h))
 		throw love::Exception("Could not generate mipmaps: image does not have power of two dimensions!");
 		throw love::Exception("Could not generate mipmaps: image does not have power of two dimensions!");
-	
+
 	bind();
 	bind();
-	
+
 	GLboolean mipmapscreated;
 	GLboolean mipmapscreated;
 	glGetTexParameteriv(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, (GLint *)&mipmapscreated);
 	glGetTexParameteriv(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, (GLint *)&mipmapscreated);
-	
+
 	// generate mipmaps for this image if we haven't already
 	// generate mipmaps for this image if we haven't already
 	if (!mipmapscreated)
 	if (!mipmapscreated)
 	{
 	{
 		glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
 		glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
-		
+
 		if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object)
 		if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object)
 			glGenerateMipmap(GL_TEXTURE_2D);
 			glGenerateMipmap(GL_TEXTURE_2D);
 		else if (GLEE_EXT_framebuffer_object)
 		else if (GLEE_EXT_framebuffer_object)
@@ -180,7 +180,7 @@ void Image::checkMipmapsCreated() const
 void Image::setFilter(const Image::Filter &f)
 void Image::setFilter(const Image::Filter &f)
 {
 {
 	filter = f;
 	filter = f;
-	
+
 	bind();
 	bind();
 	checkMipmapsCreated();
 	checkMipmapsCreated();
 	setTextureFilter(f);
 	setTextureFilter(f);
@@ -194,7 +194,7 @@ const Image::Filter &Image::getFilter() const
 void Image::setWrap(const Image::Wrap &w)
 void Image::setWrap(const Image::Wrap &w)
 {
 {
 	wrap = w;
 	wrap = w;
-	
+
 	bind();
 	bind();
 	setTextureWrap(w);
 	setTextureWrap(w);
 }
 }
@@ -208,10 +208,10 @@ void Image::setMipmapSharpness(float sharpness)
 {
 {
 	if (!hasMipmapSharpnessSupport())
 	if (!hasMipmapSharpnessSupport())
 		return;
 		return;
-	
+
 	// LOD bias has the range (-maxbias, maxbias)
 	// LOD bias has the range (-maxbias, maxbias)
 	mipmapsharpness = std::min(std::max(sharpness, -maxmipmapsharpness + 0.01f), maxmipmapsharpness - 0.01f);
 	mipmapsharpness = std::min(std::max(sharpness, -maxmipmapsharpness + 0.01f), maxmipmapsharpness - 0.01f);
-	
+
 	bind();
 	bind();
 	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -mipmapsharpness); // negative bias is sharper
 	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -mipmapsharpness); // negative bias is sharper
 }
 }
@@ -243,7 +243,7 @@ bool Image::loadVolatile()
 {
 {
 	if (hasMipmapSharpnessSupport())
 	if (hasMipmapSharpnessSupport())
 		glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &maxmipmapsharpness);
 		glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &maxmipmapsharpness);
-	
+
 	if (hasNpot())
 	if (hasNpot())
 		return loadVolatileNPOT();
 		return loadVolatileNPOT();
 	else
 	else
@@ -254,10 +254,10 @@ bool Image::loadVolatilePOT()
 {
 {
 	glGenTextures(1,(GLuint *)&texture);
 	glGenTextures(1,(GLuint *)&texture);
 	bindTexture(texture);
 	bindTexture(texture);
-	
+
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-	
+
 	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
 
@@ -290,7 +290,7 @@ bool Image::loadVolatilePOT()
 					GL_RGBA,
 					GL_RGBA,
 					GL_UNSIGNED_BYTE,
 					GL_UNSIGNED_BYTE,
 					data->getData());
 					data->getData());
-	
+
 	setMipmapSharpness(mipmapsharpness);
 	setMipmapSharpness(mipmapsharpness);
 	setFilter(filter);
 	setFilter(filter);
 	setWrap(wrap);
 	setWrap(wrap);
@@ -302,10 +302,10 @@ bool Image::loadVolatileNPOT()
 {
 {
 	glGenTextures(1,(GLuint *)&texture);
 	glGenTextures(1,(GLuint *)&texture);
 	bindTexture(texture);
 	bindTexture(texture);
-	
+
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-	
+
 	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
 
@@ -318,7 +318,7 @@ bool Image::loadVolatileNPOT()
 				 GL_RGBA,
 				 GL_RGBA,
 				 GL_UNSIGNED_BYTE,
 				 GL_UNSIGNED_BYTE,
 				 data->getData());
 				 data->getData());
-	
+
 	setMipmapSharpness(mipmapsharpness);
 	setMipmapSharpness(mipmapsharpness);
 	setFilter(filter);
 	setFilter(filter);
 	setWrap(wrap);
 	setWrap(wrap);

+ 7 - 7
src/modules/graphics/opengl/Image.h

@@ -105,9 +105,9 @@ public:
 	void setWrap(const Image::Wrap &w);
 	void setWrap(const Image::Wrap &w);
 
 
 	const Image::Wrap &getWrap() const;
 	const Image::Wrap &getWrap() const;
-	
+
 	void setMipmapSharpness(float sharpness);
 	void setMipmapSharpness(float sharpness);
-	
+
 	float getMipmapSharpness() const;
 	float getMipmapSharpness() const;
 
 
 	void bind() const;
 	void bind() const;
@@ -143,22 +143,22 @@ private:
 
 
 	// The source vertices of the image.
 	// The source vertices of the image.
 	vertex vertices[4];
 	vertex vertices[4];
-	
+
 	// Mipmap texture LOD bias value
 	// Mipmap texture LOD bias value
 	float mipmapsharpness;
 	float mipmapsharpness;
-	
+
 	// Implementation-dependent maximum/minimum mipmap sharpness values
 	// Implementation-dependent maximum/minimum mipmap sharpness values
 	float maxmipmapsharpness;
 	float maxmipmapsharpness;
-	
+
 	// The image's filter mode
 	// The image's filter mode
 	Image::Filter filter;
 	Image::Filter filter;
-	
+
 	// The image's wrap mode
 	// The image's wrap mode
 	Image::Wrap wrap;
 	Image::Wrap wrap;
 
 
 	bool loadVolatilePOT();
 	bool loadVolatilePOT();
 	bool loadVolatileNPOT();
 	bool loadVolatileNPOT();
-	
+
 	void checkMipmapsCreated() const;
 	void checkMipmapsCreated() const;
 
 
 }; // Image
 }; // Image

+ 2 - 2
src/modules/graphics/opengl/OpenGL.cpp

@@ -65,13 +65,13 @@ void setTextureFilter(const graphics::Image::Filter &f)
 	}
 	}
 	else
 	else
 	{
 	{
-		if (f.min == f.mipmap == Image::FILTER_NEAREST)
+		if (f.min == Image::FILTER_NEAREST && f.mipmap == Image::FILTER_NEAREST)
 			gmin = GL_NEAREST_MIPMAP_NEAREST;
 			gmin = GL_NEAREST_MIPMAP_NEAREST;
 		else if (f.min == Image::FILTER_NEAREST && f.mipmap == Image::FILTER_LINEAR)
 		else if (f.min == Image::FILTER_NEAREST && f.mipmap == Image::FILTER_LINEAR)
 			gmin = GL_NEAREST_MIPMAP_LINEAR;
 			gmin = GL_NEAREST_MIPMAP_LINEAR;
 		else if (f.min == Image::FILTER_LINEAR && f.mipmap == Image::FILTER_NEAREST)
 		else if (f.min == Image::FILTER_LINEAR && f.mipmap == Image::FILTER_NEAREST)
 			gmin = GL_LINEAR_MIPMAP_NEAREST;
 			gmin = GL_LINEAR_MIPMAP_NEAREST;
-		else if (f.min == f.mipmap == Image::FILTER_LINEAR)
+		else if (f.min == Image::FILTER_LINEAR && f.mipmap == Image::FILTER_LINEAR)
 			gmin = GL_LINEAR_MIPMAP_LINEAR;
 			gmin = GL_LINEAR_MIPMAP_LINEAR;
 		else
 		else
 			gmin = GL_LINEAR;
 			gmin = GL_LINEAR;

+ 17 - 16
src/modules/graphics/opengl/ParticleSystem.cpp

@@ -105,7 +105,7 @@ ParticleSystem::~ParticleSystem()
 
 
 	if (pStart != 0)
 	if (pStart != 0)
 		delete [] pStart;
 		delete [] pStart;
-	
+
 	if (particleVerts != 0)
 	if (particleVerts != 0)
 		delete [] particleVerts;
 		delete [] particleVerts;
 }
 }
@@ -207,10 +207,10 @@ void ParticleSystem::setBufferSize(unsigned int size)
 	pLast = pStart = new particle[size];
 	pLast = pStart = new particle[size];
 
 
 	pEnd = pStart + size;
 	pEnd = pStart + size;
-	
+
 	if (particleVerts != 0)
 	if (particleVerts != 0)
 		delete [] particleVerts;
 		delete [] particleVerts;
-	
+
 	// each particle has 4 vertices
 	// each particle has 4 vertices
 	particleVerts = new vertex[size*4];
 	particleVerts = new vertex[size*4];
 }
 }
@@ -468,7 +468,7 @@ bool ParticleSystem::isFull() const
 void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
 void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
 {
 {
 	if (sprite == 0) return;  // just in case of failure
 	if (sprite == 0) return;  // just in case of failure
-	
+
 	int numParticles = count();
 	int numParticles = count();
 	if (numParticles == 0) return; // don't bother if there's nothing to do
 	if (numParticles == 0) return; // don't bother if there's nothing to do
 
 
@@ -478,25 +478,26 @@ void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, flo
 	static Matrix t;
 	static Matrix t;
 	t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
 	t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
 	glMultMatrixf((const GLfloat *)t.getElements());
 	glMultMatrixf((const GLfloat *)t.getElements());
-	
+
 	const vertex * imageVerts = sprite->getVertices();
 	const vertex * imageVerts = sprite->getVertices();
-	
+
 	// set the vertex data for each particle (transformation, texcoords, color)
 	// set the vertex data for each particle (transformation, texcoords, color)
 	for (int i = 0; i < numParticles; i++)
 	for (int i = 0; i < numParticles; i++)
 	{
 	{
 		particle * p = pStart + i;
 		particle * p = pStart + i;
-		
+
 		// particle vertices are sprite vertices transformed by particle information 
 		// particle vertices are sprite vertices transformed by particle information 
 		t.setTransformation(p->position[0], p->position[1], p->rotation, p->size, p->size, offsetX, offsetY, 0.0f, 0.0f);
 		t.setTransformation(p->position[0], p->position[1], p->rotation, p->size, p->size, offsetX, offsetY, 0.0f, 0.0f);
 		t.transform(&particleVerts[i*4], &imageVerts[0], 4);
 		t.transform(&particleVerts[i*4], &imageVerts[0], 4);
-		
+
 		// set the texture coordinate and color data for particle vertices
 		// set the texture coordinate and color data for particle vertices
-		for (int v = 0; v < 4; v++) {
+		for (int v = 0; v < 4; v++)
+		{
 			int vi = (i * 4) + v; // current vertex index for particle
 			int vi = (i * 4) + v; // current vertex index for particle
-			
+
 			particleVerts[vi].s = imageVerts[v].s;
 			particleVerts[vi].s = imageVerts[v].s;
 			particleVerts[vi].t = imageVerts[v].t;
 			particleVerts[vi].t = imageVerts[v].t;
-			
+
 			// particle colors are stored as floats (0-1) but vertex colors are stored as unsigned bytes (0-255)
 			// particle colors are stored as floats (0-1) but vertex colors are stored as unsigned bytes (0-255)
 			particleVerts[vi].r = p->color.r*255;
 			particleVerts[vi].r = p->color.r*255;
 			particleVerts[vi].g = p->color.g*255;
 			particleVerts[vi].g = p->color.g*255;
@@ -504,19 +505,19 @@ void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, flo
 			particleVerts[vi].a = p->color.a*255;
 			particleVerts[vi].a = p->color.a*255;
 		}
 		}
 	}
 	}
-	
+
 	sprite->bind();
 	sprite->bind();
-	
+
 	glEnableClientState(GL_COLOR_ARRAY);
 	glEnableClientState(GL_COLOR_ARRAY);
 	glEnableClientState(GL_VERTEX_ARRAY);
 	glEnableClientState(GL_VERTEX_ARRAY);
 	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-	
+
 	glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid *)&particleVerts[0].r);
 	glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid *)&particleVerts[0].r);
 	glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&particleVerts[0].x);
 	glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&particleVerts[0].x);
 	glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&particleVerts[0].s);
 	glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&particleVerts[0].s);
-	
+
 	glDrawArrays(GL_QUADS, 0, numParticles*4);
 	glDrawArrays(GL_QUADS, 0, numParticles*4);
-	
+
 	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 	glDisableClientState(GL_VERTEX_ARRAY);
 	glDisableClientState(GL_VERTEX_ARRAY);
 	glDisableClientState(GL_COLOR_ARRAY);
 	glDisableClientState(GL_COLOR_ARRAY);

+ 1 - 1
src/modules/graphics/opengl/ParticleSystem.h

@@ -406,7 +406,7 @@ protected:
 
 
 	// Pointer to the end of the memory allocation.
 	// Pointer to the end of the memory allocation.
 	particle *pEnd;
 	particle *pEnd;
-	
+
 	// array of transformed vertex data for all particles, for drawing
 	// array of transformed vertex data for all particles, for drawing
 	vertex * particleVerts;
 	vertex * particleVerts;
 
 

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

@@ -601,10 +601,10 @@ int w_setDefaultImageFilter(lua_State *L)
 {
 {
 	Image::FilterMode min;
 	Image::FilterMode min;
 	Image::FilterMode mag;
 	Image::FilterMode mag;
-	
+
 	const char *minstr = luaL_checkstring(L, 1);
 	const char *minstr = luaL_checkstring(L, 1);
 	const char *magstr = luaL_optstring(L, 2, minstr);
 	const char *magstr = luaL_optstring(L, 2, minstr);
-	
+
 	if (!Image::getConstant(minstr, min))
 	if (!Image::getConstant(minstr, min))
 		return luaL_error(L, "Invalid filter mode: %s", minstr);
 		return luaL_error(L, "Invalid filter mode: %s", minstr);
 	if (!Image::getConstant(magstr, mag))
 	if (!Image::getConstant(magstr, mag))
@@ -613,7 +613,7 @@ int w_setDefaultImageFilter(lua_State *L)
 	Image::Filter f;
 	Image::Filter f;
 	f.min = min;
 	f.min = min;
 	f.mag = mag;
 	f.mag = mag;
-	
+
 	instance->setDefaultImageFilter(f);
 	instance->setDefaultImageFilter(f);
 
 
 	return 0;
 	return 0;

+ 14 - 14
src/modules/graphics/opengl/wrap_Image.cpp

@@ -50,17 +50,17 @@ int w_Image_getHeight(lua_State *L)
 int w_Image_setFilter(lua_State *L)
 int w_Image_setFilter(lua_State *L)
 {
 {
 	Image *t = luax_checkimage(L, 1);
 	Image *t = luax_checkimage(L, 1);
-	
+
 	Image::Filter f;
 	Image::Filter f;
-	
+
 	const char *minstr = luaL_checkstring(L, 2);
 	const char *minstr = luaL_checkstring(L, 2);
 	const char *magstr = luaL_optstring(L, 3, minstr);
 	const char *magstr = luaL_optstring(L, 3, minstr);
-	
+
 	if (!Image::getConstant(minstr, f.min))
 	if (!Image::getConstant(minstr, f.min))
 		return luaL_error(L, "Invalid filter mode: %s", minstr);
 		return luaL_error(L, "Invalid filter mode: %s", minstr);
 	if (!Image::getConstant(magstr, f.mag))
 	if (!Image::getConstant(magstr, f.mag))
 		return luaL_error(L, "Invalid filter mode: %s", magstr);
 		return luaL_error(L, "Invalid filter mode: %s", magstr);
-	
+
 	if (lua_isnoneornil(L, 4))
 	if (lua_isnoneornil(L, 4))
 		f.mipmap = Image::FILTER_NONE; // mipmapping is disabled unless third argument is given
 		f.mipmap = Image::FILTER_NONE; // mipmapping is disabled unless third argument is given
 	else
 	else
@@ -69,16 +69,16 @@ int w_Image_setFilter(lua_State *L)
 		if (!Image::getConstant(mipmapstr, f.mipmap))
 		if (!Image::getConstant(mipmapstr, f.mipmap))
 			return luaL_error(L, "Invalid filter mode: %s", mipmapstr);
 			return luaL_error(L, "Invalid filter mode: %s", mipmapstr);
 	}
 	}
-	
+
 	try
 	try
 	{
 	{
 		t->setFilter(f);
 		t->setFilter(f);
 	}
 	}
 	catch(love::Exception &e)
 	catch(love::Exception &e)
 	{
 	{
-		return luaL_error(L, e.what());
+		return luaL_error(L, "%s", e.what());
 	}
 	}
-	
+
 	return 0;
 	return 0;
 }
 }
 
 
@@ -92,32 +92,32 @@ int w_Image_getFilter(lua_State *L)
 	Image::getConstant(f.mag, magstr);
 	Image::getConstant(f.mag, magstr);
 	lua_pushstring(L, minstr);
 	lua_pushstring(L, minstr);
 	lua_pushstring(L, magstr);
 	lua_pushstring(L, magstr);
-	
+
 	const char *mipmapstr;
 	const char *mipmapstr;
 	if (Image::getConstant(f.mipmap, mipmapstr))
 	if (Image::getConstant(f.mipmap, mipmapstr))
 		lua_pushstring(L, mipmapstr);
 		lua_pushstring(L, mipmapstr);
 	else
 	else
 		lua_pushnil(L); // only return a mipmap filter if mipmapping is enabled
 		lua_pushnil(L); // only return a mipmap filter if mipmapping is enabled
-	
+
 	return 3;
 	return 3;
 }
 }
 
 
 int w_Image_setWrap(lua_State *L)
 int w_Image_setWrap(lua_State *L)
 {
 {
 	Image *i = luax_checkimage(L, 1);
 	Image *i = luax_checkimage(L, 1);
-	
+
 	Image::Wrap w;
 	Image::Wrap w;
-	
+
 	const char *sstr = luaL_checkstring(L, 2);
 	const char *sstr = luaL_checkstring(L, 2);
 	const char *tstr = luaL_optstring(L, 3, sstr);
 	const char *tstr = luaL_optstring(L, 3, sstr);
-	
+
 	if (!Image::getConstant(sstr, w.s))
 	if (!Image::getConstant(sstr, w.s))
 		return luaL_error(L, "Invalid wrap mode: %s", sstr);
 		return luaL_error(L, "Invalid wrap mode: %s", sstr);
 	if (!Image::getConstant(tstr, w.t))
 	if (!Image::getConstant(tstr, w.t))
 		return luaL_error(L, "Invalid wrap mode, %s", tstr);
 		return luaL_error(L, "Invalid wrap mode, %s", tstr);
 
 
 	i->setWrap(w);
 	i->setWrap(w);
-	
+
 	return 0;
 	return 0;
 }
 }
 
 
@@ -140,7 +140,7 @@ int w_Image_setMipmapSharpness(lua_State *L)
 	
 	
 	float sharpness = (float) luaL_checknumber(L, 2);
 	float sharpness = (float) luaL_checknumber(L, 2);
 	i->setMipmapSharpness(sharpness);
 	i->setMipmapSharpness(sharpness);
-	
+
 	return 0;
 	return 0;
 }
 }