dynamic mipmap textures

This commit is contained in:
DrPerkyLegit committed 2026-11-05 10:13:38 -05:00
1 parent 6115d0f63b
commit db2267ece7
4 files changed
+21 -2

No files matched your search

+10 -1
View File
@@ -698,7 +698,7 @@ void Texture::transferFromImage(BufferedImage *image)
c2 = ( ( c2 >> 8 ) & 0x00ffffff ) | ( c2 << 24 );
c3 = ( ( c3 >> 8 ) & 0x00ffffff ) | ( c3 << 24 );
#endif
int col = crispBlend(crispBlend(c0, c1), crispBlend(c2, c3));
int col = averageMipColors(c0, c1, c2, c3);
// 4J - and back from ARGB -> RGBA
//col = ( col << 8 ) | (( col >> 24 ) & 0xff);
//tempData[x + y * ww] = col;
@@ -743,6 +743,15 @@ void Texture::transferFromImage(BufferedImage *image)
}
// 4J Kept from older versions for where we create mip-maps for levels that do not have pre-made graphics
int Texture::averageMipColors(int c0, int c1, int c2, int c3)
{
const int a = (((c0 >> 24) & 0xff) + ((c1 >> 24) & 0xff) + ((c2 >> 24) & 0xff) + ((c3 >> 24) & 0xff)) >> 2;
const int r = (((c0 >> 16) & 0xff) + ((c1 >> 16) & 0xff) + ((c2 >> 16) & 0xff) + ((c3 >> 16) & 0xff)) >> 2;
const int g = (((c0 >> 8) & 0xff) + ((c1 >> 8) & 0xff) + ((c2 >> 8) & 0xff) + ((c3 >> 8) & 0xff)) >> 2;
const int b = ((c0 & 0xff) + (c1 & 0xff) + (c2 & 0xff) + (c3 & 0xff)) >> 2;
return (a << 24) | (r << 16) | (g << 8) | b;
}
int Texture::crispBlend(int c0, int c1)
{
int a0 = static_cast<int>(((c0 & 0xff000000) >> 24)) & 0xff;