Skip to content

Commit

Permalink
Cleanup: Moved global validCount to WorldSystem; r_main.h/cpp now cli…
Browse files Browse the repository at this point in the history
…ent-only

The server executable no longer depends on any source file in the
render domain.
  • Loading branch information
danij-deng committed Jan 15, 2014
1 parent 6bb992b commit e17ccd3
Show file tree
Hide file tree
Showing 21 changed files with 114 additions and 112 deletions.
3 changes: 1 addition & 2 deletions doomsday/client/include/de_render.h
Expand Up @@ -22,13 +22,12 @@
#ifndef DOOMSDAY_CLIENT_RENDERER
#define DOOMSDAY_CLIENT_RENDERER

#include "render/r_main.h"

#ifdef __CLIENT__
#include "render/viewports.h"
#include "render/lightgrid.h"
#include "render/projector.h"
#include "render/r_draw.h"
#include "render/r_main.h"
#include "render/r_things.h"
#include "render/rend_clip.h"
#include "render/rend_halo.h"
Expand Down
2 changes: 0 additions & 2 deletions doomsday/client/include/render/r_main.h
Expand Up @@ -23,8 +23,6 @@

#include "dd_types.h"

DENG_EXTERN_C int validCount;

DENG_EXTERN_C int levelFullBright;

DENG_EXTERN_C float pspOffset[2], pspLightLevelMultiplier;
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/world/worldsystem.h
Expand Up @@ -161,5 +161,6 @@ class WorldSystem : public de::System
} // namespace de

DENG_EXTERN_C dd_bool ddMapSetup;
DENG_EXTERN_C int validCount;

#endif // DENG_WORLD_H
27 changes: 16 additions & 11 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -56,10 +56,10 @@
# include "gl/gl_texmanager.h"
#endif

