added love.graphics.setIcon

This commit is contained in:
Bill Meltsner
2010-08-01 08:56:05 -05:00
parent f85c5f3671
commit 176645e25d
5 changed files with 36 additions and 3 deletions
+19
View File
@@ -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
View File
@@ -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.
@@ -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 },
@@ -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);