mirror of https://github.com/stella-emu/stella.git
Moved some redundant code into the parent FrameBufferSDL class.
Added the Cyberstella icon to the SDL port. No more ugly looking 'X' icon for Stella in Linux. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@224 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
f3402ce255
commit
eaa92d3faf
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: FrameBufferGL.cxx,v 1.10 2003-12-02 01:46:40 stephena Exp $
|
||||
// $Id: FrameBufferGL.cxx,v 1.11 2003-12-03 18:11:25 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -134,9 +134,7 @@ bool FrameBufferGL::init()
|
|||
mySDLFlags |= myConsole->settings().getBool("fullscreen") ? SDL_FULLSCREEN : 0;
|
||||
|
||||
// Set the window title and icon
|
||||
ostringstream name;
|
||||
name << "Stella: \"" << myConsole->properties().get("Cartridge.Name") << "\"";
|
||||
SDL_WM_SetCaption(name.str().c_str(), "stella");
|
||||
setWindowAttributes();
|
||||
|
||||
// Set up the OpenGL attributes
|
||||
myDepth = SDL_GetVideoInfo()->vfmt->BitsPerPixel;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: FrameBufferSDL.cxx,v 1.7 2003-11-30 22:50:15 stephena Exp $
|
||||
// $Id: FrameBufferSDL.cxx,v 1.8 2003-12-03 18:11:25 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -26,6 +26,8 @@
|
|||
#include "MediaSrc.hxx"
|
||||
#include "Settings.hxx"
|
||||
|
||||
#include "stella.xpm" // The Stella icon
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FrameBufferSDL::FrameBufferSDL()
|
||||
: x11Available(false),
|
||||
|
@ -185,3 +187,65 @@ uInt32 FrameBufferSDL::maxWindowSizeForScreen()
|
|||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferSDL::setWindowAttributes()
|
||||
{
|
||||
// Set the window title
|
||||
ostringstream name;
|
||||
name << "Stella: \"" << myConsole->properties().get("Cartridge.Name") << "\"";
|
||||
SDL_WM_SetCaption(name.str().c_str(), "stella");
|
||||
|
||||
// Set the window icon
|
||||
uInt32 w, h, ncols, nbytes;
|
||||
uInt32 rgba[256], icon[32 * 32];
|
||||
uInt8 mask[32][4];
|
||||
|
||||
sscanf(stella_icon[0], "%d %d %d %d", &w, &h, &ncols, &nbytes);
|
||||
if((w != 32) || (h != 32) || (ncols > 255) || (nbytes > 1))
|
||||
{
|
||||
cerr << "ERROR: Couldn't load the icon.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
for(uInt32 i = 0; i < ncols; i++)
|
||||
{
|
||||
unsigned char code;
|
||||
char color[32];
|
||||
uInt32 col;
|
||||
|
||||
sscanf(stella_icon[1 + i], "%c c %s", &code, color);
|
||||
if(!strcmp(color, "None"))
|
||||
col = 0x00000000;
|
||||
else if(!strcmp(color, "black"))
|
||||
col = 0xFF000000;
|
||||
else if (color[0] == '#')
|
||||
{
|
||||
sscanf(color + 1, "%06x", &col);
|
||||
col |= 0xFF000000;
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "ERROR: Couldn't load the icon.\n";
|
||||
return;
|
||||
}
|
||||
rgba[code] = col;
|
||||
}
|
||||
|
||||
memset(mask, 0, sizeof(mask));
|
||||
for(h = 0; h < 32; h++)
|
||||
{
|
||||
const char* line = stella_icon[1 + ncols + h];
|
||||
for(w = 0; w < 32; w++)
|
||||
{
|
||||
icon[w + 32 * h] = rgba[(int)line[w]];
|
||||
if(rgba[(int)line[w]] & 0xFF000000)
|
||||
mask[h][w >> 3] |= 1 << (7 - (w & 0x07));
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(icon, 32, 32, 32,
|
||||
32 * 4, 0xFF0000, 0x00FF00, 0x0000FF, 0xFF000000);
|
||||
SDL_WM_SetIcon(surface, (unsigned char *) mask);
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: FrameBufferSDL.hxx,v 1.7 2003-11-24 14:51:06 stephena Exp $
|
||||
// $Id: FrameBufferSDL.hxx,v 1.8 2003-12-03 18:11:25 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_SDL_HXX
|
||||
|
@ -34,7 +34,7 @@
|
|||
the core FrameBuffer.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBufferSDL.hxx,v 1.7 2003-11-24 14:51:06 stephena Exp $
|
||||
@version $Id: FrameBufferSDL.hxx,v 1.8 2003-12-03 18:11:25 stephena Exp $
|
||||
*/
|
||||
class FrameBufferSDL : public FrameBuffer
|
||||
{
|
||||
|
@ -92,6 +92,11 @@ class FrameBufferSDL : public FrameBuffer
|
|||
*/
|
||||
uInt32 maxWindowSizeForScreen();
|
||||
|
||||
/**
|
||||
Set the title and icon for the main SDL window.
|
||||
*/
|
||||
void setWindowAttributes();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// The following methods are derived from FrameBuffer.hxx
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: FrameBufferSoft.cxx,v 1.3 2003-11-30 22:50:15 stephena Exp $
|
||||
// $Id: FrameBufferSoft.cxx,v 1.4 2003-12-03 18:11:25 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -116,9 +116,7 @@ bool FrameBufferSoft::init()
|
|||
}
|
||||
|
||||
// Set the window title and icon
|
||||
ostringstream name;
|
||||
name << "Stella: \"" << myConsole->properties().get("Cartridge.Name") << "\"";
|
||||
SDL_WM_SetCaption(name.str().c_str(), "stella");
|
||||
setWindowAttributes();
|
||||
|
||||
// Create the screen
|
||||
if(!createScreen())
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/* XPM */
|
||||
static char * stella_icon[] = {
|
||||
"32 32 3 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
"+ c #FFFFFF",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" .............. ",
|
||||
" .............. ",
|
||||
" ..++..++..++.. ",
|
||||
" ..++..++..++.. ",
|
||||
" ..++..++..++.. ",
|
||||
" ..++..++..++.. ",
|
||||
" ..++..++..++.. ",
|
||||
" ..++..++..++.. ",
|
||||
" ..++..++..++.. ",
|
||||
" ..++..++..++.. ",
|
||||
" ....++..++..++.... ",
|
||||
" ....++..++..++.... ",
|
||||
" ....++++..++..++++.... ",
|
||||
" ....++++..++..++++.... ",
|
||||
" ..++++....++....++++.. ",
|
||||
" ..++++....++....++++.. ",
|
||||
" ......++......++......++...... ",
|
||||
" ......++......++......++...... ",
|
||||
" ..++++++.. ..++.. ..++++++.. ",
|
||||
" ..++++++.. ..++.. ..++++++.. ",
|
||||
" ..++++.... ..++.. ....++++.. ",
|
||||
" ..++++.... ..++.. ....++++.. ",
|
||||
" ........ ...... ........ ",
|
||||
" ........ ...... ........ ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
Loading…
Reference in New Issue