1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-25 09:44:02 +00:00

remove displaylist support

i'd rather trim all possible fat off the renderer and then modularize it
into multiple backends. gotta start somewhere.
This commit is contained in:
fgenesis 2022-05-18 03:39:33 +02:00
parent c528a6186f
commit 4db7990ac2
9 changed files with 2 additions and 192 deletions

View file

@ -44,8 +44,6 @@ Element::Element() : Quad()
bgLayer = 0;
templateIdx = -1;
eff = NULL;
setStatic(true);
}
void Element::ensureEffectData()
@ -248,14 +246,12 @@ void Element::setElementEffectByIndex(int eidx)
case EFX_SEGS:
{
setSegs(e.segsx, e.segsy, e.segs_dgox, e.segs_dgoy, e.segs_dgmx, e.segs_dgmy, e.segs_dgtm, e.segs_dgo);
setStatic(false);
}
break;
case EFX_ALPHA:
{
setBlendType(e.blendType);
alpha = e.alpha;
setStatic(false);
}
break;
case EFX_WAVY:
@ -273,12 +269,10 @@ void Element::setElementEffectByIndex(int eidx)
createGrid(2, e.segsy);
setGridFromWavy();
setStatic(false);
}
break;
default:
freeEffectData();
setStatic(true);
break;
}

View file

@ -1994,12 +1994,6 @@ bool Game::loadSceneXML(std::string scene)
this->reconstructGrid(true);
rebuildElementUpdateList();
setElementLayerFlags();
// HACK: Don't try to optimize the barrier layer in Mithalas Cathedral
// since elements are turned off dynamically.
if (nocasecmp(scene, "cathedral02") == 0)
dsq->getRenderObjectLayer(LR_ELEMENTS3)->setOptimizeStatic(false);
findMaxCameraValues();
@ -2483,19 +2477,6 @@ void Game::rebuildElementUpdateList()
}
}
void Game::setElementLayerFlags()
{
for (int i = LR_ELEMENTS1; i <= LR_ELEMENTS16; i++)
{
// FIXME: Background SchoolFish get added to ELEMENTS11, so
// we can't optimize that layer. (Maybe create a new layer?)
if (i == LR_ELEMENTS11)
continue;
dsq->getRenderObjectLayer(i)->setOptimizeStatic(!isSceneEditorActive() && dsq->user.video.displaylists);
}
}
float Game::getTimer(float mod)
{
return timer*mod;
@ -4128,7 +4109,6 @@ void Game::toggleSceneEditor()
if (!core->getAltState())
{
sceneEditor.toggle();
setElementLayerFlags();
}
}

View file

@ -386,7 +386,6 @@ public:
void ensureLimit(Entity *e, int num, int state=0);
void rebuildElementUpdateList();
void setElementLayerFlags();
float getTimer(float mod=1);
float getHalfTimer(float mod=1);

View file

@ -138,7 +138,6 @@ void UserSettings::save()
xml_screenMode->SetAttribute("vsync", video.vsync);
xml_screenMode->SetAttribute("darkfbuffer", video.darkfbuffer);
xml_screenMode->SetAttribute("darkbuffersize", video.darkbuffersize);
xml_screenMode->SetAttribute("displaylists", video.displaylists);
xml_screenMode->SetAttribute("displayindex", video.displayindex);
}
xml_video->InsertEndChild(xml_screenMode);
@ -455,7 +454,6 @@ void UserSettings::load(bool doApply, const std::string &overrideFile)
xml_screenMode->QueryIntAttribute("vsync", &video.vsync);
xml_screenMode->QueryIntAttribute("darkfbuffer", &video.darkfbuffer);
xml_screenMode->QueryIntAttribute("darkbuffersize", &video.darkbuffersize);
xml_screenMode->QueryIntAttribute("displaylists", &video.displaylists);
xml_screenMode->QueryIntAttribute("displayindex", &video.displayindex);
}

View file

@ -73,7 +73,6 @@ public:
bits = 32;
vsync = 1;
darkbuffersize = 256;
displaylists = 0;
worldMapRevealMethod = 0;
}
int blur;
@ -83,7 +82,6 @@ public:
int saveSlotScreens;
int parallaxOn0, parallaxOn1, parallaxOn2;
int numParticles;
int displaylists;
int worldMapRevealMethod;
} video;

View file

@ -120,8 +120,6 @@ public:
void moveToFront(RenderObject *r);
void moveToBack(RenderObject *r);
void setCull(bool cull);
void setOptimizeStatic(bool opt);
void sort();
void renderPass(int pass);
void reloadDevice();
@ -170,24 +168,8 @@ public:
Vector color;
protected:
void clearDisplayList();
void generateDisplayList();
inline void renderOneObject(RenderObject *robj);
bool optimizeStatic;
bool displayListValid;
int displayListGeneration;
struct DisplayListElement {
DisplayListElement() {isList = false; u.robj = 0;}
bool isList; // True if this is a GL display list
union {
RenderObject *robj;
unsigned listID;
} u;
};
std::vector<DisplayListElement> displayList;
RenderObjects renderObjects;
size_t objectCount;
size_t firstFreeIdx;

View file

@ -163,7 +163,6 @@ RenderObject::RenderObject()
decayRate = 0;
_dead = false;
_hidden = false;
_static = false;
fadeAlphaWithLife = false;
blendType = BLEND_DEFAULT;

View file

