- moved two MAPINFO settings that are not exclusively used by the OpenGL renderer to the common code.

This commit is contained in:
Christoph Oelckers 2017-03-14 18:31:11 +01:00
parent e1cd034698
commit d86bd470e5
12 changed files with 40 additions and 63 deletions

View File

@ -239,6 +239,7 @@ enum ELevelFlags : unsigned int
LEVEL3_FORCEFAKECONTRAST = 0x00000001, // forces fake contrast even with fog enabled LEVEL3_FORCEFAKECONTRAST = 0x00000001, // forces fake contrast even with fog enabled
LEVEL3_REMOVEITEMS = 0x00000002, // kills all INVBAR items on map change. LEVEL3_REMOVEITEMS = 0x00000002, // kills all INVBAR items on map change.
LEVEL3_ATTENUATE = 0x00000004, // attenuate lights? LEVEL3_ATTENUATE = 0x00000004, // attenuate lights?
LEVEL3_NOLIGHTFADE = 0x00000008, // no light fading to black.
}; };
@ -303,9 +304,9 @@ struct level_info_t
int cluster; int cluster;
int partime; int partime;
int sucktime; int sucktime;
uint32_t flags; int32_t flags;
uint32_t flags2; uint32_t flags2;
uint32_t flags3; uint32_t flags3;
FString Music; FString Music;
FString LevelName; FString LevelName;
@ -315,27 +316,28 @@ struct level_info_t
TArray<acsdefered_t> deferred; TArray<acsdefered_t> deferred;
float skyspeed1; float skyspeed1;
float skyspeed2; float skyspeed2;
uint32_t fadeto; uint32_t fadeto;
uint32_t outsidefog; uint32_t outsidefog;
int cdtrack; int cdtrack;
unsigned int cdid; unsigned int cdid;
double gravity; double gravity;
double aircontrol; double aircontrol;
int WarpTrans; int WarpTrans;
int airsupply; int airsupply;
uint32_t compatflags, compatflags2; uint32_t compatflags, compatflags2;
uint32_t compatmask, compatmask2; uint32_t compatmask, compatmask2;
FString Translator; // for converting Doom-format linedef and sector types. FString Translator; // for converting Doom-format linedef and sector types.
int DefaultEnvironment; // Default sound environment for the map. int DefaultEnvironment; // Default sound environment for the map.
FName Intermission; FName Intermission;
FName deathsequence; FName deathsequence;
FName slideshow; FName slideshow;
uint32_t hazardcolor; uint32_t hazardcolor;
uint32_t hazardflash; uint32_t hazardflash;
int fogdensity; int fogdensity;
int outsidefogdensity; int outsidefogdensity;
int skyfog; int skyfog;
float pixelstretch;
// Redirection: If any player is carrying the specified item, then // Redirection: If any player is carrying the specified item, then
// you go to the RedirectMap instead of this one. // you go to the RedirectMap instead of this one.
FName RedirectType; FName RedirectType;

View File

@ -275,6 +275,11 @@ void level_info_t::Reset()
teamdamage = 0.f; teamdamage = 0.f;
hazardcolor = 0xff004200; hazardcolor = 0xff004200;
hazardflash = 0xff00ff00; hazardflash = 0xff00ff00;
fogdensity = 0;
outsidefogdensity = 0;
skyfog = 0;
pixelstretch = 1.2f;
specialactions.Clear(); specialactions.Clear();
DefaultEnvironment = 0; DefaultEnvironment = 0;
PrecacheSounds.Clear(); PrecacheSounds.Clear();
@ -1237,6 +1242,13 @@ DEFINE_MAP_OPTION(skyfog, false)
info->skyfog = parse.sc.Number; info->skyfog = parse.sc.Number;
} }
DEFINE_MAP_OPTION(pixelratio, false)
{
parse.ParseAssign();
parse.sc.MustGetFloat();
info->pixelstretch = (float)parse.sc.Float;
}
//========================================================================== //==========================================================================
// //
@ -1344,6 +1356,7 @@ MapFlagHandlers[] =
{ "unfreezesingleplayerconversations",MITYPE_SETFLAG2, LEVEL2_CONV_SINGLE_UNFREEZE, 0 }, { "unfreezesingleplayerconversations",MITYPE_SETFLAG2, LEVEL2_CONV_SINGLE_UNFREEZE, 0 },
{ "spawnwithweaponraised", MITYPE_SETFLAG2, LEVEL2_PRERAISEWEAPON, 0 }, { "spawnwithweaponraised", MITYPE_SETFLAG2, LEVEL2_PRERAISEWEAPON, 0 },
{ "forcefakecontrast", MITYPE_SETFLAG3, LEVEL3_FORCEFAKECONTRAST, 0 }, { "forcefakecontrast", MITYPE_SETFLAG3, LEVEL3_FORCEFAKECONTRAST, 0 },
{ "nolightfade", MITYPE_SETFLAG3, LEVEL3_NOLIGHTFADE, 0 },
{ "nobotnodes", MITYPE_IGNORE, 0, 0 }, // Skulltag option: nobotnodes { "nobotnodes", MITYPE_IGNORE, 0, 0 }, // Skulltag option: nobotnodes
{ "compat_shorttex", MITYPE_COMPATFLAG, COMPATF_SHORTTEX, 0 }, { "compat_shorttex", MITYPE_COMPATFLAG, COMPATF_SHORTTEX, 0 },
{ "compat_stairs", MITYPE_COMPATFLAG, COMPATF_STAIRINDEX, 0 }, { "compat_stairs", MITYPE_COMPATFLAG, COMPATF_STAIRINDEX, 0 },

