Merge remote-tracking branch 'gzdoom/modern' into hw_postprocess

This commit is contained in:
Magnus Norddahl 2018-06-29 20:24:32 +02:00
commit a7529ce3b4
47 changed files with 233 additions and 69 deletions

View file

@ -764,7 +764,7 @@ void D_Display ()
//
// Check for the presence of dynamic lights at the start of the frame once.
if (gl_lights)
if ((gl_lights && vid_rendermode == 4) || (r_dynlights && vid_rendermode != 4))
{
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
level.HasDynamicLights = !!it.Next();

View file

@ -3,6 +3,7 @@
#include "actor.h"
#include "cycler.h"
EXTERN_CVAR(Bool, r_dynlights)
EXTERN_CVAR(Bool, gl_lights)
EXTERN_CVAR(Bool, gl_attachedlights)

View file

@ -1567,7 +1567,11 @@ DBaseStatusBar *CreateCustomStatusBar(int scriptno)
auto script = SBarInfoScript[scriptno];
if (script == nullptr) return nullptr;
auto sbar = (DBaseStatusBar*)PClass::FindClass("SBarInfoWrapper")->CreateNew();
PClass *sbarclass = PClass::FindClass("SBarInfoWrapper");
assert(sbarclass != nullptr);
assert(sbarclass->IsDescendantOf(RUNTIME_CLASS(DBaseStatusBar)));
auto sbar = (DBaseStatusBar*)sbarclass->CreateNew();
auto core = new DSBarInfo(sbar, script);
sbar->PointerVar<DSBarInfo>("core") = core;
sbar->SetSize(script->height, script->_resW, script->_resH);

View file

@ -247,6 +247,31 @@ static void CreateBaseStatusBar()
StatusBar->SetSize(0);
}
static void CreateGameInfoStatusBar(bool &shouldWarn)
{
auto cls = PClass::FindClass(gameinfo.statusbarclass);
if (cls == nullptr)
{
if (shouldWarn)
{
Printf(TEXTCOLOR_RED "Unknown status bar class \"%s\"\n", gameinfo.statusbarclass.GetChars());
shouldWarn = false;
}
}
else
{
if (cls->IsDescendantOf(RUNTIME_CLASS(DBaseStatusBar)))
{
StatusBar = (DBaseStatusBar *)cls->CreateNew();
}
else if (shouldWarn)
{
Printf(TEXTCOLOR_RED "Status bar class \"%s\" is not derived from BaseStatusBar\n", gameinfo.statusbarclass.GetChars());
shouldWarn = false;
}
}
}
void ST_CreateStatusBar(bool bTitleLevel)
{
if (StatusBar != NULL)
@ -255,6 +280,8 @@ void ST_CreateStatusBar(bool bTitleLevel)
StatusBar = NULL;
}
bool shouldWarn = true;
if (bTitleLevel)
{
CreateBaseStatusBar();
@ -268,11 +295,7 @@ void ST_CreateStatusBar(bool bTitleLevel)
int sbarinfofile = Wads.GetLumpFile(sbarinfolump);
if (gameinfo.statusbarclassfile >= gameinfo.statusbarfile && gameinfo.statusbarclassfile >= sbarinfofile)
{
auto cls = PClass::FindClass(gameinfo.statusbarclass);
if (cls != nullptr)
{
StatusBar = (DBaseStatusBar *)cls->CreateNew();
}
CreateGameInfoStatusBar(shouldWarn);
}
}
if (StatusBar == nullptr && SBarInfoScript[SCRIPT_CUSTOM] != nullptr)
@ -291,11 +314,7 @@ void ST_CreateStatusBar(bool bTitleLevel)
// SBARINFO failed so try the current statusbarclass again.
if (StatusBar == nullptr)
{
auto cls = PClass::FindClass(gameinfo.statusbarclass);
if (cls != nullptr)
{
StatusBar = (DBaseStatusBar *)cls->CreateNew();
}
CreateGameInfoStatusBar(shouldWarn);
}
}
if (StatusBar == nullptr)
@ -311,6 +330,7 @@ void ST_CreateStatusBar(bool bTitleLevel)
auto cls = PClass::FindClass(defname);
if (cls != nullptr)
{
assert(cls->IsDescendantOf(RUNTIME_CLASS(DBaseStatusBar)));
StatusBar = (DBaseStatusBar *)cls->CreateNew();
}
}

View file

