SFML

From Mario Fan Games Galaxy Wiki
Revision as of 13:38, 30 March 2010 by OniLink10 (talk | contribs) (Started Window section.)
 Stub.png This article or section is in need of expansion.

Please add further information.

SFML, or Simple and Fast Media Library, is a free and open-source media library written in C++, although it has ports to C, C#, Python, D, and Ruby. It has 5 Core Libraries, System, Window, Graphics, Audio, and Network. All of the Libraries depend on System, and Graphics also depends on Window. The Libraries are currently at V1.5, and there is a V1.6 and a V2.0 in development. V2.0 will be a complete rewrite of the Libraries.

System

Multi-Threading

The System Library has good support for Function-Based Multi-Threading. This means that it can create Threads, or "Mini-Programs", that run at the same time as the Main Program. These Threads use a Single Function for determining their code, which can use other functions as well. This Function is passed to the Thread class, sf::Thread, in the Constructor of the Thread. However, to provide more flexibility, the Thread Class can also be used as a base Class, and the code for this Base Class is stored in the Run() virtual function.

Random Number Generator

 Rewrite.gif This article/section should be rewritten or corrected.

More information may be on its talk page.

The System Library also has a good Random Number Generator. Scratch that, it has a good Pseudo-Random Number Generator. Computer's can't generate truly random numbers, Computers use a "Seed" to generate the number. Although SFML automatically sets the seed when you start the program, you can still set the seed by passing the Random Number Generator's Class a Seed with the SetSeed(newseed) function, usually the result of time() from the ctime library. In addition to that, you can also get the current seed using the GetSeed() function, for replaying. Using the Random(min, max) function will return a float or an int for a random number, depending on the seed, min, and max you gave it.

Window

The Window Library has a very simple cross-platform Window class that wraps up all of the OS-specific functions for handling a Window. The Window class takes care of grabbing events from the OS, displaying the Window, controlling the frame rate, controlling the OpenGL context, etc. All the programmer needs to do is create a loop that run while the window is open, and in that loop, make another loop that grabs and processes events from the Window class, do the logic, do the rendering, and then call the Window's display function to display the window.

Graphics

Information Soon...

Audio

Information Soon...

Network

Information Soon...

External Links