- debian related changes

This commit is contained in:
Mark Vejvoda
2011-12-15 11:16:14 +00:00
parent c11266d529
commit bb16ed2a65
8 changed files with 1107 additions and 893 deletions

View File

@@ -11,7 +11,7 @@
#include "texture.h"
#include "util.h"
#include <SDL.h>
#include "leak_dumper.h"
using namespace Shared::Util;
@@ -38,6 +38,7 @@ Texture::Texture() {
forceCompressionDisabled=false;
}
// =====================================================
// class Texture1D
// =====================================================
@@ -66,6 +67,28 @@ void Texture1D::deletePixels() {
// class Texture2D
// =====================================================
SDL_Surface* Texture2D::CreateSDLSurface(bool newPixelData) const {
SDL_Surface* surface = NULL;
unsigned char* surfData = NULL;
if (newPixelData == true) {
// copy pixel data
surfData = new unsigned char[pixmap.getW() * pixmap.getH() * pixmap.getComponents()];
memcpy(surfData, pixmap.getPixels(), pixmap.getW() * pixmap.getH() * pixmap.getComponents());
} else {
surfData = pixmap.getPixels();
}
// This will only work with 24bit RGB and 32bit RGBA pictures
surface = SDL_CreateRGBSurfaceFrom(surfData, pixmap.getW(), pixmap.getH(), 8 * pixmap.getComponents(), pixmap.getW() * pixmap.getComponents(), 0x000000FF, 0x0000FF00, 0x00FF0000, (pixmap.getComponents() == 4) ? 0xFF000000 : 0);
if ((surface == NULL) && newPixelData == true) {
// cleanup when we failed to the create surface
delete[] surfData;
}
return surface;
}
void Texture2D::load(const string &path){
this->path= path;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] this->path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->path.c_str());

View File

@@ -20,11 +20,16 @@
#include <vector>
//#include <SDL_image.h>
#include "model.h"
#include "texture.h"
#include "graphics_interface.h"
#include "graphics_factory.h"
#include "platform_common.h"
#include "leak_dumper.h"
using namespace Shared::Graphics::Gl;
using namespace Shared::Util;
using namespace Shared::Graphics;
using namespace Shared::PlatformCommon;
namespace Shared{ namespace Platform{
@@ -72,14 +77,28 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
#ifndef WIN32
string mg_icon_file = "";
#if defined(CUSTOM_DATA_INSTALL_PATH_VALUE)
if(fileExists(CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.bmp")) {
if(fileExists(CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.png")) {
mg_icon_file = CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.png";
}
else if(fileExists(CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.bmp")) {
mg_icon_file = CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.bmp";
}
#endif
if(mg_icon_file == "" && fileExists("megaglest.bmp")) {
if(mg_icon_file == "" && fileExists("megaglest.png")) {
mg_icon_file = "megaglest.png";
}
else if(mg_icon_file == "" && fileExists("megaglest.bmp")) {
mg_icon_file = "megaglest.bmp";
}
else if(mg_icon_file == "" && fileExists("/usr/share/pixmaps/megaglest.png")) {
mg_icon_file = "/usr/share/pixmaps/megaglest.png";
}
else if(mg_icon_file == "" && fileExists("/usr/share/pixmaps/megaglest.bmp")) {
mg_icon_file = "/usr/share/pixmaps/megaglest.bmp";
}
if(mg_icon_file != "") {
if(icon != NULL) {
@@ -87,7 +106,17 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
icon = NULL;
}
icon = SDL_LoadBMP(mg_icon_file.c_str());
//printf("Loading icon [%s]\n",mg_icon_file.c_str());
if(extractExtension(mg_icon_file) == "bmp") {
icon = SDL_LoadBMP(mg_icon_file.c_str());
}
else {
Texture2D *texture2D = GraphicsInterface::getInstance().getFactory()->newTexture2D();
texture2D->load(mg_icon_file);
icon = texture2D->CreateSDLSurface(true);
delete texture2D;
}
//SDL_Surface *icon = IMG_Load("megaglest.ico");
@@ -105,6 +134,10 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
printf("Error: %s\n", SDL_GetError());
}
if(icon != NULL) {
//uint32 colorkey = SDL_MapRGB(icon->format, 255, 0, 255);
//SDL_SetColorKey(icon, SDL_SRCCOLORKEY, colorkey);
SDL_WM_SetIcon(icon, NULL);
}
}