Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - NireL

Pages: [1]
1
Graphics / Access violation writing location
« on: August 10, 2018, 12:19:34 pm »
Recently I've started working with SFML 2.5. I have the following function that loads a sprite by path and the main method to test it:
#include <SFML/Graphics.hpp>

#include <string>
#include <exception>

sf::Texture loadTexture(const std::string& path)
{
        sf::Texture texture;
        if (!texture.loadFromFile(path))
        {
                throw std::runtime_error("Could not open file: " + path);
        }
        return texture; // This line causes an exception to throw
}

int main()
{
        sf::Texture gameFieldTexture = loadTexture("graphics/field.png");
        return 0;
}
Every time I run the application the commented line above causes an exception to throw with the message:"Unhandled exception at 0x1002DB43 (ig4icd32.dll) in App2_TicTacToe.exe: 0xC0000005: Access violation writing location at 0x00000010".
Everything works fine if I write this code inside the main method. The exception is thrown only when writing a separate function that loads and returns a texture.

Here is the call stack:
(click to show/hide)

My IDE is Visual Studio 2017.

P.S. Sorry if there were some mistakes in the topic. I do not know English well enough.

Pages: [1]
anything