Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup: Move utility classes away from rendersystem.cpp/h
- Loading branch information
Showing
11 changed files
with
441 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** @file projectionlist.h Projection list. | ||
* | ||
* @authors Copyright © 2006-2015 Daniel Swanson <danij@dengine.net> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef DENG_CLIENT_RENDER_PROJECTIONLIST_H | ||
#define DENG_CLIENT_RENDER_PROJECTIONLIST_H | ||
|
||
#include "projectedtexturedata.h" | ||
|
||
struct ProjectionList | ||
{ | ||
struct Node | ||
{ | ||
Node *next, *nextUsed; | ||
ProjectedTextureData projection; | ||
}; | ||
|
||
Node *head = nullptr; | ||
bool sortByLuma; ///< @c true= Sort from brightest to darkest. | ||
|
||
static void init(); | ||
static void rewind(); | ||
|
||
inline ProjectionList &operator << (ProjectedTextureData &texp) { return add(texp); } | ||
|
||
ProjectionList &add(ProjectedTextureData &texp); | ||
|
||
private: | ||
static Node *firstNode; | ||
static Node *cursorNode; | ||
|
||
static Node *newNode(); | ||
}; | ||
|
||
#endif // DENG_CLIENT_RENDER_PROJECTIONLIST_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** @file store.h Store. | ||
* | ||
* @authors Copyright © 2003-2014 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* @authors Copyright © 2006-2015 Daniel Swanson <danij@dengine.net> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
#ifndef DENG_CLIENT_RENDER_STORE_H | ||
#define DENG_CLIENT_RENDER_STORE_H | ||
|
||
#include <de/Vector> | ||
|
||
/** | ||
* Geometry backing store (arrays). | ||
* @todo Replace with GLBuffer -ds | ||
*/ | ||
struct Store | ||
{ | ||
de::Vector3f *posCoords = nullptr; | ||
de::Vector4ub *colorCoords = nullptr; | ||
de::Vector2f *texCoords[2]; | ||
de::Vector2f *modCoords = nullptr; | ||
|
||
Store(); | ||
~Store(); | ||
|
||
void rewind(); | ||
|
||
void clear(); | ||
|
||
de::duint allocateVertices(de::duint count); | ||
|
||
private: | ||
de::duint _vertCount = 0; | ||
de::duint _vertMax = 0; | ||
}; | ||
|
||
#endif // DENG_CLIENT_RENDER_STORE_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** @file vectorlightlist.h Vector light list. | ||
* | ||
* @authors Copyright © 2006-2015 Daniel Swanson <danij@dengine.net> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef DENG_CLIENT_RENDER_VECTORLIGHTLIST_H | ||
#define DENG_CLIENT_RENDER_VECTORLIGHTLIST_H | ||
|
||
#include "render/vectorlightdata.h" | ||
|
||
struct VectorLightList | ||
{ | ||
struct Node | ||
{ | ||
Node *next, *nextUsed; | ||
VectorLightData vlight; | ||
}; | ||
|
||
Node *head = nullptr; | ||
|
||
static void init(); | ||
static void rewind(); | ||
|
||
inline VectorLightList &operator << (VectorLightData &texp) { return add(texp); } | ||
|
||
VectorLightList &add(VectorLightData &texp); | ||
|
||
private: | ||
static Node *firstNode; | ||
static Node *cursorNode; | ||
|
||
static Node *newNode(); | ||
}; | ||
|
||
#endif // DENG_CLIENT_RENDER_VECTORLIGHTLIST_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** @file projectionlist.cpp Projection list. | ||
* | ||
* @authors Copyright © 2006-2015 Daniel Swanson <danij@dengine.net> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#include "render/projectionlist.h" | ||
|
||
#include <de/memoryzone.h> | ||
|
||
ProjectionList::Node *ProjectionList::firstNode = nullptr; | ||
ProjectionList::Node *ProjectionList::cursorNode = nullptr; | ||
|
||
void ProjectionList::init() // static | ||
{ | ||
static bool firstTime = true; | ||
if(firstTime) | ||
{ | ||
firstNode = 0; | ||
cursorNode = 0; | ||
firstTime = false; | ||
} | ||
} | ||
|
||
void ProjectionList::rewind() // static | ||
{ | ||
// Start reusing nodes. | ||
cursorNode = firstNode; | ||
} | ||
|
||
/// Averaged-color * alpha. | ||
static dfloat luminosity(ProjectedTextureData const &pt) // static | ||
{ | ||
return (pt.color.x + pt.color.y + pt.color.z) / 3 * pt.color.w; | ||
} | ||
|
||
ProjectionList &ProjectionList::add(ProjectedTextureData &texp) | ||
{ | ||
Node *node = newNode(); | ||
node->projection = texp; | ||
|
||
if(head && sortByLuma) | ||
{ | ||
dfloat luma = luminosity(node->projection); | ||
Node *iter = head; | ||
Node *last = iter; | ||
do | ||
{ | ||
// Is this brighter than that being added? | ||
if(luminosity(iter->projection) > luma) | ||
{ | ||
last = iter; | ||
iter = iter->next; | ||
} | ||
else | ||
{ | ||
// Insert it here. | ||
node->next = last->next; | ||
last->next = node; | ||
return *this; | ||
} | ||
} while(iter); | ||
} | ||
|
||
node->next = head; | ||
head = node; | ||
|
||
return *this; | ||
} | ||
|
||
ProjectionList::Node *ProjectionList::newNode() // static | ||
{ | ||
Node *node; | ||
|
||
// Do we need to allocate more nodes? | ||
if(!cursorNode) | ||
{ | ||
node = (Node *) Z_Malloc(sizeof(*node), PU_APPSTATIC, nullptr); | ||
|
||
// Link the new node to the list. | ||
node->nextUsed = firstNode; | ||
firstNode = node; | ||
} | ||
else | ||
{ | ||
node = cursorNode; | ||
cursorNode = cursorNode->nextUsed; | ||
} | ||
|
||
node->next = nullptr; | ||
return node; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.