Browse Source

added love.graphics.setIcon

Bill Meltsner 15 years ago
parent
commit
176645e25d

+ 1 - 1
changes.txt

@@ -9,6 +9,7 @@ LOVE 0.7.0
   * Added identity field to love.conf.
   * Added love.quit callback.
   * Added extra meter parameter to love.physics.newWorld.
+  * Added love.graphics.setIcon.
   * Enabled love.filesystem.FileData.
   * Fixed bug where the debug module was not an upvalue of the error handlers. (you can now override debug)
   * Fixed bug where love.audio.pause and friends were acting on everything, not just the passed Source.
@@ -20,7 +21,6 @@ LOVE 0.7.0
   * Moved fonts to love.font (from love.graphics), only rendering remains in love.graphics.
   * Switched font origin to top-left.
   * OS X now properly uses UTIs for .love files.
-  * Dropped the OS X version requirement to 10.4.
   * Fewer compiler warnings.
 
 LOVE 0.6.2

+ 19 - 0
src/modules/graphics/opengl/Graphics.cpp

@@ -306,6 +306,25 @@ namespace opengl
 	{
 		SDL_GL_SwapBuffers();
 	}
+	
+	void Graphics::setIcon(Image * image)
+	{
+		Uint32 rmask, gmask, bmask, amask;
+#ifdef LOVE_BIG_ENDIAN
+		rmask = 0xFF000000;
+		gmask = 0x00FF0000;
+		bmask = 0x0000FF00;
+		amask = 0x000000FF;
+#else
+		rmask = 0x000000FF;
+		gmask = 0x0000FF00;
+		bmask = 0x00FF0000;
+		amask = 0xFF000000;
+#endif
+		SDL_Surface * icon = SDL_CreateRGBSurfaceFrom(image->getData()->getData(), image->getWidth(), image->getHeight(), 32, image->getWidth() * 4, rmask, gmask, bmask, amask);
+		SDL_WM_SetIcon(icon, NULL);
+		SDL_FreeSurface(icon);
+	}
 
 	void Graphics::setCaption(const char * caption)
 	{

+ 6 - 2
src/modules/graphics/opengl/Graphics.h

@@ -176,9 +176,14 @@ namespace opengl
 		* presented on screen).
 		**/
 		void present();
+		
+		/**
+		* Sets the window's icon.
+		**/
+		void setIcon(Image * image);
 
 		/**
-		* Sets the windows caption.
+		* Sets the window's caption.
 		**/
 		void setCaption(const char * caption);
 
@@ -505,7 +510,6 @@ namespace opengl
 		* @param ... Vertex components (x1, y1, x2, y2, etc).
 		**/
 		int polygon(lua_State * L);
-		int polygong(lua_State * L);
 
 		/**
 		* Creates a screenshot of the view and saves it to the default folder.

+ 9 - 0
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -78,6 +78,13 @@ namespace opengl
 		return 0;
 	}
 
+	int w_setIcon(lua_State * L)
+	{
+		Image * image = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
+		instance->setIcon(image);
+		return 0;
+	}
+	
 	int w_setCaption(lua_State * L)
 	{
 		const char * str = luaL_checkstring(L, 1);
@@ -859,6 +866,8 @@ namespace opengl
 
 		{ "setCaption", w_setCaption },
 		{ "getCaption", w_getCaption },
+		
+		{ "setIcon", w_setIcon },
 
 		{ "getWidth", w_getWidth },
 		{ "getHeight", w_getHeight },

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

@@ -42,6 +42,7 @@ namespace opengl
 	int w_reset(lua_State * L);
 	int w_clear(lua_State * L);
 	int w_present(lua_State * L);
+	int w_setIcon(lua_State * L);
 	int w_setCaption(lua_State * L);
 	int w_getCaption(lua_State * L);
 	int w_getWidth(lua_State * L);