diff --git a/Aquaria/AnimationEditor.cpp b/Aquaria/AnimationEditor.cpp index f7e9e99..dd76efb 100644 --- a/Aquaria/AnimationEditor.cpp +++ b/Aquaria/AnimationEditor.cpp @@ -35,7 +35,7 @@ const int KEYFRAME_POS_Y = 570; class TimelineRender : public RenderObject { - void onRender() + void onRender() const OVERRIDE { glLineWidth(1); glBegin(GL_LINES); diff --git a/Aquaria/Avatar.cpp b/Aquaria/Avatar.cpp index 0aa7d9b..2231054 100644 --- a/Aquaria/Avatar.cpp +++ b/Aquaria/Avatar.cpp @@ -4447,7 +4447,7 @@ void Avatar::doShieldSong() activateAura(AURA_SHIELD); } -void Avatar::render() +void Avatar::render() const { if (dsq->continuity.form == FORM_SPIRIT && !skeletalSprite.getParent()) @@ -4462,11 +4462,6 @@ void Avatar::render() } -void Avatar::onRender() -{ - Entity::onRender(); -} - void Avatar::onEnterState(int action) { Entity::onEnterState(action); diff --git a/Aquaria/Avatar.h b/Aquaria/Avatar.h index 2617bd8..c7295ec 100644 --- a/Aquaria/Avatar.h +++ b/Aquaria/Avatar.h @@ -211,7 +211,7 @@ public: float biteDelay, urchinDelay, jellyDelay; bool movingOn; - void render(); + void render() const OVERRIDE; void activateAura(AuraType aura); void stopAura(); void setHeadTexture(const std::string &name, float t=0); @@ -434,7 +434,6 @@ protected: void onUpdate(float dt); - void onRender(); Quad *glow; bool swimming; diff --git a/Aquaria/Beam.cpp b/Aquaria/Beam.cpp index ebca410..83f8753 100644 --- a/Aquaria/Beam.cpp +++ b/Aquaria/Beam.cpp @@ -105,7 +105,7 @@ void Beam::trace() } -void Beam::onRender() +void Beam::onRender() const { Vector diff = endPos - position; diff --git a/Aquaria/Beam.h b/Aquaria/Beam.h index 64eda45..a163f40 100644 --- a/Aquaria/Beam.h +++ b/Aquaria/Beam.h @@ -27,7 +27,7 @@ public: void setBeamWidth(float w); protected: float beamWidth; - void onRender(); + void onRender() const OVERRIDE; void onEndOfLife(); void onUpdate(float dt); }; diff --git a/Aquaria/CurrentRender.cpp b/Aquaria/CurrentRender.cpp index 7a5b0ec..e97fa70 100644 --- a/Aquaria/CurrentRender.cpp +++ b/Aquaria/CurrentRender.cpp @@ -34,15 +34,7 @@ CurrentRender::CurrentRender() : RenderObject() rippleDelay = 2; } -void CurrentRender::onUpdate(float dt) -{ - RenderObject::onUpdate(dt); - - - -} - -void CurrentRender::onRender() +void CurrentRender::onRender() const { // note: Leave cull_face disabled!? //glDisable(GL_CULL_FACE); diff --git a/Aquaria/Element.cpp b/Aquaria/Element.cpp index 1e24746..0bb0503 100644 --- a/Aquaria/Element.cpp +++ b/Aquaria/Element.cpp @@ -283,7 +283,7 @@ void Element::setElementEffectByIndex(int eidx) } } -void Element::render() +void Element::render() const { if (!elementActive) return; if (dsq->game->isSceneEditorActive() && this->bgLayer == dsq->game->sceneEditor.bgLayer diff --git a/Aquaria/Element.h b/Aquaria/Element.h index 267bb7a..6097e70 100644 --- a/Aquaria/Element.h +++ b/Aquaria/Element.h @@ -66,7 +66,7 @@ public: size_t templateIdx; int bgLayer; Element *bgLayerNext; - void render(); + void render() const OVERRIDE; ElementFlag elementFlag; void fillGrid(); bool isElementActive() { return elementActive; } diff --git a/Aquaria/Entity.cpp b/Aquaria/Entity.cpp index 4fed3cb..961b97c 100644 --- a/Aquaria/Entity.cpp +++ b/Aquaria/Entity.cpp @@ -2474,7 +2474,7 @@ void Entity::doEntityAvoidance(float dt, int range, float mod, Entity *ignore) } } -void Entity::render() +void Entity::render() const { InterpolatedVector bcolor = color; InterpolatedVector bscale = scale; diff --git a/Aquaria/Entity.h b/Aquaria/Entity.h index faae225..4444bce 100644 --- a/Aquaria/Entity.h +++ b/Aquaria/Entity.h @@ -73,7 +73,7 @@ public: Vector vel; InterpolatedVector vel2; float activationRadius; - void render(); + void render() const OVERRIDE; void update(float dt); void spawnParticlesFromCollisionMask(const char *p, unsigned intv=1, int layer = LR_PARTICLES, float rotz = 0); diff --git a/Aquaria/GridRender.cpp b/Aquaria/GridRender.cpp index d58632f..06fd110 100644 --- a/Aquaria/GridRender.cpp +++ b/Aquaria/GridRender.cpp @@ -53,7 +53,7 @@ inline static void doRenderGrid(int x, int startCol, int endCol) } -void GridRender::onRender() +void GridRender::onRender() const { const signed char obsType = this->obsType; Vector camPos = core->cameraPos; @@ -145,7 +145,7 @@ void SongLineRender::clear() pts.clear(); } -void SongLineRender::onRender() +void SongLineRender::onRender() const { int w=core->getWindowWidth(); diff --git a/Aquaria/GridRender.h b/Aquaria/GridRender.h index 7e6d206..dba63ec 100644 --- a/Aquaria/GridRender.h +++ b/Aquaria/GridRender.h @@ -39,7 +39,7 @@ public: protected: ObsType obsType; void onUpdate(float dt); - void onRender(); + void onRender() const OVERRIDE; }; class MiniMapRender : public RenderObject @@ -67,8 +67,8 @@ protected: bool doRender; float lightLevel; void onUpdate(float dt); - void onRender(); - void renderIcon(MinimapIcon *ico, const Vector& pos); + void onRender() const OVERRIDE; + void renderIcon(const MinimapIcon *ico, const Vector& pos) const; InterpolatedVector lerp; @@ -115,7 +115,6 @@ protected: void clearVis(WorldMapTile *tile); bool on; void onUpdate(float dt); - void onRender(); Quad *bg; unsigned char *savedTexData; bool mb; @@ -128,7 +127,7 @@ class PathRender : public RenderObject public: PathRender(); protected: - void onRender(); + void onRender() const OVERRIDE; }; class CurrentRender : public RenderObject @@ -137,8 +136,7 @@ public: CurrentRender(); protected: float rippleDelay; - void onUpdate(float dt); - void onRender(); + void onRender() const OVERRIDE; }; class SteamRender : public RenderObject @@ -147,8 +145,7 @@ public: SteamRender(); protected: float rippleDelay; - void onUpdate(float dt); - void onRender(); + void onRender() const OVERRIDE; }; struct SongLinePoint @@ -164,7 +161,7 @@ public: void newPoint(const Vector &pt, const Vector &color); void clear(); protected: - void onRender(); + void onRender() const OVERRIDE; std::vector pts; }; diff --git a/Aquaria/Hair.cpp b/Aquaria/Hair.cpp index 4c658f3..d45ab89 100644 --- a/Aquaria/Hair.cpp +++ b/Aquaria/Hair.cpp @@ -73,7 +73,7 @@ HairNode *Hair::getHairNode(int idx) return h; } -void Hair::onRender() +void Hair::onRender() const { diff --git a/Aquaria/Hair.h b/Aquaria/Hair.h index 2bb495f..3904774 100644 --- a/Aquaria/Hair.h +++ b/Aquaria/Hair.h @@ -56,7 +56,7 @@ public: protected: float segmentLength; void onUpdate(float dt); - void onRender(); + void onRender() const OVERRIDE; }; #endif diff --git a/Aquaria/Intro.cpp b/Aquaria/Intro.cpp index 4153496..f8c563f 100644 --- a/Aquaria/Intro.cpp +++ b/Aquaria/Intro.cpp @@ -26,43 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "SkeletalSprite.h" -//class Mappy; -namespace IntroStuff -{ - //Mappy *m; - bool quitFlag; -} - -using namespace IntroStuff; - -/* -class Mappy : public RenderObject, public ActionMapper -{ -public: - Mappy() : RenderObject(), ActionMapper() {} - void render() {} - //bool isOnScreen() { return false; } - void action(int id, int state) - { - ActionMapper::action(id, state); - if (!quitFlag) - { - if (state) - { - quitFlag = true; - dsq->quitNestedMain(); - } - } - } -protected: - void onUpdate(float dt) - { - ActionMapper::onUpdate(dt); - RenderObject::onUpdate(dt); - } -}; -*/ Intro::Intro() : StateObject() { @@ -71,8 +35,6 @@ Intro::Intro() : StateObject() void Intro::applyState() { - quitFlag = false; - dsq->jiggleCursor(); dsq->cursor->alpha = 0; //core->sound->streamOgg("sc/theme", 0); @@ -97,8 +59,6 @@ void Intro::removeState() void Intro::endIntro() { - quitFlag = true; - dsq->overlay->color.stop(); dsq->overlay->alpha.stop(); diff --git a/Aquaria/MiniMapRender.cpp b/Aquaria/MiniMapRender.cpp index 12d7f2f..2569374 100644 --- a/Aquaria/MiniMapRender.cpp +++ b/Aquaria/MiniMapRender.cpp @@ -474,7 +474,7 @@ void MiniMapRender::onUpdate(float dt) toggleOn && dsq->game->avatar && dsq->game->avatar->getState() != Entity::STATE_TITLE && !(dsq->disableMiniMapOnNoInput && !dsq->game->avatar->isInputEnabled()); } -void MiniMapRender::onRender() +void MiniMapRender::onRender() const { glBindTexture(GL_TEXTURE_2D, 0); @@ -499,9 +499,6 @@ void MiniMapRender::onRender() glVertex2f(-miniMapGuiSize, -miniMapGuiSize); glEnd(); - texMinimapBtm->unbind(); - - if (lightLevel > 0) { texWaterBit->apply(); @@ -587,10 +584,7 @@ void MiniMapRender::onRender() } } } - texWaterBit->unbind(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBindTexture(GL_TEXTURE_2D, 0); - } } @@ -642,9 +636,6 @@ void MiniMapRender::onRender() glVertex2f(-hsz, -hsz); glEnd(); - texNaija->unbind(); - glBindTexture(GL_TEXTURE_2D, 0); - glColor4f(1,1,1,1); texMinimapTop->apply(); @@ -658,10 +649,6 @@ void MiniMapRender::onRender() glTexCoord2f(0, 0); glVertex2f(-miniMapGuiSize, -miniMapGuiSize); glEnd(); - texMinimapTop->unbind(); - - glBindTexture(GL_TEXTURE_2D, 0); - const int curHealthSteps = int((lerp.x/2) * healthSteps); const int maxHealthSteps = int((dsq->game->avatar->maxHealth/10.0f) * healthSteps); @@ -731,8 +718,6 @@ void MiniMapRender::onRender() } glEnd(); - texHealthBar->unbind(); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1,1,1,1); @@ -752,17 +737,12 @@ void MiniMapRender::onRender() glVertex2f(x-healthMarkerSize, y-healthMarkerSize); glEnd(); - texMarker->unbind(); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1,1,1,1); - - glBindTexture(GL_TEXTURE_2D, 0); - } -void MiniMapRender::renderIcon(MinimapIcon *ico, const Vector& pos) +void MiniMapRender::renderIcon(const MinimapIcon *ico, const Vector& pos) const { if(!ico->tex) return; diff --git a/Aquaria/PathRender.cpp b/Aquaria/PathRender.cpp index d24473d..a58a0e7 100644 --- a/Aquaria/PathRender.cpp +++ b/Aquaria/PathRender.cpp @@ -30,7 +30,7 @@ PathRender::PathRender() : RenderObject() alpha = 0.5f; } -void PathRender::onRender() +void PathRender::onRender() const { const size_t pathcount = dsq->game->getNumPaths(); if (pathcount == 0) diff --git a/Aquaria/SchoolFish.cpp b/Aquaria/SchoolFish.cpp index a3f2b59..2fe70e9 100644 --- a/Aquaria/SchoolFish.cpp +++ b/Aquaria/SchoolFish.cpp @@ -441,10 +441,3 @@ void SchoolFish::onUpdate(float dt) } } - -void SchoolFish::onRender() -{ - FlockEntity::onRender(); - -} - diff --git a/Aquaria/SchoolFish.h b/Aquaria/SchoolFish.h index f133fe1..db702ca 100644 --- a/Aquaria/SchoolFish.h +++ b/Aquaria/SchoolFish.h @@ -45,7 +45,6 @@ protected: void onEnterState(int action); void onUpdate(float dt); - void onRender(); float avoidTime; diff --git a/Aquaria/Segmented.h b/Aquaria/Segmented.h index 31b90ca..20dad2b 100644 --- a/Aquaria/Segmented.h +++ b/Aquaria/Segmented.h @@ -51,7 +51,7 @@ public: void destroy(); protected: void onUpdate(float dt); - void onRender(); + void onRender() const OVERRIDE; }; #endif diff --git a/Aquaria/SteamRender.cpp b/Aquaria/SteamRender.cpp index 482017c..aac52ec 100644 --- a/Aquaria/SteamRender.cpp +++ b/Aquaria/SteamRender.cpp @@ -34,12 +34,7 @@ SteamRender::SteamRender() : RenderObject() setBlendType(BLEND_ADD); } -void SteamRender::onUpdate(float dt) -{ - RenderObject::onUpdate(dt); -} - -void SteamRender::onRender() +void SteamRender::onRender() const { diff --git a/Aquaria/Strand.cpp b/Aquaria/Strand.cpp index c22e56d..0643429 100644 --- a/Aquaria/Strand.cpp +++ b/Aquaria/Strand.cpp @@ -49,7 +49,7 @@ void Strand::onUpdate(float dt) updateSegments(position); } -void Strand::onRender() +void Strand::onRender() const { const int numSegments = segments.size(); if (numSegments == 0) return; diff --git a/Aquaria/ToolTip.cpp b/Aquaria/ToolTip.cpp index 60e14e5..560d877 100644 --- a/Aquaria/ToolTip.cpp +++ b/Aquaria/ToolTip.cpp @@ -129,7 +129,7 @@ void ToolTip::onUpdate(float dt) } } -void ToolTip::render() +void ToolTip::render() const { if (!game->getInGameMenu()->recipeMenu.on && toolTipsOn) { diff --git a/Aquaria/ToolTip.h b/Aquaria/ToolTip.h index 73095ed..ec1d6e4 100644 --- a/Aquaria/ToolTip.h +++ b/Aquaria/ToolTip.h @@ -35,14 +35,14 @@ public: void setAreaFromCenter(const Vector ¢er, int width, int height); void setCircularAreaFromCenter(const Vector ¢er, int diameter); - void render(); + void render() const OVERRIDE; static bool toolTipsOn; bool required; protected: - void onUpdate(float dt); + void onUpdate(float dt) OVERRIDE; int areaType; Vector areaCenter; diff --git a/Aquaria/WaterSurfaceRender.cpp b/Aquaria/WaterSurfaceRender.cpp index 85687e8..7bdc475 100644 --- a/Aquaria/WaterSurfaceRender.cpp +++ b/Aquaria/WaterSurfaceRender.cpp @@ -46,10 +46,8 @@ WaterSurfaceRender::WaterSurfaceRender() : Quad() shareAlphaWithChildren = 0; } -void WaterSurfaceRender::render() +void WaterSurfaceRender::onUpdate(float dt) { - - if (dsq->game->waterLevel.x > 0) { @@ -100,20 +98,9 @@ void WaterSurfaceRender::render() if (dsq->useFrameBuffer && dsq->frameBuffer.isInited()) { qSurface->alphaMod = 0.5; - Quad::render(); - } - else - { - - Quad::render(); - - - - } - - + Quad::render(); } else { @@ -124,25 +111,12 @@ void WaterSurfaceRender::render() qLine2->alpha = 0; } } -} - -void WaterSurfaceRender::onRender() -{ - if (dsq->game->waterLevel == 0) return; - if (dsq->useFrameBuffer && dsq->frameBuffer.isInited()) - { - dsq->frameBuffer.bindTexture(); - } - else - { - glBindTexture(GL_TEXTURE_2D, 0); - } if (dsq->useFrameBuffer && dsq->frameBuffer.isInited()) { const float reflectSize = 97; const float reflectPos = (dsq->game->waterLevel.x - core->cameraPos.y) - + (dsq->game->waterLevel.x - core->screenCenter.y) / 3; + + (dsq->game->waterLevel.x - core->screenCenter.y) / 3; const float reflectOffset = -0.03f; const float coordDiv = 768; const float v0 = 1 + reflectOffset - (reflectPos * core->globalScale.x) / coordDiv; @@ -153,25 +127,31 @@ void WaterSurfaceRender::onRender() upperLeftTextureCoordinates.x = 0; lowerRightTextureCoordinates.x = core->frameBuffer.getWidthP(); + } +} +void WaterSurfaceRender::render() const +{ + if (dsq->game->waterLevel.x > 0) + Quad::render(); +} - Quad::onRender(); - - - - glBindTexture(GL_TEXTURE_2D, 0); +void WaterSurfaceRender::onRender() const +{ + if (dsq->game->waterLevel == 0) return; + if (dsq->useFrameBuffer && dsq->frameBuffer.isInited()) + { + dsq->frameBuffer.bindTexture(); } else { - - glColor4f(0.4f, 0.7f, 0.8f, 0.2f); - Quad::onRender(); - glBindTexture(GL_TEXTURE_2D, 0); + glColor4f(0.4f, 0.7f, 0.8f, 0.2f); } - RenderObject::lastTextureApplied = 0; - + Quad::onRender(); + glBindTexture(GL_TEXTURE_2D, 0); + RenderObject::lastTextureApplied = 0; } diff --git a/Aquaria/WaterSurfaceRender.h b/Aquaria/WaterSurfaceRender.h index e01f7fc..819e0a3 100644 --- a/Aquaria/WaterSurfaceRender.h +++ b/Aquaria/WaterSurfaceRender.h @@ -27,10 +27,11 @@ class WaterSurfaceRender : public Quad { public: WaterSurfaceRender(); - void render(); + void render() const OVERRIDE; protected: Quad *qSurface, *qLine, *qLine2; - void onRender(); + void onRender() const OVERRIDE; + void onUpdate(float dt) OVERRIDE; }; #endif diff --git a/Aquaria/Web.cpp b/Aquaria/Web.cpp index 3de52fa..18010d5 100644 --- a/Aquaria/Web.cpp +++ b/Aquaria/Web.cpp @@ -135,7 +135,7 @@ void Web::onUpdate(float dt) } } -void Web::onRender() +void Web::onRender() const { glBindTexture(GL_TEXTURE_2D, 0); diff --git a/Aquaria/Web.h b/Aquaria/Web.h index c7d38a8..365b4fa 100644 --- a/Aquaria/Web.h +++ b/Aquaria/Web.h @@ -44,7 +44,7 @@ protected: void onEndOfLife(); std::vector points; void onUpdate(float dt); - void onRender(); + void onRender() const OVERRIDE; }; #endif diff --git a/Aquaria/WorldMapRender.cpp b/Aquaria/WorldMapRender.cpp index fb5e7de..5228089 100644 --- a/Aquaria/WorldMapRender.cpp +++ b/Aquaria/WorldMapRender.cpp @@ -110,16 +110,12 @@ public: followCamera = 1; } - void render() - { - setProperPosition(); - Quad::render(); - } - protected: Vector truePosition; - void setProperPosition() + void onUpdate(float dt) OVERRIDE { + Quad::onUpdate(dt); + Vector wp = parent->getWorldCollidePosition(truePosition); Vector diff = wp - core->center; @@ -177,12 +173,6 @@ public: float spawnBitTimer; - void render() - { - - Quad::render(); - } - protected: BeaconData *beaconData; @@ -1241,11 +1231,6 @@ Vector WorldMapRender::getWorldToTile(WorldMapTile *tile, Vector position, bool return p; } -void WorldMapRender::onRender() -{ - RenderObject::onRender(); -} - bool WorldMapRender::isOn() { return this->on; diff --git a/BBGE/AfterEffect.cpp b/BBGE/AfterEffect.cpp index 2e4a926..1a0e5e7 100644 --- a/BBGE/AfterEffect.cpp +++ b/BBGE/AfterEffect.cpp @@ -168,7 +168,7 @@ void AfterEffectManager::destroyEffect(int id) openSpots.push_back(id); } -void AfterEffectManager::render() +void AfterEffectManager::render() const { assert(core->frameBuffer.isInited()); @@ -187,7 +187,7 @@ void AfterEffectManager::render() glPopMatrix(); } -void AfterEffectManager::renderGrid() +void AfterEffectManager::renderGrid() const { int firstShader = -1; @@ -206,9 +206,6 @@ void AfterEffectManager::renderGrid() } } - screenWidth = core->getWindowWidth(); - screenHeight = core->getWindowHeight(); - float percentX, percentY; percentX = (float)screenWidth/(float)textureWidth; percentY = (float)screenHeight/(float)textureHeight; @@ -263,8 +260,8 @@ void AfterEffectManager::renderGrid() { // From here on: secondary shader passes. // We just outputted to the backup buffer... - FrameBuffer *fbIn = &core->frameBuffer; - FrameBuffer *fbOut = &backupBuffer; + const FrameBuffer *fbIn = &core->frameBuffer; + const FrameBuffer *fbOut = &backupBuffer; for(int i = firstShader + 1; i <= lastShader; ++i) @@ -345,7 +342,7 @@ void AfterEffectManager::renderGrid() // renderGridPoints(); } -void AfterEffectManager::renderGridPoints() +void AfterEffectManager::renderGridPoints() const { glColor4f(0.0f,0.0f,0.0f,1.0f); for (int i = 0; i < (xDivs); i++) diff --git a/BBGE/AfterEffect.h b/BBGE/AfterEffect.h index d1536ad..3a0e70c 100644 --- a/BBGE/AfterEffect.h +++ b/BBGE/AfterEffect.h @@ -88,9 +88,9 @@ public: void resetGrid(); - void render(); - void renderGrid(); - void renderGridPoints(); + void render() const; + void renderGrid() const; + void renderGridPoints() const; void loadShaders(); void unloadShaders(); // unloads shaders but keeps code and data intact, so that they can be reloaded. diff --git a/BBGE/Base.h b/BBGE/Base.h index 63b7c30..a266089 100644 --- a/BBGE/Base.h +++ b/BBGE/Base.h @@ -67,6 +67,7 @@ namespace internal #pragma warning(disable:4505) // unreferenced local function has been removed #pragma warning(disable:4702) // unreachable code #pragma warning(disable:4127) // conditional expression is constant +#pragma warning(disable:26812) // unscoped enum //#pragma warning(disable:4706) // assignment within conditional expression //#pragma warning(disable:4389) // signed/unsigned mismatch diff --git a/BBGE/BitmapFont.cpp b/BBGE/BitmapFont.cpp index 5145399..158ee66 100644 --- a/BBGE/BitmapFont.cpp +++ b/BBGE/BitmapFont.cpp @@ -70,12 +70,9 @@ void BmpFont::load(const std::string &file, float scale, bool loadTexture) loaded = true; } -Texture *fontTextureTest = 0; BitmapText::BitmapText(BmpFont *bmpFont) { this->bmpFont = bmpFont; - bfePass =0; - bfe = BFE_NONE; currentScrollLine = currentScrollChar = 0; scrollDelay = 0; @@ -186,11 +183,6 @@ void BitmapText::formatText() colorIndices.clear(); } -void BitmapText::setBitmapFontEffect(BitmapFontEffect bfe) -{ - this->bfe = bfe; -} - void BitmapText::updateWordColoring() { colorIndices.resize(lines.size()); @@ -231,7 +223,6 @@ void BitmapText::setFontSize(float sz) void BitmapText::onUpdate(float dt) { - bfePass = 0; RenderObject::onUpdate(dt); if (scrollDelay > 0 && scrolling) { @@ -275,7 +266,7 @@ Vector BitmapText::getColorIndex(size_t i, size_t j) return c; } -void BitmapText::onRender() +void BitmapText::onRender() const { if (!bmpFont) return; float top_color[3] = {bmpFont->fontTopColor.x*color.x, bmpFont->fontTopColor.y*color.y, bmpFont->fontTopColor.z*color.z}; @@ -287,8 +278,6 @@ void BitmapText::onRender() bmpFont->font->Begin(); - if (fontTextureTest) fontTextureTest->apply(); - if (bmpFont->overrideTexture) bmpFont->overrideTexture->apply(); float y=0; @@ -350,25 +339,6 @@ void BitmapText::reloadDevice() setText(this->text); } -void BitmapText::render() -{ - RenderObject::render(); - if (!bfePass) - { - if (bfe == BFE_SHADOWBLUR) - { - InterpolatedVector oldAlpha = alpha, oldPos = position; - Vector adjust(rand()%5-2, rand()%5-2+2); - position += adjust; - alpha *= 0.4f; - bfePass = 1; - RenderObject::render(); - alpha = oldAlpha; - position = oldPos; - } - } -} - void BitmapText::stopScrollingText() { scrolling = false; diff --git a/BBGE/BitmapFont.h b/BBGE/BitmapFont.h index 2e88997..70fd1de 100644 --- a/BBGE/BitmapFont.h +++ b/BBGE/BitmapFont.h @@ -27,13 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace glfont { class GLFont; } -enum BitmapFontEffect -{ - BFE_NONE = 0, - BFE_SHADOWBLUR = 1, - BFE_MAX -}; - struct BmpFont { BmpFont(); @@ -69,8 +62,6 @@ public: Vector getColorIndex(size_t i, size_t j); void updateWordColoring(); void autoKern(); - void setBitmapFontEffect(BitmapFontEffect bfe); - void render(); virtual float getHeight(); void unloadDevice(); void reloadDevice(); @@ -82,8 +73,6 @@ public: protected: float scrollSpeed; BmpFont *bmpFont; - int bfePass; - BitmapFontEffect bfe; void onUpdate(float dt); float scrollDelay; bool scrolling; @@ -93,7 +82,7 @@ protected: float alignWidth; void formatText(); float fontDrawSize; - void onRender(); + void onRender() const OVERRIDE; typedef std::vector Lines; Lines lines; typedef std::vector ColorIndices; diff --git a/BBGE/Core.h b/BBGE/Core.h index 71d66b5..b8771e3 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -119,7 +119,6 @@ public: void remove(RenderObject* r); void moveToFront(RenderObject *r); void moveToBack(RenderObject *r); - void setCull(bool cull); void renderPass(int pass); void reloadDevice(); @@ -162,13 +161,13 @@ public: float followCamera; int followCameraLock; - bool cull; + bool update; Vector color; protected: - inline void renderOneObject(RenderObject *robj); + inline void renderOneObject(const RenderObject *robj); RenderObjects renderObjects; size_t objectCount; @@ -211,8 +210,6 @@ public: bool isShuttingDown(); bool isWindowFocus(); - void instantQuit(); - void cacheRender(); void reloadResources(); @@ -263,12 +260,12 @@ public: void clearGarbage(); - bool isNested() { return nestedMains > 1; } - int getNestedMains() { return nestedMains; } + bool isNested() const { return nestedMains > 1; } + int getNestedMains() const { return nestedMains; } void quitNestedMain(); - int getWindowWidth() { return width; } - int getWindowHeight() { return height; } + int getWindowWidth() const { return width; } + int getWindowHeight() const { return height; } unsigned getTicks(); diff --git a/BBGE/DarkLayer.cpp b/BBGE/DarkLayer.cpp index 07d9cc8..53b9faf 100644 --- a/BBGE/DarkLayer.cpp +++ b/BBGE/DarkLayer.cpp @@ -131,7 +131,7 @@ void DarkLayer::preRender() } } -void DarkLayer::render() +void DarkLayer::render() const { if (renderLayer != -1) { diff --git a/BBGE/DarkLayer.h b/BBGE/DarkLayer.h index 210e867..ed1a2a7 100644 --- a/BBGE/DarkLayer.h +++ b/BBGE/DarkLayer.h @@ -32,7 +32,7 @@ public: void toggle(bool on); void setLayers(int layer, int renderLayer); void preRender(); - void render(); + void render() const; int getLayer(); int getRenderLayer(); bool isUsed(); diff --git a/BBGE/DebugFont.cpp b/BBGE/DebugFont.cpp index 84d49e5..b1bbea3 100644 --- a/BBGE/DebugFont.cpp +++ b/BBGE/DebugFont.cpp @@ -130,7 +130,7 @@ void DebugFont::setText(const std::string &text) formatText(); } -void DebugFont::onRender() +void DebugFont::onRender() const { const float vspc = 1.5; diff --git a/BBGE/DebugFont.h b/BBGE/DebugFont.h index b2a63cac..6b9c600 100644 --- a/BBGE/DebugFont.h +++ b/BBGE/DebugFont.h @@ -40,7 +40,7 @@ public: protected: float fontDrawSize, textWidth; void formatText(); - void onRender(); + void onRender() const OVERRIDE; std::string text; std::vector lines; Align align; diff --git a/BBGE/Effects.cpp b/BBGE/Effects.cpp index ee67bcd..9a78c6e 100644 --- a/BBGE/Effects.cpp +++ b/BBGE/Effects.cpp @@ -69,7 +69,7 @@ void PostProcessingFX::disable(FXTypes type) enabled[int(type)] = false; } -void PostProcessingFX::render() +void PostProcessingFX::render() const { if(!core->frameBuffer.isInited()) return; diff --git a/BBGE/Effects.h b/BBGE/Effects.h index 9951831..d5de261 100644 --- a/BBGE/Effects.h +++ b/BBGE/Effects.h @@ -37,7 +37,7 @@ public: void init(); void update(float dt); void preRender(); - void render(); + void render() const; void toggle(FXTypes type); void enable(FXTypes type); void disable(FXTypes type); diff --git a/BBGE/Emitter.cpp b/BBGE/Emitter.cpp index c0a0ded..8276709 100644 --- a/BBGE/Emitter.cpp +++ b/BBGE/Emitter.cpp @@ -222,12 +222,7 @@ void Emitter::removeParticle(Particle *p) } -void Emitter::render() -{ - Quad::render(); -} - -void Emitter::onRender() +void Emitter::onRender() const { if (particles.empty()) return; @@ -250,7 +245,7 @@ void Emitter::onRender() { Vector colorMult = data.inheritColor ? pe->color : Vector(1, 1, 1); float alphaMult = data.inheritAlpha ? pe->alpha.x : 1; - for (Particles::iterator i = particles.begin(); i != particles.end(); i++) + for (Particles::const_iterator i = particles.begin(); i != particles.end(); i++) { Particle *p = *i; if (p->active) @@ -319,7 +314,7 @@ void Emitter::onRender() else { glBegin(GL_QUADS); - for (Particles::iterator i = particles.begin(); i != particles.end(); i++) + for (Particles::const_iterator i = particles.begin(); i != particles.end(); i++) { Particle *p = *i; if (p->active) diff --git a/BBGE/FrameBuffer.cpp b/BBGE/FrameBuffer.cpp index a55165e..2da51d9 100644 --- a/BBGE/FrameBuffer.cpp +++ b/BBGE/FrameBuffer.cpp @@ -204,20 +204,20 @@ void FrameBuffer::reloadDevice() init(_w, _h, _fitToScreen); } -void FrameBuffer::startCapture() +void FrameBuffer::startCapture() const { assert(inited); glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, g_frameBuffer ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); } -void FrameBuffer::endCapture() +void FrameBuffer::endCapture() const { assert(inited); glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); } -void FrameBuffer::bindTexture() +void FrameBuffer::bindTexture() const { assert(inited); glBindTexture( GL_TEXTURE_2D, g_dynamicTextureID ); diff --git a/BBGE/FrameBuffer.h b/BBGE/FrameBuffer.h index eb6a82d..32a6e48 100644 --- a/BBGE/FrameBuffer.h +++ b/BBGE/FrameBuffer.h @@ -31,9 +31,9 @@ public: ~FrameBuffer(); bool init(int width, int height, bool fitToScreen=false); bool isInited() { return inited; } - void startCapture(); - void endCapture(); - void bindTexture(); + void startCapture() const; + void endCapture() const; + void bindTexture() const; int getWidth() { return w; } int getHeight() { return h; } float getWidthP(); diff --git a/BBGE/Gradient.cpp b/BBGE/Gradient.cpp index 0f7773d..b7166b5 100644 --- a/BBGE/Gradient.cpp +++ b/BBGE/Gradient.cpp @@ -58,7 +58,7 @@ void Gradient::makeHorizontal(Vector c1, Vector c2) ulc3 = c1; } -void Gradient::onRender() +void Gradient::onRender() const { diff --git a/BBGE/Gradient.h b/BBGE/Gradient.h index 8d92d5d..296b63c 100644 --- a/BBGE/Gradient.h +++ b/BBGE/Gradient.h @@ -35,7 +35,7 @@ public: int autoWidth, autoHeight; protected: - void onRender(); + void onRender() const OVERRIDE; Vector ulc0, ulc1, ulc2, ulc3; }; diff --git a/BBGE/ParticleEffect.cpp b/BBGE/ParticleEffect.cpp index 7140146..f3f5ee2 100644 --- a/BBGE/ParticleEffect.cpp +++ b/BBGE/ParticleEffect.cpp @@ -439,9 +439,3 @@ void ParticleEffect::stop() (*i)->stop(); } } - -void ParticleEffect::onRender() -{ - RenderObject::onRender(); -} - diff --git a/BBGE/Particles.h b/BBGE/Particles.h index 636b766..d21004b 100644 --- a/BBGE/Particles.h +++ b/BBGE/Particles.h @@ -125,8 +125,6 @@ public: SpawnParticleData data; - void render(); - void start(); void stop(); @@ -138,7 +136,7 @@ public: bool hasRot; protected: Vector currentSpawn, lastSpawn; - void onRender(); + void onRender() const OVERRIDE; void spawnParticle(float perc=1); void onUpdate(float dt); @@ -170,7 +168,6 @@ protected: bool waitForParticles; void onUpdate(float dt); - void onRender(); float effectLife, effectLifeCounter; bool running; diff --git a/BBGE/Quad.cpp b/BBGE/Quad.cpp index d686cac..553a477 100644 --- a/BBGE/Quad.cpp +++ b/BBGE/Quad.cpp @@ -134,7 +134,7 @@ void Quad::setGridPoints(bool vert, const std::vector &points) } } -float Quad::getStripSegmentSize() +float Quad::getStripSegmentSize() const { return (1.0f/(float(strip.size()))); } @@ -228,7 +228,7 @@ void Quad::destroy() RenderObject::destroy(); } -bool Quad::isCoordinateInside(Vector coord, int minSize) +bool Quad::isCoordinateInside(Vector coord, int minSize) const { Vector realscale = getRealScale(); int hw = fabsf((width)*realscale.x)*0.5f; @@ -250,7 +250,7 @@ bool Quad::isCoordinateInside(Vector coord, int minSize) return false; } -bool Quad::isCoordinateInsideWorld(const Vector &coord, int minSize) +bool Quad::isCoordinateInsideWorld(const Vector &coord, int minSize) const { int hw = fabsf((width)*getRealScale().x)*0.5f; int hh = fabsf((height)*getRealScale().y)*0.5f; @@ -270,7 +270,7 @@ bool Quad::isCoordinateInsideWorld(const Vector &coord, int minSize) return false; } -bool Quad::isCoordinateInsideWorldRect(const Vector &coord, int w, int h) +bool Quad::isCoordinateInsideWorldRect(const Vector &coord, int w, int h) const { int hw = w*0.5f; int hh = h*0.5f; @@ -319,7 +319,7 @@ void Quad::updateGrid(float dt) } } -void Quad::renderGrid() +void Quad::renderGrid() const { if (xDivs < 2 || yDivs < 2) return; @@ -422,7 +422,7 @@ void Quad::repeatTextureToFill(bool on) } -void Quad::onRender() +void Quad::onRender() const { if (!renderQuad) return; @@ -657,7 +657,7 @@ CollideQuad::~CollideQuad() { } -void CollideQuad::renderCollision() +void CollideQuad::renderCollision() const { if (collideRadius > 0) { diff --git a/BBGE/Quad.h b/BBGE/Quad.h index 17c8c15..fd1bdf6 100644 --- a/BBGE/Quad.h +++ b/BBGE/Quad.h @@ -36,7 +36,7 @@ protected: int w, h, w2, h2; int lineSize; - void onRender(); + void onRender() const OVERRIDE; }; class Quad : public RenderObject @@ -46,9 +46,9 @@ public: Quad(); void createGrid(int x, int y); void destroy(); - bool isCoordinateInside(Vector coord, int minSize=0); - bool isCoordinateInsideWorld(const Vector &coord, int minSize=0); - bool isCoordinateInsideWorldRect(const Vector &coord, int w, int h); + bool isCoordinateInside(Vector coord, int minSize=0) const; + bool isCoordinateInsideWorld(const Vector &coord, int minSize=0) const; + bool isCoordinateInsideWorldRect(const Vector &coord, int w, int h) const; void flipVertical(); void flipHorizontal(); @@ -65,7 +65,7 @@ public: bool isRepeatingTextureToFill() const { return repeatingTextureToFill; } void setGridPoints(bool vert, const std::vector &points); virtual void createStrip(bool stripVert, int num); - float getStripSegmentSize(); + float getStripSegmentSize() const; void resetStrip(); Vector ** getDrawGrid() { return drawGrid; } @@ -87,7 +87,8 @@ public: char autoWidth, autoHeight; // char to save space - bool renderQuad, renderBorder, renderCenter; + bool renderQuad, renderCenter; + mutable bool renderBorder; // TODO: should be part of render state bool stripVert; std::vectorstrip; Vector texOff; @@ -103,7 +104,7 @@ protected: void resetGrid(); void updateGrid(float dt); - void renderGrid(); + void renderGrid() const; float drawGridOffsetX; @@ -116,7 +117,7 @@ protected: static Vector renderBorderColor; void onSetTexture(); - void onRender(); + void onRender() const OVERRIDE; void onUpdate(float dt); private: bool doUpdateGrid; @@ -142,7 +143,7 @@ class CollideQuad : public Quad public: CollideQuad(); virtual ~CollideQuad(); - virtual void renderCollision() OVERRIDE; + virtual void renderCollision() const OVERRIDE; float collideRadius; }; diff --git a/BBGE/QuadGrid.cpp b/BBGE/QuadGrid.cpp index 09ace66..e38fa67 100644 --- a/BBGE/QuadGrid.cpp +++ b/BBGE/QuadGrid.cpp @@ -75,7 +75,7 @@ static inline void drawOnePoint(const QuadGrid::Point& p, float ox, float oy) } -void QuadGrid::onRender() +void QuadGrid::onRender() const { glColor4f(color.x, color.y, color.z, alpha.x * alphaMod); @@ -88,8 +88,8 @@ void QuadGrid::onRender() const size_t H = quadsY(); for(size_t y = 0; y < H; ++y) { - Point * const row0 = &_points[y * NX]; - Point * const row1 = row0 + NX; + const Point * const row0 = &_points[y * NX]; + const Point * const row1 = row0 + NX; for(size_t x = 0; x < W; ++x) { glBegin(GL_QUADS); diff --git a/BBGE/QuadGrid.h b/BBGE/QuadGrid.h index 1ff563e..a19d4f3 100644 --- a/BBGE/QuadGrid.h +++ b/BBGE/QuadGrid.h @@ -42,7 +42,7 @@ public: return _points[y * _w + x]; } - virtual void onRender(); + virtual void onRender() const OVERRIDE; virtual void onUpdate(float dt); virtual void onSetTexture(); diff --git a/BBGE/RenderObject.cpp b/BBGE/RenderObject.cpp index f353024..84a3797 100644 --- a/BBGE/RenderObject.cpp +++ b/BBGE/RenderObject.cpp @@ -46,7 +46,7 @@ void RenderObject::toggleAlpha(float t) alpha.interpolateTo(0,t); } -int RenderObject::getTopLayer() +int RenderObject::getTopLayer() const { if (parent) { @@ -67,7 +67,7 @@ static const BlendParams s_blendParams[] = { GL_ZERO, GL_SRC_COLOR }, }; -void RenderObject::applyBlendType() +void RenderObject::applyBlendType() const { compile_assert(Countof(s_blendParams) == _BLEND_MAXSIZE); @@ -84,7 +84,7 @@ void RenderObject::applyBlendType() } } -void RenderObject::setColorMult(const Vector &color, const float alpha) +void RenderObject::setColorMult(const Vector &color, const float alpha) const { if (colorIsSaved) { @@ -98,13 +98,13 @@ void RenderObject::setColorMult(const Vector &color, const float alpha) this->savedAlpha = this->alpha.x; this->color *= color; this->alpha.x *= alpha; - for (Children::iterator i = children.begin(); i != children.end(); i++) + for (Children::const_iterator i = children.begin(); i != children.end(); i++) { (*i)->setColorMult(color, alpha); } } -void RenderObject::clearColorMult() +void RenderObject::clearColorMult() const { if (!colorIsSaved) { @@ -116,7 +116,7 @@ void RenderObject::clearColorMult() this->color.z = this->savedColor.z; this->alpha.x = this->savedAlpha; this->colorIsSaved = false; - for (Children::iterator i = children.begin(); i != children.end(); i++) + for (Children::const_iterator i = children.begin(); i != children.end(); i++) { (*i)->clearColorMult(); } @@ -177,12 +177,12 @@ RenderObject::~RenderObject() freeMotionBlur(); } -Vector RenderObject::getWorldPosition() +Vector RenderObject::getWorldPosition() const { return getWorldCollidePosition(); } -RenderObject* RenderObject::getTopParent() +RenderObject* RenderObject::getTopParent() const { RenderObject *p = parent; RenderObject *lastp=0; @@ -194,7 +194,7 @@ RenderObject* RenderObject::getTopParent() return lastp; } -bool RenderObject::isPieceFlippedHorizontal() +bool RenderObject::isPieceFlippedHorizontal() const { RenderObject *p = getTopParent(); if (p) @@ -203,13 +203,13 @@ bool RenderObject::isPieceFlippedHorizontal() } -Vector RenderObject::getInvRotPosition(const Vector &vec) +Vector RenderObject::getInvRotPosition(const Vector &vec) const { glPushMatrix(); glLoadIdentity(); - std::vectorchain; - RenderObject *p = this; + std::vectorchain; + const RenderObject *p = this; while(p) { chain.push_back(p); @@ -286,7 +286,7 @@ static void matrixChain(RenderObject *ro) } #endif -float RenderObject::getWorldRotation() +float RenderObject::getWorldRotation() const { Vector up = getWorldCollidePosition(Vector(0,1)); Vector orig = getWorldPosition(); @@ -295,7 +295,7 @@ float RenderObject::getWorldRotation() return rot; } -Vector RenderObject::getWorldPositionAndRotation() +Vector RenderObject::getWorldPositionAndRotation() const { Vector up = getWorldCollidePosition(Vector(0,1)); Vector orig = getWorldPosition(); @@ -303,7 +303,7 @@ Vector RenderObject::getWorldPositionAndRotation() return orig; } -Vector RenderObject::getWorldCollidePosition(const Vector &vec) +Vector RenderObject::getWorldCollidePosition(const Vector &vec) const { #ifdef BBGE_USE_GLM glm::mat4 transformMatrix = glm::translate( @@ -386,7 +386,7 @@ void RenderObject::destroy() texture = NULL; } -Vector RenderObject::getRealPosition() +Vector RenderObject::getRealPosition() const { if (parent) { @@ -395,7 +395,7 @@ Vector RenderObject::getRealPosition() return position + offset; } -Vector RenderObject::getRealScale() +Vector RenderObject::getRealScale() const { if (parent) { @@ -466,9 +466,9 @@ void RenderObject::disableMotionBlur() } } -bool RenderObject::isfhr() +bool RenderObject::isfhr() const { - RenderObject *p = this; + const RenderObject *p = this; bool fh = false; do if (p->isfh()) @@ -478,9 +478,9 @@ bool RenderObject::isfhr() } -bool RenderObject::isfvr() +bool RenderObject::isfvr() const { - RenderObject *p = this; + const RenderObject *p = this; bool fv = false; do if (p->isfv()) @@ -490,11 +490,11 @@ bool RenderObject::isfvr() } -bool RenderObject::hasRenderPass(const int pass) +bool RenderObject::hasRenderPass(const int pass) const { if (pass == renderPass) return true; - for (Children::iterator i = children.begin(); i != children.end(); i++) + for (Children::const_iterator i = children.begin(); i != children.end(); i++) { if (!(*i)->isDead() && (*i)->hasRenderPass(pass)) return true; @@ -502,7 +502,7 @@ bool RenderObject::hasRenderPass(const int pass) return false; } -void RenderObject::render() +void RenderObject::render() const { if (isHidden()) return; @@ -557,7 +557,7 @@ void RenderObject::render() renderCall(); } -void RenderObject::renderCall() +void RenderObject::renderCall() const { position += offset; @@ -645,7 +645,7 @@ void RenderObject::renderCall() glTranslatef(internalOffset.x, internalOffset.y, internalOffset.z); - for (Children::iterator i = children.begin(); i != children.end(); i++) + for (Children::const_iterator i = children.begin(); i != children.end(); i++) { if (!(*i)->isDead() && (*i)->renderBeforeParent) (*i)->render(); @@ -704,7 +704,7 @@ void RenderObject::renderCall() onRender(); - for (Children::iterator i = children.begin(); i != children.end(); i++) + for (Children::const_iterator i = children.begin(); i != children.end(); i++) { if (!(*i)->isDead() && !(*i)->renderBeforeParent) (*i)->render(); @@ -717,7 +717,7 @@ void RenderObject::renderCall() position -= offset; } -void RenderObject::renderCollision() +void RenderObject::renderCollision() const { } @@ -852,14 +852,14 @@ void RenderObject::safeKill() } } -Vector RenderObject::getNormal() +Vector RenderObject::getNormal() const { float a = MathFunctions::toRadians(getAbsoluteRotation().z); return Vector(sinf(a),cosf(a)); } // HACK: this is probably a slow implementation -Vector RenderObject::getForward() +Vector RenderObject::getForward() const { Vector v = getWorldCollidePosition(Vector(0,-1, 0)); Vector r = v - getWorldCollidePosition(); @@ -869,7 +869,7 @@ Vector RenderObject::getForward() return r; } -Vector RenderObject::getAbsoluteRotation() +Vector RenderObject::getAbsoluteRotation() const { Vector r = rotation; if (parent) @@ -1058,7 +1058,7 @@ void RenderObject::addChild(RenderObject *r, ParentManaged pm, RenderBeforeParen r->parent = this; } -StateData *RenderObject::getStateData() +StateData *RenderObject::getStateData() const { if (parent) { @@ -1073,7 +1073,7 @@ void RenderObject::setOverrideCullRadius(float ovr) overrideCullRadiusSqr = ovr * ovr; } -bool RenderObject::isCoordinateInRadius(const Vector &pos, float r) +bool RenderObject::isCoordinateInRadius(const Vector &pos, float r) const { Vector d = pos-getRealPosition(); diff --git a/BBGE/RenderObject.h b/BBGE/RenderObject.h index 61a2c99..7c87120 100644 --- a/BBGE/RenderObject.h +++ b/BBGE/RenderObject.h @@ -82,13 +82,18 @@ struct MotionBlurData class RenderObjectLayer; +// FIXME: -- fg +// I've scattered a few mutables across this class +// These should be part of some struct that gets passed along the render() calls +// instead of updating the actual class members + class RenderObject : public ScriptObject { public: friend class Core; RenderObject(); virtual ~RenderObject(); - virtual void render(); + virtual void render() const; void setTexturePointer(CountedPtr t) { @@ -137,8 +142,8 @@ public: bool isfv() const { return _fv; } // recursive - bool isfhr(); - bool isfvr(); + bool isfhr() const; + bool isfvr() const; size_t getIdx() const { return idx; } void setIdx(size_t newidx) { this->idx = newidx; } @@ -156,10 +161,10 @@ public: return w*w + h*h; } - int getTopLayer(); + int getTopLayer() const; - void setColorMult(const Vector &color, const float alpha); - void clearColorMult(); + void setColorMult(const Vector &color, const float alpha) const; // HACK: const + void clearColorMult() const; // HACK: const void enableMotionBlur(int sz=10, int off=5); void disableMotionBlur(); @@ -167,42 +172,40 @@ public: void addChild(RenderObject *r, ParentManaged pm, RenderBeforeParent rbp = RBP_NONE, ChildOrder order = CHILD_BACK); void removeChild(RenderObject *r); - Vector getRealPosition(); - Vector getRealScale(); + Vector getRealPosition() const; + Vector getRealScale() const; - StateData *getStateData(); + StateData *getStateData() const; // HACK: This is defined in RenderObject_inline.h because it needs // the class Core definition. --achurch - inline bool isOnScreen(); - - bool isCoordinateInRadius(const Vector &pos, float r); + inline bool isOnScreen() const; - const RenderObject &operator=(const RenderObject &r); + bool isCoordinateInRadius(const Vector &pos, float r) const; void toggleCull(bool value); void safeKill(); - Vector getWorldPosition(); - Vector getWorldCollidePosition(const Vector &vec=Vector(0,0,0)); - Vector getInvRotPosition(const Vector &vec); - bool isPieceFlippedHorizontal(); + Vector getWorldPosition() const; + Vector getWorldCollidePosition(const Vector &vec=Vector(0,0,0)) const; + Vector getInvRotPosition(const Vector &vec) const; + bool isPieceFlippedHorizontal() const; - RenderObject *getTopParent(); + RenderObject *getTopParent() const; virtual void onAnimationKeyPassed(int key){} - Vector getAbsoluteRotation(); - float getWorldRotation(); - Vector getWorldPositionAndRotation(); // more efficient shortcut, returns rotation in vector z component - Vector getNormal(); - Vector getForward(); + Vector getAbsoluteRotation() const; + float getWorldRotation() const; + Vector getWorldPositionAndRotation() const; // more efficient shortcut, returns rotation in vector z component + Vector getNormal() const; + Vector getForward() const; void setOverrideCullRadius(float ovr); void setRenderPass(int pass) { renderPass = pass; } - int getRenderPass() { return renderPass; } + int getRenderPass() const { return renderPass; } void setOverrideRenderPass(int pass) { overrideRenderPass = pass; } - int getOverrideRenderPass() { return overrideRenderPass; } + int getOverrideRenderPass() const { return overrideRenderPass; } enum { RENDER_ALL=314, OVERRIDE_NONE=315 }; // Defined in RenderObject_inline.h @@ -210,7 +213,7 @@ public: void lookAt(const Vector &pos, float t, float minAngle, float maxAngle, float offset=0); inline RenderObject *getParent() const {return parent;} - void applyBlendType(); + void applyBlendType() const; void fhTo(bool fh); void addDeathNotify(RenderObject *r); virtual void unloadDevice(); @@ -251,14 +254,16 @@ public: char _blendType; - InterpolatedVector position, scale, color, alpha, rotation; + mutable InterpolatedVector position, scale; + mutable InterpolatedVector color, alpha; // HACK: mutable should go! this is for setColorMult() + mutable InterpolatedVector rotation; InterpolatedVector offset, rotationOffset, internalOffset, beforeScaleOffset; InterpolatedVector velocity, gravity; CountedPtr texture; float life; - float followCamera; + mutable float followCamera; float alphaMod; float updateCull; int layer; @@ -272,9 +277,9 @@ public: float overrideCullRadiusSqr; // --- This is hack and should not exist --- - bool colorIsSaved; // Used for both color and alpha - Vector savedColor; // Saved values from setColorMult() - float savedAlpha; + mutable bool colorIsSaved; // Used for both color and alpha + mutable Vector savedColor; // Saved values from setColorMult() + mutable float savedAlpha; float width, height; // Only used by Quads, but stored here for getCullRadius() @@ -290,7 +295,7 @@ protected: virtual void onFH(){} virtual void onFV(){} virtual void onSetTexture(){} - virtual void onRender(){} + virtual void onRender() const {} virtual void onUpdate(float dt); virtual void deathNotify(RenderObject *r); virtual void onEndOfLife() {} @@ -298,10 +303,10 @@ protected: void updateLife(float dt); // Is this object or any of its children rendered in pass "pass"? - bool hasRenderPass(const int pass); + bool hasRenderPass(const int pass) const; - inline void renderCall(); - virtual void renderCollision(); + inline void renderCall() const; + virtual void renderCollision() const; typedef std::list RenderObjectList; RenderObjectList deathNotifications; @@ -309,6 +314,9 @@ protected: size_t idx; // index in layer StateData *stateData; MotionBlurData *motionBlur; + +private: + const RenderObject &operator=(const RenderObject &r); // undefined }; #endif diff --git a/BBGE/RenderObjectLayer.cpp b/BBGE/RenderObjectLayer.cpp index 567dcb2..32a2b22 100644 --- a/BBGE/RenderObjectLayer.cpp +++ b/BBGE/RenderObjectLayer.cpp @@ -30,7 +30,6 @@ RenderObjectLayer::RenderObjectLayer() visible = true; startPass = endPass = 0; followCameraLock = FCL_NONE; - cull = true; update = true; color = Vector(1,1,1); @@ -46,11 +45,6 @@ RenderObjectLayer::~RenderObjectLayer() { } -void RenderObjectLayer::setCull(bool cull) -{ - this->cull = cull; -} - void RenderObjectLayer::add(RenderObject* r) { size_t size = renderObjects.size(); @@ -234,13 +228,13 @@ void RenderObjectLayer::reloadDevice() } -inline void RenderObjectLayer::renderOneObject(RenderObject *robj) +inline void RenderObjectLayer::renderOneObject(const RenderObject *robj) { core->totalRenderObjectCount++; if (robj->getParent() || robj->alpha.x == 0) return; - if (!this->cull || !robj->cull || robj->isOnScreen()) + if (!robj->cull || robj->isOnScreen()) { robj->render(); core->renderObjectCount++; diff --git a/BBGE/RenderObject_inline.h b/BBGE/RenderObject_inline.h index 5e18199..8d76d3f 100644 --- a/BBGE/RenderObject_inline.h +++ b/BBGE/RenderObject_inline.h @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef RENDEROBJECT_INLINE_H #define RENDEROBJECT_INLINE_H -inline bool RenderObject::isOnScreen() +inline bool RenderObject::isOnScreen() const { if (followCamera == 1) return true; diff --git a/BBGE/RenderRect.cpp b/BBGE/RenderRect.cpp index f50e83a..189d629 100644 --- a/BBGE/RenderRect.cpp +++ b/BBGE/RenderRect.cpp @@ -40,7 +40,7 @@ void OutlineRect::setLineSize(int ls) lineSize = ls; } -void OutlineRect::onRender() +void OutlineRect::onRender() const { glLineWidth(lineSize); glBegin(GL_LINES); diff --git a/BBGE/RoundedRect.cpp b/BBGE/RoundedRect.cpp index b2dec5f..cf9c1dc 100644 --- a/BBGE/RoundedRect.cpp +++ b/BBGE/RoundedRect.cpp @@ -101,7 +101,7 @@ void RoundedRect::onUpdate(float dt) } } -void RoundedRect::onRender() +void RoundedRect::onRender() const { int w2 = width/2; @@ -257,7 +257,7 @@ void RoundButton::onUpdate(float dt) } } -void RoundButton::onRender() +void RoundButton::onRender() const { int w2 = width/2, h2 = height/2; glLineWidth(1); diff --git a/BBGE/RoundedRect.h b/BBGE/RoundedRect.h index cff355a..1d1bcdc 100644 --- a/BBGE/RoundedRect.h +++ b/BBGE/RoundedRect.h @@ -43,7 +43,7 @@ public: protected: void onUpdate(float dt); - void onRender(); + void onRender() const OVERRIDE; bool canMove; static RoundedRect *moving; @@ -61,7 +61,7 @@ public: EventPtr event; protected: void onUpdate(float dt); - void onRender(); + void onRender() const OVERRIDE; TTFText *label; int width, height, radius; diff --git a/BBGE/ScreenTransition.cpp b/BBGE/ScreenTransition.cpp index 89277c1..af13be5 100644 --- a/BBGE/ScreenTransition.cpp +++ b/BBGE/ScreenTransition.cpp @@ -111,7 +111,7 @@ bool ScreenTransition::isGoing() return alpha.isInterpolating(); } -void ScreenTransition::onRender() +void ScreenTransition::onRender() const { if (alpha.x == 0) return; diff --git a/BBGE/ScreenTransition.h b/BBGE/ScreenTransition.h index 3eaee57..61ec616 100644 --- a/BBGE/ScreenTransition.h +++ b/BBGE/ScreenTransition.h @@ -38,7 +38,7 @@ protected: void destroyTexture(); int textureWidth, textureHeight; int windowWidth, windowHeight; - void onRender(); + void onRender() const OVERRIDE; float width, height; diff --git a/BBGE/SkeletalSprite.cpp b/BBGE/SkeletalSprite.cpp index 5ab3986..fe7377b 100644 --- a/BBGE/SkeletalSprite.cpp +++ b/BBGE/SkeletalSprite.cpp @@ -297,7 +297,7 @@ void Bone::spawnParticlesFromCollisionMask(const char *p, unsigned intv, int lay } } -void Bone::renderCollision() +void Bone::renderCollision() const { if (!collisionMask.empty()) { diff --git a/BBGE/SkeletalSprite.h b/BBGE/SkeletalSprite.h index 567cea6..c20a8fc 100644 --- a/BBGE/SkeletalSprite.h +++ b/BBGE/SkeletalSprite.h @@ -94,7 +94,7 @@ public: void spawnParticlesFromCollisionMask(const char *p, unsigned intv, int layer, float rotz = 0); Vector getCollisionMaskNormal(size_t index); - virtual void renderCollision() OVERRIDE; + virtual void renderCollision() const OVERRIDE; protected: std::vector emitters; diff --git a/BBGE/TTFFont.cpp b/BBGE/TTFFont.cpp index 7c89b79..d938eb9 100644 --- a/BBGE/TTFFont.cpp +++ b/BBGE/TTFFont.cpp @@ -223,11 +223,6 @@ void TTFText::updateFormatting() lineHeight = font->font->LineHeight(); } -void TTFText::onUpdate(float dt) -{ - RenderObject::onUpdate(dt); -} - float TTFText::getLineHeight() { return lineHeight; @@ -245,7 +240,7 @@ int TTFText::findLine(const std::string &label) return 0; } -void TTFText::onRender() +void TTFText::onRender() const { diff --git a/BBGE/TTFFont.h b/BBGE/TTFFont.h index 1822bd8..47e41df 100644 --- a/BBGE/TTFFont.h +++ b/BBGE/TTFFont.h @@ -58,8 +58,7 @@ protected: float lineHeight; void updateAlign(); Align align; - void onUpdate(float dt); - void onRender(); + void onRender() const OVERRIDE; void updateFormatting(); std::string originalText; diff --git a/BBGE/Texture.cpp b/BBGE/Texture.cpp index e958628..0035393 100644 --- a/BBGE/Texture.cpp +++ b/BBGE/Texture.cpp @@ -284,7 +284,7 @@ bool Texture::load(std::string file, bool mipmap) return ok; } -void Texture::apply(bool repeatOverride) +void Texture::apply(bool repeatOverride) const { glBindTexture(GL_TEXTURE_2D, textures[0]); if (repeat || repeatOverride) @@ -307,10 +307,6 @@ void Texture::apply(bool repeatOverride) } } -void Texture::unbind() -{ -} - struct GlTexFormat { int internalformat, format, type; diff --git a/BBGE/Texture.h b/BBGE/Texture.h index 2aef733..c3179b1 100644 --- a/BBGE/Texture.h +++ b/BBGE/Texture.h @@ -40,8 +40,7 @@ public: ~Texture(); bool load(std::string file, bool mipmap); - void apply(bool repeatOverride=false); - void unbind(); + void apply(bool repeatOverride=false) const; void unload(); int getPixelWidth(); @@ -51,7 +50,8 @@ public: int width, height; - bool repeat, repeating; + bool repeat; + mutable bool repeating; // modified during rendering unsigned textures[1];