1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-06-08 01:22:02 +00:00

Misc code cleanups, little SkeletalSprite loading improvement.

- Removed some unused member variables.

- The BBGE_BUILD_WIDESCREEN define is now gone.

- Added an TiXMLDocument cache to prevent parsing the same file
once for each entity on the map with the same skeletal.

- Removed Lua func entity_warpToPathStart, which was essentially a no-op
because Entity::followingPath was always NULL. Removed related code.

- Set texture wrap only when required.

(Some changes taken from https://bitbucket.org/mattbierner/ios-aquaria,
special thanks for changeset 72d6460d9e60)
This commit is contained in:
fgenesis 2012-02-19 04:57:04 +01:00
parent 568178bbb4
commit 9b63b400d5
23 changed files with 209 additions and 764 deletions

View file

@ -1201,6 +1201,7 @@ void AnimationEditor::saveFile()
void AnimationEditor::loadFile() void AnimationEditor::loadFile()
{ {
SkeletalSprite::clearCache();
lastSelectedBone = 0; lastSelectedBone = 0;
editingBone = 0; editingBone = 0;
clearUndoHistory(); clearUndoHistory();

View file

@ -3996,7 +3996,6 @@ void Avatar::lockToWallCommon()
dsq->spawnParticleEffect("LockToWall", position); dsq->spawnParticleEffect("LockToWall", position);
stopBurst(); stopBurst();
stopRoll(); stopRoll();
disableOverideMaxSpeed();
core->sound->playSfx("LockToWall", 1.0, 0);//, (1000+rand()%100)/1000.0f); core->sound->playSfx("LockToWall", 1.0, 0);//, (1000+rand()%100)/1000.0f);
//bursting = false; //bursting = false;
animatedBurst = false; animatedBurst = false;
@ -4307,7 +4306,6 @@ void Avatar::lockToWall()
void Avatar::applyTripEffects() void Avatar::applyTripEffects()
{ {
color.interpolateTo(BLIND_COLOR, 0.5); color.interpolateTo(BLIND_COLOR, 0.5);
currentColor = BLIND_COLOR;
tripper->alpha.interpolateTo(1, 8); tripper->alpha.interpolateTo(1, 8);
@ -4334,7 +4332,6 @@ void Avatar::applyTripEffects()
void Avatar::removeTripEffects() void Avatar::removeTripEffects()
{ {
color.interpolateTo(Vector(1,1,1),0.5); color.interpolateTo(Vector(1,1,1),0.5);
currentColor = Vector(1,1,1);
tripper->alpha.interpolateTo(0, 4); tripper->alpha.interpolateTo(0, 4);
if (dsq->loops.trip != BBGE_AUDIO_NOCHANNEL) if (dsq->loops.trip != BBGE_AUDIO_NOCHANNEL)
@ -4350,7 +4347,6 @@ void Avatar::applyBlindEffects()
// character black // character black
color.interpolateTo(BLIND_COLOR, 0.5); color.interpolateTo(BLIND_COLOR, 0.5);
currentColor = BLIND_COLOR;
blinder->alpha.interpolateTo(1, 0.5); blinder->alpha.interpolateTo(1, 0.5);
blinder->rotation.z = 0; blinder->rotation.z = 0;
@ -4364,7 +4360,6 @@ void Avatar::applyBlindEffects()
void Avatar::removeBlindEffects() void Avatar::removeBlindEffects()
{ {
color.interpolateTo(Vector(1,1,1),0.5); color.interpolateTo(Vector(1,1,1),0.5);
currentColor = Vector(1,1,1);
blinder->alpha.interpolateTo(0, 0.5); blinder->alpha.interpolateTo(0, 0.5);
//dsq->toggleMuffleSound(0); //dsq->toggleMuffleSound(0);
} }

View file

@ -1057,11 +1057,7 @@ This build is not yet final, and as such there are a couple things lacking. They
debugLog("Init Graphics Library..."); debugLog("Init Graphics Library...");
initGraphicsLibrary(user.video.resx, user.video.resy, fullscreen, user.video.vsync, user.video.bits); initGraphicsLibrary(user.video.resx, user.video.resy, fullscreen, user.video.vsync, user.video.bits);
#ifdef BBGE_BUILD_WIDESCREEN
core->enable2DWide(user.video.resx, user.video.resy); core->enable2DWide(user.video.resx, user.video.resy);
#else
core->enable2D(800, 600, 1);
#endif
core->initFrameBuffer(); core->initFrameBuffer();
debugLog("OK"); debugLog("OK");
@ -2245,6 +2241,7 @@ void DSQ::shutdown()
core->particleManager->clearParticleBank(); core->particleManager->clearParticleBank();
Shot::clearShotBank(); Shot::clearShotBank();
SkeletalSprite::clearCache();
cursor->setTexturePointer(0, RenderObject::NO_ADD_REF); cursor->setTexturePointer(0, RenderObject::NO_ADD_REF);

View file

@ -232,7 +232,6 @@ Entity::Entity() : StateMachine(), DFSprite()
} }
entityTypeIdx = -1; entityTypeIdx = -1;
damageTime = vars->entityDamageTime; damageTime = vars->entityDamageTime;
pushAvatar= false;
slowingToStopPathTimer = 0; slowingToStopPathTimer = 0;
slowingToStopPath = 0; slowingToStopPath = 0;
followPos = 0; followPos = 0;
@ -240,21 +239,16 @@ Entity::Entity() : StateMachine(), DFSprite()
swimPath = false; swimPath = false;
currentEntityTarget = 0; currentEntityTarget = 0;
deleteOnPathEnd = false; deleteOnPathEnd = false;
overideMaxSpeedValue= 0;
overideMaxSpeedTime=0;
followingPath = 0;
multColor = Vector(1,1,1); multColor = Vector(1,1,1);
collideRadius = 24; collideRadius = 24;
entityType = EntityType(0); entityType = EntityType(0);
targets.resize(10); targets.resize(10);
attachedTo = 0; attachedTo = 0;
currentPathNode = -1;
//target = 0; //target = 0;
frozenTimer = 0; frozenTimer = 0;
canBeTargetedByAvatar = false; canBeTargetedByAvatar = false;
activationRange = 0; activationRange = 0;
activationType = ACT_NONE; activationType = ACT_NONE;
currentColor = Vector(1,1,1);
pushDamage = 0; pushDamage = 0;
//debugLog("dsq->addEntity()"); //debugLog("dsq->addEntity()");
@ -262,7 +256,6 @@ Entity::Entity() : StateMachine(), DFSprite()
dsq->addEntity(this); dsq->addEntity(this);
maxSpeed = oldMaxSpeed = 300; maxSpeed = oldMaxSpeed = 300;
entityDead = false; entityDead = false;
takeDamage = true;
health = maxHealth = 5; health = maxHealth = 5;
invincibleBreak = false; invincibleBreak = false;
activationRadius = 40; activationRadius = 40;
@ -485,7 +478,6 @@ void Entity::setName(const std::string &name)
void Entity::followPath(Path *p, int speedType, int dir, bool deleteOnEnd) void Entity::followPath(Path *p, int speedType, int dir, bool deleteOnEnd)
{ {
//Path *p = dsq->game->getPathByName(name);
if (p) if (p)
{ {
deleteOnPathEnd = deleteOnEnd; deleteOnPathEnd = deleteOnEnd;
@ -514,15 +506,6 @@ void Entity::followPath(Path *p, int speedType, int dir, bool deleteOnEnd)
debugLog("Starting"); debugLog("Starting");
position.data->path.getPathNode(0)->value = position; position.data->path.getPathNode(0)->value = position;
position.startPath(time);//, 1.0f/2.0f); position.startPath(time);//, 1.0f/2.0f);
//swimPath = true;
/*
currentPathNode = 1;
followingPath = p;
setMaxSpeed(spd);
pathDefaultMaxSpeed = spd;
lastPathMaxSpeed = spd;
followingPathLoop = loop;
*/
} }
} }
@ -538,16 +521,16 @@ void Entity::moveToNode(Path *path, int speedType, int dieOnPathEnd, bool swim)
position.stop(); position.stop();
swimPath = swim; swimPath = swim;
debugLog("Generating path to: " + path->name); //debugLog("Generating path to: " + path->name);
dsq->pathFinding.generatePath(this, TileVector(start), TileVector(dest)); dsq->pathFinding.generatePath(this, TileVector(start), TileVector(dest));
int sz = position.data->path.getNumPathNodes(); int sz = position.data->path.getNumPathNodes();
position.data->path.addPathNode(path->nodes[0].position, 1); position.data->path.addPathNode(path->nodes[0].position, 1);
VectorPath old = position.data->path; VectorPath old = position.data->path;
std::ostringstream os; /*std::ostringstream os;
os << "Path length: " << sz; os << "Path length: " << sz;
debugLog(os.str()); debugLog(os.str());*/
debugLog("Regenerating section"); //debugLog("Regenerating section");
//int ms = sz % 12; //int ms = sz % 12;
/* /*
@ -561,19 +544,19 @@ void Entity::moveToNode(Path *path, int speedType, int dieOnPathEnd, bool swim)
*/ */
this->vel = 0; this->vel = 0;
debugLog("Molesting Path"); //debugLog("Molesting Path");
dsq->pathFinding.molestPath(position.data->path); dsq->pathFinding.molestPath(position.data->path);
//position.data->path.realPercentageCalc(); //position.data->path.realPercentageCalc();
//position.data->path.cut(4); //position.data->path.cut(4);
debugLog("forcing path to minimum 2 nodes"); //debugLog("forcing path to minimum 2 nodes");
dsq->pathFinding.forceMinimumPath(position.data->path, start, dest); dsq->pathFinding.forceMinimumPath(position.data->path, start, dest);
debugLog("Done"); //debugLog("Done");
debugLog("Calculating Time"); //debugLog("Calculating Time");
float time = position.data->path.getLength()/(float)dsq->continuity.getSpeedType(speedType); float time = position.data->path.getLength()/(float)dsq->continuity.getSpeedType(speedType);
debugLog("Starting"); //debugLog("Starting");
position.data->path.getPathNode(0)->value = position; position.data->path.getPathNode(0)->value = position;
position.startPath(time);//, 1.0f/2.0f); position.startPath(time);//, 1.0f/2.0f);
@ -582,10 +565,10 @@ void Entity::moveToNode(Path *path, int speedType, int dieOnPathEnd, bool swim)
position.endOfPathEvent.set(MakeFunctionEvent(Entity, safeKill)); position.endOfPathEvent.set(MakeFunctionEvent(Entity, safeKill));
*/ */
debugLog("Set delete on Path end"); //debugLog("Set delete on Path end");
deleteOnPathEnd = dieOnPathEnd; deleteOnPathEnd = dieOnPathEnd;
debugLog("End of Generate Path"); //debugLog("End of Generate Path");
//position.startSpeedPath(dsq->continuity.getSpeedType(speedType)); //position.startSpeedPath(dsq->continuity.getSpeedType(speedType));
//position.startPath(((position.data->path.getNumPathNodes()*TILE_SIZE*4)-2)/dsq->continuity.getSpeedType(speedType)); //position.startPath(((position.data->path.getNumPathNodes()*TILE_SIZE*4)-2)/dsq->continuity.getSpeedType(speedType));
@ -624,7 +607,6 @@ void Entity::setNodeGroupActive(int group, bool v)
void Entity::stopFollowingPath() void Entity::stopFollowingPath()
{ {
followingPath = 0;
position.stopPath(); position.stopPath();
} }
@ -693,12 +675,6 @@ bool Entity::hasTarget(int t)
return (targets[t]!=0); return (targets[t]!=0);
} }
void Entity::warpToPathStart()
{
if (followingPath && !followingPath->nodes.empty())
position = followingPath->nodes[0].position;
}
void Entity::watchEntity(Entity *e) void Entity::watchEntity(Entity *e)
{ {
watchingEntity = e; watchingEntity = e;
@ -1396,7 +1372,7 @@ bool Entity::pathBurst(bool wallJump)
bool Entity::isFollowingPath() bool Entity::isFollowingPath()
{ {
return followingPath != 0 || position.isFollowingPath(); return position.isFollowingPath();
} }
void Entity::onPathEnd() void Entity::onPathEnd()
@ -1820,15 +1796,6 @@ void Entity::onUpdate(float dt)
//vel2=0; //vel2=0;
Vector lastPos = position; Vector lastPos = position;
if (overideMaxSpeedTime > 0)
{
overideMaxSpeedTime-= dt;
if (overideMaxSpeedTime < 0)
{
overideMaxSpeedTime = 0;
overideMaxSpeedValue = 0;
}
}
if (ridingOnEntity) if (ridingOnEntity)
{ {
@ -1953,56 +1920,6 @@ void Entity::onUpdate(float dt)
} }
*/ */
if (followingPath && currentPathNode != -1 && life == 1)
{
PathNode *node = &followingPath->nodes[currentPathNode];
Vector v = node->position - this->position;
v.setLength2D(1000*dt);
vel += v;
int ms = pathDefaultMaxSpeed;
if (node->maxSpeed != -1)
{
ms = node->maxSpeed;
}
if (ms != lastPathMaxSpeed)
{
float distFromNode = 0, distBetweenNodes = 0;
distFromNode = (node->position - this->position).getLength2D();
if (currentPathNode > 0)
{
PathNode *previousNode = &followingPath->nodes[currentPathNode-1];
distBetweenNodes = (node->position - previousNode->position).getLength2D();
}
setMaxSpeed(lastPathMaxSpeed + (ms - lastPathMaxSpeed)*(1.0f-(distFromNode/distBetweenNodes)));
}
//setMaxSpeed(ms);
Vector diffVec = (node->position - this->position);
if (diffVec.getSquaredLength2D() < sqr(200))
{
currentPathNode ++;
lastPathMaxSpeed = ms;
if (currentPathNode >= followingPath->nodes.size())
{
if (followingPathLoop == -1)
{
warpToPathStart();
currentPathNode = 1;
}
else
{
if (deleteOnPathEnd)
this->safeKill();
position.interpolateTo(followingPath->nodes[followingPath->nodes.size()-1].position, 0.5);
//position = followingPath->nodes[followingPath->nodes.size()-1].position;
vel = 0;
followingPath = 0;
}
}
}
}
if (getState() == STATE_PUSH) if (getState() == STATE_PUSH)
{ {
//vel = pushVec * this->time; //vel = pushVec * this->time;
@ -2415,24 +2332,9 @@ void Entity::setMaxSpeed(int ms)
maxSpeed = oldMaxSpeed = ms; maxSpeed = oldMaxSpeed = ms;
} }
void Entity::overideMaxSpeed(int ms, float time)
{
overideMaxSpeedTime = time;
overideMaxSpeedValue = ms;
}
void Entity::disableOverideMaxSpeed()
{
overideMaxSpeedValue =0;
overideMaxSpeedTime = 0;
}
int Entity::getMaxSpeed() int Entity::getMaxSpeed()
{ {
if (overideMaxSpeedValue) return maxSpeed;
return overideMaxSpeedValue;
else
return maxSpeed;
} }
void Entity::songNote(int note) void Entity::songNote(int note)
@ -2450,10 +2352,6 @@ void Entity::sound(const std::string &sound, float freq, float fadeOut)
Vector Entity::getEnergyShotTargetPosition() Vector Entity::getEnergyShotTargetPosition()
{ {
if (!energyShotTargetPosition.isZero())
{
return energyShotTargetPosition;
}
return getWorldPosition(); return getWorldPosition();
} }
@ -2883,7 +2781,7 @@ bool Entity::damage(const DamageData &dmgData)
if (d.damageType == DT_NONE) if (d.damageType == DT_NONE)
return false; return false;
//if () return true; //if () return true;
if (!takeDamage || isEntityDead()) if (isEntityDead())
{ {
//DUPE: same as below //DUPE: same as below
//HACK: hackish //HACK: hackish

View file

@ -277,7 +277,6 @@ public:
void freeze(float time); void freeze(float time);
int leaches;
virtual void onSceneFlipped() {} virtual void onSceneFlipped() {}
bool isNearObstruction(int sz, int type=0, TileVector *hitTile=0); bool isNearObstruction(int sz, int type=0, TileVector *hitTile=0);
@ -308,10 +307,7 @@ public:
virtual void onNotify(Entity *notify){} virtual void onNotify(Entity *notify){}
//void followPath(Path *p, int spd, int loop, bool deleteOnEnd = false); //void followPath(Path *p, int spd, int loop, bool deleteOnEnd = false);
void followPath(Path *p, int speedType, int dir, bool deleteOnEnd = false); void followPath(Path *p, int speedType, int dir, bool deleteOnEnd = false);
void warpToPathStart();
int currentPathNode;
Entity *attachedTo; Entity *attachedTo;
Path *followingPath;
bool touchAvatarDamage(int radius, float dmg, const Vector &override=Vector(-1,-1,-1), int speed=0, float pushTime = 0, Vector collidePos = Vector(0,0,0)); bool touchAvatarDamage(int radius, float dmg, const Vector &override=Vector(-1,-1,-1), int speed=0, float pushTime = 0, Vector collidePos = Vector(0,0,0));
void moveTowards(Vector p, float dt, int spd); void moveTowards(Vector p, float dt, int spd);
@ -372,7 +368,6 @@ public:
void slowToStopPath(float t); void slowToStopPath(float t);
bool isSlowingToStopPath(); bool isSlowingToStopPath();
Vector lastMove; Vector lastMove;
int pushAvatar;
float damageTime; float damageTime;
void setEntityProperty(EntityProperty ep, bool value=true); void setEntityProperty(EntityProperty ep, bool value=true);
@ -419,7 +414,6 @@ public:
Vector getEnergyShotTargetPosition(); Vector getEnergyShotTargetPosition();
int getRandomTargetPoint(); int getRandomTargetPoint();
Vector energyShotTargetPosition;
Vector ridingOnEntityOffset; Vector ridingOnEntityOffset;
void moveOutOfWall(); void moveOutOfWall();
bool isSittingOnInvisibleIn(); bool isSittingOnInvisibleIn();
@ -458,7 +452,6 @@ public:
bool checkSplash(const Vector &override=Vector(0,0,0)); bool checkSplash(const Vector &override=Vector(0,0,0));
EatData eatData; EatData eatData;
InterpolatedVector flipScale; InterpolatedVector flipScale;
SkeletalSprite copySkel;
bool beautyFlip; bool beautyFlip;
void attachLance(); void attachLance();
void setInvincible(bool inv); void setInvincible(bool inv);
@ -564,18 +557,11 @@ protected:
virtual void onPathEnd(); virtual void onPathEnd();
bool swimPath; bool swimPath;
bool deleteOnPathEnd; bool deleteOnPathEnd;
int overideMaxSpeedValue;
float overideMaxSpeedTime;
InterpolatedVector multColor; InterpolatedVector multColor;
EntityType entityType; EntityType entityType;
std::vector<Entity*> attachedEntities; std::vector<Entity*> attachedEntities;
std::vector<Vector> attachedEntitiesOffsets; std::vector<Vector> attachedEntitiesOffsets;
int pathDefaultMaxSpeed;
int lastPathMaxSpeed;
int followingPathLoop;
virtual void onFreeze(){} virtual void onFreeze(){}
//Entity *target; //Entity *target;
@ -587,8 +573,6 @@ protected:
void doDeathEffects(int manaBallEnergy=0, bool die=true); void doDeathEffects(int manaBallEnergy=0, bool die=true);
Vector currentColor;
bool takeDamage;
void onEnterState(int action); void onEnterState(int action);
void onExitState(int action); void onExitState(int action);
//virtual bool onDamage(int amount, Spell *spell, Entity *attacker); //virtual bool onDamage(int amount, Spell *spell, Entity *attacker);

View file

@ -2845,7 +2845,6 @@ void Game::generateCollisionMask(Quad *q, int overrideCollideRadius)
q->collideRadius = overrideCollideRadius; q->collideRadius = overrideCollideRadius;
else else
q->collideRadius = TILE_SIZE/2; q->collideRadius = TILE_SIZE/2;
q->useCollisionMask = true;
q->collisionMask.clear(); q->collisionMask.clear();
std::vector<TileVector> obs; std::vector<TileVector> obs;
TileVector tpos(q->position); TileVector tpos(q->position);
@ -4295,7 +4294,6 @@ bool Game::loadSceneXML(std::string scene)
addProgress(); addProgress();
clearObsRows(); clearObsRows();
jetStreams.clear();
warpAreas.clear(); warpAreas.clear();
TiXmlElement *lensFlare = doc.FirstChildElement("LensFlare"); TiXmlElement *lensFlare = doc.FirstChildElement("LensFlare");
while (lensFlare) while (lensFlare)
@ -6481,10 +6479,8 @@ void Game::applyState()
//dsq->getRenderObjectLayer(LR_ELEMENTS5)->update = false; //dsq->getRenderObjectLayer(LR_ELEMENTS5)->update = false;
backgroundImageRepeat = 1; backgroundImageRepeat = 1;
jetStreams.clear();
grad = 0; grad = 0;
maxZoom = -1; maxZoom = -1;
followSym = 0;
saveFile = 0; saveFile = 0;
deathTimer = 0.9; deathTimer = 0.9;
runGameOverScript = false; runGameOverScript = false;
@ -6495,6 +6491,7 @@ void Game::applyState()
elementTemplatePack =""; elementTemplatePack ="";
clearGrid(); clearGrid();
clearPointers(); clearPointers();
SkeletalSprite::clearCache();
StateObject::applyState(); StateObject::applyState();
@ -10976,9 +10973,6 @@ void Game::removeState()
clearControlHint(); clearControlHint();
dsq->overlay->color = 0; dsq->overlay->color = 0;
if (dsq->game->avatar->attachedTo)
avatarTransit = dsq->game->avatar->attachedTo->name;
//dsq->overlay->alpha = 0; //dsq->overlay->alpha = 0;
dsq->overlay->alpha.interpolateTo(1, fadeTime); dsq->overlay->alpha.interpolateTo(1, fadeTime);
dsq->main(fadeTime); dsq->main(fadeTime);

View file

@ -73,7 +73,6 @@ struct RecipeMenu
std::vector<RecipeMenuEntry*> recipeMenuEntries; std::vector<RecipeMenuEntry*> recipeMenuEntries;
}; };
class JetStream;
class Avatar; class Avatar;
class Gradient; class Gradient;
class CurrentRender; class CurrentRender;
@ -134,14 +133,6 @@ enum EditTypes
}; };
#endif #endif
class FollowSym : public Quad
{
public:
FollowSym();
protected:
void onUpdate(float dt);
};
class ManaBall : public Quad class ManaBall : public Quad
{ {
public: public:
@ -739,8 +730,6 @@ public:
TiXmlDocument *saveFile; TiXmlDocument *saveFile;
std::vector<JetStream*> jetStreams;
FollowSym *followSym;
Vector positionToAvatar; Vector positionToAvatar;
float getCoverage(Vector pos, int sampleArea = 5); float getCoverage(Vector pos, int sampleArea = 5);
@ -800,7 +789,6 @@ public:
Path *getNearestPath(const Vector &pos, PathType pathType=PATH_NONE); Path *getNearestPath(const Vector &pos, PathType pathType=PATH_NONE);
Path *getNearestPath(Path *p, std::string name); Path *getNearestPath(Path *p, std::string name);
std::string avatarTransit;
#ifdef AQUARIA_BUILD_SCENEEDITOR #ifdef AQUARIA_BUILD_SCENEEDITOR
SceneEditor sceneEditor; SceneEditor sceneEditor;
bool isSceneEditorActive() {return sceneEditor.isOn();} bool isSceneEditorActive() {return sceneEditor.isOn();}

View file

@ -2394,8 +2394,6 @@ void SceneEditor::removeEntity()
void SceneEditor::placeAvatar() void SceneEditor::placeAvatar()
{ {
dsq->game->avatar->position = dsq->getGameCursorPosition(); dsq->game->avatar->position = dsq->getGameCursorPosition();
QuadLight::clearQuadLights();
QuadLight::addQuadLight(QuadLight(Vector(dsq->game->avatar->position), Vector(1, 0, 0), 1200));
} }
void SceneEditor::scaleElementUp() void SceneEditor::scaleElementUp()

View file

@ -2672,23 +2672,6 @@ luaFunc(entity_followPath)
luaReturnNil(); luaReturnNil();
} }
luaFunc(entity_warpToPathStart)
{
ScriptedEntity *e = scriptedEntity(L);
std::string s;
if (lua_isstring(L, 2))
s = lua_tostring(L, 2);
if (s.empty())
e->warpToPathStart();
else
{
//e->followPath(s, 0, 0);
e->warpToPathStart();
e->stopFollowingPath();
}
luaReturnNil();
}
luaFunc(getIngredientGfx) luaFunc(getIngredientGfx)
{ {
luaReturnStr(dsq->continuity.getIngredientGfx(getString(L, 1)).c_str()); luaReturnStr(dsq->continuity.getIngredientGfx(getString(L, 1)).c_str());
@ -7482,7 +7465,6 @@ static const struct {
luaRegister(entity_setAnimLayerTimeMult), luaRegister(entity_setAnimLayerTimeMult),
luaRegister(entity_setCurrentTarget), luaRegister(entity_setCurrentTarget),
luaRegister(entity_warpToPathStart),
luaRegister(entity_stopInterpolating), luaRegister(entity_stopInterpolating),
luaRegister(entity_followPath), luaRegister(entity_followPath),

View file

@ -215,68 +215,28 @@ void AfterEffectManager::capture()
} }
void AfterEffectManager::render() void AfterEffectManager::render()
{ {
//if (!core->frameBuffer.isInited() && numEffects==0) return;
#ifdef BBGE_BUILD_OPENGL #ifdef BBGE_BUILD_OPENGL
if (active || core->frameBuffer.isInited()) glPushMatrix();
{ //glDisable(GL_BLEND);
glPushMatrix(); //glEnable(GL_BLEND);
//glDisable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glEnable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA, GL_ONE);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable (GL_ALPHA_TEST);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE); glDisable(GL_BLEND);
glDisable (GL_ALPHA_TEST);
glDisable(GL_BLEND);
capture(); capture();
glTranslatef(core->cameraPos.x, core->cameraPos.y, 0); glTranslatef(core->cameraPos.x, core->cameraPos.y, 0);
glScalef(core->invGlobalScale, core->invGlobalScale,0); glScalef(core->invGlobalScale, core->invGlobalScale,0);
/*
static float angle=0;
angle += 0.03f;
*/
//glRotatef(angle, 0, 0, 1);
//glColor4f(1,1,1,0.75);
glColor4f(1,1,1,1);
if (core->mode == Core::MODE_2D)
{
renderGrid();
// renderGridPoints();
}
glPopMatrix();
}
else
{
glPushMatrix();
//glDisable(GL_BLEND);
//glEnable(GL_BLEND);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glDisable (GL_ALPHA_TEST);
glDisable(GL_BLEND);
capture();
glTranslatef(core->cameraPos.x, core->cameraPos.y, 0);
glScalef(core->invGlobalScale, core->invGlobalScale,0);
/*
static float angle;
angle += 0.03f;
*/
//glRotatef(angle, 0, 0, 1);
//glColor4f(1,1,1,0.75);
glColor4f(1,1,1,1);
if (core->mode == Core::MODE_2D)
{
renderGrid();
// renderGridPoints();
}
glPopMatrix();
}
/* /*
else static float angle;
{ angle += 0.03f;
core->frameBuffer.endCapture();
}
*/ */
//glRotatef(angle, 0, 0, 1);
//glColor4f(1,1,1,0.75);
glColor4f(1,1,1,1);
renderGrid();
//renderGridPoints();
glPopMatrix();
#endif #endif
} }
@ -360,68 +320,65 @@ void AfterEffectManager::renderGrid()
int offx = -core->getVirtualOffX(); int offx = -core->getVirtualOffX();
int offy = -core->getVirtualOffY(); int offy = -core->getVirtualOffY();
if (core->mode == Core::MODE_2D) //float div = xDivs;
for (int i = 0; i < (xDivs-1); i++)
{ {
//float div = xDivs; for (int j = 0; j < (yDivs-1); j++)
for (int i = 0; i < (xDivs-1); i++)
{ {
for (int j = 0; j < (yDivs-1); j++) glBegin(GL_QUADS);
{ //glColor3f(i/div, i/div, i/div);
glBegin(GL_QUADS); glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
//glColor3f(i/div, i/div, i/div); //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); glVertex2f(offx + vw*drawGrid[i][j].x, offy + vh*drawGrid[i][j].y);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0); glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
glVertex2f(offx + vw*drawGrid[i][j].x, offy + vh*drawGrid[i][j].y); //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,(float)(screenHeight/(yDivs-1))/16);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); glVertex2f(offx + vw*drawGrid[i][j+1].x, offy + vh*drawGrid[i][j+1].y);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,(float)(screenHeight/(yDivs-1))/16); glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
glVertex2f(offx + vw*drawGrid[i][j+1].x, offy + vh*drawGrid[i][j+1].y); //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY); glVertex2f(offx + vw*drawGrid[i+1][j+1].x, offy + vh*drawGrid[i+1][j+1].y);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16); glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
glVertex2f(offx + vw*drawGrid[i+1][j+1].x, offy + vh*drawGrid[i+1][j+1].y); //glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY); glVertex2f(offx + vw*drawGrid[i+1][j].x, offy + vh*drawGrid[i+1][j].y);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0); glEnd();
glVertex2f(offx + vw*drawGrid[i+1][j].x, offy + vh*drawGrid[i+1][j].y);
glEnd();
}
} }
// uncomment to render grid points
/*
glBindTexture(GL_TEXTURE_2D, 0);
glPointSize(2);
glColor4f(1, 0, 0, 0.5);
for (int i = 0; i < (xDivs-1); i++)
{
for (int j = 0; j < (yDivs-1); j++)
{
glBegin(GL_POINTS);
//glColor3f(i/div, i/div, i/div);
glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
glVertex2f(800*drawGrid[i][j].x, 600*drawGrid[i][j].y);
glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,(float)(screenHeight/(yDivs-1))/16);
glVertex2f(800*drawGrid[i][j+1].x, 600*drawGrid[i][j+1].y);
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16);
glVertex2f(800*drawGrid[i+1][j+1].x, 600*drawGrid[i+1][j+1].y);
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0);
glVertex2f(800*drawGrid[i+1][j].x, 600*drawGrid[i+1][j].y);
glEnd();
}
}
*/
} }
// uncomment to render grid points
/*
glBindTexture(GL_TEXTURE_2D, 0);
glPointSize(2);
glColor4f(1, 0, 0, 0.5);
for (int i = 0; i < (xDivs-1); i++)
{
for (int j = 0; j < (yDivs-1); j++)
{
glBegin(GL_POINTS);
//glColor3f(i/div, i/div, i/div);
glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
glVertex2f(800*drawGrid[i][j].x, 600*drawGrid[i][j].y);
glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,(float)(screenHeight/(yDivs-1))/16);
glVertex2f(800*drawGrid[i][j+1].x, 600*drawGrid[i][j+1].y);
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16);
glVertex2f(800*drawGrid[i+1][j+1].x, 600*drawGrid[i+1][j+1].y);
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0);
glVertex2f(800*drawGrid[i+1][j].x, 600*drawGrid[i+1][j].y);
glEnd();
}
}
*/
//glDisable(GL_TEXTURE_2D); //glDisable(GL_TEXTURE_2D);
RenderObject::lastTextureApplied = 0; RenderObject::lastTextureApplied = 0;
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);

View file

@ -8,7 +8,6 @@
#define BBGE_BUILD_SHADERS 1 #define BBGE_BUILD_SHADERS 1
#define BBGE_BUILD_OPENGL 1 #define BBGE_BUILD_OPENGL 1
#define BBGE_BUILD_OPENGL_DYNAMIC 1 #define BBGE_BUILD_OPENGL_DYNAMIC 1
#define BBGE_BUILD_WIDESCREEN 1
#define BBGE_BUILD_FMOD_OPENAL_BRIDGE 1 #define BBGE_BUILD_FMOD_OPENAL_BRIDGE 1
#define BBGE_BUILD_ACHIEVEMENTS_INTERNAL 1 #define BBGE_BUILD_ACHIEVEMENTS_INTERNAL 1

View file

@ -102,7 +102,7 @@ public:
sprintf(errbuf, "Exception in ByteBuffer: '%s', rpos: %u, wpos: %u, cursize: %u, sizeparam: %u", \ sprintf(errbuf, "Exception in ByteBuffer: '%s', rpos: %u, wpos: %u, cursize: %u, sizeparam: %u", \
__e.action, __e.rpos, __e.wpos, __e.cursize, __e.sizeparam); errorLog(errbuf); abort(); } __e.action, __e.rpos, __e.wpos, __e.cursize, __e.sizeparam); errorLog(errbuf); abort(); }
#else #else
#define BYTEBUFFER_EXCEPT(bb, desc, sz) throw ByteBufferException(bb, desc, sz) #define BYTEBUFFER_EXCEPT(bb, desc, sz) throw Exception(bb, desc, sz)
#endif #endif
protected: protected:

