Guys, very nasty problem here, need your help.
I'm using Code::Blocks and C++ and when I press F9 to "Build and Run", the game starts and I can play, everything is fine.
But when I start it from the .exe file in my debug folder( all .dlls are there ), the game starts and crashes in 3 seconds.
I did some research on the stack: http://stackoverflow.com/questions/186237/program-only-crashes-as-release-build-how-to-debug
and it seems that most of the time it happens is because of a wrong variable initialization.
By using good old printf, I traced the problem to this class here. And the program crashes somewhere in the constructor. I can't even use a debugger because it works perfectly fine in CodeBlocks....
Nevermind, here is the header and then the .cpp file, watch for a wrong initialization somewhere:
class ResourceManager
{
private:
// Load models
Model fpsArmsIdle = Model( "models/fpsRig/armsIdle.dae" );
Model fpsArmsPunch = Model( "models/fpsRig/armsAttack.dae" );
Model ball = Model( "models/bullets/ball.obj" );
Model humanRun = Model( "models/guyWithSuit/suitGuyIdle2.fbx" );
Model humanKnockdown = Model("models/human/humanKnockdown.dae");
Model humanDead = Model("models/human/humanDead.dae");
vector<const GLchar*> skyboxTextures;
vector<Model*> firstPersonAnims;
vector<Model*> humanAnims;
public:
ResourceManager();
~ResourceManager();
Model mapClassic = Model( "maps/map_classic/classicmap.obj" );
Model floor = Model( "models/floor/floor.obj" );
Model lamp = Model( "models/lamp/lamp.obj" );
Model box = Model( "models/ka6on/ka6on.obj" );
void loadResources();
vector<const GLchar*> getSkyboxTextures();
vector<Model*> getFirstPersonAnims();
vector<Model*> getHumanAnims();
};
And the constructor that crashes the game:
//The headers
#include "resourcemanager.h"
ResourceManager::ResourceManager()
{
loadResources();
}
ResourceManager::~ResourceManager()
{
;
}
vector<Model*> ResourceManager::getHumanAnims()
{
return humanAnims;
}
vector<Model*> ResourceManager::getFirstPersonAnims()
{
return firstPersonAnims;
}
vector<const GLchar*> ResourceManager::getSkyboxTextures()
{
return skyboxTextures;
}
void ResourceManager::loadResources()
{
skyboxTextures.push_back( "maps/skyboxes/nebula/right.tga" );
skyboxTextures.push_back( "maps/skyboxes/nebula/left.tga" );
skyboxTextures.push_back( "maps/skyboxes/nebula/top.tga" );
skyboxTextures.push_back( "maps/skyboxes/nebula/bottom.tga" );
skyboxTextures.push_back( "maps/skyboxes/nebula/back.tga" );
skyboxTextures.push_back( "maps/skyboxes/nebula/front.tga" );
firstPersonAnims.push_back( &fpsArmsIdle );
firstPersonAnims.push_back( &fpsArmsPunch );
firstPersonAnims.push_back( &ball );
humanAnims.push_back( &humanRun );
humanAnims.push_back( &humanKnockdown );
humanAnims.push_back( &humanDead );
}
If all seems legit, then there is my App class that could be wrong, but I'm sure there are a lot of wrong things going on here.
Basically, I don't know when to use vector of pointers to objects, and when vector of objects, maybe this is where I go wrong somewhere.