SFML 2

Pages: 123
'ello everybody,

At the moment I'm creating my own little games in pure OpenGL. In the future I'd like to use a complementary lib for that. So the obvious choice: SDL vs SFML.
Pretty much everywhere I went, people recommended me SFML. I tried it recently, and there seems to be an issue with the ATI drivers for the 1.6 version...
This bug *should* get fixed by 2.0
I saw there was already a beta out from SFML 2, anyone knows how complete it is?
Xander314, you maybe?

Cheers,

Xander
closed account (S6k9GNh0)
SFML 2 is easily usable. I use it myself.

Btw, if you plan on wrapping around your multimedia library (SFML, SDL), SDL is easily a competitor. I personally use SDL over SFML any-day.
I would definitely use SFML 2.0 over 1.6. I've had very few bugs with it and the public interface is different in places so I don't really see the point in learning the old one now.
closed account (S6k9GNh0)
The tutorials and documentation aren't quite up to date on a few things but if you get some weird bugs such as incorrect function decelerations, look in the headers before complaining on the forums about it.
I find that in an IDE like MSVC++ with decent (ish) intellisense, it's possible to work out that kind of thing as you go.

EDIT: And of course, if you have a chance, you can just run doxygen over the source yourself ;)
Last edited on
At the moment I'm leaning more towards SDL, but I can't seem to find tutorials who use it with OpenGL.
They all rely on SDL for the rendering...
Here's a SDL/OpenGL tutorial: http://www.sdltutorials.com/sdl-opengl-tutorial-basics/
I'm pretty sure once you do this kind of thing, the rest is just the same as if you were using OpenGL by itself.
Last edited on
Thanks so much Xander!
I have another question. I've never compiled libraries myself. How do I go about compiling SFML 2 (in C::B) for own use? I'm going to try a bit of both and see what I like best!
You download the source, from the downloads page, generate a Code::Blocks project with CMake and then open it in CMake and build. If you want static & dynamic builds + debug & release, you will need to make each of these as a separate project using CMake.

The official tutorial: http://sfml-dev.org/tutorials/2.0/compile-with-cmake.php

