Alex Szpakowski avatar Alex Szpakowski committed 1e9aa84

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

Comments (0)

Files changed (9)

src/modules/graphics/Image.h

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

src/modules/graphics/opengl/Canvas.cpp

 
 		glGenTextures(1, &img);
 		bindTexture(img);
-		
+
 		setTextureFilter(Image::getDefaultFilter());
-		
+
 		glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height,
 			0, GL_RGBA, format, NULL);
 		bindTexture(0);
 
 		glGenTextures(1, &img);
 		bindTexture(img);
-		
+
 		setTextureFilter(Image::getDefaultFilter());
 
 		glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height,
 
 		glGenTextures(1, &img);
 		bindTexture(img);
-		
+
 		setTextureFilter(Image::getDefaultFilter());
-		
+
 		glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height,
 			0, GL_RGBA, format, NULL);
 		bindTexture(0);

src/modules/graphics/opengl/Image.cpp

 {
 	if (filter.mipmap != FILTER_NEAREST && filter.mipmap != FILTER_LINEAR)
 		return;
-	
+
 	if (!hasMipmapSupport())
 		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
 	// we can't detect which systems will do this, so we fail gracefully for all NPOT images
 	int w = int(width), h = int(height);
 	if (w != next_p2(w) || h != next_p2(h))
 		throw love::Exception("Could not generate mipmaps: image does not have power of two dimensions!");
-	
+
 	bind();
-	
+
 	GLboolean mipmapscreated;
 	glGetTexParameteriv(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, (GLint *)&mipmapscreated);
-	
+
 	// generate mipmaps for this image if we haven't already
 	if (!mipmapscreated)
 	{
 		glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
-		
+
 		if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object)
 			glGenerateMipmap(GL_TEXTURE_2D);
 		else if (GLEE_EXT_framebuffer_object)
 void Image::setFilter(const Image::Filter &f)
 {
 	filter = f;
-	
+
 	bind();
 	checkMipmapsCreated();
 	setTextureFilter(f);
 void Image::setWrap(const Image::Wrap &w)
 {
 	wrap = w;
-	
+
 	bind();
 	setTextureWrap(w);
 }
 {
 	if (!hasMipmapSharpnessSupport())
 		return;
-	
+
 	// LOD bias has the range (-maxbias, maxbias)
 	mipmapsharpness = std::min(std::max(sharpness, -maxmipmapsharpness + 0.01f), maxmipmapsharpness - 0.01f);
-	
+
 	bind();
 	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -mipmapsharpness); // negative bias is sharper
 }
 {
 	if (hasMipmapSharpnessSupport())
 		glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &maxmipmapsharpness);
-	
+
 	if (hasNpot())
 		return loadVolatileNPOT();
 	else
 {
 	glGenTextures(1,(GLuint *)&texture);
 	bindTexture(texture);
-	
+
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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_T, GL_CLAMP_TO_EDGE);
 
 					GL_RGBA,
 					GL_UNSIGNED_BYTE,
 					data->getData());
-	
+
 	setMipmapSharpness(mipmapsharpness);
 	setFilter(filter);
 	setWrap(wrap);
 {
 	glGenTextures(1,(GLuint *)&texture);
 	bindTexture(texture);
-	
+
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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_T, GL_CLAMP_TO_EDGE);
 
 				 GL_RGBA,
 				 GL_UNSIGNED_BYTE,
 				 data->getData());
-	
+
 	setMipmapSharpness(mipmapsharpness);
 	setFilter(filter);
 	setWrap(wrap);

src/modules/graphics/opengl/Image.h

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

src/modules/graphics/opengl/OpenGL.cpp

 	}
 	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;
 		else if (f.min == Image::FILTER_NEAREST && f.mipmap == Image::FILTER_LINEAR)
 			gmin = GL_NEAREST_MIPMAP_LINEAR;
 		else if (f.min == Image::FILTER_LINEAR && f.mipmap == Image::FILTER_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;
 		else
 			gmin = GL_LINEAR;

src/modules/graphics/opengl/ParticleSystem.cpp

 
 	if (pStart != 0)
 		delete [] pStart;
-	
+
 	if (particleVerts != 0)
 		delete [] particleVerts;
 }
 	pLast = pStart = new particle[size];
 
 	pEnd = pStart + size;