View File

@ -56,7 +56,6 @@
GLRenderSettings glset; GLRenderSettings glset;
long gl_frameMS; long gl_frameMS;
long gl_frameCount;
EXTERN_CVAR(Int, gl_lightmode) EXTERN_CVAR(Int, gl_lightmode)
EXTERN_CVAR(Bool, gl_brightfog) EXTERN_CVAR(Bool, gl_brightfog)
@ -193,11 +192,9 @@ struct FGLROptions : public FOptionalMapinfoData
brightfog = false; brightfog = false;
lightmode = -1; lightmode = -1;
nocoloredspritelighting = -1; nocoloredspritelighting = -1;
nolightfade = false;
notexturefill = -1; notexturefill = -1;
skyrotatevector = FVector3(0,0,1); skyrotatevector = FVector3(0,0,1);
skyrotatevector2 = FVector3(0,0,1); skyrotatevector2 = FVector3(0,0,1);
pixelstretch = 1.2f;
lightadditivesurfaces = false; lightadditivesurfaces = false;
} }
virtual FOptionalMapinfoData *Clone() const virtual FOptionalMapinfoData *Clone() const
@ -206,11 +203,9 @@ struct FGLROptions : public FOptionalMapinfoData
newopt->identifier = identifier; newopt->identifier = identifier;
newopt->lightmode = lightmode; newopt->lightmode = lightmode;
newopt->nocoloredspritelighting = nocoloredspritelighting; newopt->nocoloredspritelighting = nocoloredspritelighting;
newopt->nolightfade = nolightfade;
newopt->notexturefill = notexturefill; newopt->notexturefill = notexturefill;
newopt->skyrotatevector = skyrotatevector; newopt->skyrotatevector = skyrotatevector;
newopt->skyrotatevector2 = skyrotatevector2; newopt->skyrotatevector2 = skyrotatevector2;
newopt->pixelstretch = pixelstretch;
newopt->lightadditivesurfaces = lightadditivesurfaces; newopt->lightadditivesurfaces = lightadditivesurfaces;
return newopt; return newopt;
} }
@ -219,10 +214,8 @@ struct FGLROptions : public FOptionalMapinfoData
int8_t lightadditivesurfaces; int8_t lightadditivesurfaces;
int8_t nocoloredspritelighting; int8_t nocoloredspritelighting;
int8_t notexturefill; int8_t notexturefill;
bool nolightfade;
FVector3 skyrotatevector; FVector3 skyrotatevector;
FVector3 skyrotatevector2; FVector3 skyrotatevector2;
float pixelstretch;
}; };
DEFINE_MAP_OPTION(brightfog, false) DEFINE_MAP_OPTION(brightfog, false)
@ -255,20 +248,6 @@ DEFINE_MAP_OPTION(nocoloredspritelighting, false)
} }
} }
DEFINE_MAP_OPTION(nolightfade, false)
{
FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer");
if (parse.CheckAssign())
{
parse.sc.MustGetNumber();
opt->nolightfade = !!parse.sc.Number;
}
else
{
opt->nolightfade = true;
}
}
DEFINE_MAP_OPTION(notexturefill, false) DEFINE_MAP_OPTION(notexturefill, false)
{ {
FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer"); FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer");
@ -329,15 +308,6 @@ DEFINE_MAP_OPTION(skyrotate2, false)
opt->skyrotatevector2.MakeUnit(); opt->skyrotatevector2.MakeUnit();
} }
DEFINE_MAP_OPTION(pixelratio, false)
{
FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer");
parse.ParseAssign();
parse.sc.MustGetFloat();
opt->pixelstretch = (float)parse.sc.Float;
}
bool IsLightmodeValid() bool IsLightmodeValid()
{ {
return (glset.map_lightmode >= 0 && glset.map_lightmode <= 4) || glset.map_lightmode == 8; return (glset.map_lightmode >= 0 && glset.map_lightmode <= 4) || glset.map_lightmode == 8;
@ -370,8 +340,6 @@ void InitGLRMapinfoData()
glset.map_notexturefill = opt->notexturefill; glset.map_notexturefill = opt->notexturefill;
glset.skyrotatevector = opt->skyrotatevector; glset.skyrotatevector = opt->skyrotatevector;
glset.skyrotatevector2 = opt->skyrotatevector2; glset.skyrotatevector2 = opt->skyrotatevector2;
glset.pixelstretch = opt->pixelstretch;
glset.nolightfade = opt->nolightfade;
} }
else else
{ {
@ -382,8 +350,6 @@ void InitGLRMapinfoData()
glset.map_notexturefill = -1; glset.map_notexturefill = -1;
glset.skyrotatevector = FVector3(0, 0, 1); glset.skyrotatevector = FVector3(0, 0, 1);
glset.skyrotatevector2 = FVector3(0, 0, 1); glset.skyrotatevector2 = FVector3(0, 0, 1);
glset.pixelstretch = 1.2f;
glset.nolightfade = false;
} }
ResetOpts(); ResetOpts();
} }