View file

@ -135,8 +135,6 @@ void Core::reloadDevice()
void Core::resetGraphics(int w, int h, int fullscreen, int vsync, int bpp) void Core::resetGraphics(int w, int h, int fullscreen, int vsync, int bpp)
{ {
int lastMode = mode;
if (fullscreen == -1) if (fullscreen == -1)
fullscreen = _fullscreen; fullscreen = _fullscreen;
@ -159,19 +157,7 @@ void Core::resetGraphics(int w, int h, int fullscreen, int vsync, int bpp)
initGraphicsLibrary(w, h, fullscreen, vsync, bpp); initGraphicsLibrary(w, h, fullscreen, vsync, bpp);
switch(lastMode) enable2DWide(w, h);
{
case MODE_2D:
#ifdef BBGE_BUILD_WIDESCREEN
enable2DWide(w, h);
#else
enable2D(virtualWidth, virtualHeight, true);
#endif
break;
case MODE_3D:
enable3D();
break;
}
reloadResources(); reloadResources();
reloadDevice(); reloadDevice();
@ -1032,7 +1018,6 @@ Core::Core(const std::string &filesystem, int numRenderLayers, const std::string
nestedMains = 0; nestedMains = 0;
afterEffectManager = 0; afterEffectManager = 0;
loopDone = false; loopDone = false;
mode = 0;
core = this; core = this;
#ifdef BBGE_BUILD_WINDOWS #ifdef BBGE_BUILD_WINDOWS
@ -1051,12 +1036,6 @@ Core::Core(const std::string &filesystem, int numRenderLayers, const std::string
globalResolutionScale = globalScale = Vector(1,1,1); globalResolutionScale = globalScale = Vector(1,1,1);
lights.resize(8);
for (int i = 0; i < lights.size(); i++)
{
lights[i].num = i;
}
initRenderObjectLayers(numRenderLayers); initRenderObjectLayers(numRenderLayers);
initPlatform(filesystem); initPlatform(filesystem);
@ -1805,14 +1784,6 @@ void Core::onUpdate(float dt)
afterEffectManager->update(dt); afterEffectManager->update(dt);
} }
for (int i = 0; i < lights.size(); i++)
{
if (lights[i].enabled)
{
lights[i].update(dt);
}
}
if (!sortFlag) if (!sortFlag)
{ {
if (sortTimer>0) if (sortTimer>0)
@ -1906,13 +1877,11 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, int vsync
{ {
static bool didOnce = false; static bool didOnce = false;
//#ifdef BBGE_BUILD_WIDESCREEN
aspectX = width; aspectX = width;
aspectY = height; aspectY = height;
aspect = (aspectX/aspectY); aspect = (aspectX/aspectY);
//#endif
this->width = width; this->width = width;
@ -2135,7 +2104,6 @@ void Core::shutdownGraphicsLibrary(bool killVideo)
#endif #endif
_hasFocus = false; _hasFocus = false;
mode = MODE_NONE;
lib_graphics = false; lib_graphics = false;
@ -2341,70 +2309,6 @@ bbgePerspective(float fovy, float aspect, float zNear, float zFar)
glMultMatrixf(&m[0][0]); glMultMatrixf(&m[0][0]);
} }
// don't want to support resizing
void Core::resize3D()
{
glViewport(0,0,width,height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
bbgePerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
/*
//width/height = aspect;
if (aspect)
{
width = int(float(height)*aspect);
}
this->width = width;
this->height = height;
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}
#ifdef BBGE_BUILD_OPENGL
glViewport(0,0,width,height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
#ifdef BBGE_BUILD_GLFW
if (mode == MODE_3D)
// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
#endif
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
if (this->mode == Core::MODE_2D)
enable2D();
onResetScene();
//if (!fullscreen)
//{
//DWORD dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
//DWORD dwStyle=WS_OVERLAPPEDWINDOW;
//RECT r = {0,0,width,height};
//AdjustWindowRectEx(&r,dwStyle,false,dwExStyle);
//}
#endif
*/
}
void Core::setPixelScale(int pixelScaleX, int pixelScaleY) void Core::setPixelScale(int pixelScaleX, int pixelScaleY)
{ {
/* /*
@ -2462,13 +2366,6 @@ void Core::enable2DWide(int rx, int ry)
//vh = MAX(vh, baseVirtualHeight); //vh = MAX(vh, baseVirtualHeight);
core->enable2D(baseVirtualWidth, vh, 1); core->enable2D(baseVirtualWidth, vh, 1);
} }
//else
//{
// int vh = int(float(baseVirtualWidth) * (float(ry)/float(rx)));
// vh = MAX(vh, baseVirtualHeight);
// core->enable2D(baseVirtualWidth, vh, 1);
//}
} }
static void bbgeOrtho2D(float left, float right, float bottom, float top) static void bbgeOrtho2D(float left, float right, float bottom, float top)
@ -2499,8 +2396,6 @@ void Core::enable2D(int pixelScaleX, int pixelScaleY, bool forcePixelScale)
} }
*/ */
mode = MODE_2D;
#ifdef BBGE_BUILD_OPENGL #ifdef BBGE_BUILD_OPENGL
GLint viewPort[4]; GLint viewPort[4];
@ -2510,15 +2405,6 @@ void Core::enable2D(int pixelScaleX, int pixelScaleY, bool forcePixelScale)
//glPushMatrix(); //glPushMatrix();
glLoadIdentity(); glLoadIdentity();
//#ifdef BBGE_BUILD_WIDESCREEN
//int offx=0,offy=0;
// hackish
//float vw = float((viewPort[2] * baseVirtualHeight)) / float(viewPort[3]);
//float vw = float(aspectX * viewPort[3]) / float(aspectY);
//- baseVirtualWidth;
//offx = float(vw)*0.1f;
float vw=0,vh=0; float vw=0,vh=0;
viewOffX = viewOffY = 0; viewOffX = viewOffY = 0;
@ -2704,47 +2590,6 @@ void Core::enable2D(int pixelScaleX, int pixelScaleY, bool forcePixelScale)
} }
void Core::enable3D()
{
if (mode == MODE_3D) return;
else if (mode == MODE_2D)
{
/*
#ifdef BBGE_BUILD_OPENGL
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
#endif
*/
}
mode = MODE_3D;
glClearDepth(1.0); // Depth Buffer Setup
glLoadIdentity();
resize3D();
/*
int viewPort[4];
glGetIntegerv(GL_VIEWPORT, viewPort);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
//glOrtho(0.0f,viewPort[2],viewPort[3],0.0f,-1000.0f,1000.0f);
glOrtho(0.0f,viewPort[2],viewPort[3],0.0f,-1.0f,1.0f);
//glOrtho(0, viewPort[2], 0, viewPort[3], -100, 100);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
*/
}
void Core::quitNestedMain() void Core::quitNestedMain()
{ {
if (getNestedMains() > 1) if (getNestedMains() > 1)
@ -3963,16 +3808,6 @@ void Core::render(int startLayer, int endLayer, bool useFrameBufferIfAvail)
} }
setupRenderPositionAndScale(); setupRenderPositionAndScale();
bool e = false;
for (int i = 0; i < lights.size(); i++)
{
lights[i].apply();
if (lights[i].enabled) e = true;
}
if (e)
glEnable(GL_LIGHTING);
else
glDisable(GL_LIGHTING);
#endif #endif
#ifdef BBGE_BUILD_DIRECTX #ifdef BBGE_BUILD_DIRECTX
@ -4050,20 +3885,6 @@ void Core::render(int startLayer, int endLayer, bool useFrameBufferIfAvail)
RenderObject::rlayer = r; RenderObject::rlayer = r;
if (r->visible) if (r->visible)
{ {
if (r->mode != mode)
{
switch(r->mode)
{
case MODE_2D:
enable2DWide(width, height);
glLoadIdentity();
setupRenderPositionAndScale();
break;
case MODE_3D:
enable3D();
break;
}
}
if (r->startPass == r->endPass) if (r->startPass == r->endPass)
{ {
r->renderPass(RenderObject::RENDER_ALL); r->renderPass(RenderObject::RENDER_ALL);

View file

@ -983,7 +983,6 @@ public:
//bool createGlWindow(char* title, int width, int height, int bits, bool fullscreenflag); //bool createGlWindow(char* title, int width, int height, int bits, bool fullscreenflag);
bool createWindow(int width, int height, int bits, bool fullscreen, std::string windowTitle=""); bool createWindow(int width, int height, int bits, bool fullscreen, std::string windowTitle="");
//void setWindowTitle(const std::string &title); // func not yet written //void setWindowTitle(const std::string &title); // func not yet written
void resize3D();
void clearBuffers(); void clearBuffers();
void render(int startLayer=-1, int endLayer=-1, bool useFrameBufferIfAvail=true); void render(int startLayer=-1, int endLayer=-1, bool useFrameBufferIfAvail=true);
void showBuffer(); void showBuffer();
@ -1023,7 +1022,6 @@ public:
void toggleScreenMode(int t=0); void toggleScreenMode(int t=0);
void enable2D(int pixelScaleX=0, int pixelScaleY=0, bool forcePixelScale=false); void enable2D(int pixelScaleX=0, int pixelScaleY=0, bool forcePixelScale=false);
void enable3D();
void addRenderObject(RenderObject *o, int layer=0); void addRenderObject(RenderObject *o, int layer=0);
void switchRenderObjectLayer(RenderObject *o, int toLayer); void switchRenderObjectLayer(RenderObject *o, int toLayer);
void addResource(Resource *r); void addResource(Resource *r);
@ -1123,8 +1121,6 @@ public:
int width, height; int width, height;
int mode;
enum Modes { MODE_NONE=-1, MODE_3D=0, MODE_2D }; enum Modes { MODE_NONE=-1, MODE_3D=0, MODE_2D };
InterpolatedVector globalScale; InterpolatedVector globalScale;
@ -1140,9 +1136,6 @@ public:
int fps; int fps;
bool loopDone; bool loopDone;
std::vector<Light> lights;
Mouse mouse; Mouse mouse;
AfterEffectManager *afterEffectManager; AfterEffectManager *afterEffectManager;

View file

@ -23,30 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <assert.h> #include <assert.h>
std::vector<QuadLight> QuadLight::quadLights;
bool Quad::flipTY = true;
int Quad::_w2 = 0;
int Quad::_h2 = 0;
QuadLight::QuadLight(Vector position, Vector color, int dist)
{
this->dist = dist;
this->color = color;
this->position = position;
}
void QuadLight::clearQuadLights()
{
quadLights.clear();
}
void QuadLight::addQuadLight(const QuadLight &quadLight)
{
quadLights.push_back(quadLight);
}
Vector Quad::renderBorderColor = Vector(1,1,1); Vector Quad::renderBorderColor = Vector(1,1,1);
Quad::Quad(const std::string &tex, const Vector &pos) Quad::Quad(const std::string &tex, const Vector &pos)
@ -267,13 +243,9 @@ void Quad::initQuad()
//debugLog("Quad::initQuad()"); //debugLog("Quad::initQuad()");
repeatingTextureToFill = false; repeatingTextureToFill = false;
_w2 = _h2 = 0;
drawGrid = 0; drawGrid = 0;
lightingColor = Vector(1,1,1);
quadLighting = false;
renderBorder = false; renderBorder = false;
renderCenter = true; renderCenter = true;
width = 2; height = 2; width = 2; height = 2;
@ -439,108 +411,80 @@ void Quad::renderGrid()
const float blue = this->color.z; const float blue = this->color.z;
const float alpha = this->alpha.x * this->alphaMod; const float alpha = this->alpha.x * this->alphaMod;
if (core->mode == Core::MODE_2D) /*
glDisable(GL_BLEND);
glDisable(GL_CULL_FACE);
*/
glBegin(GL_QUADS);
float u0 = baseX;
float u1 = u0 + incX;
for (int i = 0; i < (xDivs-1); i++, u0 = u1, u1 += incX)
{ {
/* float v0 = 1 - percentY + baseY;
glDisable(GL_BLEND); float v1 = v0 + incY;
glDisable(GL_CULL_FACE); for (int j = 0; j < (yDivs-1); j++, v0 = v1, v1 += incY)
*/
glBegin(GL_QUADS);
float u0 = baseX;
float u1 = u0 + incX;
for (int i = 0; i < (xDivs-1); i++, u0 = u1, u1 += incX)
{ {
float v0 = 1 - percentY + baseY; if (drawGrid[i][j].z != 0 || drawGrid[i][j+1].z != 0 || drawGrid[i+1][j].z != 0 || drawGrid[i+1][j+1].z != 0)
float v1 = v0 + incY;
for (int j = 0; j < (yDivs-1); j++, v0 = v1, v1 += incY)
{ {
if (drawGrid[i][j].z != 0 || drawGrid[i][j+1].z != 0 || drawGrid[i+1][j].z != 0 || drawGrid[i+1][j+1].z != 0)
{
glColor4f(red, green, blue, alpha*drawGrid[i][j].z); glColor4f(red, green, blue, alpha*drawGrid[i][j].z);
glTexCoord2f(u0, v0); glTexCoord2f(u0, v0);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u0-baseX, v0-baseY); //glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u0-baseX, v0-baseY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0); //glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
glVertex2f(w*drawGrid[i][j].x, h*drawGrid[i][j].y);
//
glColor4f(red, green, blue, alpha*drawGrid[i][j+1].z);
glTexCoord2f(u0, v1);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u0-baseX, v1-baseY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,(float)(screenHeight/(yDivs-1))/16);
glVertex2f(w*drawGrid[i][j+1].x, h*drawGrid[i][j+1].y);
//
glColor4f(red, green, blue, alpha*drawGrid[i+1][j+1].z);
glTexCoord2f(u1, v1);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u1-baseX, v1-baseY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16);
glVertex2f(w*drawGrid[i+1][j+1].x, h*drawGrid[i+1][j+1].y);
//
glColor4f(red, green, blue, alpha*drawGrid[i+1][j].z);
glTexCoord2f(u1, v0);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u1-baseX, v0-baseY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0);
glVertex2f(w*drawGrid[i+1][j].x, h*drawGrid[i+1][j].y);
}
}
}
glEnd();
// debug points
if (RenderObject::renderCollisionShape)
{
glBindTexture(GL_TEXTURE_2D, 0);
glPointSize(2);
glColor3f(1,0,0);
glBegin(GL_POINTS);
for (int i = 0; i < (xDivs-1); i++)
{
for (int j = 0; j < (yDivs-1); j++)
{
glVertex2f(w*drawGrid[i][j].x, h*drawGrid[i][j].y); glVertex2f(w*drawGrid[i][j].x, h*drawGrid[i][j].y);
//
glColor4f(red, green, blue, alpha*drawGrid[i][j+1].z);
glTexCoord2f(u0, v1);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u0-baseX, v1-baseY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,(float)(screenHeight/(yDivs-1))/16);
glVertex2f(w*drawGrid[i][j+1].x, h*drawGrid[i][j+1].y); glVertex2f(w*drawGrid[i][j+1].x, h*drawGrid[i][j+1].y);
//
glColor4f(red, green, blue, alpha*drawGrid[i+1][j+1].z);
glTexCoord2f(u1, v1);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u1-baseX, v1-baseY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16);
glVertex2f(w*drawGrid[i+1][j+1].x, h*drawGrid[i+1][j+1].y); glVertex2f(w*drawGrid[i+1][j+1].x, h*drawGrid[i+1][j+1].y);
//
glColor4f(red, green, blue, alpha*drawGrid[i+1][j].z);
glTexCoord2f(u1, v0);
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u1-baseX, v0-baseY);
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0);
glVertex2f(w*drawGrid[i+1][j].x, h*drawGrid[i+1][j].y); glVertex2f(w*drawGrid[i+1][j].x, h*drawGrid[i+1][j].y);
} }
} }
}
glEnd(); glEnd();
if (texture)
// debug points glBindTexture(GL_TEXTURE_2D, texture->textures[0]);
if (RenderObject::renderCollisionShape)
{
glBindTexture(GL_TEXTURE_2D, 0);
glPointSize(2);
glColor3f(1,0,0);
glBegin(GL_POINTS);
for (int i = 0; i < (xDivs-1); i++)
{
for (int j = 0; j < (yDivs-1); j++)
{
glVertex2f(w*drawGrid[i][j].x, h*drawGrid[i][j].y);
glVertex2f(w*drawGrid[i][j+1].x, h*drawGrid[i][j+1].y);
glVertex2f(w*drawGrid[i+1][j+1].x, h*drawGrid[i+1][j+1].y);
glVertex2f(w*drawGrid[i+1][j].x, h*drawGrid[i+1][j].y);
}
}
glEnd();
if (texture)
glBindTexture(GL_TEXTURE_2D, texture->textures[0]);
}
} }
#endif #endif
} }
Vector oldQuadColor;
void Quad::render()
{
if (lightingColor.x != 1.0f || lightingColor.y != 1.0f || lightingColor.z != 1.0f)
{
oldQuadColor = color;
color *= lightingColor;
RenderObject::render();
color = oldQuadColor;
}
else
{
RenderObject::render();
}
}
void Quad::repeatTextureToFill(bool on) void Quad::repeatTextureToFill(bool on)
{ {
if (on) repeatingTextureToFill = on;
{ repeatTexture = on;
repeatingTextureToFill = true; refreshRepeatTextureToFill();
repeatTexture = true;
refreshRepeatTextureToFill();
}
else
{
repeatingTextureToFill = false;
repeatTexture = false;
refreshRepeatTextureToFill();
}
} }
void Quad::onRender() void Quad::onRender()
@ -549,8 +493,8 @@ void Quad::onRender()
#ifdef BBGE_BUILD_OPENGL #ifdef BBGE_BUILD_OPENGL
_w2 = width/2; float _w2 = width/2.0f;
_h2 = height/2; float _h2 = height/2.0f;
if (!strip.empty()) if (!strip.empty())
{ {
@ -563,23 +507,8 @@ void Quad::onRender()
if (!stripVert) if (!stripVert)
{ {
Vector pl, pr;
for (int i = 0; i < strip.size(); i++) for (int i = 0; i < strip.size(); i++)
{ {
//glNormal3f( 0.0f, 0.0f, 1.0f);
if (i == strip.size()-1)
{
}
else //if (i == 0)
{
Vector diffVec = strip[i+1] - strip[i];
diffVec.setLength2D(_h2);
pl = diffVec.getPerpendicularLeft();
pr = diffVec.getPerpendicularRight();
}
glTexCoord2f(texBits*i, 0); glTexCoord2f(texBits*i, 0);
glVertex2f(strip[i].x*width-_w2, strip[i].y*_h2*10 - _h2); glVertex2f(strip[i].x*width-_w2, strip[i].y*_h2*10 - _h2);
glTexCoord2f(texBits*i, 1); glTexCoord2f(texBits*i, 1);
@ -602,51 +531,27 @@ void Quad::onRender()
} }
else else
{ {
if (core->mode == Core::MODE_2D) if (!drawGrid)
{ {
if (!drawGrid) glBegin(GL_QUADS);
{ {
if (Quad::flipTY) glTexCoord2f(upperLeftTextureCoordinates.x, 1.0f-upperLeftTextureCoordinates.y);
{ glVertex2f(-_w2, +_h2);
glBegin(GL_QUADS);
{
glTexCoord2f(upperLeftTextureCoordinates.x, 1.0f-upperLeftTextureCoordinates.y);
glVertex2f(-_w2, +_h2);
glTexCoord2f(lowerRightTextureCoordinates.x, 1.0f-upperLeftTextureCoordinates.y); glTexCoord2f(lowerRightTextureCoordinates.x, 1.0f-upperLeftTextureCoordinates.y);
glVertex2f(+_w2, +_h2); glVertex2f(+_w2, +_h2);
glTexCoord2f(lowerRightTextureCoordinates.x, 1.0f-lowerRightTextureCoordinates.y); glTexCoord2f(lowerRightTextureCoordinates.x, 1.0f-lowerRightTextureCoordinates.y);
glVertex2f(+_w2, -_h2); glVertex2f(+_w2, -_h2);
glTexCoord2f(upperLeftTextureCoordinates.x, 1.0f-lowerRightTextureCoordinates.y); glTexCoord2f(upperLeftTextureCoordinates.x, 1.0f-lowerRightTextureCoordinates.y);
glVertex2f(-_w2, -_h2); glVertex2f(-_w2, -_h2);
}
glEnd();
}
else
{
glBegin(GL_QUADS);
{
glTexCoord2f(upperLeftTextureCoordinates.x, upperLeftTextureCoordinates.y);
glVertex2f(-_w2, +_h2);
glTexCoord2f(lowerRightTextureCoordinates.x, upperLeftTextureCoordinates.y);
glVertex2f(+_w2, +_h2);
glTexCoord2f(lowerRightTextureCoordinates.x, lowerRightTextureCoordinates.y);
glVertex2f(+_w2, -_h2);
glTexCoord2f(upperLeftTextureCoordinates.x, lowerRightTextureCoordinates.y);
glVertex2f(-_w2, -_h2);
}
glEnd();
}
}
else
{
renderGrid();
} }
glEnd();
}
else
{
renderGrid();
} }
} }
@ -820,24 +725,6 @@ void Quad::flipVertical()
RenderObject::flipVertical(); RenderObject::flipVertical();
} }
void Quad::calculateQuadLighting()
{
Vector total;
int c=0;
for (int i = 0; i < QuadLight::quadLights.size(); i++)
{
QuadLight *q = &QuadLight::quadLights[i];
Vector dist = q->position - position;
if (dist.isLength2DIn(q->dist))
{
total += q->color;
c++;
}
}
if (c > 0)
lightingColor = total/c;
}
void Quad::refreshRepeatTextureToFill() void Quad::refreshRepeatTextureToFill()
{ {
if (repeatingTextureToFill) if (repeatingTextureToFill)
@ -883,11 +770,6 @@ void Quad::onUpdate(float dt)
{ {
updateGrid(dt); updateGrid(dt);
} }
if (quadLighting)
{
calculateQuadLighting();
}
} }
void Quad::setWidthHeight(float w, float h) void Quad::setWidthHeight(float w, float h)
@ -915,8 +797,6 @@ void Quad::onSetTexture()
{ {
width = this->texture->width; width = this->texture->width;
height = this->texture->height; height = this->texture->height;
_w2 = this->texture->width/2.0f;
_h2 = this->texture->height/2.0f;
} }
} }

