Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Nov 24, 2011
1 parent 5c78017 commit 3cea557
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 39 deletions.
23 changes: 11 additions & 12 deletions doomsday/engine/portable/include/rend_list.h
Expand Up @@ -96,13 +96,12 @@ void RL_DeleteLists(void);
void RL_LoadDefaultRtus(void);

/**
* Map the texture unit write state for the identified @a idx unit
* to @a rtu. This creates a reference to @a rtu which MUST contine
* to remain accessible until the mapping is subsequently cleared
* or changed (explicitly by call to RL_MapRtu/RL_LoadDefaultRtus,
* or, implicitly by customizing the unit configuration through one
* of the RL_RTU* family of functions (at which point a copy will
* be performed).
* Map the texture unit write state for the identified @a idx unit to
* @a rtu. This creates a reference to @a rtu which MUST continue to
* remain accessible until the mapping is subsequently cleared or
* changed (explicitly by call to RL_MapRtu/RL_LoadDefaultRtus, or,
* implicitly by customizing the unit configuration through one of the
* RL_RTU* family of functions (at which point a copy will be performed).
*/
void RL_MapRtu(uint idx, const rtexmapunit_t* rtu);

Expand All @@ -117,19 +116,19 @@ void RL_CopyRtu(uint idx, const rtexmapunit_t* rtu);

/// Change the scale property of the identified @a idx texture unit.
void RL_Rtu_SetScale(uint idx, float s, float t);
void RL_Rtu_SetScalev(uint idx, float st[2]);
void RL_Rtu_SetScalev(uint idx, float const st[2]);

/// Scale the offset and scale properties of the identified @a idx
/// Scale the offset and scale properties of the identified @a idx texture unit.
void RL_Rtu_Scale(uint idx, float scalar);
void RL_Rtu_ScaleST(uint idx, float st[2]);
void RL_Rtu_ScaleST(uint idx, float const st[2]);

/// Change the offset property of the identified @a idx texture unit.
void RL_Rtu_SetOffset(uint idx, float s, float t);
void RL_Rtu_SetOffsetv(uint idx, float st[2]);
void RL_Rtu_SetOffsetv(uint idx, float const st[2]);

/// Translate the offset property of the identified @a idx texture unit.
void RL_Rtu_TranslateOffset(uint idx, float s, float t);
void RL_Rtu_TranslateOffsetv(uint idx, float st[2]);
void RL_Rtu_TranslateOffsetv(uint idx, float const st[2]);

/// Change the texture assigned to the identified @idx texture unit.
void RL_Rtu_SetTexture(uint idx, DGLuint glName);
Expand Down
13 changes: 5 additions & 8 deletions doomsday/engine/portable/src/rend_list.c
Expand Up @@ -1041,7 +1041,7 @@ void RL_Rtu_SetScale(uint idx, float s, float t)
Rtu_SetScale(rtuState + idx, s, t);
}

void RL_Rtu_SetScalev(uint idx, float st[2])
void RL_Rtu_SetScalev(uint idx, float const st[2])
{
errorIfNotValidRTUIndex(idx, "RL_Rtu_SetScalev");
copyMappedRtuToState(idx);
Expand All @@ -1055,7 +1055,7 @@ void RL_Rtu_Scale(uint idx, float scalar)
Rtu_Scale(rtuState + idx, scalar);
}

void RL_Rtu_ScaleST(uint idx, float st[2])
void RL_Rtu_ScaleST(uint idx, float const st[2])
{
errorIfNotValidRTUIndex(idx, "RL_Rtu_ScaleST");
copyMappedRtuToState(idx);
Expand All @@ -1069,7 +1069,7 @@ void RL_Rtu_SetOffset(uint idx, float x, float y)
Rtu_SetOffset(rtuState + idx, x, y);
}

void RL_Rtu_SetOffsetv(uint idx, float xy[2])
void RL_Rtu_SetOffsetv(uint idx, float const xy[2])
{
errorIfNotValidRTUIndex(idx, "RL_Rtu_SetOffsetv");
copyMappedRtuToState(idx);
Expand All @@ -1083,7 +1083,7 @@ void RL_Rtu_TranslateOffset(uint idx, float x, float y)
Rtu_TranslateOffset(rtuState + idx, x, y);
}