View File

@ -10,7 +10,6 @@ struct GLRenderSettings
{ {
int8_t lightmode; int8_t lightmode;
bool nocoloredspritelighting; bool nocoloredspritelighting;
bool nolightfade;
bool notexturefill; bool notexturefill;
bool brightfog; bool brightfog;
bool lightadditivesurfaces; bool lightadditivesurfaces;
@ -23,9 +22,6 @@ struct GLRenderSettings
FVector3 skyrotatevector; FVector3 skyrotatevector;
FVector3 skyrotatevector2; FVector3 skyrotatevector2;
float pixelstretch;
}; };
extern GLRenderSettings glset; extern GLRenderSettings glset;

View File

@ -1055,7 +1055,7 @@ void gl_RenderModel(GLSprite * spr)
gl_RenderState.mModelMatrix.rotate(-smf->rolloffset, 1, 0, 0); gl_RenderState.mModelMatrix.rotate(-smf->rolloffset, 1, 0, 0);
// consider the pixel stretching. For non-voxels this must be factored out here // consider the pixel stretching. For non-voxels this must be factored out here
float stretch = (smf->modelIDs[0] != -1 ? Models[smf->modelIDs[0]]->getAspectFactor() : 1.f) / glset.pixelstretch; float stretch = (smf->modelIDs[0] != -1 ? Models[smf->modelIDs[0]]->getAspectFactor() : 1.f) / level.info->pixelstretch;
gl_RenderState.mModelMatrix.scale(1, stretch, 1); gl_RenderState.mModelMatrix.scale(1, stretch, 1);

View File

@ -37,6 +37,7 @@
#include "g_level.h" #include "g_level.h"
#include "colormatcher.h" #include "colormatcher.h"
#include "textures/bitmap.h" #include "textures/bitmap.h"
#include "g_levellocals.h"
//#include "gl/gl_intern.h" //#include "gl/gl_intern.h"
#include "gl/system/gl_interface.h" #include "gl/system/gl_interface.h"
@ -429,7 +430,7 @@ int FVoxelModel::FindFrame(const char * name)
float FVoxelModel::getAspectFactor() float FVoxelModel::getAspectFactor()
{ {
return glset.pixelstretch; return level.info->pixelstretch;
} }
//=========================================================================== //===========================================================================

View File