And I hesitate to advertise my blog/etc. on here, but if you want a video you could try mine :P
http://www.youtube.com/watch?v=NmUN87zIB3M
(it's the first video a search would find anyway...)

EDIT: Please forgive the fact that I say import libraries are static libraries (it didn't seem worth rerecording the whole video for).
Last edited on
I'm following your textual tutorial and I'm stuck already...

CMake shows this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
The C compiler identification is unknown
The CXX compiler identification is unknown
Check for working C compiler: c:/MinGW/bin/gcc.exe
Check for working C compiler: c:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
  The C compiler "c:/MinGW/bin/gcc.exe" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: C:/SFML/SFML2/buildd/CMakeFiles/CMakeTmp

  

  Run Build Command:c:/MinGW/bin/mingw32-make.exe "cmTryCompileExec/fast"

  c:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTryCompileExec.dir\build.make
  CMakeFiles/cmTryCompileExec.dir/build

  mingw32-make.exe[1]: Entering directory
  `C:/SFML/SFML2/buildd/CMakeFiles/CMakeTmp'

  "C:\Program Files (x86)\CMake 2.8\bin\cmake.exe" -E cmake_progress_report
  C:\SFML\SFML2\buildd\CMakeFiles\CMakeTmp\CMakeFiles 1

  Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj

  c:\MinGW\bin\gcc.exe -o CMakeFiles\cmTryCompileExec.dir\testCCompiler.c.obj
  -c C:\SFML\SFML2\buildd\CMakeFiles\CMakeTmp\testCCompiler.c

  mingw32-make.exe[1]: ***
  [CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.obj] Error 1

  mingw32-make.exe[1]: Leaving directory
  `C:/SFML/SFML2/buildd/CMakeFiles/CMakeTmp'

  mingw32-make.exe: *** [cmTryCompileExec/fast] Error 2

  

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:11 (project)


Configuring incomplete, errors occurred!



I also get the error (about 5 times !?)
libgmp-10.dll is missing!
While it's obviously there in C:\Program Files\CodeBlocks\MinGW\bin
I have just tried to replicate your error, and have done so inconsistently :/

I suggest therefore that you try deleting the sfml2 folder and replacing it, before retrying with CMake. Is your Code::Blocks + MinGW installed in an irregular location?

Actually, what is your OS? It looks like CMake is looking for everything in Program Files (x86) and you say Code::Blocks is installed in Program Files. Maybe this is the problem? You could (:S) try reinstalling Code::Blocks in the Program Files (x86) directory, although one would imagine that CMake is clever enough to check both...

PS: You accidentally called your build directory 'buildd' - thought you might like to know ;)
Ok I changed it all around. I set up C::B to use another version of MinGW (int C:\MinGW).
Everything works fine, I can still compile everything in C::B. So I had another go with CMake. This time I just chose "MinGW Makefiles", so no more C::B. Now I get this error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:C:/SFML/SFML2/Build/CMakeFiles/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file:C:/SFML/SFML2/Build/CMakeFiles/CMakeCXXCompiler.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
Configuring incomplete, errors occurred!



FYI: I did include C:\MinGW in the Path variable...
I set up C::B to use another version of MinGW

As in your downloaded and installed MinGW separately?

And you chose "MinGW Makefiles" rather than "Codeblocks - MinGW Makefiles"? If you want to build with Code::Blocks, you are going to have to pick the second one.
Indeed, and I don't want to build with Codeblocks.
What could cause the error?
Ok I finally got it working (with yet another version of MinGW -.-)
So how do I link it now in C::B?
I mean, I don't have an include folder or something like that generated...

EDIT: got it all working, FINALLY!

I'd like to thank you all for taking the time to help me, especially Xander ;)
Last edited on
especially Xander

Hah! I'm not sure I really helped at all :/

In fact, I'd be interested to hear how you fixed everything in the end, if you have the time to post. It would be useful for me to add any relevant bits to my tutorial. :)

EDIT: I'm guessing you got hold of MAKE and ran that with the makefile CMake gives you. I think I might read up on this stuff a bit and write some "Building SFML 2.0 with MinGW|Visual Studio Makefiles" tutorials, as it is probably better to do it that way than to use IDEs as I have previously done.
Last edited on
Ok this is how I did it:
Instead of the MinGW distro at nuwen.net (which includes boost, SDL and other handy libs) I downloaded the tDragon one: http://tdm-gcc.tdragon.net .
I STILL got errors, but then I thought of something. I moved that MinGW BEFORE the other in the PATH variable. From then on everything went smooth! I could even choose C::B w/ MinGW Makefiles :) (at first I thought it would compile it with the compiler specified in C::B, which it doesn't, it just creates a project!)
So I compiled it, et voila!
One more question though. I complied "all". I got .dll and .a files. My program only works if I link it to sfml-system instead of (in all the tuts it's like this) -lsfml-system with sometimes -d attached for the debug or static. How do I generate those files?
Compile it again?

Cheers,
Xander
So in the end you generated a Code::Blocks workspace and built the libraries using that?

From my experience, although Code::Blocks supports multiple configurations, the SFML project generated by CMake doesn't have them.

If you want to have the '-d' then you have to reopen CMake and look at the options highlighted in red after you have configured.

One should be called "BUILD_SHARED_LIBS". Checking this gives you the dlls and import libraries, whereas unchecking it gives you the static -s libraries.

There is another, but I can't remember what it's called - I'm at school and don't have CMake to hand right now. But it's value by default is "Release". You can change it to "Debug".

If you change either of these, and re generate your project file, you can rebuild to get the corresponding libraries with -d extension, which you should be using for debug builds.

As for the 'l' at the start, I think (but am not sure as I don't build on the command line) that this is just an artifice of the command line argument format, and lsfml-system will in fact link sfml-system.

Regards,
Xander314
Alright so I built them all now...
Dynamic release and dynamic debug both work.
Static, none of them does...
This is the error:
1
2
3
4
5
6
7
8
9
||=== testt, Release ===|
c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.6.0\..\..\..\libsfml-window-s.a(VideoMode.cpp.obj):VideoMode.cpp|| undefined reference to `__gxx_personality_sj0'|
c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.6.0\..\..\..\libsfml-window-s.a(VideoMode.cpp.obj):VideoMode.cpp|| undefined reference to `_Unwind_SjLj_Register'|
c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.6.0\..\..\..\libsfml-window-s.a(VideoMode.cpp.obj):VideoMode.cpp|| undefined reference to `_Unwind_SjLj_Unregister'|
c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.6.0\..\..\..\libsfml-window-s.a(VideoMode.cpp.obj):VideoMode.cpp|| undefined reference to `_Unwind_SjLj_Resume'|
c:\mingw\bin\..\lib\gcc\i686-pc-mingw32\4.6.0\..\..\..\libsfml-window-s.a(Window.cpp.obj):Window.cpp|| undefined reference to `__gxx_personality_sj0'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===| 


It really don't get it...
when I try the debug static ones it says it cant find them, while they ARE in the folder with the rest of the libs....
This is the error:

The first problem is because to link statically to SFML, one must define the preprocessor macro SFML_STATIC. One should do it either in IDE settings or on the command line (i.e. don't use #define).

when I try the debug static ones it says it cant find them, while they ARE in the folder with the rest of the libs....

Are you writing, e.g. sfml-graphics-d-s rather than sfml-graphics-s-d? Just a guess...
Pages: 123