From 4db7990ac23fb346b3aa51b1a6089c919f02ff2b Mon Sep 17 00:00:00 2001 From: fgenesis Date: Wed, 18 May 2022 03:39:33 +0200 Subject: [PATCH] remove displaylist support i'd rather trim all possible fat off the renderer and then modularize it into multiple backends. gotta start somewhere. --- Aquaria/Element.cpp | 6 -- Aquaria/Game.cpp | 20 ------ Aquaria/Game.h | 1 - Aquaria/UserSettings.cpp | 2 - Aquaria/UserSettings.h | 2 - BBGE/Core.h | 18 ----- BBGE/RenderObject.cpp | 1 - BBGE/RenderObject.h | 8 --- BBGE/RenderObjectLayer.cpp | 136 +------------------------------------ 9 files changed, 2 insertions(+), 192 deletions(-) diff --git a/Aquaria/Element.cpp b/Aquaria/Element.cpp index 5764da4..00ad9ca 100644 --- a/Aquaria/Element.cpp +++ b/Aquaria/Element.cpp @@ -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; } diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index b2189d7..f779c04 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -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(); } } diff --git a/Aquaria/Game.h b/Aquaria/Game.h index e91b688..8c6be4b 100644 --- a/Aquaria/Game.h +++ b/Aquaria/Game.h @@ -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); diff --git a/Aquaria/UserSettings.cpp b/Aquaria/UserSettings.cpp index a6ff2ec..b3c5084 100644 --- a/Aquaria/UserSettings.cpp +++ b/Aquaria/UserSettings.cpp @@ -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); } diff --git a/Aquaria/UserSettings.h b/Aquaria/UserSettings.h index 01d9e29..2909dae 100644 --- a/Aquaria/UserSettings.h +++ b/Aquaria/UserSettings.h @@ -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; diff --git a/BBGE/Core.h b/BBGE/Core.h index 68add58..71d66b5 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -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 displayList; - RenderObjects renderObjects; size_t objectCount; size_t firstFreeIdx; diff --git a/BBGE/RenderObject.cpp b/BBGE/RenderObject.cpp index b8cff8b..e53449d 100644 --- a/BBGE/RenderObject.cpp +++ b/BBGE/RenderObject.cpp @@ -163,7 +163,6 @@ RenderObject::RenderObject() decayRate = 0; _dead = false; _hidden = false; - _static = false; fadeAlphaWithLife = false; blendType = BLEND_DEFAULT; diff --git a/BBGE/RenderObject.h b/BBGE/RenderObject.h index 29c4e3b..3f7bce7 100644 --- a/BBGE/RenderObject.h +++ b/BBGE/RenderObject.h @@ -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; diff --git a/BBGE/RenderObjectLayer.cpp b/BBGE/RenderObjectLayer.cpp index 858fda3..567dcb2 100644 --- a/BBGE/RenderObjectLayer.cpp +++ b/BBGE/RenderObjectLayer.cpp @@ -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) {