void RL_Rtu_TranslateOffsetv(uint idx, float xy[2])
void RL_Rtu_TranslateOffsetv(uint idx, float const xy[2])
{
errorIfNotValidRTUIndex(idx, "RL_Rtu_TranslateOffsetv");
copyMappedRtuToState(idx);
Expand Down Expand Up @@ -1137,16 +1137,13 @@ void RL_AddPolyWithCoordsModulationReflection(primtype_t primType, int flags,
const rcolor_t* reflectionColors, const rtexcoord_t* reflectionCoords,
const rtexcoord_t* reflectionMaskCoords)
{
const rtexmapunit_t* rtuShiny;

prepareTextureUnitMap();
writePoly(primType, choosePolyType(flags), flags, numElements,
vertices, colors, primaryCoords, interCoords, modTex, modColor, modCoords);

// We are currently limited to two texture units, therefore shiny effects
// must be drawn in a separate pass using a new primitive.
rtuShiny = rtuMap[RTU_REFLECTION]? rtuMap[RTU_REFLECTION] : &rtuDefault;
if(!rtuShiny->tex) return;
if(!rtuMap[RTU_REFLECTION]->tex) return;

prepareTextureUnitMapForShinyPoly();
writePoly(primType, PT_SHINY, flags & ~RPF_HAS_DYNLIGHTS, numElements,
Expand Down
28 changes: 9 additions & 19 deletions doomsday/engine/portable/src/rend_main.c
Expand Up @@ -1472,21 +1472,18 @@ static boolean renderWorldPoly(rvertex_t* rvertices, uint numVertices,
RL_MapRtu(RTU_REFLECTION, shinyRTU);
RL_MapRtu(RTU_REFLECTION_MASK, shinyMaskRTU);

/// \todo Avoid modifying the RTU write state for the purposes of primitive
/// specific translations by implementing these as arguments to the RL_Add*
/// family of functions.
if(primaryRTU)
{
rtexmapunit_t rtu;
memcpy(&rtu, primaryRTU, sizeof rtu);
if(p->texOffset) Rtu_TranslateOffsetv(&rtu, p->texOffset);
if(p->texScale) Rtu_ScaleST(&rtu, p->texScale);
RL_CopyRtu(RTU_PRIMARY, &rtu);
if(p->texOffset) RL_Rtu_TranslateOffsetv(RTU_PRIMARY, p->texOffset);
if(p->texScale) RL_Rtu_ScaleST(RTU_PRIMARY, p->texScale);
}

if(primaryDetailRTU)
{
rtexmapunit_t rtu;
memcpy(&rtu, primaryDetailRTU, sizeof rtu);
if(p->texOffset) Rtu_TranslateOffsetv(&rtu, p->texOffset);
RL_CopyRtu(RTU_PRIMARY_DETAIL, &rtu);
if(p->texOffset) RL_Rtu_TranslateOffsetv(RTU_PRIMARY_DETAIL, p->texOffset);
}

if(interRTU)
Expand All @@ -1509,17 +1506,10 @@ static boolean renderWorldPoly(rvertex_t* rvertices, uint numVertices,
}
}

if(shinyRTU)
if(shinyMaskRTU)
{
RL_CopyRtu(RTU_REFLECTION, shinyRTU);
if(shinyMaskRTU)
{
rtexmapunit_t rtu;
memcpy(&rtu, shinyMaskRTU, sizeof rtu);
if(p->texOffset) Rtu_TranslateOffsetv(&rtu, p->texOffset);
if(p->texScale) Rtu_ScaleST(&rtu, p->texScale);
RL_CopyRtu(RTU_REFLECTION_MASK, &rtu);
}
if(p->texOffset) RL_Rtu_TranslateOffsetv(RTU_REFLECTION_MASK, p->texOffset);
if(p->texScale) RL_Rtu_ScaleST(RTU_REFLECTION_MASK, p->texScale);
}

// Write multiple polys depending on rend params.
Expand Down

0 comments on commit 3cea557

Please sign in to comment.