Do you compile in debug mode, and link the SFML debug libraries?
Yes, I do.
Can you use a sf::RenderTexture with the same size in a separate project?
No , I cannot. I have created a very small test that generates the exact same error.
Unhandled exception at 0x1002CA1C (ig4icd32.dll) in HelloWorld.exe: 0xC0000005: Access violation writing location 0x0000001C.
When you close the window the access violation will occur. The timing is similar to what is occurring with the book's code. The book's access violation occurs when the player either dies or finishing the mission causing the GameState and GameOverState to begining destroying its resources.
You'll notice I only create the RenderTexture and never use it. The access violation occurs regardless.
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(1024, 768), "SFML works!");
sf::RenderTexture mSceneTexture;
mSceneTexture.create(1024, 768);
sf::Texture mTexture;
mTexture.loadFromFile("Textures/Entities.png");
sf::Sprite mSprite;
mSprite.setTexture(mTexture);
mSprite.setPosition(100.f, 100.f);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(mSprite);
window.display();
}
return 0;
}
Do you have the stack trace for it?
ig4icd32.dll!1002ca1c() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for ig4icd32.dll]
ig4icd32.dll!1002dae2() Unknown
sfml-graphics-d-2.dll!589c6bf0() Unknown
sfml-graphics-d-2.dll!589c7326() Unknown
sfml-graphics-d-2.dll!5899bf72() Unknown
Sandbox.exe!`eh vector destructor iterator'(void * ptr, unsigned int size, int count, void (void *) * pDtor) C++
Sandbox.exe!std::array<sf::RenderTexture,2>::~array<sf::RenderTexture,2>() C++
Sandbox.exe!BloomEffect::~BloomEffect() C++
Sandbox.exe!World::~World() C++
Sandbox.exe!GameState::~GameState() C++
Sandbox.exe!GameState::`scalar deleting destructor'(unsigned int) C++
> Sandbox.exe!std::default_delete<State>::operator()(State * _Ptr) Line 1152 C++
Sandbox.exe!std::unique_ptr<State,std::default_delete<State> >::_Delete() Line 1445 C++
Sandbox.exe!std::unique_ptr<State,std::default_delete<State> >::~unique_ptr<State,std::default_delete<State> >() Line 1400 C++
Sandbox.exe!std::unique_ptr<State,std::default_delete<State> >::`scalar deleting destructor'(unsigned int) C++
Sandbox.exe!std::allocator<std::unique_ptr<State,std::default_delete<State> > >::destroy<std::unique_ptr<State,std::default_delete<State> > >(std::unique_ptr<State,std::default_delete<State> > * _Ptr) Line 624 C++
Sandbox.exe!std::allocator_traits<std::allocator<std::unique_ptr<State,std::default_delete<State> > > >::destroy<std::unique_ptr<State,std::default_delete<State> > >(std::allocator<std::unique_ptr<State,std::default_delete<State> > > & _Al, std::unique_ptr<State,std::default_delete<State> > * _Ptr) Line 758 C++
Sandbox.exe!std::_Wrap_alloc<std::allocator<std::unique_ptr<State,std::default_delete<State> > > >::destroy<std::unique_ptr<State,std::default_delete<State> > >(std::unique_ptr<State,std::default_delete<State> > * _Ptr) Line 909 C++
Sandbox.exe!std::_Destroy_range<std::_Wrap_alloc<std::allocator<std::unique_ptr<State,std::default_delete<State> > > > >(std::unique_ptr<State,std::default_delete<State> > * _First, std::unique_ptr<State,std::default_delete<State> > * _Last, std::_Wrap_alloc<std::allocator<std::unique_ptr<State,std::default_delete<State> > > > & _Al, std::_Nonscalar_ptr_iterator_tag __formal) Line 89 C++
Sandbox.exe!std::_Destroy_range<std::_Wrap_alloc<std::allocator<std::unique_ptr<State,std::default_delete<State> > > > >(std::unique_ptr<State,std::default_delete<State> > * _First, std::unique_ptr<State,std::default_delete<State> > * _Last, std::_Wrap_alloc<std::allocator<std::unique_ptr<State,std::default_delete<State> > > > & _Al) Line 80 C++
Sandbox.exe!std::vector<std::unique_ptr<State,std::default_delete<State> >,std::allocator<std::unique_ptr<State,std::default_delete<State> > > >::_Destroy(std::unique_ptr<State,std::default_delete<State> > * _First, std::unique_ptr<State,std::default_delete<State> > * _Last) Line 1480 C++
Sandbox.exe!std::vector<std::unique_ptr<State,std::default_delete<State> >,std::allocator<std::unique_ptr<State,std::default_delete<State> > > >::clear() Line 1416 C++
Sandbox.exe!StateStack::applyPendingChanges() Line 91 C++
Sandbox.exe!StateStack::update(sf::Time dt) Line 24 C++
Sandbox.exe!Application::update(sf::Time dt) Line 81 C++
Sandbox.exe!Application::run() Line 57 C++
Sandbox.exe!main() Line 13 C++
Sandbox.exe!__tmainCRTStartup() Line 536 C
Sandbox.exe!mainCRTStartup() Line 377 C
kernel32.dll!74bd336a() Unknown
ntdll.dll!76f69f72() Unknown
ntdll.dll!76f69f45() Unknown