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

Author Topic: Unhandled Exception Error with Texture  (Read 2731 times)

0 Members and 2 Guests are viewing this topic.

random_canadian

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Unhandled Exception Error with Texture
« on: June 12, 2013, 03:26:34 am »
Hello lovely sfml community. First, let me apologize if the question I'm about to ask is considered "stupid." I am fairly new at sfml/c++, having been dabbling in other programming languages in my free time over the past few years. Anyways, I seemed to have stumbled onto a problem. It seems that I cannot load texture images from a file! After finding the source of the problem in my code, I isolated the issue. I removed all other code paths so that only the following code should run, considering it is the main() function. However, the following code does not even work:

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
        sf::Texture texture = sf::Texture();
        texture.loadFromFile("image.png"); //This line is the source of the error. The file "image.png" exists, I assure you.

        return 0;
}

I receive the following (very scary) error:

Quote
Unhandled exception at 0x6CCDDEF8 (msvcr110.dll) in MyGame.exe: 0xC0000005: Access violation reading location 0x00D41000.

Then, Visual Studio directs me to line 367 in the file "memcpy.asm"

        rep     movsd           ;N - move all of our dwords

I honestly have no clue what is going on  :P. I've isolated the issue and don't know where to go from here. Any help is greatly appreciated!
« Last Edit: June 12, 2013, 03:28:41 am by random_canadian »

Sqasher

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Unhandled Exception Error with Texture
« Reply #1 on: June 12, 2013, 07:10:50 pm »
Have you tried other images? Some images are corrupted but load fine in (some) image viewers.

random_canadian

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Unhandled Exception Error with Texture
« Reply #2 on: June 12, 2013, 07:48:10 pm »
I think it's a problem with the way I set up visual studio with SFML. I have problems linking it statically, but I managed to fix some stuff. I got the error to disappear. However, now I am stuck with:
Quote
Failed to load image "image.png". Reason : Unable to open file.
Doesn't even work when include the full C:/ ... directory. Hmm... Now to try and fix this...

random_canadian

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Unhandled Exception Error with Texture
« Reply #3 on: June 12, 2013, 07:51:11 pm »
Update: actually it does work when I include the full C:/... directory :P. So I think it's a problem with the Working Directory. Does anyone know how to fix the Working Directory to load images from the Resource Files folder in the project? (I'm assuming that's where I should put my source images??)