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

Author Topic: Can Someone Help With Loading A sprite  (Read 2634 times)

0 Members and 1 Guest are viewing this topic.

Ram012593

  • Newbie
  • *
  • Posts: 2
    • View Profile
Can Someone Help With Loading A sprite
« on: September 05, 2011, 02:09:49 am »
Heres the source code im having trouble with: http://pastebin.com/bUeS97DY
 
This is the part thats giving me troubles if i remove this it runs fine obviously without the image i want to load.

sf::Texture texture;
         if (!texture.LoadFromFile("Untitled.png"))
             return EXIT_FAILURE;
         sf::Sprite sprite(texture);

It Compiles fine then when i go to run it:
Unhandled exception at 0x645167b4 in sfmltester.exe: 0xC0000005: Access violation reading location 0x0040f000.


Call Stack:
    sfml-system-2.dll!645167b4()    
    [Frames below may be incorrect and/or missing, no symbols loaded for sfml-system-2.dll]   
    sfml-system-2.dll!6451188f()    
    sfml-graphics-2.dll!62634184()    
    sfml-graphics-2.dll!6264614f()    
    sfml-graphics-2.dll!6263999c()    
    sfml-graphics-2.dll!626501f4()    
>   sfmltester.exe!main()  Line 11 + 0x35 bytes   C++
    sfmltester.exe!__tmainCRTStartup()  Line 555 + 0x19 bytes   C
    sfmltester.exe!mainCRTStartup()  Line 371   C
    kernel32.dll!76873677()    
    ntdll.dll!77129d72()    
    ntdll.dll!77129d45()    

the image is here: http://localhostr.com/file/dxh9O2d/Untitled.png/17/unledlmp.png/

Also i am using sfml version 2 not 1.6 the latest one from the repository
I am using Microsoft Visual C++ Express Edition 2010
Any help would be greatly appreciated.

System Specs:
cpu:amd phenon 2 black edition 3.33ghz hex core(i have it clocked to 3.86ghz)
Motherboard: Asus Crosshair V Formula
RAM: 4 *4(16gb) G sniper series 1866mhz
GPU: ATI Readon 6970
OS: Windows 7 64bit Ultimate





 :(

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Can Someone Help With Loading A sprite
« Reply #1 on: September 05, 2011, 02:19:51 am »
It looks fine, normally.

Maybe you are just missing Release libraries with Debug build, check everything and try again :)

retep998

  • Newbie
  • *
  • Posts: 17
    • View Profile
Can Someone Help With Loading A sprite
« Reply #2 on: September 05, 2011, 02:26:47 am »
If he was missing the dlls then the program would crash when it first tried to create the window, and if his libraries are wrong the program wouldn't build at all. Considering everything else works except the image loading, I suspect there may be an issue with the implementation of libpng in the latest git version.

thePyro_13

  • Full Member
  • ***
  • Posts: 156
    • View Profile
Can Someone Help With Loading A sprite
« Reply #3 on: September 05, 2011, 04:22:12 am »
Step through your program one line at a time and find which line it throws the error on.

Ram012593

  • Newbie
  • *
  • Posts: 2
    • View Profile
Can Someone Help With Loading A sprite
« Reply #4 on: September 05, 2011, 04:30:45 am »
thePyro_13 Thanks i actualy didnt know that in visual studio in debug mode the working directory is the one with the project in it so i tried putting it in there instead of the debug folder with the exe in it however i still got the same error.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can Someone Help With Loading A sprite
« Reply #5 on: September 05, 2011, 07:30:46 am »
Quote
if his libraries are wrong the program wouldn't build at all

Release and debug libraries export the same ABI, so mixing them doesn't hurt the linker but can make the program crash.

I think this is what happens, given that he's debugging his app (so he's in debug mode) and SFML DLLs miss the -d suffix (so it's the release version of them).
Laurent Gomila - SFML developer