Commits

Alex Szpakowski  committed 629d1c4

Fixed smooth lines with love.graphics.origin() after love.graphics.scale

  • Participants
  • Parent commits 52e08ff

Comments (0)

Files changed (4)

File src/common/Module.cpp

 
 namespace love
 {
-	void Module::registerInstance(Module *instance)
+
+void Module::registerInstance(Module *instance)
+{
+	if (instance == NULL)
+		throw Exception("Module instance is NULL");
+
+	std::string name(instance->getName());
+
+	std::map<std::string, Module*>::iterator it = registry.find(name);
+
+	if (registry.end() != it)
 	{
-		if (instance == NULL)
-			throw Exception("Module instance is NULL");
-
-		std::string name(instance->getName());
-
-		std::map<std::string, Module*>::iterator it = registry.find(name);
-
-		if (registry.end() != it)
-		{
-			if (it->second == instance)
-				return;
-			throw Exception("Module %s already registered!", instance->getName());
-		}
-
-		registry.insert(make_pair(name, instance));
+		if (it->second == instance)
+			return;
+		throw Exception("Module %s already registered!", instance->getName());
 	}
 
-	Module *Module::getInstance(const char *name)
-	{
-		std::map<std::string, Module*>::iterator it = registry.find(std::string(name));
+	registry.insert(make_pair(name, instance));
+}
 
-		if (registry.end() == it)
-			return NULL;
+Module *Module::getInstance(const char *name)
+{
+	std::map<std::string, Module*>::iterator it = registry.find(std::string(name));
 
-		return it->second;
-	}
-} // namespace love
+	if (registry.end() == it)
+		return NULL;
+
+	return it->second;
+}
+
+} // love

File src/common/runtime.cpp

 	return 1;
 }
 
-Reference *luax_refif (lua_State *L, int type)
+Reference *luax_refif(lua_State *L, int type)
 {
 	Reference *r = 0;
 
 
 	// The modules themselves. Only add abstracted modules here.
 	{"filesystem", MODULE_FILESYSTEM_ID},
+	{"graphics", MODULE_GRAPHICS_ID},
 	{"image", MODULE_IMAGE_ID},
 	{"sound", MODULE_SOUND_ID},
 };

File src/modules/graphics/opengl/Graphics.cpp

 
 void Graphics::unSetMode()
 {
-	// Window creation may destroy the OpenGL context, so we must save the state.
+	// Window re-creation may destroy the GL context, so we must save the state.
 	if (isCreated())
 		savedState = saveState();
 
-	// Unload all volatile objects. These must be reloaded after
-	// the display mode change.
+	// Unload all volatile objects. These must be reloaded after the display
+	// mode change.
 	Volatile::unloadAll();
 
 	gl.deInitContext();
 void Graphics::setScissor(int x, int y, int width, int height)
 {
 	glEnable(GL_SCISSOR_TEST);
-	glScissor(x, getRenderHeight() - (y + height), width, height); // Compensates for the fact that our y-coordinate is reverse of OpenGLs.
+	// Compensates for the fact that our y-coordinate is reverse of OpenGL's.
+	glScissor(x, getRenderHeight() - (y + height), width, height);
 }
 
 void Graphics::setScissor()
 	glDisableClientState(GL_COLOR_ARRAY);
 	// "if GL_COLOR_ARRAY is enabled, the value of the current color is
 	// undefined after glDrawArrays executes"
-	
+
 	gl.setColor(c);
 
 	delete[] colors;
 void Graphics::origin()
 {
 	glLoadIdentity();
-	pixel_size_stack.clear();
-	pixel_size_stack.push_back(1);
+	pixel_size_stack.back() = 1;
 }
 
 } // opengl

File src/modules/graphics/opengl/SpriteBatch.cpp

 		return -1;
 
 	if (geom->getVertexCount() != 4)
-		throw love::Exception("Can only add quadliteral geometries to SpriteBatch");
+		throw love::Exception("Can only add quadrilateral geometries to SpriteBatch");
 
 	for (size_t i = 0; i < 4; i++)
 		sprite[i] = geom->getVertex(i);
 
 void SpriteBatch::setImage(Image *newimage)
 {
+	newimage->retain();
 	image->release();
 	image = newimage;
-	image->retain();
 }
 
 Image *SpriteBatch::getImage()