SFML community forums
Help => Graphics => Topic started by: jerryd on April 20, 2013, 07:28:37 am
-
SFML forum,
SFML 1.6 Visual C++ Express 2010
I'm new to SFML and have a very simple "open a window" program
called FirstWindow that works.
Now I try to load an image with this code:
sf::Image MyImage;
MyImage.LoadFromFile("Sprite2.bmp");
It compiles without errors but when I run it I get this message:
"FirstWindow has encountered an error and must close".
If I comment out the LoadFromFile command the program runs OK.
The file Sprite2.bmp resides in the program folder and I
can open it and see the bmp image.
Any suggestions?
jerryd
-
You must recompile SFML (you downloaded the Visual Studio 2008 version, didn't you?).
-
Laurent,
Thanks for the reply.
I'm following a tutorial at:
http://www.sfml-dev.org/tutorials/1.6/graphics-sprite.php
These totorials are for SFML 1.6 and Visual C++ 2010 Express
so I never loaded Visual Studio 2008. Also I don't know how
to compile SFML.
Can you give me some instructions?
jerryd
-
Laurent,
I realized that I could get all the instructions I
needed on the net.
I went through the entire tutorial on compiling SFML at:
https://www.youtube.com/watch?v=-uHGZGgMETg
and got the sample program to work.
I changed all the properties in my FirstWindow solution but
got the same error message.
Here's my code:
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
int main()
{
// Render up a window called MyWindow
sf::RenderWindow MyWindow(sf::VideoMode(800, 600, 16), "SFML Window");
MyWindow.SetFramerateLimit(60); // Limit to 60 frames per second
// load the image
sf::Image MyImage;
//MyImage.LoadFromFile("Sprite2.bmp");
bool Running = true;
while (Running)
{
// check if there are any events
sf::Event MyEvent;
while (MyWindow.GetEvent(MyEvent))
{
// Window closed by X
if (MyEvent.Type == sf::Event::Closed) MyWindow.Close();
// Escape key pressed
if ((MyEvent.Type == sf::Event::KeyPressed) && (MyEvent.Key.Code == sf::Key::Escape))
MyWindow.Close();
}
// Clear the screen to black
MyWindow.Clear(sf::Color(0, 0, 0));
// display the window pointed to by MyWindow
MyWindow.Display();
}
return EXIT_SUCCESS;
}
See anything wrong here?
jerryd
-
I recommend SFML 2, see here (https://github.com/SFML/SFML/wiki/FAQ#wiki-grl-version) for the reasons.
In fact, we should start a broad campaign on YouTube to deprecate all the SFML 1.6 tutorials ;)
Also, use the [code=cpp] [/code] tags to show C++ code.
-
In fact, we should start a broad campaign on YouTube to deprecate all the SFML 1.6 tutorials ;)
Wanna go trolling for 2.0. ;D Sounds awesome.
Maybe someone who can write good could start here: http://en.wikipedia.org/wiki/SFML
Supported languages
The number indicates the version for which the bindings are available:
Official bindings
C++ : 1.6
C : 1.6
.NET : 1.6
External bindings
Python : 1.6
D : 1.3
Ruby : RC-2.0
OCaml : 1.6 and RC-2.0
Java
Things like that are just stupid.
-
SMFL forum,
Found the problem. I didn't have sfml-graphics-d.lib in the
Linker INPUTS.
I have downloaded and compiled SFML 2.0.
I made a solution similar to this one but when I click on the
"build" the compiler option is grayed out. If I type F5 I get
an error message that says:
"LINK : fatal error LNK1561: entry point must be defined"
What am I missing?
jerryd