diff --git a/client/CAnimation.cpp b/client/CAnimation.cpp index 6bcf203a6..773b43367 100644 --- a/client/CAnimation.cpp +++ b/client/CAnimation.cpp @@ -635,6 +635,7 @@ SDLImage::SDLImage(std::string filename, bool compressed): { SDL_Surface *temp = surf; // add RLE flag + #if 0 if (surf->format->palette) { const SDL_Color &c = temp->format->palette->colors[0]; @@ -643,6 +644,17 @@ SDLImage::SDLImage(std::string filename, bool compressed): } else SDL_SetColorKey(temp, SDL_RLEACCEL, 0); + #else + if (surf->format->palette) + { + const SDL_Color &c = temp->format->palette->colors[0]; + SDL_SetColorKey(temp, (SDL_SRCCOLORKEY ), + SDL_MapRGB(temp -> format, c.r, c.g, c.b)); + } + SDL_SetSurfaceRLE(temp, SDL_RLEACCEL); + + #endif + // convert surface to enable RLE surf = SDL_ConvertSurface(temp, temp->format, temp->flags); diff --git a/client/CDefHandler.cpp b/client/CDefHandler.cpp index 68f13a6e3..b37c145c9 100644 --- a/client/CDefHandler.cpp +++ b/client/CDefHandler.cpp @@ -173,23 +173,35 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const SDL_Co add=0; ret = SDL_CreateRGBSurface(SDL_SWSURFACE, FullWidth, FullHeight, 8, 0, 0, 0, 0); + + if(nullptr == ret) + { + logGlobal->errorStream() << __FUNCTION__ <<": Unable to create surface"; + logGlobal->errorStream() << FullWidth << "X" << FullHeight; + logGlobal->errorStream() << SDL_GetError(); + throw std::runtime_error("Unable to create surface"); + } BaseOffset += sizeof(SSpriteDef); int BaseOffsetor = BaseOffset; + #if 0 for(int i=0; i<256; ++i) - { + { SDL_Color pr; pr.r = palette[i].r; pr.g = palette[i].g; pr.b = palette[i].b; - #if 0 pr.unused = palette[i].unused; - #else - pr.a = palette[i].a; - #endif // 0 - (*(ret->format->palette->colors+i))=pr; + (*(ret->format->palette->colors+i))=pr; } + #else + if(SDL_SetPaletteColors(ret->format->palette,palette,0,256) != 0) + { + throw std::runtime_error("Unable to set palette"); + } + + #endif int ftcp=0; diff --git a/client/CMT.cpp b/client/CMT.cpp index e6a99298b..233728e3c 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -344,7 +344,11 @@ int main(int argc, char** argv) if(!gNoGUI) { + #if 0 if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO)) + #else + if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO|SDL_INIT_NOPARACHUTE)) + #endif { logGlobal->errorStream()<<"Something was wrong: "<< SDL_GetError(); exit(-1); @@ -354,7 +358,7 @@ int main(int argc, char** argv) setScreenRes(res["width"].Float(), res["height"].Float(), video["bitsPerPixel"].Float(), video["fullscreen"].Bool()); logGlobal->infoStream() <<"\tInitializing screen: "<infoStream()<<"\tInitializing video: "<infoStream()<<"Initialization of VCMI (together): "< tasks; //preparing list of graphics to load tasks += boost::bind(&Graphics::loadFonts,this); tasks += boost::bind(&Graphics::loadPaletteAndColors,this); @@ -153,6 +154,16 @@ Graphics::Graphics() CThreadHelper th(&tasks,std::max((ui32)1,boost::thread::hardware_concurrency())); th.run(); + #else + loadFonts(); + loadPaletteAndColors(); + loadHeroFlags(); + initializeBattleGraphics(); + loadErmuToPicture(); + initializeImageLists(); + resources32 = CDefHandler::giveDefEss("RESOURCE.DEF"); + heroMoveArrows = CDefHandler::giveDefEss("ADAG.DEF"); + #endif for(auto & elem : heroMoveArrows->ourImages) { @@ -290,12 +301,19 @@ void Graphics::loadHeroFlags() pr[3].first = &Graphics::flags4; pr[3].second+=("AF00.DEF"),("AF01.DEF"),("AF02.DEF"),("AF03.DEF"),("AF04.DEF"), ("AF05.DEF"),("AF06.DEF"),("AF07.DEF"); + #if 0 boost::thread_group grupa; for(int g=3; g>=0; --g) { grupa.create_thread(boost::bind(&Graphics::loadHeroFlagsDetail, this, boost::ref(pr[g]), true)); } grupa.join_all(); + #else + for(auto p: pr) + { + loadHeroFlagsDetail(p,true); + } + #endif logGlobal->infoStream() << "Loading and transforming heroes' flags: "<update(); // calls a update and drawing process of the loaded game interface object at the moment + SDL_SetRenderDrawColor(mainRenderer, 0, 0, 0, 0); SDL_RenderClear(mainRenderer); SDL_RenderCopy(mainRenderer, screenTexture, NULL, NULL);