mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-03 18:14:01 +00:00
Add RenderState to be passed through the scene graph
This will eventually handle all mutable state during rendering
This commit is contained in:
parent
b6c5d90d3a
commit
68b3c61852
57 changed files with 201 additions and 150 deletions
|
@ -35,7 +35,7 @@ const int KEYFRAME_POS_Y = 570;
|
||||||
|
|
||||||
class TimelineRender : public RenderObject
|
class TimelineRender : public RenderObject
|
||||||
{
|
{
|
||||||
void onRender() const OVERRIDE
|
void onRender(const RenderState& rs) const OVERRIDE
|
||||||
{
|
{
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
|
|
|
@ -4447,18 +4447,18 @@ void Avatar::doShieldSong()
|
||||||
activateAura(AURA_SHIELD);
|
activateAura(AURA_SHIELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::render() const
|
void Avatar::render(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
|
|
||||||
if (dsq->continuity.form == FORM_SPIRIT && !skeletalSprite.getParent())
|
if (dsq->continuity.form == FORM_SPIRIT && !skeletalSprite.getParent())
|
||||||
{
|
{
|
||||||
skeletalSprite.position = bodyPosition+bodyOffset;
|
skeletalSprite.position = bodyPosition+bodyOffset;
|
||||||
skeletalSprite.color = Vector(0.2f, 0.3f, 0.6f);
|
skeletalSprite.color = Vector(0.2f, 0.3f, 0.6f);
|
||||||
skeletalSprite.render();
|
skeletalSprite.render(rs);
|
||||||
skeletalSprite.color = Vector(1,1,1);
|
skeletalSprite.color = Vector(1,1,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity::render();
|
Entity::render(rs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ public:
|
||||||
float biteDelay, urchinDelay, jellyDelay;
|
float biteDelay, urchinDelay, jellyDelay;
|
||||||
bool movingOn;
|
bool movingOn;
|
||||||
|
|
||||||
void render() const OVERRIDE;
|
void render(const RenderState& rs) const OVERRIDE;
|
||||||
void activateAura(AuraType aura);
|
void activateAura(AuraType aura);
|
||||||
void stopAura();
|
void stopAura();
|
||||||
void setHeadTexture(const std::string &name, float t=0);
|
void setHeadTexture(const std::string &name, float t=0);
|
||||||
|
|
|
@ -105,7 +105,7 @@ void Beam::trace()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Beam::onRender() const
|
void Beam::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
|
|
||||||
Vector diff = endPos - position;
|
Vector diff = endPos - position;
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
void setBeamWidth(float w);
|
void setBeamWidth(float w);
|
||||||
protected:
|
protected:
|
||||||
float beamWidth;
|
float beamWidth;
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
void onEndOfLife();
|
void onEndOfLife();
|
||||||
void onUpdate(float dt);
|
void onUpdate(float dt);
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,11 +30,11 @@ CurrentRender::CurrentRender() : RenderObject()
|
||||||
cull = false;
|
cull = false;
|
||||||
|
|
||||||
setTexture("Particles/Current");
|
setTexture("Particles/Current");
|
||||||
texture->repeat = true;
|
repeatTexture = true;
|
||||||
rippleDelay = 2;
|
rippleDelay = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurrentRender::onRender() const
|
void CurrentRender::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
// note: Leave cull_face disabled!?
|
// note: Leave cull_face disabled!?
|
||||||
//glDisable(GL_CULL_FACE);
|
//glDisable(GL_CULL_FACE);
|
||||||
|
|
|
@ -283,7 +283,7 @@ void Element::setElementEffectByIndex(int eidx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Element::render() const
|
void Element::render(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
if (!elementActive) return;
|
if (!elementActive) return;
|
||||||
if (dsq->game->isSceneEditorActive() && this->bgLayer == dsq->game->sceneEditor.bgLayer
|
if (dsq->game->isSceneEditorActive() && this->bgLayer == dsq->game->sceneEditor.bgLayer
|
||||||
|
@ -307,7 +307,7 @@ void Element::render() const
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Quad::render();
|
Quad::render(rs);
|
||||||
|
|
||||||
renderBorder = false;
|
renderBorder = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
size_t templateIdx;
|
size_t templateIdx;
|
||||||
int bgLayer;
|
int bgLayer;
|
||||||
Element *bgLayerNext;
|
Element *bgLayerNext;
|
||||||
void render() const OVERRIDE;
|
void render(const RenderState& rs) const OVERRIDE;
|
||||||
ElementFlag elementFlag;
|
ElementFlag elementFlag;
|
||||||
void fillGrid();
|
void fillGrid();
|
||||||
bool isElementActive() { return elementActive; }
|
bool isElementActive() { return elementActive; }
|
||||||
|
|
|
@ -2474,7 +2474,7 @@ void Entity::doEntityAvoidance(float dt, int range, float mod, Entity *ignore)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::render() const
|
void Entity::render(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
InterpolatedVector bcolor = color;
|
InterpolatedVector bcolor = color;
|
||||||
InterpolatedVector bscale = scale;
|
InterpolatedVector bscale = scale;
|
||||||
|
@ -2499,7 +2499,7 @@ void Entity::render() const
|
||||||
skeletalSprite.setColorMult(this->color, this->alpha.x);
|
skeletalSprite.setColorMult(this->color, this->alpha.x);
|
||||||
|
|
||||||
|
|
||||||
Quad::render();
|
Quad::render(rs);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ public:
|
||||||
Vector vel;
|
Vector vel;
|
||||||
InterpolatedVector vel2;
|
InterpolatedVector vel2;
|
||||||
float activationRadius;
|
float activationRadius;
|
||||||
void render() const OVERRIDE;
|
void render(const RenderState& rs) const OVERRIDE;
|
||||||
void update(float dt);
|
void update(float dt);
|
||||||
|
|
||||||
void spawnParticlesFromCollisionMask(const char *p, unsigned intv=1, int layer = LR_PARTICLES, float rotz = 0);
|
void spawnParticlesFromCollisionMask(const char *p, unsigned intv=1, int layer = LR_PARTICLES, float rotz = 0);
|
||||||
|
|
|
@ -4160,7 +4160,7 @@ void Game::setParallaxTextureCoordinates(Quad *q, float speed)
|
||||||
{
|
{
|
||||||
//int backgroundImageRepeat = 1.2;
|
//int backgroundImageRepeat = 1.2;
|
||||||
q->followCamera = 1;
|
q->followCamera = 1;
|
||||||
q->texture->repeat = true;
|
q->repeatTexture = true;
|
||||||
|
|
||||||
float camx = (core->cameraPos.x/800.0f)*speed;
|
float camx = (core->cameraPos.x/800.0f)*speed;
|
||||||
float camy = -(core->cameraPos.y/600.0f)*speed;
|
float camy = -(core->cameraPos.y/600.0f)*speed;
|
||||||
|
|
|
@ -53,7 +53,7 @@ inline static void doRenderGrid(int x, int startCol, int endCol)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridRender::onRender() const
|
void GridRender::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
const signed char obsType = this->obsType;
|
const signed char obsType = this->obsType;
|
||||||
Vector camPos = core->cameraPos;
|
Vector camPos = core->cameraPos;
|
||||||
|
@ -145,7 +145,7 @@ void SongLineRender::clear()
|
||||||
pts.clear();
|
pts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongLineRender::onRender() const
|
void SongLineRender::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
int w=core->getWindowWidth();
|
int w=core->getWindowWidth();
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
ObsType obsType;
|
ObsType obsType;
|
||||||
void onUpdate(float dt);
|
void onUpdate(float dt);
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MiniMapRender : public RenderObject
|
class MiniMapRender : public RenderObject
|
||||||
|
@ -67,7 +67,7 @@ protected:
|
||||||
bool doRender;
|
bool doRender;
|
||||||
float lightLevel;
|
float lightLevel;
|
||||||
void onUpdate(float dt);
|
void onUpdate(float dt);
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
void renderIcon(const MinimapIcon *ico, const Vector& pos) const;
|
void renderIcon(const MinimapIcon *ico, const Vector& pos) const;
|
||||||
|
|
||||||
InterpolatedVector lerp;
|
InterpolatedVector lerp;
|
||||||
|
@ -127,7 +127,7 @@ class PathRender : public RenderObject
|
||||||
public:
|
public:
|
||||||
PathRender();
|
PathRender();
|
||||||
protected:
|
protected:
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CurrentRender : public RenderObject
|
class CurrentRender : public RenderObject
|
||||||
|
@ -136,7 +136,7 @@ public:
|
||||||
CurrentRender();
|
CurrentRender();
|
||||||
protected:
|
protected:
|
||||||
float rippleDelay;
|
float rippleDelay;
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SteamRender : public RenderObject
|
class SteamRender : public RenderObject
|
||||||
|
@ -145,7 +145,7 @@ public:
|
||||||
SteamRender();
|
SteamRender();
|
||||||
protected:
|
protected:
|
||||||
float rippleDelay;
|
float rippleDelay;
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SongLinePoint
|
struct SongLinePoint
|
||||||
|
@ -161,7 +161,7 @@ public:
|
||||||
void newPoint(const Vector &pt, const Vector &color);
|
void newPoint(const Vector &pt, const Vector &color);
|
||||||
void clear();
|
void clear();
|
||||||
protected:
|
protected:
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
std::vector<SongLinePoint> pts;
|
std::vector<SongLinePoint> pts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ HairNode *Hair::getHairNode(int idx)
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hair::onRender() const
|
void Hair::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
float segmentLength;
|
float segmentLength;
|
||||||
void onUpdate(float dt);
|
void onUpdate(float dt);
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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());
|
toggleOn && dsq->game->avatar && dsq->game->avatar->getState() != Entity::STATE_TITLE && !(dsq->disableMiniMapOnNoInput && !dsq->game->avatar->isInputEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MiniMapRender::onRender() const
|
void MiniMapRender::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
|
@ -30,7 +30,7 @@ PathRender::PathRender() : RenderObject()
|
||||||
alpha = 0.5f;
|
alpha = 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathRender::onRender() const
|
void PathRender::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
const size_t pathcount = dsq->game->getNumPaths();
|
const size_t pathcount = dsq->game->getNumPaths();
|
||||||
if (pathcount == 0)
|
if (pathcount == 0)
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
void destroy();
|
void destroy();
|
||||||
protected:
|
protected:
|
||||||
void onUpdate(float dt);
|
void onUpdate(float dt);
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,12 +29,12 @@ SteamRender::SteamRender() : RenderObject()
|
||||||
|
|
||||||
alpha = 0.7f;
|
alpha = 0.7f;
|
||||||
setTexture("Particles/Steam");
|
setTexture("Particles/Steam");
|
||||||
texture->repeat = true;
|
repeatTexture = true;
|
||||||
rippleDelay = 2;
|
rippleDelay = 2;
|
||||||
setBlendType(BLEND_ADD);
|
setBlendType(BLEND_ADD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SteamRender::onRender() const
|
void SteamRender::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ void Strand::onUpdate(float dt)
|
||||||
updateSegments(position);
|
updateSegments(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Strand::onRender() const
|
void Strand::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
const int numSegments = segments.size();
|
const int numSegments = segments.size();
|
||||||
if (numSegments == 0) return;
|
if (numSegments == 0) return;
|
||||||
|
|
|
@ -129,10 +129,10 @@ void ToolTip::onUpdate(float dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::render() const
|
void ToolTip::render(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
if (!game->getInGameMenu()->recipeMenu.on && toolTipsOn)
|
if (!game->getInGameMenu()->recipeMenu.on && toolTipsOn)
|
||||||
{
|
{
|
||||||
RenderObject::render();
|
RenderObject::render(rs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
void setAreaFromCenter(const Vector ¢er, int width, int height);
|
void setAreaFromCenter(const Vector ¢er, int width, int height);
|
||||||
void setCircularAreaFromCenter(const Vector ¢er, int diameter);
|
void setCircularAreaFromCenter(const Vector ¢er, int diameter);
|
||||||
|
|
||||||
void render() const OVERRIDE;
|
void render(const RenderState& rs) const OVERRIDE;
|
||||||
|
|
||||||
static bool toolTipsOn;
|
static bool toolTipsOn;
|
||||||
|
|
||||||
|
|
|
@ -99,8 +99,6 @@ void WaterSurfaceRender::onUpdate(float dt)
|
||||||
{
|
{
|
||||||
qSurface->alphaMod = 0.5;
|
qSurface->alphaMod = 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quad::render();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -130,13 +128,13 @@ void WaterSurfaceRender::onUpdate(float dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterSurfaceRender::render() const
|
void WaterSurfaceRender::render(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
if (dsq->game->waterLevel.x > 0)
|
if (dsq->game->waterLevel.x > 0)
|
||||||
Quad::render();
|
Quad::render(rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterSurfaceRender::onRender() const
|
void WaterSurfaceRender::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
if (dsq->game->waterLevel == 0) return;
|
if (dsq->game->waterLevel == 0) return;
|
||||||
if (dsq->useFrameBuffer && dsq->frameBuffer.isInited())
|
if (dsq->useFrameBuffer && dsq->frameBuffer.isInited())
|
||||||
|
@ -149,7 +147,7 @@ void WaterSurfaceRender::onRender() const
|
||||||
glColor4f(0.4f, 0.7f, 0.8f, 0.2f);
|
glColor4f(0.4f, 0.7f, 0.8f, 0.2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Quad::onRender();
|
Quad::onRender(rs);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,10 @@ class WaterSurfaceRender : public Quad
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WaterSurfaceRender();
|
WaterSurfaceRender();
|
||||||
void render() const OVERRIDE;
|
void render(const RenderState& rs) const OVERRIDE;
|
||||||
protected:
|
protected:
|
||||||
Quad *qSurface, *qLine, *qLine2;
|
Quad *qSurface, *qLine, *qLine2;
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
void onUpdate(float dt) OVERRIDE;
|
void onUpdate(float dt) OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ void Web::onUpdate(float dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Web::onRender() const
|
void Web::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ protected:
|
||||||
void onEndOfLife();
|
void onEndOfLife();
|
||||||
std::vector<Vector> points;
|
std::vector<Vector> points;
|
||||||
void onUpdate(float dt);
|
void onUpdate(float dt);
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -266,7 +266,7 @@ Vector BitmapText::getColorIndex(size_t i, size_t j)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapText::onRender() const
|
void BitmapText::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
if (!bmpFont) return;
|
if (!bmpFont) return;
|
||||||
float top_color[3] = {bmpFont->fontTopColor.x*color.x, bmpFont->fontTopColor.y*color.y, bmpFont->fontTopColor.z*color.z};
|
float top_color[3] = {bmpFont->fontTopColor.x*color.x, bmpFont->fontTopColor.y*color.y, bmpFont->fontTopColor.z*color.z};
|
||||||
|
|
|
@ -82,7 +82,7 @@ protected:
|
||||||
float alignWidth;
|
float alignWidth;
|
||||||
void formatText();
|
void formatText();
|
||||||
float fontDrawSize;
|
float fontDrawSize;
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
typedef std::vector<std::string> Lines;
|
typedef std::vector<std::string> Lines;
|
||||||
Lines lines;
|
Lines lines;
|
||||||
typedef std::vector<Vector> ColorIndices;
|
typedef std::vector<Vector> ColorIndices;
|
||||||
|
|
|
@ -75,6 +75,8 @@ set(BBGE_SRCS
|
||||||
RenderObject_inline.h
|
RenderObject_inline.h
|
||||||
RenderObjectLayer.cpp
|
RenderObjectLayer.cpp
|
||||||
RenderRect.cpp
|
RenderRect.cpp
|
||||||
|
RenderState.cpp
|
||||||
|
RenderState.h
|
||||||
RoundedRect.cpp
|
RoundedRect.cpp
|
||||||
RoundedRect.h
|
RoundedRect.h
|
||||||
ScreenTransition.cpp
|
ScreenTransition.cpp
|
||||||
|
|
|
@ -1761,6 +1761,8 @@ void Core::render(int startLayer, int endLayer, bool useFrameBufferIfAvail)
|
||||||
processedRenderObjectCount = 0;
|
processedRenderObjectCount = 0;
|
||||||
totalRenderObjectCount = 0;
|
totalRenderObjectCount = 0;
|
||||||
|
|
||||||
|
CombinedRenderAndGPUState rgstate;
|
||||||
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glLoadIdentity(); // Reset The View
|
glLoadIdentity(); // Reset The View
|
||||||
|
@ -1818,13 +1820,13 @@ void Core::render(int startLayer, int endLayer, bool useFrameBufferIfAvail)
|
||||||
{
|
{
|
||||||
if (r->startPass == r->endPass)
|
if (r->startPass == r->endPass)
|
||||||
{
|
{
|
||||||
r->renderPass(RenderObject::RENDER_ALL);
|
r->renderPass(rgstate, RenderObject::RENDER_ALL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int pass = r->startPass; pass <= r->endPass; pass++)
|
for (int pass = r->startPass; pass <= r->endPass; pass++)
|
||||||
{
|
{
|
||||||
r->renderPass(pass);
|
r->renderPass(rgstate, pass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ public:
|
||||||
void remove(RenderObject* r);
|
void remove(RenderObject* r);
|
||||||
void moveToFront(RenderObject *r);
|
void moveToFront(RenderObject *r);
|
||||||
void moveToBack(RenderObject *r);
|
void moveToBack(RenderObject *r);
|
||||||
void renderPass(int pass);
|
void renderPass(const RenderState& rs, int pass);
|
||||||
void reloadDevice();
|
void reloadDevice();
|
||||||
|
|
||||||
inline bool empty()
|
inline bool empty()
|
||||||
|
@ -167,7 +167,7 @@ public:
|
||||||
Vector color;
|
Vector color;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline void renderOneObject(const RenderObject *robj);
|
inline void renderOneObject(const RenderState& rs, const RenderObject *robj);
|
||||||
|
|
||||||
RenderObjects renderObjects;
|
RenderObjects renderObjects;
|
||||||
size_t objectCount;
|
size_t objectCount;
|
||||||
|
|
|
@ -130,7 +130,7 @@ void DebugFont::setText(const std::string &text)
|
||||||
formatText();
|
formatText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugFont::onRender() const
|
void DebugFont::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
const float vspc = 1.5;
|
const float vspc = 1.5;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
float fontDrawSize, textWidth;
|
float fontDrawSize, textWidth;
|
||||||
void formatText();
|
void formatText();
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
std::string text;
|
std::string text;
|
||||||
std::vector<std::string> lines;
|
std::vector<std::string> lines;
|
||||||
Align align;
|
Align align;
|
||||||
|
|
|
@ -222,7 +222,7 @@ void Emitter::removeParticle(Particle *p)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emitter::onRender() const
|
void Emitter::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
if (particles.empty()) return;
|
if (particles.empty()) return;
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ void Gradient::makeHorizontal(Vector c1, Vector c2)
|
||||||
ulc3 = c1;
|
ulc3 = c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gradient::onRender() const
|
void Gradient::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
|
|
||||||
int autoWidth, autoHeight;
|
int autoWidth, autoHeight;
|
||||||
protected:
|
protected:
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
Vector ulc0, ulc1, ulc2, ulc3;
|
Vector ulc0, ulc1, ulc2, ulc3;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ public:
|
||||||
bool hasRot;
|
bool hasRot;
|
||||||
protected:
|
protected:
|
||||||
Vector currentSpawn, lastSpawn;
|
Vector currentSpawn, lastSpawn;
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
void spawnParticle(float perc=1);
|
void spawnParticle(float perc=1);
|
||||||
void onUpdate(float dt);
|
void onUpdate(float dt);
|
||||||
|
|
||||||
|
|
|
@ -422,7 +422,7 @@ void Quad::repeatTextureToFill(bool on)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Quad::onRender() const
|
void Quad::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
if (!renderQuad) return;
|
if (!renderQuad) return;
|
||||||
|
|
||||||
|
@ -657,7 +657,7 @@ CollideQuad::~CollideQuad()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollideQuad::renderCollision() const
|
void CollideQuad::renderCollision(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
if (collideRadius > 0)
|
if (collideRadius > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,7 +36,7 @@ protected:
|
||||||
int w, h, w2, h2;
|
int w, h, w2, h2;
|
||||||
int lineSize;
|
int lineSize;
|
||||||
|
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Quad : public RenderObject
|
class Quad : public RenderObject
|
||||||
|
@ -117,7 +117,7 @@ protected:
|
||||||
static Vector renderBorderColor;
|
static Vector renderBorderColor;
|
||||||
|
|
||||||
void onSetTexture();
|
void onSetTexture();
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
void onUpdate(float dt);
|
void onUpdate(float dt);
|
||||||
private:
|
private:
|
||||||
bool doUpdateGrid;
|
bool doUpdateGrid;
|
||||||
|
@ -143,7 +143,7 @@ class CollideQuad : public Quad
|
||||||
public:
|
public:
|
||||||
CollideQuad();
|
CollideQuad();
|
||||||
virtual ~CollideQuad();
|
virtual ~CollideQuad();
|
||||||
virtual void renderCollision() const OVERRIDE;
|
virtual void renderCollision(const RenderState& rs) const OVERRIDE;
|
||||||
|
|
||||||
float collideRadius;
|
float collideRadius;
|
||||||
};
|
};
|
||||||
|
|
|
@ -75,7 +75,7 @@ static inline void drawOnePoint(const QuadGrid::Point& p, float ox, float oy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QuadGrid::onRender() const
|
void QuadGrid::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
glColor4f(color.x, color.y, color.z, alpha.x * alphaMod);
|
glColor4f(color.x, color.y, color.z, alpha.x * alphaMod);
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
return _points[y * _w + x];
|
return _points[y * _w + x];
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void onRender() const OVERRIDE;
|
virtual void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
virtual void onUpdate(float dt);
|
virtual void onUpdate(float dt);
|
||||||
virtual void onSetTexture();
|
virtual void onSetTexture();
|
||||||
|
|
||||||
|
|
|
@ -55,35 +55,6 @@ int RenderObject::getTopLayer() const
|
||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BlendParams
|
|
||||||
{
|
|
||||||
GLenum src, dst;
|
|
||||||
};
|
|
||||||
static const BlendParams s_blendParams[] =
|
|
||||||
{
|
|
||||||
{ GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA },
|
|
||||||
{ GL_SRC_ALPHA, GL_ONE },
|
|
||||||
{ GL_ZERO, GL_SRC_ALPHA },
|
|
||||||
{ GL_ZERO, GL_SRC_COLOR },
|
|
||||||
};
|
|
||||||
|
|
||||||
void RenderObject::applyBlendType() const
|
|
||||||
{
|
|
||||||
compile_assert(Countof(s_blendParams) == _BLEND_MAXSIZE);
|
|
||||||
|
|
||||||
if (_blendType >= BLEND_DEFAULT)
|
|
||||||
{
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
const BlendParams& bp = s_blendParams[_blendType];
|
|
||||||
glBlendFunc(bp.src, bp.dst);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glDisable(GL_ALPHA_TEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderObject::setColorMult(const Vector &color, const float alpha) const
|
void RenderObject::setColorMult(const Vector &color, const float alpha) const
|
||||||
{
|
{
|
||||||
if (colorIsSaved)
|
if (colorIsSaved)
|
||||||
|
@ -502,7 +473,7 @@ bool RenderObject::hasRenderPass(const int pass) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderObject::render() const
|
void RenderObject::render(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
if (isHidden()) return;
|
if (isHidden()) return;
|
||||||
|
|
||||||
|
@ -547,17 +518,17 @@ void RenderObject::render() const
|
||||||
position = mb->positions[i].position;
|
position = mb->positions[i].position;
|
||||||
rotation.z = mb->positions[i].rotz;
|
rotation.z = mb->positions[i].rotz;
|
||||||
alpha = (1.0f-(float(i) * m)) * m2;
|
alpha = (1.0f-(float(i) * m)) * m2;
|
||||||
renderCall();
|
renderCall(rs);
|
||||||
}
|
}
|
||||||
position = oldPos;
|
position = oldPos;
|
||||||
alpha.x = oldAlpha;
|
alpha.x = oldAlpha;
|
||||||
rotation.z = oldRotZ;
|
rotation.z = oldRotZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderCall();
|
renderCall(rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderObject::renderCall() const
|
void RenderObject::renderCall(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
position += offset;
|
position += offset;
|
||||||
|
|
||||||
|
@ -648,7 +619,7 @@ void RenderObject::renderCall() const
|
||||||
for (Children::const_iterator i = children.begin(); i != children.end(); i++)
|
for (Children::const_iterator i = children.begin(); i != children.end(); i++)
|
||||||
{
|
{
|
||||||
if (!(*i)->isDead() && (*i)->renderBeforeParent)
|
if (!(*i)->isDead() && (*i)->renderBeforeParent)
|
||||||
(*i)->render();
|
(*i)->render(rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -680,7 +651,7 @@ void RenderObject::renderCall() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyBlendType();
|
rs.gpu.setBlend(getBlendType());
|
||||||
|
|
||||||
|
|
||||||
bool doRender = true;
|
bool doRender = true;
|
||||||
|
@ -698,16 +669,16 @@ void RenderObject::renderCall() const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderCollisionShape)
|
if (renderCollisionShape)
|
||||||
renderCollision();
|
renderCollision(rs);
|
||||||
|
|
||||||
if (doRender)
|
if (doRender)
|
||||||
onRender();
|
onRender(rs);
|
||||||
|
|
||||||
|
|
||||||
for (Children::const_iterator i = children.begin(); i != children.end(); i++)
|
for (Children::const_iterator i = children.begin(); i != children.end(); i++)
|
||||||
{
|
{
|
||||||
if (!(*i)->isDead() && !(*i)->renderBeforeParent)
|
if (!(*i)->isDead() && !(*i)->renderBeforeParent)
|
||||||
(*i)->render();
|
(*i)->render(rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -717,7 +688,7 @@ void RenderObject::renderCall() const
|
||||||
position -= offset;
|
position -= offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderObject::renderCollision() const
|
void RenderObject::renderCollision(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "EngineEnums.h"
|
#include "EngineEnums.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "ScriptObject.h"
|
#include "ScriptObject.h"
|
||||||
|
#include "RenderState.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
class Core;
|
class Core;
|
||||||
|
@ -93,7 +94,7 @@ public:
|
||||||
friend class Core;
|
friend class Core;
|
||||||
RenderObject();
|
RenderObject();
|
||||||
virtual ~RenderObject();
|
virtual ~RenderObject();
|
||||||
virtual void render() const;
|
virtual void render(const RenderState& rs) const;
|
||||||
|
|
||||||
void setTexturePointer(CountedPtr<Texture> t)
|
void setTexturePointer(CountedPtr<Texture> t)
|
||||||
{
|
{
|
||||||
|
@ -213,7 +214,6 @@ public:
|
||||||
|
|
||||||
void lookAt(const Vector &pos, float t, float minAngle, float maxAngle, float offset=0);
|
void lookAt(const Vector &pos, float t, float minAngle, float maxAngle, float offset=0);
|
||||||
inline RenderObject *getParent() const {return parent;}
|
inline RenderObject *getParent() const {return parent;}
|
||||||
void applyBlendType() const;
|
|
||||||
void fhTo(bool fh);
|
void fhTo(bool fh);
|
||||||
void addDeathNotify(RenderObject *r);
|
void addDeathNotify(RenderObject *r);
|
||||||
virtual void unloadDevice();
|
virtual void unloadDevice();
|
||||||
|
@ -295,7 +295,7 @@ protected:
|
||||||
virtual void onFH(){}
|
virtual void onFH(){}
|
||||||
virtual void onFV(){}
|
virtual void onFV(){}
|
||||||
virtual void onSetTexture(){}
|
virtual void onSetTexture(){}
|
||||||
virtual void onRender() const {}
|
virtual void onRender(const RenderState& rs) const {}
|
||||||
virtual void onUpdate(float dt);
|
virtual void onUpdate(float dt);
|
||||||
virtual void deathNotify(RenderObject *r);
|
virtual void deathNotify(RenderObject *r);
|
||||||
virtual void onEndOfLife() {}
|
virtual void onEndOfLife() {}
|
||||||
|
@ -305,8 +305,8 @@ protected:
|
||||||
// Is this object or any of its children rendered in pass "pass"?
|
// Is this object or any of its children rendered in pass "pass"?
|
||||||
bool hasRenderPass(const int pass) const;
|
bool hasRenderPass(const int pass) const;
|
||||||
|
|
||||||
inline void renderCall() const;
|
inline void renderCall(const RenderState& rs) const;
|
||||||
virtual void renderCollision() const;
|
virtual void renderCollision(const RenderState& rs) const;
|
||||||
|
|
||||||
typedef std::list<RenderObject*> RenderObjectList;
|
typedef std::list<RenderObject*> RenderObjectList;
|
||||||
RenderObjectList deathNotifications;
|
RenderObjectList deathNotifications;
|
||||||
|
|
|
@ -212,14 +212,13 @@ void RenderObjectLayer::moveToBack(RenderObject *r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderObjectLayer::renderPass(int pass)
|
void RenderObjectLayer::renderPass(const RenderState& rs, int pass)
|
||||||
{
|
{
|
||||||
core->currentLayerPass = pass;
|
core->currentLayerPass = pass;
|
||||||
|
|
||||||
|
|
||||||
for (RenderObject *robj = getFirst(); robj; robj = getNext())
|
for (RenderObject *robj = getFirst(); robj; robj = getNext())
|
||||||
{
|
{
|
||||||
renderOneObject(robj);
|
renderOneObject(rs, robj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,8 +226,7 @@ void RenderObjectLayer::reloadDevice()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void RenderObjectLayer::renderOneObject(const RenderState& rs, const RenderObject *robj)
|
||||||
inline void RenderObjectLayer::renderOneObject(const RenderObject *robj)
|
|
||||||
{
|
{
|
||||||
core->totalRenderObjectCount++;
|
core->totalRenderObjectCount++;
|
||||||
if (robj->getParent() || robj->alpha.x == 0)
|
if (robj->getParent() || robj->alpha.x == 0)
|
||||||
|
@ -236,7 +234,7 @@ inline void RenderObjectLayer::renderOneObject(const RenderObject *robj)
|
||||||
|
|
||||||
if (!robj->cull || robj->isOnScreen())
|
if (!robj->cull || robj->isOnScreen())
|
||||||
{
|
{
|
||||||
robj->render();
|
robj->render(rs);
|
||||||
core->renderObjectCount++;
|
core->renderObjectCount++;
|
||||||
}
|
}
|
||||||
core->processedRenderObjectCount++;
|
core->processedRenderObjectCount++;
|
||||||
|
|
|
@ -40,7 +40,7 @@ void OutlineRect::setLineSize(int ls)
|
||||||
lineSize = ls;
|
lineSize = ls;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutlineRect::onRender() const
|
void OutlineRect::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
glLineWidth(lineSize);
|
glLineWidth(lineSize);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
|
|
49
BBGE/RenderState.cpp
Normal file
49
BBGE/RenderState.cpp
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
#include "RenderState.h"
|
||||||
|
#include "Base.h"
|
||||||
|
#include "RenderBase.h"
|
||||||
|
|
||||||
|
|
||||||
|
RenderState::RenderState(GPUState &gpu)
|
||||||
|
: gpu(gpu), color(1,1,1), alpha(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct BlendParams
|
||||||
|
{
|
||||||
|
GLenum src, dst;
|
||||||
|
};
|
||||||
|
static const BlendParams s_blendParams[] =
|
||||||
|
{
|
||||||
|
{ GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA },
|
||||||
|
{ GL_SRC_ALPHA, GL_ONE },
|
||||||
|
{ GL_ZERO, GL_SRC_ALPHA },
|
||||||
|
{ GL_ZERO, GL_SRC_COLOR },
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GPUState::GPUState()
|
||||||
|
: _blendType(BLEND_DISABLED)
|
||||||
|
{
|
||||||
|
setBlend(BLEND_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPUState::setBlend(BlendType bt)
|
||||||
|
{
|
||||||
|
compile_assert(Countof(s_blendParams) == _BLEND_MAXSIZE);
|
||||||
|
if(_blendType == bt)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_blendType = bt;
|
||||||
|
if (bt >= BLEND_DEFAULT)
|
||||||
|
{
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
const BlendParams& bp = s_blendParams[bt];
|
||||||
|
glBlendFunc(bp.src, bp.dst);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
}
|
||||||
|
}
|
43
BBGE/RenderState.h
Normal file
43
BBGE/RenderState.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#ifndef BBGE_RENDERSTATE_H
|
||||||
|
#define BBGE_RENDERSTATE_H
|
||||||
|
|
||||||
|
#include "Vector.h"
|
||||||
|
#include "EngineEnums.h"
|
||||||
|
|
||||||
|
struct CombinedRenderAndGPUState;
|
||||||
|
|
||||||
|
// Only once of these exists at any time.
|
||||||
|
// It stores the known GPU state so that we don't need so many futile state changes
|
||||||
|
struct GPUState
|
||||||
|
{
|
||||||
|
friend struct CombinedRenderAndGPUState;
|
||||||
|
GPUState();
|
||||||
|
|
||||||
|
void setBlend(BlendType bt);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BlendType _blendType;
|
||||||
|
};
|
||||||
|
|
||||||
|
// The RenderState is passed through the scene graph as each layer is rendered
|
||||||
|
// TODO: what needs to end up here? matrix stack too?
|
||||||
|
struct RenderState
|
||||||
|
{
|
||||||
|
GPUState& gpu;
|
||||||
|
|
||||||
|
Vector color;
|
||||||
|
float alpha;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
RenderState(GPUState& gpu);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CombinedRenderAndGPUState : public RenderState
|
||||||
|
{
|
||||||
|
GPUState gpu;
|
||||||
|
CombinedRenderAndGPUState() : RenderState(gpu) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -101,7 +101,7 @@ void RoundedRect::onUpdate(float dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoundedRect::onRender() const
|
void RoundedRect::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
|
|
||||||
int w2 = width/2;
|
int w2 = width/2;
|
||||||
|
@ -257,7 +257,7 @@ void RoundButton::onUpdate(float dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoundButton::onRender() const
|
void RoundButton::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
int w2 = width/2, h2 = height/2;
|
int w2 = width/2, h2 = height/2;
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onUpdate(float dt);
|
void onUpdate(float dt);
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
|
|
||||||
bool canMove;
|
bool canMove;
|
||||||
static RoundedRect *moving;
|
static RoundedRect *moving;
|
||||||
|
@ -61,7 +61,7 @@ public:
|
||||||
EventPtr event;
|
EventPtr event;
|
||||||
protected:
|
protected:
|
||||||
void onUpdate(float dt);
|
void onUpdate(float dt);
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
|
|
||||||
TTFText *label;
|
TTFText *label;
|
||||||
int width, height, radius;
|
int width, height, radius;
|
||||||
|
|
|
@ -111,7 +111,7 @@ bool ScreenTransition::isGoing()
|
||||||
return alpha.isInterpolating();
|
return alpha.isInterpolating();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenTransition::onRender() const
|
void ScreenTransition::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
if (alpha.x == 0) return;
|
if (alpha.x == 0) return;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ protected:
|
||||||
void destroyTexture();
|
void destroyTexture();
|
||||||
int textureWidth, textureHeight;
|
int textureWidth, textureHeight;
|
||||||
int windowWidth, windowHeight;
|
int windowWidth, windowHeight;
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
float width, height;
|
float width, height;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -297,7 +297,7 @@ void Bone::spawnParticlesFromCollisionMask(const char *p, unsigned intv, int lay
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bone::renderCollision() const
|
void Bone::renderCollision(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
if (!collisionMask.empty())
|
if (!collisionMask.empty())
|
||||||
{
|
{
|
||||||
|
@ -332,7 +332,7 @@ void Bone::renderCollision() const
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CollideQuad::renderCollision();
|
CollideQuad::renderCollision(rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector Bone::getCollisionMaskNormal(size_t index)
|
Vector Bone::getCollisionMaskNormal(size_t index)
|
||||||
|
|
|
@ -94,7 +94,7 @@ public:
|
||||||
void spawnParticlesFromCollisionMask(const char *p, unsigned intv, int layer, float rotz = 0);
|
void spawnParticlesFromCollisionMask(const char *p, unsigned intv, int layer, float rotz = 0);
|
||||||
Vector getCollisionMaskNormal(size_t index);
|
Vector getCollisionMaskNormal(size_t index);
|
||||||
|
|
||||||
virtual void renderCollision() const OVERRIDE;
|
virtual void renderCollision(const RenderState& rs) const OVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<ParticleEffect*> emitters;
|
std::vector<ParticleEffect*> emitters;
|
||||||
|
|
|
@ -240,7 +240,7 @@ int TTFText::findLine(const std::string &label)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTFText::onRender() const
|
void TTFText::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ protected:
|
||||||
float lineHeight;
|
float lineHeight;
|
||||||
void updateAlign();
|
void updateAlign();
|
||||||
Align align;
|
Align align;
|
||||||
void onRender() const OVERRIDE;
|
void onRender(const RenderState& rs) const OVERRIDE;
|
||||||
void updateFormatting();
|
void updateFormatting();
|
||||||
|
|
||||||
std::string originalText;
|
std::string originalText;
|
||||||
|
|
|
@ -34,8 +34,7 @@ Texture::Texture()
|
||||||
textures[0] = 0;
|
textures[0] = 0;
|
||||||
width = height = 0;
|
width = height = 0;
|
||||||
|
|
||||||
repeat = false;
|
_repeating = false;
|
||||||
repeating = false;
|
|
||||||
ow = oh = -1;
|
ow = oh = -1;
|
||||||
loadResult = TEX_FAILED;
|
loadResult = TEX_FAILED;
|
||||||
_mipmap = false;
|
_mipmap = false;
|
||||||
|
@ -218,7 +217,6 @@ bool Texture::load(std::string file, bool mipmap)
|
||||||
file = adjustFilenameCase(file);
|
file = adjustFilenameCase(file);
|
||||||
|
|
||||||
loadName = file;
|
loadName = file;
|
||||||
repeating = false;
|
|
||||||
_mipmap = mipmap;
|
_mipmap = mipmap;
|
||||||
|
|
||||||
size_t pos = file.find_last_of('.');
|
size_t pos = file.find_last_of('.');
|
||||||
|
@ -284,26 +282,16 @@ bool Texture::load(std::string file, bool mipmap)
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::apply(bool repeatOverride) const
|
static const GLenum repeatLUT[] = { GL_CLAMP_TO_EDGE, GL_REPEAT };
|
||||||
|
void Texture::apply(bool repeat) const
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
||||||
if (repeat || repeatOverride)
|
if(repeat != _repeating)
|
||||||
{
|
{
|
||||||
if (!repeating)
|
_repeating = repeat;
|
||||||
{
|
GLenum rep = repeatLUT[repeat];
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, rep);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, rep);
|
||||||
repeating = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (repeating)
|
|
||||||
{
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
||||||
repeating = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,6 +326,7 @@ bool Texture::loadInternal(const ImageData& img, bool mipmap)
|
||||||
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
_repeating = false;
|
||||||
|
|
||||||
const GlTexFormat& f = formatLUT[img.channels - 1];
|
const GlTexFormat& f = formatLUT[img.channels - 1];
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
~Texture();
|
~Texture();
|
||||||
|
|
||||||
bool load(std::string file, bool mipmap);
|
bool load(std::string file, bool mipmap);
|
||||||
void apply(bool repeatOverride=false) const;
|
void apply(bool repeat = false) const;
|
||||||
void unload();
|
void unload();
|
||||||
|
|
||||||
int getPixelWidth();
|
int getPixelWidth();
|
||||||
|
@ -50,9 +50,6 @@ public:
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
bool repeat;
|
|
||||||
mutable bool repeating; // modified during rendering
|
|
||||||
|
|
||||||
unsigned textures[1];
|
unsigned textures[1];
|
||||||
|
|
||||||
void reload();
|
void reload();
|
||||||
|
@ -74,6 +71,8 @@ protected:
|
||||||
int ow, oh;
|
int ow, oh;
|
||||||
TextureLoadResult loadResult;
|
TextureLoadResult loadResult;
|
||||||
bool _mipmap;
|
bool _mipmap;
|
||||||
|
private:
|
||||||
|
mutable bool _repeating; // modified during rendering
|
||||||
};
|
};
|
||||||
|
|
||||||
#define UNREFTEX(x) if (x) {x = NULL;}
|
#define UNREFTEX(x) if (x) {x = NULL;}
|
||||||
|
|
Loading…
Add table
Reference in a new issue