@ -290,7 +290,7 @@ float gl_GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity)
else if ((fogcolor.d & 0xffffff) == 0) else if ((fogcolor.d & 0xffffff) == 0)
{ {
// case 2: black fog // case 2: black fog
if (glset.lightmode != 8 && !glset.nolightfade) if (glset.lightmode != 8 && !(level.flags3 & LEVEL3_NOLIGHTFADE))
{ {
density = distfogtable[glset.lightmode != 0][gl_ClampLight(lightlevel)]; density = distfogtable[glset.lightmode != 0][gl_ClampLight(lightlevel)];
} }

View File

@ -221,7 +221,7 @@ void GLSceneDrawer::SetProjection(VSMatrix matrix)
void GLSceneDrawer::SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror) void GLSceneDrawer::SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror)
{ {
float mult = mirror? -1:1; float mult = mirror? -1:1;
float planemult = planemirror? -glset.pixelstretch : glset.pixelstretch; float planemult = planemirror? -level.info->pixelstretch : level.info->pixelstretch;
gl_RenderState.mViewMatrix.loadIdentity(); gl_RenderState.mViewMatrix.loadIdentity();
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll.Degrees, 0.0f, 0.0f, 1.0f); gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll.Degrees, 0.0f, 0.0f, 1.0f);
@ -796,7 +796,7 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
// We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1. // We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1.
double radPitch = r_viewpoint.Angles.Pitch.Normalized180().Radians(); double radPitch = r_viewpoint.Angles.Pitch.Normalized180().Radians();
double angx = cos(radPitch); double angx = cos(radPitch);
double angy = sin(radPitch) * glset.pixelstretch; double angy = sin(radPitch) * level.info->pixelstretch;
double alen = sqrt(angx*angx + angy*angy); double alen = sqrt(angx*angx + angy*angy);
GLRenderer->mAngles.Pitch = (float)RAD2DEG(asin(angy / alen)); GLRenderer->mAngles.Pitch = (float)RAD2DEG(asin(angy / alen));
@ -869,7 +869,6 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
} }
stereo3dMode.TearDown(); stereo3dMode.TearDown();
gl_frameCount++; // This counter must be increased right before the interpolations are restored.
interpolator.RestoreInterpolations (); interpolator.RestoreInterpolations ();
return lviewsector; return lviewsector;
} }

View File

@ -13,7 +13,6 @@ class FSimpleVertexBuffer;
class FGLDebug; class FGLDebug;
extern long gl_frameMS; extern long gl_frameMS;
extern long gl_frameCount;
#ifdef _WIN32 #ifdef _WIN32
class OpenGLFrameBuffer : public Win32GLFrameBuffer class OpenGLFrameBuffer : public Win32GLFrameBuffer
{ {

View File

@ -32,6 +32,7 @@
#include "d_net.h" #include "d_net.h"
#include "po_man.h" #include "po_man.h"
#include "st_stuff.h" #include "st_stuff.h"
#include "g_levellocals.h"
#include "swrenderer/scene/r_scene.h" #include "swrenderer/scene/r_scene.h"
#include "swrenderer/scene/r_light.h" #include "swrenderer/scene/r_light.h"
#include "swrenderer/drawers/r_draw_rgba.h" #include "swrenderer/drawers/r_draw_rgba.h"
@ -196,7 +197,7 @@ void PolyRenderer::SetupPerspectiveMatrix()
const auto &viewwindow = Thread.Viewport->viewwindow; const auto &viewwindow = Thread.Viewport->viewwindow;
double radPitch = viewpoint.Angles.Pitch.Normalized180().Radians(); double radPitch = viewpoint.Angles.Pitch.Normalized180().Radians();
double angx = cos(radPitch); double angx = cos(radPitch);
double angy = sin(radPitch) * glset.pixelstretch; double angy = sin(radPitch) * level.info->pixelstretch;
double alen = sqrt(angx*angx + angy*angy); double alen = sqrt(angx*angx + angy*angy);
float adjustedPitch = (float)asin(angy / alen); float adjustedPitch = (float)asin(angy / alen);
float adjustedViewAngle = (float)(viewpoint.Angles.Yaw - 90).Radians(); float adjustedViewAngle = (float)(viewpoint.Angles.Yaw - 90).Radians();
@ -208,7 +209,7 @@ void PolyRenderer::SetupPerspectiveMatrix()
TriMatrix worldToView = TriMatrix worldToView =
TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) *
TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) *
TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * TriMatrix::scale(1.0f, level.info->pixelstretch, 1.0f) *
TriMatrix::swapYZ() * TriMatrix::swapYZ() *
TriMatrix::translate((float)-viewpoint.Pos.X, (float)-viewpoint.Pos.Y, (float)-viewpoint.Pos.Z); TriMatrix::translate((float)-viewpoint.Pos.X, (float)-viewpoint.Pos.Y, (float)-viewpoint.Pos.Z);

View File