@ -96,19 +96,12 @@ public:
virtual void update(float dt);
bool isDead() const {return _dead;}
bool isHidden() const {return _hidden || (parent && parent->isHidden());}
bool isStatic() const {return _static;}
// Set whether the object is hidden. If hidden, no updates (except
// lifetime checks) or render operations will be performed, and no
// child objects will be updated or rendered.
void setHidden(bool hidden) {_hidden = hidden;}
// Set whether the object is static. If static, the object's data
// (including position, scale, rotation, color, etc.) are assumed
// not to change over the lifetime of the object, to allow for
// optimized rendering.
void setStatic(bool staticFlag) {_static = staticFlag;}
void setLife(float newlife)
{
maxLife = this->life = newlife;
@ -316,7 +309,6 @@ protected:
bool _dead;
bool _hidden;
bool _static;
bool _fv, _fh;
size_t idx;

View file

@ -32,12 +32,9 @@ RenderObjectLayer::RenderObjectLayer()
followCameraLock = FCL_NONE;
cull = true;
update = true;
optimizeStatic = false;
color = Vector(1,1,1);
displayListValid = false;
const int size = renderObjects.size();
for (int i = 0; i < size; i++)
renderObjects[i] = 0;
@ -47,7 +44,6 @@ RenderObjectLayer::RenderObjectLayer()
RenderObjectLayer::~RenderObjectLayer()
{
clearDisplayList();
}
void RenderObjectLayer::setCull(bool cull)
@ -55,12 +51,6 @@ void RenderObjectLayer::setCull(bool cull)
this->cull = cull;
}
void RenderObjectLayer::setOptimizeStatic(bool opt)
{
this->optimizeStatic = opt;
clearDisplayList();
}
void RenderObjectLayer::add(RenderObject* r)
{
size_t size = renderObjects.size();
@ -79,8 +69,6 @@ void RenderObjectLayer::add(RenderObject* r)
if (!renderObjects[firstFreeIdx])
break;
}
clearDisplayList();
}
void RenderObjectLayer::remove(RenderObject* r)
@ -101,8 +89,6 @@ void RenderObjectLayer::remove(RenderObject* r)
if (idx < firstFreeIdx)
firstFreeIdx = idx;
r->setIdx(-1);
clearDisplayList();
}
void RenderObjectLayer::moveToFront(RenderObject *r)
@ -164,8 +150,6 @@ void RenderObjectLayer::moveToFront(RenderObject *r)
while (renderObjects[firstFreeIdx])
firstFreeIdx++;
}
clearDisplayList();
}
void RenderObjectLayer::moveToBack(RenderObject *r)
@ -232,139 +216,23 @@ void RenderObjectLayer::moveToBack(RenderObject *r)
break;
}
}
clearDisplayList();
}
void RenderObjectLayer::renderPass(int pass)
{
core->currentLayerPass = pass;
if (optimizeStatic && (followCamera == 0 || followCamera == NO_FOLLOW_CAMERA))
{
if (!displayListValid)
generateDisplayList();
const int size = displayList.size();
for (int i = 0; i < size; i++)
{
if (displayList[i].isList)
{
glCallList(displayList[i].u.listID);
RenderObject::lastTextureApplied = 0;
}
else
renderOneObject(displayList[i].u.robj);
}
}
else
for (RenderObject *robj = getFirst(); robj; robj = getNext())
{
for (RenderObject *robj = getFirst(); robj; robj = getNext())
{
renderOneObject(robj);
}
renderOneObject(robj);
}
}
void RenderObjectLayer::reloadDevice()
{
if (displayListValid)
clearDisplayList();
}
void RenderObjectLayer::clearDisplayList()
{
if (!displayListValid)
return;
const int size = displayList.size();
for (int i = 0; i < size; i++)
{
if (displayList[i].isList)
glDeleteLists(displayList[i].u.listID, 1);
}
displayList.resize(0);
displayListValid = false;
}
void RenderObjectLayer::generateDisplayList()
{
// Temporarily disable culling so all static objects are entered into
// the display list.
bool savedCull = this->cull;
this->cull = false;
int listSize = 0, listLength = 0;
bool lastWasStatic = false;
for (RenderObject *robj = getFirst(); robj; robj = getNext())
{
if (listLength >= listSize)
{
listSize += 100;
displayList.resize(listSize);
}
bool addEntry = true; // Add an entry for this robj?
if (robj->isStatic() && robj->followCamera == 0)
{
if (lastWasStatic)
{
addEntry = false;
}
else
{
int listID = glGenLists(1);
if (listID != 0)
{
(void) glGetError(); // Clear error state
glNewList(listID, GL_COMPILE);
if (glGetError() == GL_NO_ERROR)
{
displayList[listLength].isList = true;
displayList[listLength].u.listID = listID;
listLength++;
lastWasStatic = true;
addEntry = false;
RenderObject::lastTextureApplied = 0;
}
else
debugLog("glNewList failed");
}
else
debugLog("glGenLists failed");
}
}
else
{
if (lastWasStatic)
{
glEndList();
lastWasStatic = false;
}
}
if (addEntry)
{
displayList[listLength].isList = false;
displayList[listLength].u.robj = robj;
listLength++;
}
else
{
renderOneObject(robj);
}
}
if (lastWasStatic)
{
glEndList();
}
displayList.resize(listLength);
displayListValid = true;
this->cull = savedCull;
}
inline void RenderObjectLayer::renderOneObject(RenderObject *robj)
{