View file

@ -23,19 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "RenderObject.h" #include "RenderObject.h"
class QuadLight
{
public:
QuadLight(Vector position, Vector color, int dist);
Vector position, color;
int dist;
static std::vector<QuadLight> quadLights;
static void addQuadLight(const QuadLight &quadLight);
static void clearQuadLights();
};
class OutlineRect : public RenderObject class OutlineRect : public RenderObject
{ {
public: public:
@ -78,7 +65,6 @@ public:
void setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo); void setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo);
void setDrawGridAlpha(int x, int y, float alpha); void setDrawGridAlpha(int x, int y, float alpha);
void calculateQuadLighting(); void calculateQuadLighting();
void render();
void repeatTextureToFill(bool on); void repeatTextureToFill(bool on);
void refreshRepeatTextureToFill(); void refreshRepeatTextureToFill();
bool isRepeatingTextureToFill() const { return repeatingTextureToFill; } bool isRepeatingTextureToFill() const { return repeatingTextureToFill; }
@ -89,8 +75,6 @@ public:
void resetStrip(); void resetStrip();
Vector ** getDrawGrid() { return drawGrid; } Vector ** getDrawGrid() { return drawGrid; }
static bool flipTY;
void reloadDevice(); void reloadDevice();
void deleteGrid(); void deleteGrid();
@ -110,7 +94,6 @@ public:
char autoWidth, autoHeight; // char to save space char autoWidth, autoHeight; // char to save space
bool quadLighting;
bool renderQuad, renderBorder, renderCenter; bool renderQuad, renderBorder, renderCenter;
bool stripVert; bool stripVert;
std::vector<Vector>strip; std::vector<Vector>strip;
@ -121,7 +104,6 @@ public:
protected: protected:
bool repeatingTextureToFill; bool repeatingTextureToFill;
Vector lightingColor;
float gridTimer; float gridTimer;
int xDivs, yDivs; int xDivs, yDivs;
Vector ** drawGrid; Vector ** drawGrid;
@ -138,7 +120,6 @@ protected:
float drawGridTimeMultiplier; float drawGridTimeMultiplier;
bool drawGridOut; bool drawGridOut;
static int _w2, _h2;
static Vector renderBorderColor; static Vector renderBorderColor;
void onSetTexture(); void onSetTexture();