#include "render/r_main.h" // R_Init, R_ResetViewer
#ifdef __CLIENT__
# include "render/cameralensfx.h"
# include "render/r_draw.h" // R_InitViewWindow
# include "render/r_main.h" // R_Init, R_ResetViewer
# include "render/rend_font.h"
# include "render/rend_main.h"
# include "render/rend_particle.h" // Rend_ParticleLoadSystemTextures
Expand Down Expand Up @@ -2303,7 +2303,11 @@ ddvalue_t ddValues[DD_LAST_VALUE - DD_FIRST_VALUE - 1] = {
#endif
{0, 0},
{0, 0}, //{&mouseInverseY, &mouseInverseY},
#ifdef __CLIENT__
{&levelFullBright, &levelFullBright},
#else
{0, 0},
#endif
{&CmdReturnValue, 0},
#ifdef __CLIENT__
{&gameReady, &gameReady},
Expand All @@ -2324,10 +2328,11 @@ ddvalue_t ddValues[DD_LAST_VALUE - DD_FIRST_VALUE - 1] = {
{0, 0},
#ifdef __CLIENT__
{&clientPaused, &clientPaused},
{&weaponOffsetScaleY, &weaponOffsetScaleY},
#else
{0, 0},
{0, 0},
#endif
{&weaponOffsetScaleY, &weaponOffsetScaleY},
{&gameDataFormat, &gameDataFormat},
#ifdef __CLIENT__
{&gameDrawHUD, 0},
Expand Down Expand Up @@ -2479,6 +2484,14 @@ void *DD_GetVariable(int ddvalue)
valueD = App_WorldSystem().hasMap()? App_WorldSystem().map().bounds().maxY : 0;
return &valueD;

/*case DD_CPLAYER_THRUST_MUL:
return &cplrThrustMul;*/

case DD_GRAVITY:
valueD = App_WorldSystem().hasMap()? App_WorldSystem().map().gravity() : 0;
return &valueD;

#ifdef __CLIENT__
case DD_PSPRITE_OFFSET_X:
return &pspOffset[VX];

Expand All @@ -2488,14 +2501,6 @@ void *DD_GetVariable(int ddvalue)
case DD_PSPRITE_LIGHTLEVEL_MULTIPLIER:
return &pspLightLevelMultiplier;

/*case DD_CPLAYER_THRUST_MUL:
return &cplrThrustMul;*/

case DD_GRAVITY:
valueD = App_WorldSystem().hasMap()? App_WorldSystem().map().gravity() : 0;
return &valueD;

#ifdef __CLIENT__
case DD_TORCH_RED:
return &torchColor.x;

Expand Down Expand Up @@ -2557,6 +2562,7 @@ void DD_SetVariable(int ddvalue, void *parm)
App_WorldSystem().map().setGravity(*(coord_t*) parm);
return;

#ifdef __CLIENT__
case DD_PSPRITE_OFFSET_X:
pspOffset[VX] = *(float *) parm;
return;
Expand All @@ -2569,7 +2575,6 @@ void DD_SetVariable(int ddvalue, void *parm)
pspLightLevelMultiplier = *(float *) parm;
return;

#ifdef __CLIENT__
case DD_TORCH_RED:
torchColor.x = de::clamp(0.f, *((float*) parm), 1.f);
return;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/dd_pinit.cpp
Expand Up @@ -38,10 +38,10 @@
#include "gl/svg.h"
#ifdef __CLIENT__
# include "render/r_draw.h"
# include "render/r_main.h"
# include "render/rend_main.h"
# include "updater.h"
#endif
#include "render/r_main.h"

#include "api_internaldata.h"

Expand Down
104 changes: 54 additions & 50 deletions doomsday/client/src/gl/gl_tex.cpp
Expand Up @@ -17,28 +17,32 @@
* http://www.gnu.org/licenses</small>
*/

#include <cstdlib>
#include <cmath>
#include <cctype>
#include "de_platform.h"
#include "gl/gl_tex.h"

#include <de/vector1.h>
#include "con_main.h"

#include "de_platform.h"
#include "de_base.h"
#include "de_console.h"
#include "color.h"
#include "render/r_main.h"

#include "gl/gl_tex.h"
#include "resource/resourcesystem.h"
#include "resource/colorpalette.h"

#include <de/memory.h>
#include <de/memoryzone.h>
#include <de/vector1.h>
#include <cstdlib>
#include <cmath>
#include <cctype>

static uint8_t* scratchBuffer = NULL;
static size_t scratchBufferSize = 0;
static uint8_t *scratchBuffer;
static size_t scratchBufferSize;

/**
* Provides a persistent scratch buffer for use by texture manipulation
* routines e.g. scaleLine().
*/
static uint8_t* GetScratchBuffer(size_t size)
static uint8_t *GetScratchBuffer(size_t size)
{
// Need to enlarge?
if(size > scratchBufferSize)
Expand Down Expand Up @@ -769,23 +773,23 @@ dd_bool GL_PalettizeImage(uint8_t *out, int outformat, ColorPalette const *palet
{
de::Vector3ub palColor = palette->color(*in);

out[CR] = palColor.x;
out[CG] = palColor.y;
out[CB] = palColor.z;
out[0] = palColor.x;
out[1] = palColor.y;
out[2] = palColor.z;

if(applyTexGamma)
{
out[CR] = texGammaLut[out[CR]];
out[CG] = texGammaLut[out[CG]];
out[CB] = texGammaLut[out[CB]];
out[0] = texGammaLut[out[0]];
out[1] = texGammaLut[out[1]];
out[2] = texGammaLut[out[2]];
}

if(outformat == 4)
{
if(informat == 2)
out[CA] = in[numPels * inSize];
out[3] = in[numPels * inSize];
else
out[CA] = 0;
out[3] = 0;
}

in += inSize;
Expand Down Expand Up @@ -901,19 +905,19 @@ void FindAverageLineColorIdx(uint8_t const *data, int w, int h, int line,
if(!hasAlpha || alphaStart[i])
{
de::Vector3ub palColor = palette[start[i]];
avg[CR] += palColor.x;
avg[CG] += palColor.y;
avg[CB] += palColor.z;
avg[0] += palColor.x;
avg[1] += palColor.y;
avg[2] += palColor.z;
++count;
}
}

// All transparent? Sorry...
if(!count) return;

V3f_Set(color->rgb, avg[CR] / count * reciprocal255,
avg[CG] / count * reciprocal255,
avg[CB] / count * reciprocal255);
V3f_Set(color->rgb, avg[0] / count * reciprocal255,
avg[1] / count * reciprocal255,
avg[2] / count * reciprocal255);
}

void FindAverageLineColor(const uint8_t* pixels, int width, int height,
Expand Down Expand Up @@ -942,14 +946,14 @@ void FindAverageLineColor(const uint8_t* pixels, int width, int height,
src = pixels + pixelSize * width * line;
for(i = 0; i < width; ++i, src += pixelSize)
{
avg[CR] += src[CR];
avg[CG] += src[CG];
avg[CB] += src[CB];
avg[0] += src[0];
avg[1] += src[1];
avg[2] += src[2];
}

V3f_Set(color->rgb, avg[CR] / width * reciprocal255,
avg[CG] / width * reciprocal255,
avg[CB] / width * reciprocal255);
V3f_Set(color->rgb, avg[0] / width * reciprocal255,
avg[1] / width * reciprocal255,
avg[2] / width * reciprocal255);
}

void FindAverageColor(const uint8_t* pixels, int width, int height,
Expand Down Expand Up @@ -978,14 +982,14 @@ void FindAverageColor(const uint8_t* pixels, int width, int height,
src = pixels;
for(i = 0; i < numpels; ++i, src += pixelSize)
{
avg[CR] += src[CR];
avg[CG] += src[CG];
avg[CB] += src[CB];
avg[0] += src[0];
avg[1] += src[1];
avg[2] += src[2];
}

V3f_Set(color->rgb, avg[CR] / numpels * reciprocal255,
avg[CG] / numpels * reciprocal255,
avg[CB] / numpels * reciprocal255);
V3f_Set(color->rgb, avg[0] / numpels * reciprocal255,
avg[1] / numpels * reciprocal255,
avg[2] / numpels * reciprocal255);
}

void FindAverageColorIdx(uint8_t const *data, int w, int h, ColorPalette const &palette,
Expand All @@ -1010,19 +1014,19 @@ void FindAverageColorIdx(uint8_t const *data, int w, int h, ColorPalette const &
if(!hasAlpha || alphaStart[i])
{
de::Vector3ub palColor = palette[data[i]];
avg[CR] += palColor.x;
avg[CG] += palColor.y;
avg[CB] += palColor.z;
avg[0] += palColor.x;
avg[1] += palColor.y;
avg[2] += palColor.z;
++count;
}
}

// All transparent? Sorry...
if(0 == count) return;

V3f_Set(color->rgb, avg[CR] / count * reciprocal255,
avg[CG] / count * reciprocal255,
avg[CB] / count * reciprocal255);
V3f_Set(color->rgb, avg[0] / count * reciprocal255,
avg[1] / count * reciprocal255,
avg[2] / count * reciprocal255);
}

void FindAverageAlpha(const uint8_t* pixels, int width, int height,
Expand Down Expand Up @@ -1064,7 +1068,7 @@ void FindAverageAlpha(const uint8_t* pixels, int width, int height,
src = pixels;
for(i = 0; i < numPels; ++i, src += 4)
{
const uint8_t val = src[CA];
const uint8_t val = src[3];
avg += val;
if(val < 255) alphaCount++;
}
Expand Down Expand Up @@ -1362,9 +1366,9 @@ void Desaturate(uint8_t* pixels, int width, int height, int comps)
numpels = width * height;
for(i = 0, pix = pixels; i < numpels; ++i, pix += comps)
{
int min = MIN_OF(pix[CR], MIN_OF(pix[CG], pix[CB]));
int max = MAX_OF(pix[CR], MAX_OF(pix[CG], pix[CB]));
pix[CR] = pix[CG] = pix[CB] = (min + max) / 2;
int min = MIN_OF(pix[0], MIN_OF(pix[1], pix[2]));
int max = MAX_OF(pix[0], MAX_OF(pix[1], pix[2]));
pix[0] = pix[1] = pix[2] = (min + max) / 2;
}
}
}
Expand Down Expand Up @@ -1512,8 +1516,8 @@ void SharpenPixels(uint8_t* pixels, int width, int height, int comps)
static inline bool isKeyedColor(uint8_t *color)
{
DENG2_ASSERT(color);
return color[CB] == 0xff && ((color[CR] == 0xff && color[CG] == 0) ||
(color[CR] == 0 && color[CG] == 0xff));
return color[2] == 0xff && ((color[0] == 0xff && color[1] == 0) ||
(color[0] == 0 && color[1] == 0xff));
}

/**
Expand Down Expand Up @@ -1556,7 +1560,7 @@ uint8_t *ApplyColorKeying(uint8_t *buf, int width, int height, int pixelSize)
}

std::memcpy(out, in, 3); // The color itself.
out[CA] = 255; // Opaque.
out[3] = 255; // Opaque.
}
return ckdest;
}
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/src/gl/gl_texmanager.cpp
@@ -1,10 +1,10 @@
/** @file gl_texmanager.cpp GL-Texture management
/** @file gl_texmanager.cpp GL-Texture management.
*
* @todo This file needs to be split into smaller portions.
*
* @authors Copyright &copy; 1999-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright &copy; 2005-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright &copy; 2002 Graham Jackson <no contact email published>
* @authors Copyright © 1999-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2002 Graham Jackson <no contact email published>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand Down
5 changes: 0 additions & 5 deletions doomsday/client/src/render/r_main.cpp
Expand Up @@ -42,15 +42,10 @@

using namespace de;

int validCount = 1; // Increment every time a check is made.

int levelFullBright;
int weaponOffsetScaleY = 1000;
int psp3d;

// Precalculated math tables.
fixed_t *fineCosine = &finesine[FINEANGLES / 4];

float pspLightLevelMultiplier = 1;
float pspOffset[2];

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/resource/api_resource.cpp
Expand Up @@ -24,8 +24,8 @@
#include "gl/gl_tex.h" // averagealpha_analysis_t, etc...
#ifdef __CLIENT__
# include "render/r_draw.h" // Rend_PatchTextureSpec()
# include "render/r_main.h" // texGammaLut
#endif
#include "render/r_main.h" // texGammaLut

using namespace de;

Expand Down

0 comments on commit e17ccd3

Please sign in to comment.