mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
fix loading to pregame. Looks awful. More work to do.
* video temprorary disabled * multithread loading seems to be broken - disabled
This commit is contained in:
parent
e072b2664f
commit
cd81e85a61
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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: "<<pomtime.getDiff();
|
||||
}
|
||||
|
||||
#define DISABLE_VIDEO 1
|
||||
|
||||
CCS = new CClientState;
|
||||
CGI = new CGameInfo; //contains all global informations about game (texts, lodHandlers, map handler etc.)
|
||||
@ -371,14 +375,14 @@ int main(int argc, char** argv)
|
||||
logGlobal->infoStream()<<"\tInitializing video: "<<pomtime.getDiff();
|
||||
|
||||
|
||||
|
||||
#ifndef __ANDROID__
|
||||
//we can properly play intro only in the main thread, so we have to move loading to the separate thread
|
||||
boost::thread loading(init);
|
||||
#else
|
||||
//
|
||||
//#ifndef __ANDROID__
|
||||
// //we can properly play intro only in the main thread, so we have to move loading to the separate thread
|
||||
// boost::thread loading(init);
|
||||
//#else
|
||||
// on Android threaded init is broken
|
||||
init();
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
if(!gNoGUI )
|
||||
{
|
||||
@ -388,9 +392,9 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
CSDL_Ext::update(screen);
|
||||
#ifndef __ANDROID__
|
||||
loading.join();
|
||||
#endif
|
||||
//#ifndef __ANDROID__
|
||||
// loading.join();
|
||||
//#endif
|
||||
logGlobal->infoStream()<<"Initialization of VCMI (together): "<<total.getDiff();
|
||||
|
||||
if(!vm.count("battle"))
|
||||
@ -876,6 +880,10 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen)
|
||||
}
|
||||
|
||||
screenBuf = bufOnScreen ? screen : screen2;
|
||||
|
||||
SDL_SetRenderDrawColor(mainRenderer, 0, 0, 0, 0);
|
||||
SDL_RenderClear(mainRenderer);
|
||||
SDL_RenderPresent(mainRenderer);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -893,6 +901,9 @@ static void setScreenRes(int w, int h, int bpp, bool fullscreen, bool resetVideo
|
||||
|
||||
#if 0
|
||||
SDL_EnableUNICODE(1);
|
||||
#else
|
||||
|
||||
|
||||
#endif // 0
|
||||
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
@ -141,6 +141,7 @@ void Graphics::initializeBattleGraphics()
|
||||
}
|
||||
Graphics::Graphics()
|
||||
{
|
||||
#if 0
|
||||
std::vector<Task> 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: "<<th.getDiff();
|
||||
}
|
||||
|
||||
|
@ -401,6 +401,7 @@ void CGuiHandler::run()
|
||||
if(curInt)
|
||||
curInt->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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user