View file

@ -168,7 +168,6 @@ RenderObject::RenderObject()
alphaMod = 1; alphaMod = 1;
collisionMaskRadius = 0; collisionMaskRadius = 0;
collideRadius = 0; collideRadius = 0;
useCollisionMask = false;
motionBlurTransition = false; motionBlurTransition = false;
motionBlurFrameOffsetCounter = 0; motionBlurFrameOffsetCounter = 0;
motionBlurFrameOffset = 0; motionBlurFrameOffset = 0;
@ -634,12 +633,6 @@ void RenderObject::renderCall()
glRotatef(180, 0, 1, 0); glRotatef(180, 0, 1, 0);
} }
if (core->mode == Core::MODE_3D)
{
glRotatef(rotation.x+rotationOffset.x, 1, 0, 0);
glRotatef(rotation.y+rotationOffset.y, 0, 1, 0);
}
glRotatef(rotation.z+rotationOffset.z, 0, 0, 1); glRotatef(rotation.z+rotationOffset.z, 0, 0, 1);
#endif #endif
#ifdef BBGE_BUILD_DIRECTX #ifdef BBGE_BUILD_DIRECTX
@ -665,11 +658,6 @@ void RenderObject::renderCall()
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glRotatef(180, 0, 1, 0); glRotatef(180, 0, 1, 0);
} }
if (core->mode == Core::MODE_3D)
{
glRotatef(rotation.x+rotationOffset.x, 1, 0, 0);
glRotatef(rotation.y+rotationOffset.y, 0, 1, 0);
}
glRotatef(rotation.z+rotationOffset.z, 0, 0, 1); glRotatef(rotation.z+rotationOffset.z, 0, 0, 1);
#endif #endif
#ifdef BBGE_BUILD_DIRECTX #ifdef BBGE_BUILD_DIRECTX
@ -723,12 +711,6 @@ void RenderObject::renderCall()
#endif #endif
#ifdef BBGE_BUILD_OPENGL #ifdef BBGE_BUILD_OPENGL
if (core->mode == Core::MODE_3D)
{
glRotatef(rotation.x+rotationOffset.x, 1, 0, 0);
glRotatef(rotation.y+rotationOffset.y, 0, 1, 0);
}
glRotatef(rotation.z+rotationOffset.z, 0, 0, 1); glRotatef(rotation.z+rotationOffset.z, 0, 0, 1);
if (isfh()) if (isfh())
{ {
@ -753,10 +735,7 @@ void RenderObject::renderCall()
#ifdef BBGE_BUILD_OPENGL #ifdef BBGE_BUILD_OPENGL
glTranslatef(beforeScaleOffset.x, beforeScaleOffset.y, beforeScaleOffset.z); glTranslatef(beforeScaleOffset.x, beforeScaleOffset.y, beforeScaleOffset.z);
if (core->mode == Core::MODE_3D) glScalef(scale.x, scale.y, 1);
glScalef(scale.x, scale.y, scale.z);
else
glScalef(scale.x, scale.y, 1);
glTranslatef(internalOffset.x, internalOffset.y, internalOffset.z); glTranslatef(internalOffset.x, internalOffset.y, internalOffset.z);
#endif #endif
#ifdef BBGE_BUILD_DIRECTX #ifdef BBGE_BUILD_DIRECTX

View file

@ -189,9 +189,6 @@ public:
const RenderObject &operator=(const RenderObject &r); const RenderObject &operator=(const RenderObject &r);
void enableProjectCollision();
void disableProjectCollision();
void toggleCull(bool value); void toggleCull(bool value);
void safeKill(); void safeKill();
@ -293,8 +290,6 @@ public:
int collideRadius; int collideRadius;
Vector collidePosition; Vector collidePosition;
bool useCollisionMask;
//Vector collisionMaskHalfVector;
std::vector<Vector> collisionMask; std::vector<Vector> collisionMask;
std::vector<Vector> transformedCollisionMask; std::vector<Vector> transformedCollisionMask;

View file

@ -30,6 +30,21 @@ std::string SkeletalSprite::skinPath = "skins/";
std::string SkeletalSprite::secondaryAnimationPath = ""; std::string SkeletalSprite::secondaryAnimationPath = "";
static std::map<std::string, TiXmlDocument> skelCache;
static TiXmlDocument& _retrieveSkeletalXML(const std::string& name)
{
TiXmlDocument& doc = skelCache[name];
if (!doc.RootElement())
doc.LoadFile(name);
return doc;
}
void SkeletalSprite::clearCache()
{
skelCache.clear();
}
void SkeletalKeyframe::copyAllButTime(SkeletalKeyframe *copy) void SkeletalKeyframe::copyAllButTime(SkeletalKeyframe *copy)
{ {
@ -842,7 +857,8 @@ void SkeletalSprite::saveSkeletal(const std::string &fn)
file = animationPath + filename + ".xml"; file = animationPath + filename + ".xml";
int i = 0; int i = 0;
TiXmlDocument xml; TiXmlDocument& xml = _retrieveSkeletalXML(file);
xml.Clear();
TiXmlElement animationLayers("AnimationLayers"); TiXmlElement animationLayers("AnimationLayers");
for (i = 0; i < animLayers.size(); i++) for (i = 0; i < animLayers.size(); i++)
@ -1141,8 +1157,6 @@ Animation *SkeletalSprite::getAnimation(std::string anim)
void SkeletalSprite::loadSkin(const std::string &fn) void SkeletalSprite::loadSkin(const std::string &fn)
{ {
TiXmlDocument d;
std::string file; std::string file;
if (!secondaryAnimationPath.empty()) if (!secondaryAnimationPath.empty())
@ -1162,7 +1176,7 @@ void SkeletalSprite::loadSkin(const std::string &fn)
errorLog("Could not load skin[" + file + "]"); errorLog("Could not load skin[" + file + "]");
return; return;
} }
d.LoadFile(file); TiXmlDocument& d = _retrieveSkeletalXML(file);
TiXmlElement *bonesXml = d.FirstChildElement("Bones"); TiXmlElement *bonesXml = d.FirstChildElement("Bones");
if (bonesXml) if (bonesXml)
@ -1294,7 +1308,7 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
loaded = true; loaded = true;
TiXmlDocument xml; TiXmlDocument& xml = _retrieveSkeletalXML(file);
xml.LoadFile(file.c_str()); xml.LoadFile(file.c_str());
TiXmlElement *bones = xml.FirstChildElement("Bones"); TiXmlElement *bones = xml.FirstChildElement("Bones");

View file

@ -259,6 +259,7 @@ public:
std::string filenameLoaded; std::string filenameLoaded;
static std::string animationPath, skinPath, secondaryAnimationPath; static std::string animationPath, skinPath, secondaryAnimationPath;
static void clearCache();
protected: protected:
bool frozen; bool frozen;

View file

@ -58,7 +58,6 @@ TexErr Texture::textureError = TEXERR_OK;
Texture::Texture() : Resource() Texture::Texture() : Resource()
{ {
components = 0;
#ifdef BBGE_BUILD_OPENGL #ifdef BBGE_BUILD_OPENGL
textures[0] = 0; textures[0] = 0;
#endif #endif
@ -68,6 +67,7 @@ Texture::Texture() : Resource()
width = height = 0; width = height = 0;
repeat = false; repeat = false;
repeating = false;
pngSetStandardOrientation(0); pngSetStandardOrientation(0);
imageData = 0; imageData = 0;
@ -291,20 +291,14 @@ void Texture::reload()
Resource::reload(); Resource::reload();
debugLog("RELOADING TEXTURE: " + name + " with loadName " + loadName + "..."); debugLog("RELOADING TEXTURE: " + name + " with loadName " + loadName + "...");
if (true)
{
unload();
load(loadName);
if (ow != -1 && oh != -1) unload();
{ load(loadName);
width = ow;
height = oh; if (ow != -1 && oh != -1)
}
}
else
{ {
debugLog("name was too short, didn't load"); width = ow;
height = oh;
} }
debugLog("DONE"); debugLog("DONE");
} }
@ -419,13 +413,21 @@ void Texture::apply(bool repeatOverride)
glBindTexture(GL_TEXTURE_2D, textures[0]); glBindTexture(GL_TEXTURE_2D, textures[0]);
if (repeat || repeatOverride) if (repeat || repeatOverride)
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); if (!repeating)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
repeating = true;
}
} }
else else
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); if (repeating)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, 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);
repeating = false;
}
} }
#endif #endif
#ifdef BBGE_BUILD_DIRECTX #ifdef BBGE_BUILD_DIRECTX
@ -473,18 +475,6 @@ void Texture::loadPNG(const std::string &file)
textures[0] = pngBind(file.c_str(), PNG_BUILDMIPMAPS, pngType, &info, GL_CLAMP_TO_EDGE, GL_LINEAR_MIPMAP_LINEAR, filter); textures[0] = pngBind(file.c_str(), PNG_BUILDMIPMAPS, pngType, &info, GL_CLAMP_TO_EDGE, GL_LINEAR_MIPMAP_LINEAR, filter);
} }
if (info.Alpha)
components = 4;
else
components = 3;
/*
pngRawInfo rawinfo;
bool success = pngLoadRaw(file.c_str(), &rawinfo);
glBindTexture(GL_TEXTURE_2D, id);
gluBuild2DMipmaps( GL_TEXTURE_2D, 3, rawinfo.Width, rawinfo.Height,
GL_RGB, GL_UNSIGNED_BYTE, rawinfo.Data);
*/
if (textures[0] != 0) if (textures[0] != 0)
{ {
width = info.Width; width = info.Width;

View file

@ -62,9 +62,8 @@ public:
static ImageTGA *TGAloadMem(void *mem, int size); static ImageTGA *TGAloadMem(void *mem, int size);
static bool useMipMaps; static bool useMipMaps;
bool repeat; bool repeat, repeating;
int components;
#ifdef BBGE_BUILD_OPENGL #ifdef BBGE_BUILD_OPENGL
static GLint filter; static GLint filter;
static GLint format; static GLint format;

View file

@ -215,7 +215,6 @@ ADD_DEFINITIONS(-DBBGE_BUILD_FRAMEBUFFER=1)
#ADD_DEFINITIONS(-DBBGE_BUILD_SHADERS=1) #ADD_DEFINITIONS(-DBBGE_BUILD_SHADERS=1)
ADD_DEFINITIONS(-DBBGE_BUILD_OPENGL=1) ADD_DEFINITIONS(-DBBGE_BUILD_OPENGL=1)
ADD_DEFINITIONS(-DBBGE_BUILD_OPENGL_DYNAMIC=1) ADD_DEFINITIONS(-DBBGE_BUILD_OPENGL_DYNAMIC=1)
ADD_DEFINITIONS(-DBBGE_BUILD_WIDESCREEN=1)
ADD_DEFINITIONS(-DBBGE_BUILD_FMOD_OPENAL_BRIDGE=1) ADD_DEFINITIONS(-DBBGE_BUILD_FMOD_OPENAL_BRIDGE=1)
IF(AQUARIA_DEVELOPER_BUILD) IF(AQUARIA_DEVELOPER_BUILD)
@ -384,8 +383,6 @@ SET(BBGE_SRCS
${BBGEDIR}/Interpolator.cpp ${BBGEDIR}/Interpolator.cpp
${BBGEDIR}/Joystick.cpp ${BBGEDIR}/Joystick.cpp
${BBGEDIR}/LensFlare.cpp ${BBGEDIR}/LensFlare.cpp
${BBGEDIR}/LightCone.cpp
${BBGEDIR}/Light.cpp
${BBGEDIR}/Math.cpp ${BBGEDIR}/Math.cpp
${BBGEDIR}/ParticleEffect.cpp ${BBGEDIR}/ParticleEffect.cpp
${BBGEDIR}/ParticleManager.cpp ${BBGEDIR}/ParticleManager.cpp
@ -454,6 +451,8 @@ SET(BBGE_SRCS_UNUSED
${BBGEDIR}/CShim.cpp ${BBGEDIR}/CShim.cpp
${BBGEDIR}/Cutscene.cpp ${BBGEDIR}/Cutscene.cpp
${BBGEDIR}/FileVars.cpp ${BBGEDIR}/FileVars.cpp
${BBGEDIR}/Light.cpp
${BBGEDIR}/LightCone.cpp
${BBGEDIR}/Model.cpp ${BBGEDIR}/Model.cpp
${BBGEDIR}/OggStream.cpp ${BBGEDIR}/OggStream.cpp
${BBGEDIR}/PackRead.cpp ${BBGEDIR}/PackRead.cpp