-	
+
 	if (particleVerts != 0)
 		delete [] particleVerts;
-	
+
 	// each particle has 4 vertices
 	particleVerts = new vertex[size*4];
 }
 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
-	
+
 	int numParticles = count();
 	if (numParticles == 0) return; // don't bother if there's nothing to do
 
 	static Matrix t;
 	t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
 	glMultMatrixf((const GLfloat *)t.getElements());
-	
+
 	const vertex * imageVerts = sprite->getVertices();
-	
+
 	// set the vertex data for each particle (transformation, texcoords, color)
 	for (int i = 0; i < numParticles; i++)
 	{
 		particle * p = pStart + i;
-		
+
 		// 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.transform(&particleVerts[i*4], &imageVerts[0], 4);
-		
+
 		// 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
-			
+
 			particleVerts[vi].s = imageVerts[v].s;
 			particleVerts[vi].t = imageVerts[v].t;
-			
+
 			// 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].g = p->color.g*255;
 			particleVerts[vi].a = p->color.a*255;
 		}
 	}
-	
+
 	sprite->bind();
-	
+
 	glEnableClientState(GL_COLOR_ARRAY);
 	glEnableClientState(GL_VERTEX_ARRAY);
 	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-	
+
 	glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid *)&particleVerts[0].r);
 	glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&particleVerts[0].x);
 	glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&particleVerts[0].s);
-	
+
 	glDrawArrays(GL_QUADS, 0, numParticles*4);
-	
+
 	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 	glDisableClientState(GL_VERTEX_ARRAY);
 	glDisableClientState(GL_COLOR_ARRAY);

src/modules/graphics/opengl/ParticleSystem.h

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

src/modules/graphics/opengl/wrap_Graphics.cpp

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

src/modules/graphics/opengl/wrap_Image.cpp

 int w_Image_setFilter(lua_State *L)
 {
 	Image *t = luax_checkimage(L, 1);
-	
+
 	Image::Filter f;
-	
+
 	const char *minstr = luaL_checkstring(L, 2);
 	const char *magstr = luaL_optstring(L, 3, minstr);
-	
+
 	if (!Image::getConstant(minstr, f.min))
 		return luaL_error(L, "Invalid filter mode: %s", minstr);
 	if (!Image::getConstant(magstr, f.mag))
 		return luaL_error(L, "Invalid filter mode: %s", magstr);
-	
+
 	if (lua_isnoneornil(L, 4))
 		f.mipmap = Image::FILTER_NONE; // mipmapping is disabled unless third argument is given
 	else
 		if (!Image::getConstant(mipmapstr, f.mipmap))
 			return luaL_error(L, "Invalid filter mode: %s", mipmapstr);
 	}
-	
+
 	try
 	{
 		t->setFilter(f);
 	}
 	catch(love::Exception &e)
 	{
-		return luaL_error(L, e.what());
+		return luaL_error(L, "%s", e.what());
 	}
-	
+
 	return 0;
 }
 
 	Image::getConstant(f.mag, magstr);
 	lua_pushstring(L, minstr);
 	lua_pushstring(L, magstr);
-	
+
 	const char *mipmapstr;
 	if (Image::getConstant(f.mipmap, mipmapstr))
 		lua_pushstring(L, mipmapstr);
 	else
 		lua_pushnil(L); // only return a mipmap filter if mipmapping is enabled
-	
+
 	return 3;
 }
 
 int w_Image_setWrap(lua_State *L)
 {
 	Image *i = luax_checkimage(L, 1);
-	
+
 	Image::Wrap w;
-	
+
 	const char *sstr = luaL_checkstring(L, 2);
 	const char *tstr = luaL_optstring(L, 3, sstr);
-	
+
 	if (!Image::getConstant(sstr, w.s))
 		return luaL_error(L, "Invalid wrap mode: %s", sstr);
 	if (!Image::getConstant(tstr, w.t))
 		return luaL_error(L, "Invalid wrap mode, %s", tstr);
 
 	i->setWrap(w);
-	
+
 	return 0;
 }
 
 	
 	float sharpness = (float) luaL_checknumber(L, 2);
 	i->setMipmapSharpness(sharpness);
-	
+
 	return 0;
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.