1. Robin Wellner
  2. selove

Commits

Bart van Strien  committed eb360c7

Centralize NPOT support check for image, export it to isSupported

  • Participants
  • Parent commits f111106
  • Branches default

Comments (0)

Files changed (5)

File src/modules/graphics/Graphics.cpp

View file
 	{
 		{ "canvas", Graphics::SUPPORT_CANVAS },
 		{ "pixeleffect", Graphics::SUPPORT_PIXELEFFECT },
+		{ "npot", Graphics::SUPPORT_NPOT },
 	};
 
 	StringMap<Graphics::Support, Graphics::SUPPORT_MAX_ENUM> Graphics::support(Graphics::supportEntries, sizeof(Graphics::supportEntries));

File src/modules/graphics/Graphics.h

View file
 		{
 			SUPPORT_CANVAS = 1,
 			SUPPORT_PIXELEFFECT,
+			SUPPORT_NPOT,
 			SUPPORT_MAX_ENUM
 		};
 

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

View file
 
 	bool Image::loadVolatile()
 	{
-		if (GLEE_ARB_texture_non_power_of_two)
+		if (hasNpot())
 			return loadVolatileNPOT();
 		else
 			return loadVolatilePOT();
 		glPopMatrix();
 	}
 
+	bool Image::hasNpot()
+	{
+		return GLEE_ARB_texture_non_power_of_two;
+	}
+
 } // opengl
 } // graphics
 } // love

File src/modules/graphics/opengl/Image.h

View file
 {
 namespace opengl
 {
-
 	/**
 	* A drawable image based on OpenGL-textures. This class takes ImageData
 	* objects and create textures on the GPU for fast drawing.
 		bool loadVolatile();
 		void unloadVolatile();
 
+		static bool hasNpot();
+
 	private:
 
 		void drawv(const Matrix & t, const vertex * v) const;

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

View file
 					if (!PixelEffect::isSupported())
 						supported = false;
 					break;
+				case Graphics::SUPPORT_NPOT:
+					if (!Image::hasNpot())
+						supported = false;
+					break;
 				default:
 					supported = false;
 			}