- took the sky cap color getter out of the texture system.
# Conflicts: # src/common/textures/textures.h
This commit is contained in:
parent
d1da26895b
commit
c563f4993f
10 changed files with 92 additions and 83 deletions
|
|
@ -39,6 +39,8 @@
|
|||
#include "v_text.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "texturemanager.h"
|
||||
#include "palentry.h"
|
||||
#include "bitmap.h"
|
||||
|
||||
//
|
||||
// sky mapping
|
||||
|
|
@ -54,6 +56,46 @@ CUSTOM_CVAR (Int, r_skymode, 2, CVAR_ARCHIVE|CVAR_NOINITCALL)
|
|||
|
||||
CVAR(Float, skyoffset, 0, 0) // for testing
|
||||
|
||||
|
||||
struct SkyColor
|
||||
{
|
||||
FTextureID Texture;
|
||||
std::pair<PalEntry, PalEntry> Colors;
|
||||
};
|
||||
|
||||
static TArray<SkyColor> SkyColors;
|
||||
|
||||
std::pair<PalEntry, PalEntry>& R_GetSkyCapColor(FGameTexture* tex)
|
||||
{
|
||||
for (auto& sky : SkyColors)
|
||||
{
|
||||
if (sky.Texture == tex->GetID()) return sky.Colors;
|
||||
}
|
||||
|
||||
auto itex = tex->GetTexture();
|
||||
SkyColor sky;
|
||||
|
||||
FBitmap bitmap = itex->GetBgraBitmap(nullptr);
|
||||
int w = bitmap.GetWidth();
|
||||
int h = bitmap.GetHeight();
|
||||
|
||||
const uint32_t* buffer = (const uint32_t*)bitmap.GetPixels();
|
||||
if (buffer)
|
||||
{
|
||||
sky.Colors.first = averageColor((uint32_t*)buffer, w * MIN(30, h), 0);
|
||||
if (h > 30)
|
||||
{
|
||||
sky.Colors.second = averageColor(((uint32_t*)buffer) + (h - 30) * w, w * 30, 0);
|
||||
}
|
||||
else sky.Colors.second = sky.Colors.first;
|
||||
}
|
||||
sky.Texture = tex->GetID();
|
||||
SkyColors.Push(sky);
|
||||
|
||||
return SkyColors.Last().Colors;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_InitSkyMap
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue