Browse Source

Move the default image filter to the Image class, instead of Graphics applying it on newImage

Bart van Strien 13 years ago
parent
commit
1e00f0f981

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

@@ -38,7 +38,7 @@ namespace opengl
 {
 
 	Graphics::Graphics()
-		: currentFont(0), currentImageFilter(), lineStyle(LINE_SMOOTH), lineWidth(1), matrixLimit(0), userMatrices(0)
+		: currentFont(0), lineStyle(LINE_SMOOTH), lineWidth(1), matrixLimit(0), userMatrices(0)
 	{
 		currentWindow = love::window::sdl::Window::getSingleton();
 
@@ -342,8 +342,6 @@ namespace opengl
 			return 0;
 		}
 
-		image->setFilter(currentImageFilter);
-
 		return image;
 	}
 
@@ -557,7 +555,7 @@ namespace opengl
 
 	void Graphics::setDefaultImageFilter(const Image::Filter& f)
 	{
-		currentImageFilter = f;
+		Image::setDefaultFilter(f);
 	}
 
 	Graphics::BlendMode Graphics::getBlendMode ()
@@ -596,7 +594,7 @@ namespace opengl
 
 	const Image::Filter& Graphics::getDefaultImageFilter() const
 	{
-		return currentImageFilter;
+		return Image::getDefaultFilter();
 	}
 
 	void Graphics::setLineWidth( float width )

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

@@ -106,7 +106,6 @@ namespace opengl
 	private:
 
 		Font * currentFont;
-		Image::Filter currentImageFilter;
 		love::window::Window *currentWindow;
 
 		LineStyle lineStyle;

+ 13 - 0
src/modules/graphics/opengl/Image.cpp

@@ -32,6 +32,8 @@ namespace graphics
 {
 namespace opengl
 {
+	Image::Filter Image::defaultFilter;
+
 	Image::Image(love::image::ImageData * data)
 		: width((float)(data->getWidth())), height((float)(data->getHeight())), texture(0)
 	{
@@ -49,6 +51,8 @@ namespace opengl
 		vertices[1].s = 0; vertices[1].t = 1;
 		vertices[2].s = 1; vertices[2].t = 1;
 		vertices[3].s = 1; vertices[3].t = 0;
+
+		settings.filter = defaultFilter;
 	}
 
 	Image::~Image()
@@ -394,6 +398,15 @@ namespace opengl
 		return GLEE_ARB_texture_non_power_of_two != 0;
 	}
 
+	void Image::setDefaultFilter(const Image::Filter &f)
+	{
+		defaultFilter = f;
+	}
+
+	const Image::Filter &Image::getDefaultFilter()
+	{
+		return defaultFilter;
+	}
 } // opengl
 } // graphics
 } // love

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

@@ -71,6 +71,9 @@ namespace opengl
 		bool loadVolatilePOT();
 		bool loadVolatileNPOT();
 
+		// The default image filter
+		static Image::Filter defaultFilter;
+
 	public:
 
 		/**
@@ -141,6 +144,10 @@ namespace opengl
 
 		static bool hasNpot();
 
+		// The default filter.
+		static void setDefaultFilter(const Image::Filter &f);
+		static const Image::Filter &getDefaultFilter();
+
 	private:
 
 		void drawv(const Matrix & t, const vertex * v) const;