mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-12-11 04:41:06 +00:00
Merge branch 'master' of https://github.com/coelckers/gzdoom
# Conflicts: # src/r_draw.cpp # src/r_draw.h
This commit is contained in:
commit
dcc9a1ca6e
22 changed files with 301 additions and 72 deletions
|
@ -167,7 +167,7 @@ void gl_GenerateGlobalBrightmapFromColormap()
|
||||||
// component becomes one.
|
// component becomes one.
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
PalEntry averageColor(const DWORD *data, int size, int maxout)
|
static PalEntry averageColor(const DWORD *data, int size, int maxout)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned int r, g, b;
|
unsigned int r, g, b;
|
||||||
|
@ -216,10 +216,7 @@ FTexture::MiscGLInfo::MiscGLInfo() throw()
|
||||||
GlowColor = 0;
|
GlowColor = 0;
|
||||||
GlowHeight = 128;
|
GlowHeight = 128;
|
||||||
bSkybox = false;
|
bSkybox = false;
|
||||||
FloorSkyColor = 0;
|
|
||||||
CeilingSkyColor = 0;
|
|
||||||
bFullbright = false;
|
bFullbright = false;
|
||||||
bSkyColorDone = false;
|
|
||||||
bBrightmapChecked = false;
|
bBrightmapChecked = false;
|
||||||
bDisableFullbright = false;
|
bDisableFullbright = false;
|
||||||
bNoFilter = false;
|
bNoFilter = false;
|
||||||
|
@ -326,38 +323,6 @@ void FTexture::GetGlowColor(float *data)
|
||||||
data[2]=gl_info.GlowColor.b/255.0f;
|
data[2]=gl_info.GlowColor.b/255.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// Gets the average color of a texture for use as a sky cap color
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
PalEntry FTexture::GetSkyCapColor(bool bottom)
|
|
||||||
{
|
|
||||||
PalEntry col;
|
|
||||||
int w;
|
|
||||||
int h;
|
|
||||||
|
|
||||||
if (!gl_info.bSkyColorDone)
|
|
||||||
{
|
|
||||||
gl_info.bSkyColorDone = true;
|
|
||||||
|
|
||||||
unsigned char *buffer = GLRenderer->GetTextureBuffer(this, w, h);
|
|
||||||
|
|
||||||
if (buffer)
|
|
||||||
{
|
|
||||||
gl_info.CeilingSkyColor = averageColor((DWORD *) buffer, w * MIN(30, h), 0);
|
|
||||||
if (h>30)
|
|
||||||
{
|
|
||||||
gl_info.FloorSkyColor = averageColor(((DWORD *) buffer)+(h-30)*w, w * 30, 0);
|
|
||||||
}
|
|
||||||
else gl_info.FloorSkyColor = gl_info.CeilingSkyColor;
|
|
||||||
delete[] buffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bottom? gl_info.FloorSkyColor : gl_info.CeilingSkyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Finds gaps in the texture which can be skipped by the renderer
|
// Finds gaps in the texture which can be skipped by the renderer
|
||||||
|
|
|
@ -24,7 +24,6 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
void gl_GenerateGlobalBrightmapFromColormap();
|
void gl_GenerateGlobalBrightmapFromColormap();
|
||||||
PalEntry averageColor(const DWORD *data, int size, int maxout);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,8 @@ int M_ReadFile (char const *name, BYTE **buffer)
|
||||||
handle = open (name, O_RDONLY | O_BINARY, 0666);
|
handle = open (name, O_RDONLY | O_BINARY, 0666);
|
||||||
if (handle == -1)
|
if (handle == -1)
|
||||||
I_Error ("Couldn't read file %s", name);
|
I_Error ("Couldn't read file %s", name);
|
||||||
if (fstat (handle,&fileinfo) == -1)
|
// [BL] Use stat instead of fstat for v140_xp hack
|
||||||
|
if (stat (name,&fileinfo) == -1)
|
||||||
I_Error ("Couldn't read file %s", name);
|
I_Error ("Couldn't read file %s", name);
|
||||||
length = fileinfo.st_size;
|
length = fileinfo.st_size;
|
||||||
buf = new BYTE[length];
|
buf = new BYTE[length];
|
||||||
|
@ -150,7 +151,8 @@ int M_ReadFileMalloc (char const *name, BYTE **buffer)
|
||||||
handle = open (name, O_RDONLY | O_BINARY, 0666);
|
handle = open (name, O_RDONLY | O_BINARY, 0666);
|
||||||
if (handle == -1)
|
if (handle == -1)
|
||||||
I_Error ("Couldn't read file %s", name);
|
I_Error ("Couldn't read file %s", name);
|
||||||
if (fstat (handle,&fileinfo) == -1)
|
// [BL] Use stat instead of fstat for v140_xp hack
|
||||||
|
if (stat (name,&fileinfo) == -1)
|
||||||
I_Error ("Couldn't read file %s", name);
|
I_Error ("Couldn't read file %s", name);
|
||||||
length = fileinfo.st_size;
|
length = fileinfo.st_size;
|
||||||
buf = (BYTE*)M_Malloc(length);
|
buf = (BYTE*)M_Malloc(length);
|
||||||
|
|
|
@ -331,6 +331,10 @@ void FRandom::StaticReadRNGState(FSerializer &arc)
|
||||||
FRandom *rng;
|
FRandom *rng;
|
||||||
|
|
||||||
arc("rngseed", rngseed);
|
arc("rngseed", rngseed);
|
||||||
|
|
||||||
|
// Call StaticClearRandom in order to ensure that SFMT is initialized
|
||||||
|
FRandom::StaticClearRandom ();
|
||||||
|
|
||||||
if (arc.BeginArray("rngs"))
|
if (arc.BeginArray("rngs"))
|
||||||
{
|
{
|
||||||
int count = arc.ArraySize();
|
int count = arc.ArraySize();
|
||||||
|
|
|
@ -1616,7 +1616,7 @@ void FBehavior::StaticSerializeModuleStates (FSerializer &arc)
|
||||||
{
|
{
|
||||||
if (arc.isReading())
|
if (arc.isReading())
|
||||||
{
|
{
|
||||||
int modnum = arc.ArraySize();
|
auto modnum = arc.ArraySize();
|
||||||
if (modnum != StaticModules.Size())
|
if (modnum != StaticModules.Size())
|
||||||
{
|
{
|
||||||
I_Error("Level was saved with a different number of ACS modules. (Have %d, save has %d)", StaticModules.Size(), modnum);
|
I_Error("Level was saved with a different number of ACS modules. (Have %d, save has %d)", StaticModules.Size(), modnum);
|
||||||
|
@ -2933,7 +2933,7 @@ void DACSThinker::Serialize(FSerializer &arc)
|
||||||
if (arc.BeginArray("runningscripts"))
|
if (arc.BeginArray("runningscripts"))
|
||||||
{
|
{
|
||||||
auto cnt = arc.ArraySize();
|
auto cnt = arc.ArraySize();
|
||||||
for (int i = 0; i < cnt; i++)
|
for (unsigned i = 0; i < cnt; i++)
|
||||||
{
|
{
|
||||||
SavingRunningscript srs;
|
SavingRunningscript srs;
|
||||||
arc(nullptr, srs);
|
arc(nullptr, srs);
|
||||||
|
|
|
@ -890,10 +890,10 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
||||||
// deep down in the deserializer or just a crash if the few insufficient safeguards were not triggered.
|
// deep down in the deserializer or just a crash if the few insufficient safeguards were not triggered.
|
||||||
BYTE chk[16] = { 0 };
|
BYTE chk[16] = { 0 };
|
||||||
arc.Array("checksum", chk, 16);
|
arc.Array("checksum", chk, 16);
|
||||||
if (arc.GetSize("linedefs") != numlines ||
|
if (arc.GetSize("linedefs") != (unsigned)numlines ||
|
||||||
arc.GetSize("sidedefs") != numsides ||
|
arc.GetSize("sidedefs") != (unsigned)numsides ||
|
||||||
arc.GetSize("sectors") != numsectors ||
|
arc.GetSize("sectors") != (unsigned)numsectors ||
|
||||||
arc.GetSize("polyobjs") != po_NumPolyobjs ||
|
arc.GetSize("polyobjs") != (unsigned)po_NumPolyobjs ||
|
||||||
memcmp(chk, level.md5, 16))
|
memcmp(chk, level.md5, 16))
|
||||||
{
|
{
|
||||||
I_Error("Savegame is from a different level");
|
I_Error("Savegame is from a different level");
|
||||||
|
|
165
src/r_plane.cpp
165
src/r_plane.cpp
|
@ -63,6 +63,8 @@
|
||||||
#pragma warning(disable:4244)
|
#pragma warning(disable:4244)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
EXTERN_CVAR(Int, r_skymode)
|
||||||
|
|
||||||
//EXTERN_CVAR (Int, tx)
|
//EXTERN_CVAR (Int, tx)
|
||||||
//EXTERN_CVAR (Int, ty)
|
//EXTERN_CVAR (Int, ty)
|
||||||
|
|
||||||
|
@ -898,8 +900,171 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x)
|
||||||
return composite;
|
return composite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void R_DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, double scale, double texturemid, double yrepeat)
|
||||||
|
{
|
||||||
|
uint32_t height = frontskytex->GetHeight();
|
||||||
|
|
||||||
|
for (int i = 0; i < columns; i++)
|
||||||
|
{
|
||||||
|
double uv_stepd = skyiscale * yrepeat;
|
||||||
|
double v = (texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height;
|
||||||
|
double v_step = uv_stepd / height;
|
||||||
|
|
||||||
|
uint32_t uv_pos = (uint32_t)(v * 0x01000000);
|
||||||
|
uint32_t uv_step = (uint32_t)(v_step * 0x01000000);
|
||||||
|
|
||||||
|
int x = start_x + i;
|
||||||
|
if (MirrorFlags & RF_XFLIP)
|
||||||
|
x = (viewwidth - x);
|
||||||
|
|
||||||
|
DWORD ang, angle1, angle2;
|
||||||
|
|
||||||
|
ang = (skyangle + xtoviewangle[x]) ^ skyflip;
|
||||||
|
angle1 = (DWORD)((UMulScale16(ang, frontcyl) + frontpos) >> FRACBITS);
|
||||||
|
angle2 = (DWORD)((UMulScale16(ang, backcyl) + backpos) >> FRACBITS);
|
||||||
|
|
||||||
|
bufplce[i] = (const BYTE *)frontskytex->GetColumn(angle1, nullptr);
|
||||||
|
bufplce2[i] = backskytex ? (const BYTE *)backskytex->GetColumn(angle2, nullptr) : nullptr;
|
||||||
|
|
||||||
|
vince[i] = uv_step;
|
||||||
|
vplce[i] = uv_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
bufheight[0] = height;
|
||||||
|
bufheight[1] = backskytex ? backskytex->GetHeight() : height;
|
||||||
|
dc_dest = (ylookup[y1] + start_x) + dc_destorg;
|
||||||
|
dc_count = y2 - y1;
|
||||||
|
|
||||||
|
uint32_t solid_top = frontskytex->GetSkyCapColor(false);
|
||||||
|
uint32_t solid_bottom = frontskytex->GetSkyCapColor(true);
|
||||||
|
|
||||||
|
if (columns == 4)
|
||||||
|
if (!backskytex)
|
||||||
|
R_DrawSingleSkyCol4(solid_top, solid_bottom);
|
||||||
|
else
|
||||||
|
R_DrawDoubleSkyCol4(solid_top, solid_bottom);
|
||||||
|
else
|
||||||
|
if (!backskytex)
|
||||||
|
R_DrawSingleSkyCol1(solid_top, solid_bottom);
|
||||||
|
else
|
||||||
|
R_DrawDoubleSkyCol1(solid_top, solid_bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_DrawSkyColumn(int start_x, int y1, int y2, int columns)
|
||||||
|
{
|
||||||
|
if (1 << frontskytex->HeightBits == frontskytex->GetHeight())
|
||||||
|
{
|
||||||
|
double texturemid = skymid * frontskytex->Scale.Y + frontskytex->GetHeight();
|
||||||
|
R_DrawSkyColumnStripe(start_x, y1, y2, columns, frontskytex->Scale.Y, texturemid, frontskytex->Scale.Y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double yrepeat = frontskytex->Scale.Y;
|
||||||
|
double scale = frontskytex->Scale.Y * skyscale;
|
||||||
|
double iscale = 1 / scale;
|
||||||
|
short drawheight = short(frontskytex->GetHeight() * scale);
|
||||||
|
double topfrac = fmod(skymid + iscale * (1 - CenterY), frontskytex->GetHeight());
|
||||||
|
if (topfrac < 0) topfrac += frontskytex->GetHeight();
|
||||||
|
double texturemid = topfrac - iscale * (1 - CenterY);
|
||||||
|
R_DrawSkyColumnStripe(start_x, y1, y2, columns, scale, texturemid, yrepeat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_DrawCapSky(visplane_t *pl)
|
||||||
|
{
|
||||||
|
int x1 = pl->left;
|
||||||
|
int x2 = pl->right;
|
||||||
|
short *uwal = (short *)pl->top;
|
||||||
|
short *dwal = (short *)pl->bottom;
|
||||||
|
|
||||||
|
// Calculate where 4 column alignment begins and ends:
|
||||||
|
int aligned_x1 = clamp((x1 + 3) / 4 * 4, x1, x2);
|
||||||
|
int aligned_x2 = clamp(x2 / 4 * 4, x1, x2);
|
||||||
|
|
||||||
|
// First unaligned columns:
|
||||||
|
for (int x = x1; x < aligned_x1; x++)
|
||||||
|
{
|
||||||
|
int y1 = uwal[x];
|
||||||
|
int y2 = dwal[x];
|
||||||
|
if (y2 <= y1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
R_DrawSkyColumn(x, y1, y2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The aligned columns
|
||||||
|
for (int x = aligned_x1; x < aligned_x2; x += 4)
|
||||||
|
{
|
||||||
|
// Find y1, y2, light and uv values for four columns:
|
||||||
|
int y1[4] = { uwal[x], uwal[x + 1], uwal[x + 2], uwal[x + 3] };
|
||||||
|
int y2[4] = { dwal[x], dwal[x + 1], dwal[x + 2], dwal[x + 3] };
|
||||||
|
|
||||||
|
// Figure out where we vertically can start and stop drawing 4 columns in one go
|
||||||
|
int middle_y1 = y1[0];
|
||||||
|
int middle_y2 = y2[0];
|
||||||
|
for (int i = 1; i < 4; i++)
|
||||||
|
{
|
||||||
|
middle_y1 = MAX(y1[i], middle_y1);
|
||||||
|
middle_y2 = MIN(y2[i], middle_y2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we got an empty column in our set we cannot draw 4 columns in one go:
|
||||||
|
bool empty_column_in_set = false;
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (y2[i] <= y1[i])
|
||||||
|
empty_column_in_set = true;
|
||||||
|
}
|
||||||
|
if (empty_column_in_set || middle_y2 <= middle_y1)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (y2[i] <= y1[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
R_DrawSkyColumn(x + i, y1[i], y2[i], 1);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw the first rows where not all 4 columns are active
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (y1[i] < middle_y1)
|
||||||
|
R_DrawSkyColumn(x + i, y1[i], middle_y1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw the area where all 4 columns are active
|
||||||
|
R_DrawSkyColumn(x, middle_y1, middle_y2, 4);
|
||||||
|
|
||||||
|
// Draw the last rows where not all 4 columns are active
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (middle_y2 < y2[i])
|
||||||
|
R_DrawSkyColumn(x + i, middle_y2, y2[i], 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The last unaligned columns:
|
||||||
|
for (int x = aligned_x2; x < x2; x++)
|
||||||
|
{
|
||||||
|
int y1 = uwal[x];
|
||||||
|
int y2 = dwal[x];
|
||||||
|
if (y2 <= y1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
R_DrawSkyColumn(x, y1, y2, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void R_DrawSky (visplane_t *pl)
|
static void R_DrawSky (visplane_t *pl)
|
||||||
{
|
{
|
||||||
|
if (r_skymode == 2)
|
||||||
|
{
|
||||||
|
R_DrawCapSky(pl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
float swal;
|
float swal;
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,19 @@ bool skystretch;
|
||||||
fixed_t sky1cyl, sky2cyl;
|
fixed_t sky1cyl, sky2cyl;
|
||||||
double sky1pos, sky2pos;
|
double sky1pos, sky2pos;
|
||||||
|
|
||||||
|
CUSTOM_CVAR(Int, testskyoffset, 0, 0)
|
||||||
|
{
|
||||||
|
R_InitSkyMap();
|
||||||
|
}
|
||||||
|
|
||||||
// [RH] Stretch sky texture if not taller than 128 pixels?
|
// [RH] Stretch sky texture if not taller than 128 pixels?
|
||||||
CUSTOM_CVAR (Bool, r_stretchsky, true, CVAR_ARCHIVE)
|
// Also now controls capped skies. 0 = normal, 1 = stretched, 2 = capped
|
||||||
|
CUSTOM_CVAR (Int, r_skymode, 2, CVAR_ARCHIVE)
|
||||||
{
|
{
|
||||||
R_InitSkyMap ();
|
R_InitSkyMap ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int freelookviewheight;
|
int freelookviewheight;
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -100,7 +107,7 @@ void R_InitSkyMap ()
|
||||||
skytexturemid = 0;
|
skytexturemid = 0;
|
||||||
if (skyheight >= 128 && skyheight < 200)
|
if (skyheight >= 128 && skyheight < 200)
|
||||||
{
|
{
|
||||||
skystretch = (r_stretchsky
|
skystretch = (r_skymode == 1
|
||||||
&& skyheight >= 128
|
&& skyheight >= 128
|
||||||
&& level.IsFreelookAllowed()
|
&& level.IsFreelookAllowed()
|
||||||
&& !(level.flags & LEVEL_FORCENOSKYSTRETCH)) ? 1 : 0;
|
&& !(level.flags & LEVEL_FORCENOSKYSTRETCH)) ? 1 : 0;
|
||||||
|
@ -108,7 +115,7 @@ void R_InitSkyMap ()
|
||||||
}
|
}
|
||||||
else if (skyheight > 200)
|
else if (skyheight > 200)
|
||||||
{
|
{
|
||||||
skytexturemid = (200 - skyheight) * skytex1->Scale.Y;
|
skytexturemid = (200 - skyheight) * skytex1->Scale.Y +(r_skymode == 2 ? skytex1->SkyOffset + testskyoffset : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewwidth != 0 && viewheight != 0)
|
if (viewwidth != 0 && viewheight != 0)
|
||||||
|
|
|
@ -392,7 +392,8 @@ int FZipLump::FillCache()
|
||||||
int FZipLump::GetFileOffset()
|
int FZipLump::GetFileOffset()
|
||||||
{
|
{
|
||||||
if (Method != METHOD_STORED) return -1;
|
if (Method != METHOD_STORED) return -1;
|
||||||
if (Flags & LUMPFZIP_NEEDFILESTART) SetLumpAddress(); return Position;
|
if (Flags & LUMPFZIP_NEEDFILESTART) SetLumpAddress();
|
||||||
|
return Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -381,7 +381,7 @@ void FSerializer::Close()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
int FSerializer::ArraySize()
|
unsigned FSerializer::ArraySize()
|
||||||
{
|
{
|
||||||
if (r != nullptr && r->mObjects.Last().mObject->IsArray())
|
if (r != nullptr && r->mObjects.Last().mObject->IsArray())
|
||||||
{
|
{
|
||||||
|
@ -709,7 +709,7 @@ FSerializer &FSerializer::Sprite(const char *key, int32_t &spritenum, int32_t *d
|
||||||
{
|
{
|
||||||
if (val->IsString())
|
if (val->IsString())
|
||||||
{
|
{
|
||||||
int name = *reinterpret_cast<const int*>(val->GetString());
|
uint32_t name = *reinterpret_cast<const uint32_t*>(val->GetString());
|
||||||
for (auto hint = NumStdSprites; hint-- != 0; )
|
for (auto hint = NumStdSprites; hint-- != 0; )
|
||||||
{
|
{
|
||||||
if (sprites[hint].dwName == name)
|
if (sprites[hint].dwName == name)
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
FWriter *w = nullptr;
|
FWriter *w = nullptr;
|
||||||
FReader *r = nullptr;
|
FReader *r = nullptr;
|
||||||
|
|
||||||
int ArraySize();
|
unsigned ArraySize();
|
||||||
void WriteKey(const char *key);
|
void WriteKey(const char *key);
|
||||||
void WriteObjects();
|
void WriteObjects();
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "m_fixed.h"
|
#include "m_fixed.h"
|
||||||
#include "textures/textures.h"
|
#include "textures/textures.h"
|
||||||
|
#include "v_palette.h"
|
||||||
|
|
||||||
typedef bool (*CheckFunc)(FileReader & file);
|
typedef bool (*CheckFunc)(FileReader & file);
|
||||||
typedef FTexture * (*CreateFunc)(FileReader & file, int lumpnum);
|
typedef FTexture * (*CreateFunc)(FileReader & file, int lumpnum);
|
||||||
|
@ -569,6 +570,78 @@ void FTexture::SetScaledSize(int fitwidth, int fitheight)
|
||||||
if (int(Scale.Y * fitheight) != Height) Scale.Y += (1 / 65536.);
|
if (int(Scale.Y * fitheight) != Height) Scale.Y += (1 / 65536.);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// Gets the average color of a texture for use as a sky cap color
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
PalEntry averageColor(const DWORD *data, int size, int maxout)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
unsigned int r, g, b;
|
||||||
|
|
||||||
|
// First clear them.
|
||||||
|
r = g = b = 0;
|
||||||
|
if (size == 0)
|
||||||
|
{
|
||||||
|
return PalEntry(255, 255, 255);
|
||||||
|
}
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
b += BPART(data[i]);
|
||||||
|
g += GPART(data[i]);
|
||||||
|
r += RPART(data[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
r = r / size;
|
||||||
|
g = g / size;
|
||||||
|
b = b / size;
|
||||||
|
|
||||||
|
int maxv = MAX(MAX(r, g), b);
|
||||||
|
|
||||||
|
if (maxv && maxout)
|
||||||
|
{
|
||||||
|
r = Scale(r, maxout, maxv);
|
||||||
|
g = Scale(g, maxout, maxv);
|
||||||
|
b = Scale(b, maxout, maxv);
|
||||||
|
}
|
||||||
|
return PalEntry(255, r, g, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PalEntry FTexture::GetSkyCapColor(bool bottom)
|
||||||
|
{
|
||||||
|
PalEntry col;
|
||||||
|
int w;
|
||||||
|
int h;
|
||||||
|
|
||||||
|
if (!bSWSkyColorDone)
|
||||||
|
{
|
||||||
|
bSWSkyColorDone = true;
|
||||||
|
|
||||||
|
FBitmap bitmap;
|
||||||
|
bitmap.Create(GetWidth(), GetHeight());
|
||||||
|
CopyTrueColorPixels(&bitmap, 0, 0);
|
||||||
|
int w = GetWidth();
|
||||||
|
int h = GetHeight();
|
||||||
|
|
||||||
|
const uint32_t *buffer = (const uint32_t *)bitmap.GetPixels();
|
||||||
|
if (buffer)
|
||||||
|
{
|
||||||
|
CeilingSkyColor = averageColor((DWORD *)buffer, w * MIN(30, h), 0);
|
||||||
|
if (h>30)
|
||||||
|
{
|
||||||
|
FloorSkyColor = averageColor(((DWORD *)buffer) + (h - 30)*w, w * 30, 0);
|
||||||
|
}
|
||||||
|
else FloorSkyColor = CeilingSkyColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bottom ? FloorSkyColor : CeilingSkyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FDummyTexture::FDummyTexture ()
|
FDummyTexture::FDummyTexture ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -262,6 +262,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetScaledSize(int fitwidth, int fitheight);
|
void SetScaledSize(int fitwidth, int fitheight);
|
||||||
|
PalEntry GetSkyCapColor(bool bottom);
|
||||||
|
|
||||||
virtual void HackHack (int newheight); // called by FMultipatchTexture to discover corrupt patches.
|
virtual void HackHack (int newheight); // called by FMultipatchTexture to discover corrupt patches.
|
||||||
|
|
||||||
|
@ -285,6 +286,11 @@ protected:
|
||||||
gl_info.areas = NULL;
|
gl_info.areas = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool bSWSkyColorDone = false;
|
||||||
|
PalEntry FloorSkyColor;
|
||||||
|
PalEntry CeilingSkyColor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void FlipSquareBlock (BYTE *block, int x, int y);
|
static void FlipSquareBlock (BYTE *block, int x, int y);
|
||||||
static void FlipSquareBlockRemap (BYTE *block, int x, int y, const BYTE *remap);
|
static void FlipSquareBlockRemap (BYTE *block, int x, int y, const BYTE *remap);
|
||||||
|
@ -301,8 +307,6 @@ public:
|
||||||
FGLTexture *SystemTexture[2];
|
FGLTexture *SystemTexture[2];
|
||||||
FTexture *Brightmap;
|
FTexture *Brightmap;
|
||||||
PalEntry GlowColor;
|
PalEntry GlowColor;
|
||||||
PalEntry FloorSkyColor;
|
|
||||||
PalEntry CeilingSkyColor;
|
|
||||||
int GlowHeight;
|
int GlowHeight;
|
||||||
FloatRect *areas;
|
FloatRect *areas;
|
||||||
int areacount;
|
int areacount;
|
||||||
|
@ -312,7 +316,6 @@ public:
|
||||||
bool bGlowing:1; // Texture glows
|
bool bGlowing:1; // Texture glows
|
||||||
bool bFullbright:1; // always draw fullbright
|
bool bFullbright:1; // always draw fullbright
|
||||||
bool bSkybox:1; // This is a skybox
|
bool bSkybox:1; // This is a skybox
|
||||||
bool bSkyColorDone:1; // Fill color for sky
|
|
||||||
char bBrightmapChecked:1; // Set to 1 if brightmap has been checked
|
char bBrightmapChecked:1; // Set to 1 if brightmap has been checked
|
||||||
bool bDisableFullbright:1; // This texture will not be displayed as fullbright sprite
|
bool bDisableFullbright:1; // This texture will not be displayed as fullbright sprite
|
||||||
bool bNoFilter:1;
|
bool bNoFilter:1;
|
||||||
|
@ -325,7 +328,6 @@ public:
|
||||||
MiscGLInfo gl_info;
|
MiscGLInfo gl_info;
|
||||||
|
|
||||||
void GetGlowColor(float *data);
|
void GetGlowColor(float *data);
|
||||||
PalEntry GetSkyCapColor(bool bottom);
|
|
||||||
bool isGlowing() { return gl_info.bGlowing; }
|
bool isGlowing() { return gl_info.bGlowing; }
|
||||||
bool isFullbright() { return gl_info.bFullbright; }
|
bool isFullbright() { return gl_info.bFullbright; }
|
||||||
void CreateDefaultBrightmap();
|
void CreateDefaultBrightmap();
|
||||||
|
|
|
@ -91,7 +91,7 @@ static const FLOP FxFlops[] =
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FCompileContext::FCompileContext(PClassActor *cls, PPrototype *ret) : Class(cls), ReturnProto(ret)
|
FCompileContext::FCompileContext(PClassActor *cls, PPrototype *ret) : ReturnProto(ret), Class(cls)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,7 +959,7 @@ ExpEmit FxUnaryNotBoolean::Emit(VMFunctionBuilder *build)
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FxPreIncrDecr::FxPreIncrDecr(FxExpression *base, int token)
|
FxPreIncrDecr::FxPreIncrDecr(FxExpression *base, int token)
|
||||||
: FxExpression(base->ScriptPosition), Base(base), Token(token)
|
: FxExpression(base->ScriptPosition), Token(token), Base(base)
|
||||||
{
|
{
|
||||||
AddressRequested = false;
|
AddressRequested = false;
|
||||||
AddressWritable = false;
|
AddressWritable = false;
|
||||||
|
@ -1045,7 +1045,7 @@ ExpEmit FxPreIncrDecr::Emit(VMFunctionBuilder *build)
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FxPostIncrDecr::FxPostIncrDecr(FxExpression *base, int token)
|
FxPostIncrDecr::FxPostIncrDecr(FxExpression *base, int token)
|
||||||
: FxExpression(base->ScriptPosition), Base(base), Token(token)
|
: FxExpression(base->ScriptPosition), Token(token), Base(base)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,8 @@ ACTOR DoomImp
|
||||||
TROO U -1
|
TROO U -1
|
||||||
Stop
|
Stop
|
||||||
Raise:
|
Raise:
|
||||||
TROO MLKJI 8
|
TROO ML 8
|
||||||
|
TROO KJI 6
|
||||||
Goto See
|
Goto See
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1786,7 +1786,7 @@ DSPLYMNU_BLOODFADE = "Blood Flash Intensity";
|
||||||
DSPLYMNU_PICKUPFADE = "Pickup Flash Intensity";
|
DSPLYMNU_PICKUPFADE = "Pickup Flash Intensity";
|
||||||
DSPLYMNU_PALLETEHACK = "DirectDraw palette hack"; // Not used
|
DSPLYMNU_PALLETEHACK = "DirectDraw palette hack"; // Not used
|
||||||
DSPLYMNU_ATTACHEDSURFACES = "Use attached surfaces"; // Not used
|
DSPLYMNU_ATTACHEDSURFACES = "Use attached surfaces"; // Not used
|
||||||
DSPLYMNU_STRETCHSKY = "Stretch short skies";
|
DSPLYMNU_SKYMODE = "Sky render mode";
|
||||||
DSPLYMNU_DRAWFUZZ = "Use fuzz effect";
|
DSPLYMNU_DRAWFUZZ = "Use fuzz effect";
|
||||||
DSPLYMNU_TRANSSOUL = "Lost Soul translucency";
|
DSPLYMNU_TRANSSOUL = "Lost Soul translucency";
|
||||||
DSPLYMNU_FAKECONTRAST = "Use fake contrast";
|
DSPLYMNU_FAKECONTRAST = "Use fake contrast";
|
||||||
|
@ -2187,6 +2187,9 @@ OPTVAL_INVERTED = "Inverted";
|
||||||
OPTVAL_NOTINVERTED = "Not Inverted";
|
OPTVAL_NOTINVERTED = "Not Inverted";
|
||||||
OPTVAL_ORIGINAL = "Original";
|
OPTVAL_ORIGINAL = "Original";
|
||||||
OPTVAL_OPTIMIZED = "Optimized";
|
OPTVAL_OPTIMIZED = "Optimized";
|
||||||
|
OPTVAL_NORMAL = "Normal";
|
||||||
|
OPTVAL_STRETCH = "Stretch";
|
||||||
|
OPTVAL_CAPPED = "Capped";
|
||||||
OPTVAL_PARTICLES = "Particles";
|
OPTVAL_PARTICLES = "Particles";
|
||||||
OPTVAL_SPRITES = "Sprites";
|
OPTVAL_SPRITES = "Sprites";
|
||||||
OPTVAL_SPRITESPARTICLES = "Sprites & Particles";
|
OPTVAL_SPRITESPARTICLES = "Sprites & Particles";
|
||||||
|
|
|
@ -600,6 +600,13 @@ OptionValue ColumnMethods
|
||||||
1.0, "$OPTVAL_OPTIMIZED"
|
1.0, "$OPTVAL_OPTIMIZED"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OptionValue SkyModes
|
||||||
|
{
|
||||||
|
0.0, "$OPTVAL_NORMAL"
|
||||||
|
1.0, "$OPTVAL_STRETCH"
|
||||||
|
2.0, "$OPTVAL_CAPPED"
|
||||||
|
}
|
||||||
|
|
||||||
OptionValue RocketTrailTypes
|
OptionValue RocketTrailTypes
|
||||||
{
|
{
|
||||||
0.0, "$OPTVAL_OFF"
|
0.0, "$OPTVAL_OFF"
|
||||||
|
@ -688,7 +695,7 @@ OptionMenu "VideoOptions"
|
||||||
//Option "$DSPLYMNU_ATTACHEDSURFACES", "vid_attachedsurfaces", "OnOff"
|
//Option "$DSPLYMNU_ATTACHEDSURFACES", "vid_attachedsurfaces", "OnOff"
|
||||||
}
|
}
|
||||||
|
|
||||||
Option "$DSPLYMNU_STRETCHSKY", "r_stretchsky", "OnOff"
|
Option "$DSPLYMNU_SKYMODE", "r_skymode", "SkyModes"
|
||||||
Option "$DSPLYMNU_DRAWFUZZ", "r_drawfuzz", "Fuzziness"
|
Option "$DSPLYMNU_DRAWFUZZ", "r_drawfuzz", "Fuzziness"
|
||||||
Slider "$DSPLYMNU_TRANSSOUL", "transsouls", 0.25, 1.0, 0.05, 2
|
Slider "$DSPLYMNU_TRANSSOUL", "transsouls", 0.25, 1.0, 0.05, 2
|
||||||
Option "$DSPLYMNU_FAKECONTRAST", "r_fakecontrast", "Contrast"
|
Option "$DSPLYMNU_FAKECONTRAST", "r_fakecontrast", "Contrast"
|
||||||
|
|
Loading…
Reference in a new issue