Skip to content

Commit

Permalink
Refactor|Client|Map Renderer: Dismantled more of obsolete/old "rendpo…
Browse files Browse the repository at this point in the history
…ly" stuff
  • Loading branch information
danij-deng committed Oct 30, 2013
1 parent f3cca1d commit 0912713
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 253 deletions.
72 changes: 72 additions & 0 deletions doomsday/client/include/gl/gl_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,78 @@ DENG_EXTERN_C int r_detail;
# define LIBDENG_ASSERT_GL_TEXTURE_ISBOUND(tex)
#endif

/**
* Symbolic identifiers for (virtual) texture units.
*/
typedef enum {
RTU_PRIMARY = 0,
RTU_PRIMARY_DETAIL,
RTU_INTER,
RTU_INTER_DETAIL,
RTU_REFLECTION,
RTU_REFLECTION_MASK,
NUM_TEXMAP_UNITS
} rtexmapunitid_t;

/**
* @defgroup textureUnitFlags Texture Unit Flags
* @ingroup flags
*/
///@{
#define TUF_TEXTURE_IS_MANAGED 0x1 ///< A managed texture is bound to this unit.
///@}

struct rtexmapunit_texture_t
{
union {
struct {
DGLuint name; ///< Texture used on this layer (if any).
int magMode; ///< GL texture magnification filter.
int wrapS; ///< GL texture S axis wrap mode.
int wrapT; ///< GL texture T axis wrap mode.
} gl;
de::TextureVariant *variant;
};
/// @ref textureUnitFlags
int flags;

rtexmapunit_texture_t() : flags(0)
{
gl.name = 0;
gl.magMode = GL_LINEAR;
gl.wrapS = GL_REPEAT;
gl.wrapT = GL_REPEAT;
}

inline bool hasTexture() const
{
if(flags & TUF_TEXTURE_IS_MANAGED)
{
return variant && variant->glName() != 0;
}
return gl.name != 0;
}
};

/**
* GL Texture unit config.
*/
struct rtexmapunit_t
{
rtexmapunit_texture_t texture; ///< Info about the bound texture for this unit.
blendmode_t blendMode; ///< Currently used only with reflection.
float opacity; ///< Opacity of this layer [0..1].
de::Vector2f scale; ///< Texture-space scale multiplier.
de::Vector2f offset; ///< Texture-space origin translation (unscaled).

rtexmapunit_t() : blendMode(BM_NORMAL), opacity(1), scale(1, 1)
{}

bool hasTexture() const {
return texture.hasTexture();
}
};

void GL_AssertContextActive();

/// Register the console commands, variables, etc..., of this module.
Expand Down
2 changes: 2 additions & 0 deletions doomsday/client/include/render/rend_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
// Multiplicative blending for dynamic lights?
#define IS_MUL (dynlightBlend != 1 && !usingFog)

struct rtexmapunit_t;

/**
* Types of render primitive supported by this module (polygons only).
*/
Expand Down
121 changes: 4 additions & 117 deletions doomsday/client/include/render/rendpoly.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,93 +22,17 @@
#ifndef DENG_RENDER_RENDPOLY_H
#define DENG_RENDER_RENDPOLY_H

#include "api_gl.h"
#include "color.h"

#include <de/vector1.h> /// @todo remove me.
#include <de/libdeng1.h>
#include <de/Vector>

#include "Texture"

/**
* Symbolic identifiers for (virtual) texture units.
*/
typedef enum {
RTU_PRIMARY = 0,
RTU_PRIMARY_DETAIL,
RTU_INTER,
RTU_INTER_DETAIL,
RTU_REFLECTION,
RTU_REFLECTION_MASK,
NUM_TEXMAP_UNITS
} rtexmapunitid_t;

/**
* @defgroup textureUnitFlags Texture Unit Flags
* @ingroup flags
*/
///@{
#define TUF_TEXTURE_IS_MANAGED 0x1 ///< A managed texture is bound to this unit.
///@}

typedef struct rtexmapunit_texture_s {
union {
struct {
DGLuint name; ///< Texture used on this layer (if any).
int magMode; ///< GL texture magnification filter.
int wrapS; ///< GL texture S axis wrap mode.
int wrapT; ///< GL texture T axis wrap mode.
} gl;
de::TextureVariant *variant;
};
/// @ref textureUnitFlags
int flags;
DENG_EXTERN_C byte rendInfoRPolys;

#ifdef __cplusplus
inline bool hasTexture() const
{
if(flags & TUF_TEXTURE_IS_MANAGED)
return variant && variant->glName() != 0;
return gl.name != 0;
}
#endif
} rtexmapunit_texture_t;

