Right, after some debugging I have found what I think is the problem...
here is my 'main loop'
#include <SFML/Graphics.hpp>
#include "GameEngine.hpp"
#include "sGraphicsManager.h"
#include "IntroState.hpp"
#include <Box2D\Box2D.h>
//Include MemoryLeak Detector.
//#include <vld.h>
int main()
{
GameEngine Game( "MPEngine Alpha 1.0", 1600, 900, 32, true);
Game.run( Game.build<IntroState>( true ) );
// main loop
while( Game.running() )
{
Game.nextState();
Game.update();
Game.draw();
}
sGraphicsManager *Graphics = sGraphicsManager::Instance();
Graphics->Release();
return 0;
}
now if I remove the lines
sGraphicsManager *Graphics = sGraphicsManager::Instance();
Graphics->Release();
Release mode runs fine.. but why would this cause an error?
Graphics Release
void sGraphicsManager::Release()
{
// Release single instance
if(msGraphicsManagerInstance)
{
std::cout << "Cleaning up Graphics Instance" << std::endl;
delete msGraphicsManagerInstance;
msGraphicsManagerInstance = NULL;
std::cout << msGraphicsManagerInstance << std::endl;
}
}
and my destructor
sGraphicsManager::~sGraphicsManager(void)
{
for (std::vector<sf::Texture*>::iterator deleter = mTextureList.begin(); deleter < mTextureList.end(); deleter++)
{
delete *deleter;
}
}
now if I remove the texture deleting code inside the destuctor.. release runs fine
if I move the texture delete code out of the destructor and into the Release function the is has changed and is now;
Windows has triggered a breakpoint in Box2D_SFML_Test.exe.
This may be due to a corruption of the heap, which indicates a bug in Box2D_SFML_Test.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while Box2D_SFML_Test.exe has focus.
The output window may have more diagnostic information... and this ONLY happens in RELEASE compile