mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
added love.graphics.setIcon
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user