@ -55,7 +55,6 @@
void FDrawInfo::SetupSubsectorLights(GLFlat *flat, int pass, subsector_t * sub, int *dli)
{
if (isFullbrightScene()) return;
if (dli != NULL && *dli != -1)
{
gl_RenderState.ApplyLightIndex(GLRenderer->mLights->GetIndex(*dli));
@ -84,7 +83,6 @@ void FDrawInfo::SetupSubsectorLights(GLFlat *flat, int pass, subsector_t * sub,
void FDrawInfo::SetupSectorLights(GLFlat *flat, int pass, int *dli)
{
if (isFullbrightScene()) return;
if (dli != NULL && *dli != -1)
{
gl_RenderState.ApplyLightIndex(GLRenderer->mLights->GetIndex(*dli));
@ -303,6 +301,7 @@ void FDrawInfo::DrawFlat(GLFlat *flat, int pass, bool trans) // trans only has m
int rel = getExtraLight();
auto &plane = flat->plane;
auto processLights = level.HasDynamicLights && !isFullbrightScene();
gl_RenderState.SetNormal(plane.plane.Normal().X, plane.plane.Normal().Z, plane.plane.Normal().Y);
switch (pass)
@ -316,19 +315,19 @@ void FDrawInfo::DrawFlat(GLFlat *flat, int pass, bool trans) // trans only has m
{
gl_RenderState.SetMaterial(flat->gltexture, CLAMP_NONE, 0, -1, false);
gl_RenderState.SetPlaneTextureRotation(&plane, flat->gltexture);
DrawSubsectors(flat, pass, (pass == GLPASS_ALL || flat->dynlightindex > -1), false);
DrawSubsectors(flat, pass, processLights && (gl.lightmethod == LM_DIRECT || flat->dynlightindex > -1), false);
gl_RenderState.EnableTextureMatrix(false);
}
else
{
gl_RenderState.SetMaterial(flat->gltexture, CLAMP_XY, 0, -1, false);
DrawSkyboxSector(flat, pass, (pass == GLPASS_ALL || flat->dynlightindex > -1));
DrawSkyboxSector(flat, pass, processLights && (gl.lightmethod == LM_DIRECT || flat->dynlightindex > -1));
}
gl_RenderState.SetObjectColor(0xffffffff);
break;
case GLPASS_LIGHTSONLY:
if (!trans || flat->gltexture)
if ((!trans || flat->gltexture) && processLights)
{
ProcessLights(flat, trans);
}
@ -353,7 +352,7 @@ void FDrawInfo::DrawFlat(GLFlat *flat, int pass, bool trans) // trans only has m
else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
gl_RenderState.SetMaterial(flat->gltexture, CLAMP_NONE, 0, -1, false);
gl_RenderState.SetPlaneTextureRotation(&plane, flat->gltexture);
DrawSubsectors(flat, pass, (gl.lightmethod == LM_DIRECT || flat->dynlightindex > -1), true);
DrawSubsectors(flat, pass, processLights && (gl.lightmethod == LM_DIRECT || flat->dynlightindex > -1), true);
gl_RenderState.EnableTextureMatrix(false);
}
if (flat->renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

View file

@ -151,6 +151,7 @@ public:
void SightCheck::P_SightOpening(SightOpening &open, const line_t *linedef, double x, double y)
{
open.portalflags = 0;
open.bottom = open.top = 0;
sector_t *front = linedef->frontsector;
sector_t *back = linedef->backsector;
@ -159,8 +160,10 @@ void SightCheck::P_SightOpening(SightOpening &open, const line_t *linedef, doubl
// single sided line
if (linedef->flags & ML_PORTALCONNECT)
{
if (!front->PortalBlocksSight(sector_t::ceiling)) open.portalflags |= SO_TOPFRONT;
if (!front->PortalBlocksSight(sector_t::floor)) open.portalflags |= SO_BOTTOMFRONT;
if (!front->PortalBlocksSight(sector_t::ceiling)) open.top = LINEOPEN_MAX, open.portalflags |= SO_TOPFRONT;
if (!front->PortalBlocksSight(sector_t::floor)) open.bottom = LINEOPEN_MIN, open.portalflags |= SO_BOTTOMFRONT;
if (open.top == 0) open.top = front->floorplane.ZatPoint(x, y);
if (open.bottom == 0) open.bottom = front->ceilingplane.ZatPoint(x, y);
}
open.range = 0;
@ -213,7 +216,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in)
//
// ignore self referencing sectors if COMPAT_TRACE is on
if ((i_compatflags & COMPATF_TRACE) && li->frontsector == li->backsector)
if ((i_compatflags & COMPATF_TRACE) && li->frontsector == li->backsector)
return true;
double trX = Trace.x + Trace.dx * in->frac;
@ -224,7 +227,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in)
{
// This may not skip P_SightOpening, but only reduce the open range to 0.
open.range = 0;
open.bottom = open.top;
if (open.bottom != LINEOPEN_MIN) open.bottom = open.top;
}
FLinePortal *lport = li->getPortal();

View file

@ -56,7 +56,7 @@ PolyModelRenderer::PolyModelRenderer(PolyRenderThread *thread, const Mat4f &worl
void PolyModelRenderer::AddLights(AActor *actor)
{
if (gl_lights && actor)
if (r_dynlights && actor)
{
auto &addedLights = Thread->AddedLightsArray;

View file

@ -269,6 +269,12 @@ void RenderPolyPlane::SetLightLevel(PolyRenderThread *thread, PolyDrawArgs &args
void RenderPolyPlane::SetDynLights(PolyRenderThread *thread, PolyDrawArgs &args, subsector_t *sub, bool ceiling)
{
if (!r_dynlights)
{
args.SetLights(nullptr, 0);
return;
}
FLightNode *light_list = sub->lighthead;
auto cameraLight = PolyCameraLight::Instance();

View file

@ -374,6 +374,12 @@ void RenderPolyWall::Render(PolyRenderThread *thread)
void RenderPolyWall::SetDynLights(PolyRenderThread *thread, PolyDrawArgs &args)
{
if (!r_dynlights)
{
args.SetLights(nullptr, 0);
return;
}
FLightNode *light_list = (LineSeg && LineSeg->sidedef) ? LineSeg->sidedef->lighthead : nullptr;
auto cameraLight = PolyCameraLight::Instance();

View file

@ -83,8 +83,6 @@ protected:
void SetFullscreenMode();
void SetWindowedMode();
void InitializeState();
void SwapBuffers();
void SetGammaTable(uint16_t* table);

View file

@ -555,11 +555,13 @@ void ProcessKeyboardEvent(NSEvent* theEvent)
return;
}
const bool isARepeat = [theEvent isARepeat];
if (k_allowfullscreentoggle
&& (kVK_ANSI_F == keyCode)
&& (NSCommandKeyMask & [theEvent modifierFlags])
&& (NSKeyDown == [theEvent type])
&& ![theEvent isARepeat])
&& !isARepeat)
{
ToggleFullscreen = !ToggleFullscreen;
return;
@ -569,7 +571,7 @@ void ProcessKeyboardEvent(NSEvent* theEvent)
{
ProcessKeyboardEventInMenu(theEvent);
}
else
else if (!isARepeat)
{
event_t event = {};

View file

@ -152,6 +152,7 @@ static void I_DetectOS()
case 11: name = "OS X El Capitan"; break;
case 12: name = "macOS Sierra"; break;
case 13: name = "macOS High Sierra"; break;
case 14: name = "macOS Mojave"; break;
}
char release[16] = "unknown";

View file

@ -319,6 +319,9 @@ NSOpenGLPixelFormat* CreatePixelFormat(const NSOpenGLPixelFormatAttribute profil
// ---------------------------------------------------------------------------
static SystemGLFrameBuffer* frameBuffer;
SystemGLFrameBuffer::SystemGLFrameBuffer(void*, const bool fullscreen)
: DFrameBuffer(vid_defwidth, vid_defheight)
, m_window(CreateWindow(STYLE_MASK_WINDOWED))
@ -383,6 +386,8 @@ SystemGLFrameBuffer::SystemGLFrameBuffer(void*, const bool fullscreen)
}
}
frameBuffer = this;
FConsoleWindow::GetInstance().Show(false);
}
@ -417,10 +422,6 @@ void SystemGLFrameBuffer::SetVSync(bool vsync)
}
void SystemGLFrameBuffer::InitializeState()
{
}
void SystemGLFrameBuffer::SwapBuffers()
{
[[NSOpenGLContext currentContext] flushBuffer];
@ -532,24 +533,19 @@ void SystemGLFrameBuffer::SetMode(const bool fullscreen, const bool hiDPI)
}
static SystemGLFrameBuffer* GetSystemFrameBuffer()
{
return static_cast<SystemGLFrameBuffer*>(screen);
}
void SystemGLFrameBuffer::UseHiDPI(const bool hiDPI)
{
if (auto fb = GetSystemFrameBuffer())
if (frameBuffer != nullptr)
{
fb->SetMode(fb->m_fullscreen, hiDPI);
frameBuffer->SetMode(frameBuffer->m_fullscreen, hiDPI);
}
}
void SystemGLFrameBuffer::SetCursor(NSCursor* cursor)
{
if (auto fb = GetSystemFrameBuffer())
if (frameBuffer != nullptr)
{
NSWindow* const window = fb->m_window;
NSWindow* const window = frameBuffer->m_window;
CocoaView* const view = [window contentView];
[view setCursor:cursor];
@ -559,15 +555,15 @@ void SystemGLFrameBuffer::SetCursor(NSCursor* cursor)
void SystemGLFrameBuffer::SetWindowVisible(bool visible)
{
if (auto fb = GetSystemFrameBuffer())
if (frameBuffer != nullptr)
{
if (visible)
{
[fb->m_window orderFront:nil];
[frameBuffer->m_window orderFront:nil];
}
else
{
[fb->m_window orderOut:nil];
[frameBuffer->m_window orderOut:nil];
}
I_SetNativeMouse(!visible);
@ -576,11 +572,11 @@ void SystemGLFrameBuffer::SetWindowVisible(bool visible)
void SystemGLFrameBuffer::SetWindowTitle(const char* title)
{
if (auto fb = GetSystemFrameBuffer())
if (frameBuffer != nullptr)
{
NSString* const nsTitle = nullptr == title ? nil :
[NSString stringWithCString:title encoding:NSISOLatin1StringEncoding];
[fb->m_window setTitle:nsTitle];
[frameBuffer->m_window setTitle:nsTitle];
}
}

View file

@ -32,7 +32,6 @@ public:
protected:
void SetGammaTable(uint16_t *tbl);
void ResetGammaTable();
void InitializeState();
SystemGLFrameBuffer () {}
uint8_t GammaTable[3][256];

View file

@ -65,6 +65,10 @@ void I_ShutdownGraphics ()
void I_InitGraphics ()
{
#ifdef __APPLE__
SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, "0");
#endif // __APPLE__
if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0)
{
I_FatalError ("Could not initialize SDL video:\n%s\n", SDL_GetError());

View file

@ -62,8 +62,6 @@ EXTERN_CVAR (Bool, fullscreen)
extern int WaitingForKey, chatmodeon;
extern constate_e ConsoleState;
static bool DownState[SDL_NUM_SCANCODES];
static const SDL_Keycode DIKToKeySym[256] =
{
0, SDLK_ESCAPE, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6,
@ -188,10 +186,6 @@ static void I_CheckGUICapture ()
if (wantCapt != GUICapture)
{
GUICapture = wantCapt;
if (wantCapt)
{
memset (DownState, 0, sizeof(DownState));
}
ResetButtonStates();
}
}
@ -393,6 +387,11 @@ void MessagePump (const SDL_Event &sev)
case SDL_KEYUP:
if (!GUICapture)
{
if (sev.key.repeat)
{
break;
}
event.type = sev.type == SDL_KEYDOWN ? EV_KeyDown : EV_KeyUp;
// Try to look up our key mapped key for conversion to DirectInput.
@ -422,17 +421,9 @@ void MessagePump (const SDL_Event &sev)
((kmod & KMOD_CTRL) ? GKM_CTRL : 0) |
((kmod & KMOD_ALT) ? GKM_ALT : 0);
if (event.subtype == EV_GUI_KeyDown)
if (event.subtype == EV_GUI_KeyDown && sev.key.repeat)
{
if (DownState[sev.key.keysym.scancode])
{
event.subtype = EV_GUI_KeyRepeat;
}
DownState[sev.key.keysym.scancode] = 1;
}
else
{
DownState[sev.key.keysym.scancode] = 0;
event.subtype = EV_GUI_KeyRepeat;
}
switch (sev.key.keysym.sym)

View file

@ -273,12 +273,6 @@ SystemGLFrameBuffer::~SystemGLFrameBuffer ()
}
void SystemGLFrameBuffer::InitializeState()
{
}
void SystemGLFrameBuffer::SetGammaTable(uint16_t *tbl)
{
if (m_supportsGamma)

View file

@ -188,6 +188,17 @@ bool FWadFile::Open(bool quiet)
Lumps[i].Namespace = ns_global;
Lumps[i].Flags = Lumps[i].Compressed? LUMPF_COMPRESSED : 0;
Lumps[i].FullName = NULL;
// Check if the lump is within the WAD file and print a warning if not.
if (Lumps[i].Position + Lumps[i].LumpSize > wadSize || Lumps[i].Position < 0 || Lumps[i].LumpSize < 0)
{
if (Lumps[i].LumpSize != 0)
{
Printf(PRINT_HIGH, "%s: Lump %s contains invalid positioning info and will be ignored\n", Filename, Lumps[i].Name);
Lumps[i].Name[0] = 0;
}
Lumps[i].LumpSize = Lumps[i].Position = 0;
}
}
delete[] fileinfo;

View file

@ -98,7 +98,7 @@ namespace swrenderer
void SWModelRenderer::AddLights(AActor *actor)
{
if (gl_lights && actor)
if (r_dynlights && actor)
{
auto &addedLights = Thread->AddedLightsArray;