1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

framerate keeper for main loop, working wersion of color converter (blue -> player's) and small tweak

This commit is contained in:
mateuszb
2007-07-15 13:36:04 +00:00
parent bcc3b16f80
commit 21bbfda899
4 changed files with 226 additions and 4 deletions

View File

@@ -514,13 +514,70 @@ void CSDL_Ext::blueToPlayersAdv(SDL_Surface * sur, int player)
std::swap(sort2[0], sort2[1]);
for(int hh=0; hh<3; ++hh)
{
(*sort2[hh].second) = (sort1[hh] + sort2[hh].first)/2;
(*sort2[hh].second) = (sort1[hh]*0.8 + sort2[hh].first)/2;
}
}
}
}
else if(sur->format->BitsPerPixel == 24)
{
for(int y=0; y<sur->h; ++y)
{
for(int x=0; x<sur->w; ++x)
{
Uint8* cp = (Uint8*)sur->pixels + y+sur->pitch + x*3;
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
{
if(cp[2]>cp[1] && cp[2]>cp[0])
{
std::vector<long long int> sort1;
sort1.push_back(cp[0]);
sort1.push_back(cp[1]);
sort1.push_back(cp[2]);
std::vector< std::pair<long long int, Uint8*> > sort2;
sort2.push_back(std::make_pair(CGameInfo::mainObj->playerColors[player].r, &(cp[0])));
sort2.push_back(std::make_pair(CGameInfo::mainObj->playerColors[player].g, &(cp[1])));
sort2.push_back(std::make_pair(CGameInfo::mainObj->playerColors[player].b, &(cp[2])));
std::sort(sort1.begin(), sort1.end());
if(sort2[0].first>sort2[1].first)
std::swap(sort2[0], sort2[1]);
if(sort2[1].first>sort2[2].first)
std::swap(sort2[1], sort2[2]);
if(sort2[0].first>sort2[1].first)
std::swap(sort2[0], sort2[1]);
for(int hh=0; hh<3; ++hh)
{
(*sort2[hh].second) = (sort1[hh] + sort2[hh].first)/2.2;
}
}
}
else
{
if(cp[0]>cp[1] && cp[0]>cp[2])
{
std::vector<long long int> sort1;
sort1.push_back(cp[2]);
sort1.push_back(cp[1]);
sort1.push_back(cp[0]);
std::vector< std::pair<long long int, Uint8*> > sort2;
sort2.push_back(std::make_pair(CGameInfo::mainObj->playerColors[player].r, &(cp[2])));
sort2.push_back(std::make_pair(CGameInfo::mainObj->playerColors[player].g, &(cp[1])));
sort2.push_back(std::make_pair(CGameInfo::mainObj->playerColors[player].b, &(cp[0])));
std::sort(sort1.begin(), sort1.end());
if(sort2[0].first>sort2[1].first)
std::swap(sort2[0], sort2[1]);
if(sort2[1].first>sort2[2].first)
std::swap(sort2[1], sort2[2]);
if(sort2[0].first>sort2[1].first)
std::swap(sort2[0], sort2[1]);
for(int hh=0; hh<3; ++hh)
{
(*sort2[hh].second) = (sort1[hh]*0.8 + sort2[hh].first)/2;
}
}
}
}
}
}
}