SFML community forums

Help => Graphics => Topic started by: sadin97 on September 14, 2017, 10:34:28 pm

Title: Exception Thrown at line where I defined sf::Texture
Post by: sadin97 on September 14, 2017, 10:34:28 pm
Code: [Select]
Exception thrown at 0x7749B2E3 (ntdll.dll) in App.exe: 0xC0000005: Access violation writing location 0x00000004.

At line:

Code: [Select]
sf::Texture seaTexture;
In file resources.cpp

I also put:

Code: [Select]
extern sf::Texture seaTexture;
in file resources.h

So... can I do something like this. Im using seaTexture in another file so I tried to put extern to it.
Title: Re: Exception Thrown at line where I defined sf::Texture
Post by: eXpl0it3r on September 15, 2017, 12:20:23 am
You're probably using the wrong DLLs, e.g. outdated DLLs, x64 vs x86 mismatch or DLLs with different runtime libraries. Make sure everything is matching and that you don't have old libraries and keep in mind that VS comes with two kinds of compilers, one for x86 and one for x64, you have to pick the right one.
Title: Re: Exception Thrown at line where I defined sf::Texture
Post by: sadin97 on September 15, 2017, 12:48:27 am
You're probably using the wrong DLLs, e.g. outdated DLLs, x64 vs x86 mismatch or DLLs with different runtime libraries. Make sure everything is matching and that you don't have old libraries and keep in mind that VS comes with two kinds of compilers, one for x86 and one for x64, you have to pick the right one.

Are you sure that is the problem? I can use generally sf::Texture... but with this making it extern I got problems.
Title: Re: Exception Thrown at line where I defined sf::Texture
Post by: Laurent on September 15, 2017, 06:27:55 am
Some SFML resources can't be declared in the global scope. They do internal stuff during their construction and destruction, which involves other global variables that may not be available due to non-deterministic order of initialization of globals.
Title: Re: Exception Thrown at line where I defined sf::Texture
Post by: sadin97 on September 16, 2017, 10:33:08 pm
Some SFML resources can't be declared in the global scope. They do internal stuff during their construction and destruction, which involves other global variables that may not be available due to non-deterministic order of initialization of globals.

So... any hint? How should I use same texture in other file if it is even possible?
Title: Re: Exception Thrown at line where I defined sf::Texture
Post by: eXpl0it3r on September 16, 2017, 11:59:16 pm
Pass by reference.
Title: Re: Exception Thrown at line where I defined sf::Texture
Post by: sadin97 on September 17, 2017, 06:48:49 pm
Pass by reference.

Can you post some simple examples using textures?
Title: Re: Exception Thrown at line where I defined sf::Texture
Post by: eXpl0it3r on September 17, 2017, 08:30:09 pm
A reference works the same way for any type. If you don't know how a reference works, you should go back to pure C++ for a bit and read it up in a good C++ book. ;)
Title: Re: Exception Thrown at line where I defined sf::Texture
Post by: sadin97 on September 17, 2017, 09:44:00 pm
A reference works the same way for any type. If you don't know how a reference works, you should go back to pure C++ for a bit and read it up in a good C++ book. ;)

Okay, thanks for help! :)