/**
* Texture unit state (POD).
*
* A simple Record data structure for storing properties used for
* configuring a GL texture unit during render.
*/
typedef struct rtexmapuint_s {
/// Info about the bound texture for this unit.
rtexmapunit_texture_t texture;

/// Currently used only with reflection.
blendmode_t blendMode;

/// Opacity of this layer [0..1].
float opacity;

/// Texture-space scale multiplier.
vec2f_t scale;

/// Texture-space origin translation (unscaled).
vec2f_t offset;

#ifdef __cplusplus
bool hasTexture() const { return texture.hasTexture(); }
#endif
} rtexmapunit_t;

extern byte rendInfoRPolys;

void R_PrintRendPoolInfo(void);
void R_PrintRendPoolInfo();

/**
* @note Should be called at the start of each map.
*/
void R_InitRendPolyPools(void);
void R_InitRendPolyPools();

/**
* Allocate a new contiguous range of position coordinates from the specialized
Expand Down Expand Up @@ -155,41 +79,4 @@ void R_FreeRendColors(de::Vector4f *colorCoords);
*/
void R_FreeRendTexCoords(de::Vector2f *texCoords);

/// Manipulators, for convenience.
void Rtu_Init(rtexmapunit_t *rtu);

boolean Rtu_HasTexture(rtexmapunit_t const *rtu);

/// Change the scale property.
void Rtu_SetScale(rtexmapunit_t *rtu, de::Vector2f const &st);

inline void Rtu_SetScale(rtexmapunit_t *rtu, float s, float t) {
Rtu_SetScale(rtu, de::Vector2f(s, t));
}

/**
* Multiply the offset and scale properties by @a scalar.
* @note @a scalar is applied to both scale and offset properties
* however the offset remains independent from scale (i.e., it is
* still considered "unscaled").
*/
void Rtu_Scale(rtexmapunit_t *rtu, float scalar);

void Rtu_ScaleST(rtexmapunit_t *rtu, de::Vector2f const &scaleST);

/// Change the offset property.
void Rtu_SetOffset(rtexmapunit_t *rtu, de::Vector2f const &st);

inline void Rtu_SetOffset(rtexmapunit_t *rtu, float s, float t) {
Rtu_SetOffset(rtu, de::Vector2f(s, t));
}

/// Translate the offset property.
void Rtu_TranslateOffset(rtexmapunit_t *rtu, de::Vector2f const &st);

inline void Rtu_TranslateOffset(rtexmapunit_t *rtu, float s, float t)
{
Rtu_TranslateOffset(rtu, de::Vector2f(s, t));
}

#endif // DENG_RENDER_RENDPOLY_H
4 changes: 3 additions & 1 deletion doomsday/client/include/resource/materialsnapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ enum {
NUM_MATERIAL_TEXTURE_UNITS
};

struct rtexmapunit_t;

namespace de {

/**
Expand Down Expand Up @@ -133,7 +135,7 @@ class MaterialSnapshot
* @param id Identifier of the texture unit to lookup.
* @return The associated prepared texture unit.
*/
rtexmapunit_t const &unit(rtexmapunitid_t id) const;
rtexmapunit_t const &unit(int index) const;

/**
* Lookup a material snapshot decoration by index.
Expand Down
2 changes: 2 additions & 0 deletions doomsday/client/src/client/cl_mobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#define DENG_NO_API_MACROS_CLIENT

#include <de/vector1.h>

#include "de_base.h"
#include "de_defs.h"
#include "de_system.h"
Expand Down
2 changes: 2 additions & 0 deletions doomsday/client/src/render/lumobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* 02110-1301 USA</small>
*/

#include <de/vector1.h>

#include "de_platform.h"
#include "de_console.h"
#include "de_render.h"
Expand Down
2 changes: 2 additions & 0 deletions doomsday/client/src/render/r_things.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* 02110-1301 USA</small>
*/

#include <de/vector1.h>

#include "de_platform.h"
#include "de_render.h"
#include "de_resource.h"
Expand Down
Loading

0 comments on commit 0912713

Please sign in to comment.