Add menu option to enable dynamic lights (independent of the OpenGL setting so that you can have it on in OpenGL and off in Software)

This commit is contained in:
Magnus Norddahl 2016-12-23 23:44:52 +01:00
parent 06bc911828
commit 2bb2395569
6 changed files with 109 additions and 87 deletions

View file

@ -53,6 +53,8 @@
#include "r_draw_pal.h" #include "r_draw_pal.h"
#include "r_thread.h" #include "r_thread.h"
CVAR(Bool, r_dynlights, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
namespace swrenderer namespace swrenderer
{ {
// Needed by R_DrawFogBoundary (which probably shouldn't be part of this file) // Needed by R_DrawFogBoundary (which probably shouldn't be part of this file)

View file

@ -16,6 +16,7 @@ EXTERN_CVAR(Int, r_drawfuzz);
EXTERN_CVAR(Bool, r_drawtrans); EXTERN_CVAR(Bool, r_drawtrans);
EXTERN_CVAR(Float, transsouls); EXTERN_CVAR(Float, transsouls);
EXTERN_CVAR(Int, r_columnmethod); EXTERN_CVAR(Int, r_columnmethod);
EXTERN_CVAR(Bool, r_dynlights);
namespace swrenderer namespace swrenderer
{ {

View file

@ -257,6 +257,8 @@ void R_MapPlane (int y, int x1)
} }
if (r_swtruecolor) if (r_swtruecolor)
{
if (r_dynlights)
{ {
// Find row position in view space // Find row position in view space
float zspan = planeheight / (fabs(y + 0.5 - CenterY) / InvZtoScale); float zspan = planeheight / (fabs(y + 0.5 - CenterY) / InvZtoScale);
@ -307,6 +309,11 @@ void R_MapPlane (int y, int x1)
if (nextlightindex == 64 * 1024) if (nextlightindex == 64 * 1024)
nextlightindex = 0; nextlightindex = 0;
} }
else
{
dc_num_lights = 0;
}
}
ds_y = y; ds_y = y;
ds_x1 = x1; ds_x1 = x1;
@ -348,6 +355,9 @@ namespace
void R_AddPlaneLights(visplane_t *plane, FLightNode *node) void R_AddPlaneLights(visplane_t *plane, FLightNode *node)
{ {
if (!r_dynlights)
return;
while (node) while (node)
{ {
if (!(node->lightsource->flags2&MF2_DORMANT)) if (!(node->lightsource->flags2&MF2_DORMANT))

View file

@ -538,6 +538,8 @@ WallSampler::WallSampler(int y1, float swal, double yrepeat, fixed_t xoffset, do
static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, void(*draw1column)()) static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, void(*draw1column)())
{ {
if (r_swtruecolor) if (r_swtruecolor)
{
if (r_dynlights)
{ {
// Find column position in view space // Find column position in view space
float w1 = 1.0f / WallC.sz1; float w1 = 1.0f / WallC.sz1;
@ -594,6 +596,11 @@ static void Draw1Column(int x, int y1, int y2, WallSampler &sampler, void(*draw1
if (nextlightindex == 64 * 1024) if (nextlightindex == 64 * 1024)
nextlightindex = 0; nextlightindex = 0;
}
else
{
dc_num_lights = 0;
}
int count = y2 - y1; int count = y2 - y1;

View file

@ -2754,4 +2754,5 @@ TCMNU_TRUECOLOR = "True color output";
TCMNU_MINFILTER = "Linear filter when downscaling"; TCMNU_MINFILTER = "Linear filter when downscaling";
TCMNU_MAGFILTER = "Linear filter when upscaling"; TCMNU_MAGFILTER = "Linear filter when upscaling";
TCMNU_MIPMAP = "Use mipmapped textures"; TCMNU_MIPMAP = "Use mipmapped textures";
TCMNU_DYNLIGHTS = "Dynamic lights";

View file

@ -675,6 +675,7 @@ OptionMenu "TrueColorOptions"
Option "$TCMNU_MINFILTER", "r_minfilter", "OnOff" Option "$TCMNU_MINFILTER", "r_minfilter", "OnOff"
Option "$TCMNU_MAGFILTER", "r_magfilter", "OnOff" Option "$TCMNU_MAGFILTER", "r_magfilter", "OnOff"
Option "$TCMNU_MIPMAP", "r_mipmap", "OnOff" Option "$TCMNU_MIPMAP", "r_mipmap", "OnOff"
Option "$TCMNU_DYNLIGHTS", "r_dynlights", "OnOff"
} }
OptionMenu "VideoOptions" OptionMenu "VideoOptions"