mojobas.blogg.se

Visual studio sfml texture unable to find image
Visual studio sfml texture unable to find image









visual studio sfml texture unable to find image

SFML sports file formats like JPEG, PNG and some other, if your are using JPEG image than write jpg after dot like cartoon.jpg.Ī: assert is a macro contained by #include or #include. The purpose of sf::Texture Class is to load image and hold it, sf::Sprite Class utilize this texture and draws this on RenderWindow, this class also contains some handy function like rotation, scale, set origin and change sprite color etc we will see them after short time.Īt line # 8 & 9 declare sf::Texture and sf::Sprite variableĪt line # 11 loadFromFile function of Texture class loads image from hard-drive to main memory parameter to this function is string that is path to image with file name. In SFML top left corner of window is 0,0. Sf::RenderWindow window(sf::VideoMode(800, 600), "Pong")

visual studio sfml texture unable to find image

Texture stores image and Sprite draws it.ĭownload this image and put this in project folder I might roll back to version 2.1 since that was the most stable version on my part.Ĭan anyone explain why on SFML 2.Drawing image is very simple all you need sf::Texture & sf::Sprite class objects. I've also checked the drawing method, but that isn't important right now because not even the image is being loaded. Before you start pointing the finger at pointers I also tried them as raw variables, but I still get the same error. loadFromFile ( "assets/graphics/explorer.png" ) )Ĭerr << "Unable to load image!" << endl Sf :: RenderWindow window (sf :: VideoMode ( 200, 200 ), "SFML works!" ) I'm convinced that this is a SFML 2.3 bug. I even compiled and ran the tutorial example and that ran fine too. All libraries are linked and SFML runs just fine. This code runs under Linux just fine, so I honestly don't see how it can't work under Windows 8.1 64-bit. I even added the absolute path of the image file and I still get the same error. I've also duplicated the assets folder everywhere (silly, I know) and I still get the same error. The image I have is a *.png file so I assume SFML supports it because they use a png example on the tutorials. I have used an older version of SFML under my Linux machine so I don't know what's exactly changed with regards to how SFML loads images. When I launch my program it says that SFML is unable to load the image. I have ported an app from Linux to Windows on Visual Studio and I have the assets directory under the VC++ Project file directory. Before you start barking at me about incorrect file paths, I'd like to remind you that I've been using SFML for a long time on both Windows and Linux.











Visual studio sfml texture unable to find image