@ -51,7 +51,7 @@ void PolyDrawSectorPortal::Render(int portalDepth)
const auto &viewwindow = PolyRenderer::Instance()->Thread.Viewport->viewwindow; const auto &viewwindow = PolyRenderer::Instance()->Thread.Viewport->viewwindow;
double radPitch = viewpoint.Angles.Pitch.Normalized180().Radians(); double radPitch = viewpoint.Angles.Pitch.Normalized180().Radians();
double angx = cos(radPitch); double angx = cos(radPitch);
double angy = sin(radPitch) * glset.pixelstretch; double angy = sin(radPitch) * level.info->pixelstretch;
double alen = sqrt(angx*angx + angy*angy); double alen = sqrt(angx*angx + angy*angy);
float adjustedPitch = (float)asin(angy / alen); float adjustedPitch = (float)asin(angy / alen);
float adjustedViewAngle = (float)(viewpoint.Angles.Yaw - 90).Radians(); float adjustedViewAngle = (float)(viewpoint.Angles.Yaw - 90).Radians();
@ -61,7 +61,7 @@ void PolyDrawSectorPortal::Render(int portalDepth)
TriMatrix worldToView = TriMatrix worldToView =
TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) *
TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) *
TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * TriMatrix::scale(1.0f, level.info->pixelstretch, 1.0f) *
TriMatrix::swapYZ() * TriMatrix::swapYZ() *
TriMatrix::translate((float)-viewpoint.Pos.X, (float)-viewpoint.Pos.Y, (float)-viewpoint.Pos.Z); TriMatrix::translate((float)-viewpoint.Pos.X, (float)-viewpoint.Pos.Y, (float)-viewpoint.Pos.Z);
TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView; TriMatrix worldToClip = TriMatrix::perspective(fovy, ratio, 5.0f, 65535.0f) * worldToView;
@ -160,7 +160,7 @@ void PolyDrawLinePortal::Render(int portalDepth)
const auto &viewwindow = PolyRenderer::Instance()->Thread.Viewport->viewwindow; const auto &viewwindow = PolyRenderer::Instance()->Thread.Viewport->viewwindow;
double radPitch = viewpoint.Angles.Pitch.Normalized180().Radians(); double radPitch = viewpoint.Angles.Pitch.Normalized180().Radians();
double angx = cos(radPitch); double angx = cos(radPitch);
double angy = sin(radPitch) * glset.pixelstretch; double angy = sin(radPitch) * level.info->pixelstretch;
double alen = sqrt(angx*angx + angy*angy); double alen = sqrt(angx*angx + angy*angy);
float adjustedPitch = (float)asin(angy / alen); float adjustedPitch = (float)asin(angy / alen);
float adjustedViewAngle = (float)(viewpoint.Angles.Yaw - 90).Radians(); float adjustedViewAngle = (float)(viewpoint.Angles.Yaw - 90).Radians();
@ -170,7 +170,7 @@ void PolyDrawLinePortal::Render(int portalDepth)
TriMatrix worldToView = TriMatrix worldToView =
TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) *
TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) *
TriMatrix::scale(1.0f, glset.pixelstretch, 1.0f) * TriMatrix::scale(1.0f, level.info->pixelstretch, 1.0f) *
TriMatrix::swapYZ() * TriMatrix::swapYZ() *
TriMatrix::translate((float)-viewpoint.Pos.X, (float)-viewpoint.Pos.Y, (float)-viewpoint.Pos.Z); TriMatrix::translate((float)-viewpoint.Pos.X, (float)-viewpoint.Pos.Y, (float)-viewpoint.Pos.Z);
if (Mirror) if (Mirror)

View File

@ -140,12 +140,12 @@ namespace swrenderer
TiltVisibility = float(vis * viewport->viewwindow.FocalTangent * (16.f * 320.f) / viewwidth); TiltVisibility = float(vis * viewport->viewwindow.FocalTangent * (16.f * 320.f) / viewwidth);
NoLightFade = glset.nolightfade; NoLightFade = !!(level.flags3 & LEVEL3_NOLIGHTFADE);
} }
fixed_t LightVisibility::LightLevelToShade(int lightlevel, bool foggy) fixed_t LightVisibility::LightLevelToShade(int lightlevel, bool foggy)
{ {
bool nolightfade = !foggy && (glset.nolightfade); bool nolightfade = !foggy && ((level.flags3 & LEVEL3_NOLIGHTFADE));
if (nolightfade) if (nolightfade)
{ {
return (MAX(255 - lightlevel, 0) * NUMCOLORMAPS) << (FRACBITS - 8); return (MAX(255 - lightlevel, 0) * NUMCOLORMAPS) << (FRACBITS - 8);