SFML - Simple and Fast Multimedia Library

SFML
  • Main Page
  • Modules
  • Classes
  • Files
Modules
Here is a list of all modules:
o Audio module | Sounds, streaming (musics or custom sources), recording, spatialization
o Graphics module | 2D graphics module: sprites, text, shapes, ..
o Network module | Socket-based communication, utilities and higher-level network protocols (HTTP, FTP)
o System module | Base module of SFML, defining various utilities
\ Window module | Provides OpenGL-based windows, and abstractions for events and input handling
Copyright © Laurent Gomila :: Documentation generated by doxygen ::


  • Classes
  • Files
Classes
Audio module

Sounds, streaming (musics or custom sources), recording, spatialization. More...

Classes

class | sf::Listener
The audio listener is the point in the scene from where all the sounds are heard. More...
class | sf::Music
Streamed music played from an audio file. More...
class | sf::Sound
Regular sound that can be played in the audio environment. More...
class | sf::SoundBuffer
Storage for audio samples defining a sound. More...
class | sf::SoundBufferRecorder
Specialized SoundRecorder which stores the captured audio data into a sound buffer. More...
class | sf::SoundRecorder
Abstract base class for capturing sound data. More...
class | sf::SoundSource
Base class defining a sound's properties. More...
class | sf::SoundStream
Abstract base class for streamed audio sources. More...
struct | sf::SoundStream::Chunk
Structure defining a chunk of audio data to stream. More...

Detailed Description

Sounds, streaming (musics or custom sources), recording, spatialization.


  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • sf
  • Listener
Static Public Member Functions | List of all members
sf::Listener Class Reference
Audio module

The audio listener is the point in the scene from where all the sounds are heard. More...

#include <Listener.hpp>

Static Public Member Functions

static void | setGlobalVolume (float volume)
Change the global volume of all the sounds and musics.
static float | getGlobalVolume ()
Get the current value of the global volume.
static void | setPosition (float x, float y, float z)
Set the position of the listener in the scene.
static void | setPosition (const Vector3f &position)
Set the position of the listener in the scene.
static Vector3f | getPosition ()
Get the current position of the listener in the scene.
static void | setDirection (float x, float y, float z)
Set the orientation of the listener in the scene.
static void | setDirection (const Vector3f &direction)
Set the orientation of the listener in the scene.
static Vector3f | getDirection ()
Get the current orientation of the listener in the scene.

Detailed Description

The audio listener is the point in the scene from where all the sounds are heard.

The audio listener defines the global properties of the audio environment, it defines where and how sounds and musics are heard.

If sf::View is the eyes of the user, then sf::Listener is his ears (by the way, they are often linked together – same position, orientation, etc.).

sf::Listener is a simple interface, which allows to setup the listener in the 3D audio environment (position and direction), and to adjust the global volume.

Because the listener is unique in the scene, sf::Listener only contains static functions and doesn't have to be instanciated.

Usage example:

// Move the listener to the position (1, 0, -5)
sf::Listener::setPosition(1, 0, -5);
// Make it face the right axis (1, 0, 0)
sf::Listener::setDirection(1, 0, 0);
// Reduce the global volume
sf::Listener::setGlobalVolume(50);

Definition at line 42 of file Listener.hpp.

Member Function Documentation

static Vector3f sf::Listener::getDirection ( )
static

Get the current orientation of the listener in the scene.

Returns
Listener's orientation
See Also
setDirection
static float sf::Listener::getGlobalVolume ( )
static

Get the current value of the global volume.

Returns
Current global volume, in the range [0, 100]
See Also
setGlobalVolume
static Vector3f sf::Listener::getPosition ( )
static

Get the current position of the listener in the scene.

Returns
Listener's position
See Also
setPosition
static void sf::Listener::setDirection | ( | float | x,
 |  | float | y,
 |  | float | z
 | ) |  |
static

Set the orientation of the listener in the scene.

The orientation defines the 3D axes of the listener (left, up, front) in the scene. The orientation vector doesn't have to be normalized. The default listener's orientation is (0, 0, -1).

Parameters
x | X coordinate of the listener's orientation
y | Y coordinate of the listener's orientation
z | Z coordinate of the listener's orientation
See Also
getDirection, setPosition
static void sf::Listener::setDirection ( const Vector3f & direction )
static

Set the orientation of the listener in the scene.

The orientation defines the 3D axes of the listener (left, up, front) in the scene. The orientation vector doesn't have to be normalized. The default listener's orientation is (0, 0, -1).

Parameters
direction New listener's orientation
See Also
getDirection, setPosition
static void sf::Listener::setGlobalVolume ( float volume )
static

Change the global volume of all the sounds and musics.

The volume is a number between 0 and 100; it is combined with the individual volume of each sound / music. The default value for the volume is 100 (maximum).

Parameters
volume New global volume, in the range [0, 100]
See Also
getGlobalVolume
static void sf::Listener::setPosition | ( | float | x,
 |  | float | y,
 |  | float | z
 | ) |  |
static

Set the position of the listener in the scene.

The default listener's position is (0, 0, 0).

Parameters
x | X coordinate of the listener's position
y | Y coordinate of the listener's position
z | Z coordinate of the listener's position
See Also
getPosition, setDirection
static void sf::Listener::setPosition ( const Vector3f & position )
static

Set the position of the listener in the scene.

The default listener's position is (0, 0, 0).

Parameters
position New listener's position
See Also
getPosition, setDirection
The documentation for this class was generated from the following file:
  • Listener.hpp


  • Class Hierarchy
  • Class Members
  • sf
  • Music
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sf::Music Class Reference
Audio module

Streamed music played from an audio file. More...

#include <Music.hpp>

Inheritance diagram for sf::Music:
sf::SoundStream sf::SoundSource

Public Types

enum Status {
Stopped,
Paused,
Playing
}
Enumeration of the sound source states. More...

Public Member Functions

Music ()
Default constructor.
~Music ()
Destructor.
bool | openFromFile (const std::string &filename)
Open a music from an audio file.
bool | openFromMemory (const void *data, std::size_t sizeInBytes)
Open a music from an audio file in memory.
bool | openFromStream (InputStream &stream)
Open a music from an audio file in a custom stream.
Time | getDuration () const
Get the total duration of the music.
void | play ()
Start or resume playing the audio stream.
void | pause ()
Pause the audio stream.
void | stop ()
Stop playing the audio stream.
unsigned int | getChannelCount () const
Return the number of channels of the stream.
unsigned int | getSampleRate () const
Get the stream sample rate of the stream.
Status | getStatus () const
Get the current status of the stream (stopped, paused, playing)
void | setPlayingOffset (Time timeOffset)
Change the current playing position of the stream.
Time | getPlayingOffset () const
Get the current playing position of the stream.
void | setLoop (bool loop)
Set whether or not the stream should loop after reaching the end.
bool | getLoop () const
Tell whether or not the stream is in loop mode.
void | setPitch (float pitch)
Set the pitch of the sound.
void | setVolume (float volume)
Set the volume of the sound.
void | setPosition (float x, float y, float z)
Set the 3D position of the sound in the audio scene.
void | setPosition (const Vector3f &position)
Set the 3D position of the sound in the audio scene.
void | setRelativeToListener (bool relative)
Make the sound's position relative to the listener or absolute.
void | setMinDistance (float distance)
Set the minimum distance of the sound.
void | setAttenuation (float attenuation)
Set the attenuation factor of the sound.
float | getPitch () const
Get the pitch of the sound.
float | getVolume () const
Get the volume of the sound.
Vector3f | getPosition () const
Get the 3D position of the sound in the audio scene.
bool | isRelativeToListener () const
Tell whether the sound's position is relative to the listener or is absolute.
float | getMinDistance () const
Get the minimum distance of the sound.
float | getAttenuation () const
Get the attenuation factor of the sound.

Protected Member Functions

virtual bool | onGetData (Chunk &data)
Request a new chunk of audio samples from the stream source.
virtual void | onSeek (Time timeOffset)
Change the current playing position in the stream source.
void | initialize (unsigned int channelCount, unsigned int sampleRate)
Define the audio stream parameters.

Protected Attributes

unsigned int m_source
OpenAL source identifier.

Detailed Description

Streamed music played from an audio file.

Musics are sounds that are streamed rather than completely loaded in memory.

This is especially useful for compressed musics that usually take hundreds of MB when they are uncompressed: by streaming it instead of loading it entirely, you avoid saturating the memory and have almost no loading delay.

Apart from that, a sf::Music has almost the same features as the sf::SoundBuffer / sf::Sound pair: you can play/pause/stop it, request its parameters (channels, sample rate), change the way it is played (pitch, volume, 3D position, ...), etc.

As a sound stream, a music is played in its own thread in order not to block the rest of the program. This means that you can leave the music alone after calling play(), it will manage itself very well.

Usage example:

// Declare a new music
sf::Music music;
// Open it from an audio file
if (!music.openFromFile("music.ogg"))
{
// error...
}
// Change some parameters
music.setPosition(0, 1, 10); // change its 3D position
music.setPitch(2); // increase the pitch
music.setVolume(50); // reduce the volume
music.setLoop(true); // make it loop
// Play it
music.play();
See Also
sf::Sound, sf::SoundStream

Definition at line 52 of file Music.hpp.

Member Enumeration Documentation

enum sf::SoundSource::Status
inherited

Enumeration of the sound source states.

Enumerator:
Stopped

Sound is not playing.

Paused

Sound is paused.

Playing

Sound is playing.

Definition at line 49 of file SoundSource.hpp.

Constructor & Destructor Documentation

sf::Music::Music ( )

Default constructor.

sf::Music::~Music ( )

Destructor.

Member Function Documentation

float sf::SoundSource::getAttenuation ( ) const
inherited

Get the attenuation factor of the sound.

Returns
Attenuation factor of the sound
See Also
setAttenuation, getMinDistance
unsigned int sf::SoundStream::getChannelCount ( ) const
inherited

Return the number of channels of the stream.

1 channel means a mono sound, 2 means stereo, etc.

Returns
Number of channels
Time sf::Music::getDuration ( ) const

Get the total duration of the music.

Returns
Music duration
bool sf::SoundStream::getLoop ( ) const
inherited

Tell whether or not the stream is in loop mode.

Returns
True if the stream is looping, false otherwise
See Also
setLoop
float sf::SoundSource::getMinDistance ( ) const
inherited

Get the minimum distance of the sound.

Returns
Minimum distance of the sound
See Also
setMinDistance, getAttenuation
float sf::SoundSource::getPitch ( ) const
inherited

Get the pitch of the sound.

Returns
Pitch of the sound
See Also
setPitch
Time sf::SoundStream::getPlayingOffset ( ) const
inherited

Get the current playing position of the stream.

Returns
Current playing position, from the beginning of the stream
See Also
setPlayingOffset
Vector3f sf::SoundSource::getPosition ( ) const
inherited

Get the 3D position of the sound in the audio scene.

Returns
Position of the sound
See Also
setPosition
unsigned int sf::SoundStream::getSampleRate ( ) const
inherited

Get the stream sample rate of the stream.

The sample rate is the number of audio samples played per second. The higher, the better the quality.

Returns
Sample rate, in number of samples per second
Status sf::SoundStream::getStatus ( ) const
inherited

Get the current status of the stream (stopped, paused, playing)

Returns
Current status
float sf::SoundSource::getVolume ( ) const
inherited

Get the volume of the sound.

Returns
Volume of the sound, in the range [0, 100]
See Also
setVolume
void sf::SoundStream::initialize | ( | unsigned int | channelCount,
 |  | unsigned int | sampleRate
 | ) |  |
protectedinherited

Define the audio stream parameters.

This function must be called by derived classes as soon as they know the audio settings of the stream to play. Any attempt to manipulate the stream (play(), ...) before calling this function will fail. It can be called multiple times if the settings of the audio stream change, but only when the stream is stopped.

Parameters
channelCount | Number of channels of the stream
sampleRate | Sample rate, in samples per second
bool sf::SoundSource::isRelativeToListener ( ) const
inherited

Tell whether the sound's position is relative to the listener or is absolute.

Returns
True if the position is relative, false if it's absolute
See Also
setRelativeToListener
virtual bool sf::Music::onGetData ( Chunk & data )
protectedvirtual

Request a new chunk of audio samples from the stream source.

This function fills the chunk from the next samples to read from the audio file.

Parameters
data Chunk of data to fill
Returns
True to continue playback, false to stop

Implements sf::SoundStream.

virtual void sf::Music::onSeek ( Time timeOffset )
protectedvirtual

Change the current playing position in the stream source.

Parameters
timeOffset New playing position, from the beginning of the music

Implements sf::SoundStream.

bool sf::Music::openFromFile ( const std::string & filename )

Open a music from an audio file.

This function doesn't start playing the music (call play() to do so). Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.

Parameters
filename Path of the music file to open
Returns
True if loading succeeded, false if it failed
See Also
openFromMemory, openFromStream
bool sf::Music::openFromMemory | ( | const void * | data,
 |  | std::size_t | sizeInBytes
 | ) |  |

Open a music from an audio file in memory.

This function doesn't start playing the music (call play() to do so). Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. Since the music is not loaded completely but rather streamed continuously, the data must remain available as long as the music is playing (ie. you can't deallocate it right after calling this function).

Parameters
data | Pointer to the file data in memory
sizeInBytes | Size of the data to load, in bytes
Returns
True if loading succeeded, false if it failed
See Also
openFromFile, openFromStream
bool sf::Music::openFromStream ( InputStream & stream )

Open a music from an audio file in a custom stream.

This function doesn't start playing the music (call play() to do so). Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. Since the music is not loaded completely but rather streamed continuously, the stream must remain alive as long as the music is playing (ie. you can't destroy it right after calling this function).

Parameters
stream Source stream to read from
Returns
True if loading succeeded, false if it failed
See Also
openFromFile, openFromMemory
void sf::SoundStream::pause ( )
inherited

Pause the audio stream.

This function pauses the stream if it was playing, otherwise (stream already paused or stopped) it has no effect.

See Also
play, stop
void sf::SoundStream::play ( )
inherited

Start or resume playing the audio stream.

This function starts the stream if it was stopped, resumes it if it was paused, and restarts it from beginning if it was it already playing. This function uses its own thread so that it doesn't block the rest of the program while the stream is played.

See Also
pause, stop
void sf::SoundSource::setAttenuation ( float attenuation )
inherited

Set the attenuation factor of the sound.

The attenuation is a multiplicative factor which makes the sound more or less loud according to its distance from the listener. An attenuation of 0 will produce a non-attenuated sound, i.e. its volume will always be the same whether it is heard from near or from far. On the other hand, an attenuation value such as 100 will make the sound fade out very quickly as it gets further from the listener. The default value of the attenuation is 1.

Parameters
attenuation New attenuation factor of the sound
See Also
getAttenuation, setMinDistance
void sf::SoundStream::setLoop ( bool loop )
inherited

Set whether or not the stream should loop after reaching the end.

If set, the stream will restart from beginning after reaching the end and so on, until it is stopped or setLoop(false) is called. The default looping state for streams is false.

Parameters
loop True to play in loop, false to play once
See Also
getLoop
void sf::SoundSource::setMinDistance ( float distance )
inherited

Set the minimum distance of the sound.

The "minimum distance" of a sound is the maximum distance at which it is heard at its maximum volume. Further than the minimum distance, it will start to fade out according to its attenuation factor. A value of 0 ("inside the head of the listener") is an invalid value and is forbidden. The default value of the minimum distance is 1.

Parameters
distance New minimum distance of the sound
See Also
getMinDistance, setAttenuation
void sf::SoundSource::setPitch ( float pitch )
inherited

Set the pitch of the sound.

The pitch represents the perceived fundamental frequency of a sound; thus you can make a sound more acute or grave by changing its pitch. A side effect of changing the pitch is to modify the playing speed of the sound as well. The default value for the pitch is 1.

Parameters
pitch New pitch to apply to the sound
See Also
getPitch
void sf::SoundStream::setPlayingOffset ( Time timeOffset )
inherited

Change the current playing position of the stream.

The playing position can be changed when the stream is either paused or playing.

Parameters
timeOffset New playing position, from the beginning of the stream
See Also
getPlayingOffset
void sf::SoundSource::setPosition | ( | float | x,
 |  | float | y,
 |  | float | z
 | ) |  |
inherited

Set the 3D position of the sound in the audio scene.

Only sounds with one channel (mono sounds) can be spatialized. The default position of a sound is (0, 0, 0).

Parameters
x | X coordinate of the position of the sound in the scene
y | Y coordinate of the position of the sound in the scene
z | Z coordinate of the position of the sound in the scene
See Also
getPosition
void sf::SoundSource::setPosition ( const Vector3f & position )
inherited

Set the 3D position of the sound in the audio scene.

Only sounds with one channel (mono sounds) can be spatialized. The default position of a sound is (0, 0, 0).

Parameters
position Position of the sound in the scene
See Also
getPosition
void sf::SoundSource::setRelativeToListener ( bool relative )
inherited

Make the sound's position relative to the listener or absolute.

Making a sound relative to the listener will ensure that it will always be played the same way regardless the position of the listener. This can be useful for non-spatialized sounds, sounds that are produced by the listener, or sounds attached to it. The default value is false (position is absolute).

Parameters
relative True to set the position relative, false to set it absolute
See Also
isRelativeToListener
void sf::SoundSource::setVolume ( float volume )
inherited

Set the volume of the sound.

The volume is a value between 0 (mute) and 100 (full volume). The default value for the volume is 100.

Parameters
volume Volume of the sound
See Also
getVolume
void sf::SoundStream::stop ( )
inherited

Stop playing the audio stream.

This function stops the stream if it was playing or paused, and does nothing if it was already stopped. It also resets the playing position (unlike pause()).

See Also
play, pause

Member Data Documentation

unsigned int sf::SoundSource::m_source
protectedinherited

OpenAL source identifier.

Definition at line 263 of file SoundSource.hpp.

The documentation for this class was generated from the following file:
  • Music.hpp


  • sf
  • Sound
Public Types | Public Member Functions | Protected Attributes | List of all members
sf::Sound Class Reference
Audio module

Regular sound that can be played in the audio environment. More...

#include <Sound.hpp>

Inheritance diagram for sf::Sound:
sf::SoundSource

Public Types

enum Status {
Stopped,
Paused,
Playing
}
Enumeration of the sound source states. More...

Public Member Functions

Sound ()
Default constructor.
Sound (const SoundBuffer &buffer)
Construct the sound with a buffer.
Sound (const Sound &copy)
Copy constructor.
~Sound ()
Destructor.
void | play ()
Start or resume playing the sound.
void | pause ()
Pause the sound.
void | stop ()
stop playing the sound
void | setBuffer (const SoundBuffer &buffer)
Set the source buffer containing the audio data to play.
void | setLoop (bool loop)
Set whether or not the sound should loop after reaching the end.
void | setPlayingOffset (Time timeOffset)
Change the current playing position of the sound.
const SoundBuffer * | getBuffer () const
Get the audio buffer attached to the sound.
bool | getLoop () const
Tell whether or not the sound is in loop mode.
Time | getPlayingOffset () const
Get the current playing position of the sound.
Status | getStatus () const
Get the current status of the sound (stopped, paused, playing)
Sound & | operator= (const Sound &right)
Overload of assignment operator.
void | resetBuffer ()
Reset the internal buffer of the sound.
void | setPitch (float pitch)
Set the pitch of the sound.
void | setVolume (float volume)
Set the volume of the sound.
void | setPosition (float x, float y, float z)
Set the 3D position of the sound in the audio scene.
void | setPosition (const Vector3f &position)
Set the 3D position of the sound in the audio scene.
void | setRelativeToListener (bool relative)
Make the sound's position relative to the listener or absolute.
void | setMinDistance (float distance)
Set the minimum distance of the sound.
void | setAttenuation (float attenuation)
Set the attenuation factor of the sound.
float | getPitch () const
Get the pitch of the sound.
float | getVolume () const
Get the volume of the sound.
Vector3f | getPosition () const
Get the 3D position of the sound in the audio scene.
bool | isRelativeToListener () const
Tell whether the sound's position is relative to the listener or is absolute.
float | getMinDistance () const
Get the minimum distance of the sound.
float | getAttenuation () const
Get the attenuation factor of the sound.

Protected Attributes

unsigned int m_source
OpenAL source identifier.

Detailed Description

Regular sound that can be played in the audio environment.

sf::Sound is the class to use to play sounds.

It provides:

  • Control (play, pause, stop)
  • Ability to modify output parameters in real-time (pitch, volume, ...)
  • 3D spatial features (position, attenuation, ...).

sf::Sound is perfect for playing short sounds that can fit in memory and require no latency, like foot steps or gun shots. For longer sounds, like background musics or long speeches, rather see sf::Music (which is based on streaming).

In order to work, a sound must be given a buffer of audio data to play. Audio data (samples) is stored in sf::SoundBuffer, and attached to a sound with the setBuffer() function. The buffer object attached to a sound must remain alive as long as the sound uses it. Note that multiple sounds can use the same sound buffer at the same time.

Usage example:

sf::SoundBuffer buffer;
buffer.loadFromFile("sound.wav");
sf::Sound sound;
sound.setBuffer(buffer);
sound.play();
See Also
sf::SoundBuffer, sf::Music

Definition at line 45 of file Sound.hpp.

Member Enumeration Documentation

enum sf::SoundSource::Status
inherited

Enumeration of the sound source states.

Enumerator:
Stopped

Sound is not playing.

Paused

Sound is paused.

Playing

Sound is playing.

Definition at line 49 of file SoundSource.hpp.

Constructor & Destructor Documentation

sf::Sound::Sound ( )

Default constructor.

sf::Sound::Sound ( const SoundBuffer & buffer )
explicit

Construct the sound with a buffer.

Parameters
buffer Sound buffer containing the audio data to play with the sound
sf::Sound::Sound ( const Sound & copy )

Copy constructor.

Parameters
copy Instance to copy
sf::Sound::~Sound ( )

Destructor.

Member Function Documentation

float sf::SoundSource::getAttenuation ( ) const
inherited

Get the attenuation factor of the sound.

Returns
Attenuation factor of the sound
See Also
setAttenuation, getMinDistance
const SoundBuffer* sf::Sound::getBuffer ( ) const

Get the audio buffer attached to the sound.

Returns
Sound buffer attached to the sound (can be NULL)
bool sf::Sound::getLoop ( ) const

Tell whether or not the sound is in loop mode.

Returns
True if the sound is looping, false otherwise
See Also
setLoop
float sf::SoundSource::getMinDistance ( ) const
inherited

Get the minimum distance of the sound.

Returns
Minimum distance of the sound
See Also
setMinDistance, getAttenuation
float sf::SoundSource::getPitch ( ) const
inherited

Get the pitch of the sound.

Returns
Pitch of the sound
See Also
setPitch
Time sf::Sound::getPlayingOffset ( ) const

Get the current playing position of the sound.

Returns
Current playing position, from the beginning of the sound
See Also
setPlayingOffset
Vector3f sf::SoundSource::getPosition ( ) const
inherited

Get the 3D position of the sound in the audio scene.

Returns
Position of the sound
See Also
setPosition
Status sf::Sound::getStatus ( ) const

Get the current status of the sound (stopped, paused, playing)

Returns
Current status of the sound
float sf::SoundSource::getVolume ( ) const
inherited

Get the volume of the sound.

Returns
Volume of the sound, in the range [0, 100]
See Also
setVolume
bool sf::SoundSource::isRelativeToListener ( ) const
inherited

Tell whether the sound's position is relative to the listener or is absolute.

Returns
True if the position is relative, false if it's absolute
See Also
setRelativeToListener
Sound& sf::Sound::operator= ( const Sound & right )

Overload of assignment operator.

Parameters
right Instance to assign
Returns
Reference to self
void sf::Sound::pause ( )

Pause the sound.

This function pauses the sound if it was playing, otherwise (sound already paused or stopped) it has no effect.

See Also
play, stop
void sf::Sound::play ( )

Start or resume playing the sound.

This function starts the stream if it was stopped, resumes it if it was paused, and restarts it from beginning if it was it already playing. This function uses its own thread so that it doesn't block the rest of the program while the sound is played.

See Also
pause, stop
void sf::Sound::resetBuffer ( )

Reset the internal buffer of the sound.

This function is for internal use only, you don't have to use it. It is called by the sf::SoundBuffer that this sound uses, when it is destroyed in order to prevent the sound from using a dead buffer.

void sf::SoundSource::setAttenuation ( float attenuation )
inherited

Set the attenuation factor of the sound.

The attenuation is a multiplicative factor which makes the sound more or less loud according to its distance from the listener. An attenuation of 0 will produce a non-attenuated sound, i.e. its volume will always be the same whether it is heard from near or from far. On the other hand, an attenuation value such as 100 will make the sound fade out very quickly as it gets further from the listener. The default value of the attenuation is 1.

Parameters
attenuation New attenuation factor of the sound
See Also
getAttenuation, setMinDistance
void sf::Sound::setBuffer ( const SoundBuffer & buffer )

Set the source buffer containing the audio data to play.

It is important to note that the sound buffer is not copied, thus the sf::SoundBuffer instance must remain alive as long as it is attached to the sound.

Parameters
buffer Sound buffer to attach to the sound
See Also
getBuffer
void sf::Sound::setLoop ( bool loop )

Set whether or not the sound should loop after reaching the end.

If set, the sound will restart from beginning after reaching the end and so on, until it is stopped or setLoop(false) is called. The default looping state for sound is false.

Parameters
loop True to play in loop, false to play once
See Also
getLoop
void sf::SoundSource::setMinDistance ( float distance )
inherited

Set the minimum distance of the sound.

The "minimum distance" of a sound is the maximum distance at which it is heard at its maximum volume. Further than the minimum distance, it will start to fade out according to its attenuation factor. A value of 0 ("inside the head of the listener") is an invalid value and is forbidden. The default value of the minimum distance is 1.

Parameters
distance New minimum distance of the sound
See Also
getMinDistance, setAttenuation
void sf::SoundSource::setPitch ( float pitch )
inherited

Set the pitch of the sound.

The pitch represents the perceived fundamental frequency of a sound; thus you can make a sound more acute or grave by changing its pitch. A side effect of changing the pitch is to modify the playing speed of the sound as well. The default value for the pitch is 1.

Parameters
pitch New pitch to apply to the sound
See Also
getPitch
void sf::Sound::setPlayingOffset ( Time timeOffset )

Change the current playing position of the sound.

The playing position can be changed when the sound is either paused or playing.

Parameters
timeOffset New playing position, from the beginning of the sound
See Also
getPlayingOffset
void sf::SoundSource::setPosition | ( | float | x,
 |  | float | y,
 |  | float | z
 | ) |  |
inherited

Set the 3D position of the sound in the audio scene.

Only sounds with one channel (mono sounds) can be spatialized. The default position of a sound is (0, 0, 0).

Parameters
x | X coordinate of the position of the sound in the scene
y | Y coordinate of the position of the sound in the scene
z | Z coordinate of the position of the sound in the scene
See Also
getPosition
void sf::SoundSource::setPosition ( const Vector3f & position )
inherited

Set the 3D position of the sound in the audio scene.

Only sounds with one channel (mono sounds) can be spatialized. The default position of a sound is (0, 0, 0).

Parameters
position Position of the sound in the scene
See Also
getPosition
void sf::SoundSource::setRelativeToListener ( bool relative )
inherited

Make the sound's position relative to the listener or absolute.

Making a sound relative to the listener will ensure that it will always be played the same way regardless the position of the listener. This can be useful for non-spatialized sounds, sounds that are produced by the listener, or sounds attached to it. The default value is false (position is absolute).

Parameters
relative True to set the position relative, false to set it absolute
See Also
isRelativeToListener
void sf::SoundSource::setVolume ( float volume )
inherited

Set the volume of the sound.

The volume is a value between 0 (mute) and 100 (full volume). The default value for the volume is 100.

Parameters
volume Volume of the sound
See Also
getVolume
void sf::Sound::stop ( )

stop playing the sound

This function stops the sound if it was playing or paused, and does nothing if it was already stopped. It also resets the playing position (unlike pause()).

See Also
play, pause

Member Data Documentation

unsigned int sf::SoundSource::m_source
protectedinherited

OpenAL source identifier.

Definition at line 263 of file SoundSource.hpp.

The documentation for this class was generated from the following file:
  • Sound.hpp


  • sf
  • SoundBuffer
Public Member Functions | Friends | List of all members
sf::SoundBuffer Class Reference
Audio module

Storage for audio samples defining a sound. More...

#include <SoundBuffer.hpp>

Public Member Functions

SoundBuffer ()
Default constructor.
SoundBuffer (const SoundBuffer &copy)
Copy constructor.
~SoundBuffer ()
Destructor.
bool | loadFromFile (const std::string &filename)
Load the sound buffer from a file.
bool | loadFromMemory (const void *data, std::size_t sizeInBytes)
Load the sound buffer from a file in memory.
bool | loadFromStream (InputStream &stream)
Load the sound buffer from a custom stream.
bool | loadFromSamples (const Int16 *samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate)
Load the sound buffer from an array of audio samples.
bool | saveToFile (const std::string &filename) const
Save the sound buffer to an audio file.
const Int16 * | getSamples () const
Get the array of audio samples stored in the buffer.
std::size_t | getSampleCount () const
Get the number of samples stored in the buffer.
unsigned int | getSampleRate () const
Get the sample rate of the sound.
unsigned int | getChannelCount () const
Get the number of channels used by the sound.
Time | getDuration () const
Get the total duration of the sound.
SoundBuffer & | operator= (const SoundBuffer &right)
Overload of assignment operator.

Friends

class Sound

Detailed Description

Storage for audio samples defining a sound.

A sound buffer holds the data of a sound, which is an array of audio samples.

A sample is a 16 bits signed integer that defines the amplitude of the sound at a given time. The sound is then restituted by playing these samples at a high rate (for example, 44100 samples per second is the standard rate used for playing CDs). In short, audio samples are like texture pixels, and a sf::SoundBuffer is similar to a sf::Texture.

A sound buffer can be loaded from a file (see loadFromFile() for the complete list of supported formats), from memory, from a custom stream (see sf::InputStream) or directly from an array of samples. It can also be saved back to a file.

Sound buffers alone are not very useful: they hold the audio data but cannot be played. To do so, you need to use the sf::Sound class, which provides functions to play/pause/stop the sound as well as changing the way it is outputted (volume, pitch, 3D position, ...). This separation allows more flexibility and better performances: indeed a sf::SoundBuffer is a heavy resource, and any operation on it is slow (often too slow for real-time applications). On the other side, a sf::Sound is a lightweight object, which can use the audio data of a sound buffer and change the way it is played without actually modifying that data. Note that it is also possible to bind several sf::Sound instances to the same sf::SoundBuffer.

It is important to note that the sf::Sound instance doesn't copy the buffer that it uses, it only keeps a reference to it. Thus, a sf::SoundBuffer must not be destructed while it is used by a sf::Sound (i.e. never write a function that uses a local sf::SoundBuffer instance for loading a sound).

Usage example:

// Declare a new sound buffer
sf::SoundBuffer buffer;
// Load it from a file
if (!buffer.loadFromFile("sound.wav"))
{
// error...
}
// Create a sound source and bind it to the buffer
sf::Sound sound1;
sound1.setBuffer(buffer);
// Play the sound
sound1.play();
// Create another sound source bound to the same buffer
sf::Sound sound2;
sound2.setBuffer(buffer);
// Play it with a higher pitch -- the first sound remains unchanged
sound2.setPitch(2);
sound2.play();
See Also
sf::Sound, sf::SoundBufferRecorder

Definition at line 52 of file SoundBuffer.hpp.

Constructor & Destructor Documentation

sf::SoundBuffer::SoundBuffer ( )

Default constructor.

sf::SoundBuffer::SoundBuffer ( const SoundBuffer & copy )

Copy constructor.

Parameters
copy Instance to copy
sf::SoundBuffer::~SoundBuffer ( )

Destructor.

Member Function Documentation

unsigned int sf::SoundBuffer::getChannelCount ( ) const

Get the number of channels used by the sound.

If the sound is mono then the number of channels will be 1, 2 for stereo, etc.

Returns
Number of channels
See Also
getSampleRate, getDuration
Time sf::SoundBuffer::getDuration ( ) const

Get the total duration of the sound.

Returns
Sound duration
See Also
getSampleRate, getChannelCount
std::size_t sf::SoundBuffer::getSampleCount ( ) const

Get the number of samples stored in the buffer.

The array of samples can be accessed with the getSamples() function.

Returns
Number of samples
See Also
getSamples
unsigned int sf::SoundBuffer::getSampleRate ( ) const

Get the sample rate of the sound.

The sample rate is the number of samples played per second. The higher, the better the quality (for example, 44100 samples/s is CD quality).

Returns
Sample rate (number of samples per second)
See Also
getChannelCount, getDuration
const Int16* sf::SoundBuffer::getSamples ( ) const

Get the array of audio samples stored in the buffer.

The format of the returned samples is 16 bits signed integer (sf::Int16). The total number of samples in this array is given by the getSampleCount() function.

Returns
Read-only pointer to the array of sound samples
See Also
getSampleCount
bool sf::SoundBuffer::loadFromFile ( const std::string & filename )

Load the sound buffer from a file.

Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.

Parameters
filename Path of the sound file to load
Returns
True if loading succeeded, false if it failed
See Also
loadFromMemory, loadFromStream, loadFromSamples, saveToFile
bool sf::SoundBuffer::loadFromMemory | ( | const void * | data,
 |  | std::size_t | sizeInBytes
 | ) |  |

Load the sound buffer from a file in memory.

Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.

Parameters
data | Pointer to the file data in memory
sizeInBytes | Size of the data to load, in bytes
Returns
True if loading succeeded, false if it failed
See Also
loadFromFile, loadFromStream, loadFromSamples
bool sf::SoundBuffer::loadFromSamples | ( | const Int16 * | samples,
 |  | std::size_t | sampleCount,
 |  | unsigned int | channelCount,
 |  | unsigned int | sampleRate
 | ) |  |

Load the sound buffer from an array of audio samples.

The assumed format of the audio samples is 16 bits signed integer (sf::Int16).

Parameters
samples | Pointer to the array of samples in memory
sampleCount | Number of samples in the array
channelCount | Number of channels (1 = mono, 2 = stereo, ...)
sampleRate | Sample rate (number of samples to play per second)
Returns
True if loading succeeded, false if it failed
See Also
loadFromFile, loadFromMemory, saveToFile
bool sf::SoundBuffer::loadFromStream ( InputStream & stream )

Load the sound buffer from a custom stream.

Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.

Parameters
stream Source stream to read from
Returns
True if loading succeeded, false if it failed
See Also
loadFromFile, loadFromMemory, loadFromSamples
SoundBuffer& sf::SoundBuffer::operator= ( const SoundBuffer & right )

Overload of assignment operator.

Parameters
right Instance to assign
Returns
Reference to self
bool sf::SoundBuffer::saveToFile ( const std::string & filename ) const

Save the sound buffer to an audio file.

Here is a complete list of all the supported audio formats: ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.

Parameters
filename Path of the sound file to write
Returns
True if saving succeeded, false if it failed
See Also
loadFromFile, loadFromMemory, loadFromSamples
The documentation for this class was generated from the following file:
  • SoundBuffer.hpp


  • sf
  • SoundBufferRecorder
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
sf::SoundBufferRecorder Class Reference
Audio module

Specialized SoundRecorder which stores the captured audio data into a sound buffer. More...

#include <SoundBufferRecorder.hpp>

Inheritance diagram for sf::SoundBufferRecorder:
sf::SoundRecorder

Public Member Functions

const SoundBuffer & | getBuffer () const
Get the sound buffer containing the captured audio data.
void | start (unsigned int sampleRate=44100)
Start the capture.
void | stop ()
Stop the capture.
unsigned int | getSampleRate () const
Get the sample rate.

Static Public Member Functions

static bool isAvailable ()
Check if the system supports audio capture.

Protected Member Functions

virtual bool | onStart ()
Start capturing audio data.
virtual bool | onProcessSamples (const Int16 *samples, std::size_t sampleCount)
Process a new chunk of recorded samples.
virtual void | onStop ()
Stop capturing audio data.

Detailed Description

Specialized SoundRecorder which stores the captured audio data into a sound buffer.

sf::SoundBufferRecorder allows to access a recorded sound through a sf::SoundBuffer, so that it can be played, saved to a file, etc.

It has the same simple interface as its base class (start(), stop()) and adds a function to retrieve the recorded sound buffer (getBuffer()).

As usual, don't forget to call the isAvailable() function before using this class (see sf::SoundRecorder for more details about this).

Usage example:

if (sf::SoundBufferRecorder::isAvailable())
{
// Record some audio data
sf::SoundBufferRecorder recorder;
recorder.start();
...
recorder.stop();
// Get the buffer containing the captured audio data
const sf::SoundBuffer& buffer = recorder.getBuffer();
// Save it to a file (for example...)
buffer.saveToFile("my_record.ogg");
}
See Also
sf::SoundRecorder

Definition at line 44 of file SoundBufferRecorder.hpp.

Member Function Documentation

const SoundBuffer& sf::SoundBufferRecorder::getBuffer ( ) const

Get the sound buffer containing the captured audio data.

The sound buffer is valid only after the capture has ended. This function provides a read-only access to the internal sound buffer, but it can be copied if you need to make any modification to it.

Returns
Read-only access to the sound buffer
unsigned int sf::SoundRecorder::getSampleRate ( ) const
inherited

Get the sample rate.

The sample rate defines the number of audio samples captured per second. The higher, the better the quality (for example, 44100 samples/sec is CD quality).

Returns
Sample rate, in samples per second
static bool sf::SoundRecorder::isAvailable ( )
staticinherited

Check if the system supports audio capture.

This function should always be called before using the audio capture features. If it returns false, then any attempt to use sf::SoundRecorder or one of its derived classes will fail.

Returns
True if audio capture is supported, false otherwise
virtual bool sf::SoundBufferRecorder::onProcessSamples | ( | const Int16 * | samples,
 |  | std::size_t | sampleCount
 | ) |  |
protectedvirtual

Process a new chunk of recorded samples.

Parameters
samples | Pointer to the new chunk of recorded samples
sampleCount | Number of samples pointed by samples
Returns
True to continue the capture, or false to stop it

Implements sf::SoundRecorder.

virtual bool sf::SoundBufferRecorder::onStart ( )
protectedvirtual

Start capturing audio data.

Returns
True to start the capture, or false to abort it

Reimplemented from sf::SoundRecorder.

virtual void sf::SoundBufferRecorder::onStop ( )
protectedvirtual

Stop capturing audio data.

Reimplemented from sf::SoundRecorder.

void sf::SoundRecorder::start ( unsigned int sampleRate = 44100 )
inherited

Start the capture.

The sampleRate parameter defines the number of audio samples captured per second. The higher, the better the quality (for example, 44100 samples/sec is CD quality). This function uses its own thread so that it doesn't block the rest of the program while the capture runs. Please note that only one capture can happen at the same time.

Parameters
sampleRate Desired capture rate, in number of samples per second
See Also
stop
void sf::SoundRecorder::stop ( )
inherited

Stop the capture.

See Also
start
The documentation for this class was generated from the following file:
  • SoundBufferRecorder.hpp


  • sf
  • SoundRecorder
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
sf::SoundRecorder Class Referenceabstract
Audio module

Abstract base class for capturing sound data. More...

#include <SoundRecorder.hpp>

Inheritance diagram for sf::SoundRecorder:
sf::SoundBufferRecorder

Public Member Functions

virtual | ~SoundRecorder ()
destructor
void | start (unsigned int sampleRate=44100)
Start the capture.
void | stop ()
Stop the capture.
unsigned int | getSampleRate () const
Get the sample rate.

Static Public Member Functions

static bool isAvailable ()
Check if the system supports audio capture.

Protected Member Functions

SoundRecorder ()
Default constructor.
virtual bool | onStart ()
Start capturing audio data.
virtual bool | onProcessSamples (const Int16 *samples, std::size_t sampleCount)=0
Process a new chunk of recorded samples.
virtual void | onStop ()
Stop capturing audio data.

Detailed Description

Abstract base class for capturing sound data.

sf::SoundBuffer provides a simple interface to access the audio recording capabilities of the computer (the microphone).

As an abstract base class, it only cares about capturing sound samples, the task of making something useful with them is left to the derived class. Note that SFML provides a built-in specialization for saving the captured data to a sound buffer (see sf::SoundBufferRecorder).

A derived class has only one virtual function to override:

  • onProcessSamples provides the new chunks of audio samples while the capture happens

Moreover, two additionnal virtual functions can be overriden as well if necessary:

  • onStart is called before the capture happens, to perform custom initializations
  • onStop is called after the capture ends, to perform custom cleanup

The audio capture feature may not be supported or activated on every platform, thus it is recommended to check its availability with the isAvailable() function. If it returns false, then any attempt to use an audio recorder will fail.

It is important to note that the audio capture happens in a separate thread, so that it doesn't block the rest of the program. In particular, the onProcessSamples and onStop virtual functions (but not onStart) will be called from this separate thread. It is important to keep this in mind, because you may have to take care of synchronization issues if you share data between threads.

Usage example:

class CustomRecorder : public sf::SoundRecorder
{
virtual bool onStart() // optional
{
// Initialize whatever has to be done before the capture starts
...
// Return true to start playing
return true;
}
virtual bool onProcessSamples(const Int16* samples, std::size_t sampleCount)
{
// Do something with the new chunk of samples (store them, send them, ...)
...
// Return true to continue playing
return true;
}
virtual void onStop() // optional
{
// Clean up whatever has to be done after the capture ends
...
}
}
// Usage
if (CustomRecorder::isAvailable())
{
CustomRecorder recorder;
recorder.start();
...
recorder.stop();
}
See Also
sf::SoundBufferRecorder

Definition at line 42 of file SoundRecorder.hpp.

Constructor & Destructor Documentation

virtual sf::SoundRecorder::~SoundRecorder ( )
virtual

destructor

sf::SoundRecorder::SoundRecorder ( )
protected

Default constructor.

This constructor is only meant to be called by derived classes.

Member Function Documentation

unsigned int sf::SoundRecorder::getSampleRate ( ) const

Get the sample rate.

The sample rate defines the number of audio samples captured per second. The higher, the better the quality (for example, 44100 samples/sec is CD quality).

Returns
Sample rate, in samples per second
static bool sf::SoundRecorder::isAvailable ( )
static

Check if the system supports audio capture.

This function should always be called before using the audio capture features. If it returns false, then any attempt to use sf::SoundRecorder or one of its derived classes will fail.

Returns
True if audio capture is supported, false otherwise
virtual bool sf::SoundRecorder::onProcessSamples | ( | const Int16 * | samples,
 |  | std::size_t | sampleCount
 | ) |  |
protectedpure virtual

Process a new chunk of recorded samples.

This virtual function is called every time a new chunk of recorded data is available. The derived class can then do whatever it wants with it (storing it, playing it, sending it over the network, etc.).

Parameters
samples | Pointer to the new chunk of recorded samples
sampleCount | Number of samples pointed by samples
Returns
True to continue the capture, or false to stop it

Implemented in sf::SoundBufferRecorder.

virtual bool sf::SoundRecorder::onStart ( )
protectedvirtual

Start capturing audio data.

This virtual function may be overriden by a derived class if something has to be done every time a new capture starts. If not, this function can be ignored; the default implementation does nothing.

Returns
True to start the capture, or false to abort it

Reimplemented in sf::SoundBufferRecorder.

virtual void sf::SoundRecorder::onStop ( )
protectedvirtual

Stop capturing audio data.

This virtual function may be overriden by a derived class if something has to be done every time the capture ends. If not, this function can be ignored; the default implementation does nothing.

Reimplemented in sf::SoundBufferRecorder.

void sf::SoundRecorder::start ( unsigned int sampleRate = 44100 )

Start the capture.

The sampleRate parameter defines the number of audio samples captured per second. The higher, the better the quality (for example, 44100 samples/sec is CD quality). This function uses its own thread so that it doesn't block the rest of the program while the capture runs. Please note that only one capture can happen at the same time.

Parameters
sampleRate Desired capture rate, in number of samples per second
See Also
stop
void sf::SoundRecorder::stop ( )

Stop the capture.

See Also
start
The documentation for this class was generated from the following file:
  • SoundRecorder.hpp


  • sf
  • SoundSource
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sf::SoundSource Class Reference
Audio module

Base class defining a sound's properties. More...

#include <SoundSource.hpp>

Inheritance diagram for sf::SoundSource:
sf::Sound sf::SoundStream sf::Music

Public Types

enum Status {
Stopped,
Paused,
Playing
}
Enumeration of the sound source states. More...

Public Member Functions

SoundSource (const SoundSource &copy)
Copy constructor.
virtual | ~SoundSource ()
Destructor.
void | setPitch (float pitch)
Set the pitch of the sound.
void | setVolume (float volume)
Set the volume of the sound.
void | setPosition (float x, float y, float z)
Set the 3D position of the sound in the audio scene.
void | setPosition (const Vector3f &position)
Set the 3D position of the sound in the audio scene.
void | setRelativeToListener (bool relative)
Make the sound's position relative to the listener or absolute.
void | setMinDistance (float distance)
Set the minimum distance of the sound.
void | setAttenuation (float attenuation)
Set the attenuation factor of the sound.
float | getPitch () const
Get the pitch of the sound.
float | getVolume () const
Get the volume of the sound.
Vector3f | getPosition () const
Get the 3D position of the sound in the audio scene.
bool | isRelativeToListener () const
Tell whether the sound's position is relative to the listener or is absolute.
float | getMinDistance () const
Get the minimum distance of the sound.
float | getAttenuation () const
Get the attenuation factor of the sound.

Protected Member Functions

SoundSource ()
Default constructor.
Status getStatus () const
Get the current status of the sound (stopped, paused, playing)

Protected Attributes

unsigned int m_source
OpenAL source identifier.

Detailed Description

Base class defining a sound's properties.

sf::SoundSource is not meant to be used directly, it only serves as a common base for all audio objects that can live in the audio environment.

It defines several properties for the sound: pitch, volume, position, attenuation, etc. All of them can be changed at any time with no impact on performances.

See Also
sf::Sound, sf::SoundStream

Definition at line 41 of file SoundSource.hpp.

Member Enumeration Documentation

enum sf::SoundSource::Status

Enumeration of the sound source states.

Enumerator:
Stopped

Sound is not playing.

Paused

Sound is paused.

Playing

Sound is playing.

Definition at line 49 of file SoundSource.hpp.

Constructor & Destructor Documentation

sf::SoundSource::SoundSource ( const SoundSource & copy )

Copy constructor.

Parameters
copy Instance to copy
virtual sf::SoundSource::~SoundSource ( )
virtual

Destructor.

sf::SoundSource::SoundSource ( )
protected

Default constructor.

This constructor is meant ot be called by derived classes only.

Member Function Documentation

float sf::SoundSource::getAttenuation ( ) const

Get the attenuation factor of the sound.

Returns
Attenuation factor of the sound
See Also
setAttenuation, getMinDistance
float sf::SoundSource::getMinDistance ( ) const

Get the minimum distance of the sound.

Returns
Minimum distance of the sound
See Also
setMinDistance, getAttenuation
float sf::SoundSource::getPitch ( ) const

Get the pitch of the sound.

Returns
Pitch of the sound
See Also
setPitch
Vector3f sf::SoundSource::getPosition ( ) const

Get the 3D position of the sound in the audio scene.

Returns
Position of the sound
See Also
setPosition
Status sf::SoundSource::getStatus ( ) const
protected

Get the current status of the sound (stopped, paused, playing)

Returns
Current status of the sound
float sf::SoundSource::getVolume ( ) const

Get the volume of the sound.

Returns
Volume of the sound, in the range [0, 100]
See Also
setVolume
bool sf::SoundSource::isRelativeToListener ( ) const

Tell whether the sound's position is relative to the listener or is absolute.

Returns
True if the position is relative, false if it's absolute
See Also
setRelativeToListener
void sf::SoundSource::setAttenuation ( float attenuation )

Set the attenuation factor of the sound.

The attenuation is a multiplicative factor which makes the sound more or less loud according to its distance from the listener. An attenuation of 0 will produce a non-attenuated sound, i.e. its volume will always be the same whether it is heard from near or from far. On the other hand, an attenuation value such as 100 will make the sound fade out very quickly as it gets further from the listener. The default value of the attenuation is 1.

Parameters
attenuation New attenuation factor of the sound
See Also
getAttenuation, setMinDistance
void sf::SoundSource::setMinDistance ( float distance )

Set the minimum distance of the sound.

The "minimum distance" of a sound is the maximum distance at which it is heard at its maximum volume. Further than the minimum distance, it will start to fade out according to its attenuation factor. A value of 0 ("inside the head of the listener") is an invalid value and is forbidden. The default value of the minimum distance is 1.

Parameters
distance New minimum distance of the sound
See Also
getMinDistance, setAttenuation
void sf::SoundSource::setPitch ( float pitch )

Set the pitch of the sound.

The pitch represents the perceived fundamental frequency of a sound; thus you can make a sound more acute or grave by changing its pitch. A side effect of changing the pitch is to modify the playing speed of the sound as well. The default value for the pitch is 1.

Parameters
pitch New pitch to apply to the sound
See Also
getPitch
void sf::SoundSource::setPosition | ( | float | x,
 |  | float | y,
 |  | float | z
 | ) |  |

Set the 3D position of the sound in the audio scene.

Only sounds with one channel (mono sounds) can be spatialized. The default position of a sound is (0, 0, 0).

Parameters
x | X coordinate of the position of the sound in the scene
y | Y coordinate of the position of the sound in the scene
z | Z coordinate of the position of the sound in the scene
See Also
getPosition
void sf::SoundSource::setPosition ( const Vector3f & position )

Set the 3D position of the sound in the audio scene.

Only sounds with one channel (mono sounds) can be spatialized. The default position of a sound is (0, 0, 0).

Parameters
position Position of the sound in the scene
See Also
getPosition
void sf::SoundSource::setRelativeToListener ( bool relative )

Make the sound's position relative to the listener or absolute.

Making a sound relative to the listener will ensure that it will always be played the same way regardless the position of the listener. This can be useful for non-spatialized sounds, sounds that are produced by the listener, or sounds attached to it. The default value is false (position is absolute).

Parameters
relative True to set the position relative, false to set it absolute
See Also
isRelativeToListener
void sf::SoundSource::setVolume ( float volume )

Set the volume of the sound.

The volume is a value between 0 (mute) and 100 (full volume). The default value for the volume is 100.

Parameters
volume Volume of the sound
See Also
getVolume

Member Data Documentation

unsigned int sf::SoundSource::m_source
protected

OpenAL source identifier.

Definition at line 263 of file SoundSource.hpp.

The documentation for this class was generated from the following file:
  • SoundSource.hpp


  • sf
  • SoundStream
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sf::SoundStream Class Referenceabstract
Audio module

Abstract base class for streamed audio sources. More...

#include <SoundStream.hpp>

Inheritance diagram for sf::SoundStream:
sf::SoundSource sf::Music

Classes

struct Chunk
Structure defining a chunk of audio data to stream. More...

Public Types

enum Status {
Stopped,
Paused,
Playing
}
Enumeration of the sound source states. More...

Public Member Functions

virtual | ~SoundStream ()
Destructor.
void | play ()
Start or resume playing the audio stream.
void | pause ()
Pause the audio stream.
void | stop ()
Stop playing the audio stream.
unsigned int | getChannelCount () const
Return the number of channels of the stream.
unsigned int | getSampleRate () const
Get the stream sample rate of the stream.
Status | getStatus () const
Get the current status of the stream (stopped, paused, playing)
void | setPlayingOffset (Time timeOffset)
Change the current playing position of the stream.
Time | getPlayingOffset () const
Get the current playing position of the stream.
void | setLoop (bool loop)
Set whether or not the stream should loop after reaching the end.
bool | getLoop () const
Tell whether or not the stream is in loop mode.
void | setPitch (float pitch)
Set the pitch of the sound.
void | setVolume (float volume)
Set the volume of the sound.
void | setPosition (float x, float y, float z)
Set the 3D position of the sound in the audio scene.
void | setPosition (const Vector3f &position)
Set the 3D position of the sound in the audio scene.
void | setRelativeToListener (bool relative)
Make the sound's position relative to the listener or absolute.
void | setMinDistance (float distance)
Set the minimum distance of the sound.
void | setAttenuation (float attenuation)
Set the attenuation factor of the sound.
float | getPitch () const
Get the pitch of the sound.
float | getVolume () const
Get the volume of the sound.
Vector3f | getPosition () const
Get the 3D position of the sound in the audio scene.
bool | isRelativeToListener () const
Tell whether the sound's position is relative to the listener or is absolute.
float | getMinDistance () const
Get the minimum distance of the sound.
float | getAttenuation () const
Get the attenuation factor of the sound.

Protected Member Functions

SoundStream ()
Default constructor.
void | initialize (unsigned int channelCount, unsigned int sampleRate)
Define the audio stream parameters.
virtual bool | onGetData (Chunk &data)=0
Request a new chunk of audio samples from the stream source.
virtual void | onSeek (Time timeOffset)=0
Change the current playing position in the stream source.

Protected Attributes

unsigned int m_source
OpenAL source identifier.

Detailed Description

Abstract base class for streamed audio sources.

Unlike audio buffers (see sf::SoundBuffer), audio streams are never completely loaded in memory.

Instead, the audio data is acquired continuously while the stream is playing. This behaviour allows to play a sound with no loading delay, and keeps the memory consumption very low.

Sound sources that need to be streamed are usually big files (compressed audio musics that would eat hundreds of MB in memory) or files that would take a lot of time to be received (sounds played over the network).

sf::SoundStream is a base class that doesn't care about the stream source, which is left to the derived class. SFML provides a built-in specialization for big files (see sf::Music). No network stream source is provided, but you can write your own by combining this class with the network module.

A derived class has to override two virtual functions:

  • onGetData fills a new chunk of audio data to be played
  • onSeek changes the current playing position in the source

It is important to note that each SoundStream is played in its own separate thread, so that the streaming loop doesn't block the rest of the program. In particular, the OnGetData and OnSeek virtual functions may sometimes be called from this separate thread. It is important to keep this in mind, because you may have to take care of synchronization issues if you share data between threads.

Usage example:

class CustomStream : public sf::SoundStream
{
public :
bool open(const std::string& location)
{
// Open the source and get audio settings
...
unsigned int channelCount = ...;
unsigned int sampleRate = ...;
// Initialize the stream -- important!
initialize(channelCount, sampleRate);
}
private :
virtual bool onGetData(Chunk& data)
{
// Fill the chunk with audio data from the stream source
data.samples = ...;
data.sampleCount = ...;
// Return true to continue playing
return true;
}
virtual void onSeek(Uint32 timeOffset)
{
// Change the current position in the stream source
...
}
}
// Usage
CustomStream stream;
stream.open("path/to/stream");
stream.play();
See Also
sf::Music

Definition at line 44 of file SoundStream.hpp.

Member Enumeration Documentation

enum sf::SoundSource::Status
inherited

Enumeration of the sound source states.

Enumerator:
Stopped

Sound is not playing.

Paused

Sound is paused.

Playing

Sound is playing.

Definition at line 49 of file SoundSource.hpp.

Constructor & Destructor Documentation

virtual sf::SoundStream::~SoundStream ( )
virtual

Destructor.

sf::SoundStream::SoundStream ( )
protected

Default constructor.

This constructor is only meant to be called by derived classes.

Member Function Documentation

float sf::SoundSource::getAttenuation ( ) const
inherited

Get the attenuation factor of the sound.

Returns
Attenuation factor of the sound
See Also
setAttenuation, getMinDistance
unsigned int sf::SoundStream::getChannelCount ( ) const

Return the number of channels of the stream.

1 channel means a mono sound, 2 means stereo, etc.

Returns
Number of channels
bool sf::SoundStream::getLoop ( ) const

Tell whether or not the stream is in loop mode.

Returns
True if the stream is looping, false otherwise
See Also
setLoop
float sf::SoundSource::getMinDistance ( ) const
inherited

Get the minimum distance of the sound.

Returns
Minimum distance of the sound
See Also
setMinDistance, getAttenuation
float sf::SoundSource::getPitch ( ) const
inherited

Get the pitch of the sound.

Returns
Pitch of the sound
See Also
setPitch
Time sf::SoundStream::getPlayingOffset ( ) const

Get the current playing position of the stream.

Returns
Current playing position, from the beginning of the stream
See Also
setPlayingOffset
Vector3f sf::SoundSource::getPosition ( ) const
inherited

Get the 3D position of the sound in the audio scene.

Returns
Position of the sound
See Also
setPosition
unsigned int sf::SoundStream::getSampleRate ( ) const

Get the stream sample rate of the stream.

The sample rate is the number of audio samples played per second. The higher, the better the quality.

Returns
Sample rate, in number of samples per second
Status sf::SoundStream::getStatus ( ) const

Get the current status of the stream (stopped, paused, playing)

Returns
Current status
float sf::SoundSource::getVolume ( ) const
inherited

Get the volume of the sound.

Returns
Volume of the sound, in the range [0, 100]
See Also
setVolume
void sf::SoundStream::initialize | ( | unsigned int | channelCount,
 |  | unsigned int | sampleRate
 | ) |  |
protected

Define the audio stream parameters.

This function must be called by derived classes as soon as they know the audio settings of the stream to play. Any attempt to manipulate the stream (play(), ...) before calling this function will fail. It can be called multiple times if the settings of the audio stream change, but only when the stream is stopped.

Parameters
channelCount | Number of channels of the stream
sampleRate | Sample rate, in samples per second
bool sf::SoundSource::isRelativeToListener ( ) const
inherited

Tell whether the sound's position is relative to the listener or is absolute.

Returns
True if the position is relative, false if it's absolute
See Also
setRelativeToListener
virtual bool sf::SoundStream::onGetData ( Chunk & data )
protectedpure virtual

Request a new chunk of audio samples from the stream source.

This function must be overriden by derived classes to provide the audio samples to play. It is called continuously by the streaming loop, in a separate thread. The source can choose to stop the streaming loop at any time, by returning false to the caller.

Parameters
data Chunk of data to fill
Returns
True to continue playback, false to stop

Implemented in sf::Music.

virtual void sf::SoundStream::onSeek ( Time timeOffset )
protectedpure virtual

Change the current playing position in the stream source.

This function must be overriden by derived classes to allow random seeking into the stream source.

Parameters
timeOffset New playing position, relative to the beginning of the stream

Implemented in sf::Music.

void sf::SoundStream::pause ( )

Pause the audio stream.

This function pauses the stream if it was playing, otherwise (stream already paused or stopped) it has no effect.

See Also
play, stop
void sf::SoundStream::play ( )

Start or resume playing the audio stream.

This function starts the stream if it was stopped, resumes it if it was paused, and restarts it from beginning if it was it already playing. This function uses its own thread so that it doesn't block the rest of the program while the stream is played.

See Also
pause, stop
void sf::SoundSource::setAttenuation ( float attenuation )
inherited

Set the attenuation factor of the sound.

The attenuation is a multiplicative factor which makes the sound more or less loud according to its distance from the listener. An attenuation of 0 will produce a non-attenuated sound, i.e. its volume will always be the same whether it is heard from near or from far. On the other hand, an attenuation value such as 100 will make the sound fade out very quickly as it gets further from the listener. The default value of the attenuation is 1.

Parameters
attenuation New attenuation factor of the sound
See Also
getAttenuation, setMinDistance
void sf::SoundStream::setLoop ( bool loop )

Set whether or not the stream should loop after reaching the end.

If set, the stream will restart from beginning after reaching the end and so on, until it is stopped or setLoop(false) is called. The default looping state for streams is false.

Parameters
loop True to play in loop, false to play once
See Also
getLoop
void sf::SoundSource::setMinDistance ( float distance )
inherited

Set the minimum distance of the sound.

The "minimum distance" of a sound is the maximum distance at which it is heard at its maximum volume. Further than the minimum distance, it will start to fade out according to its attenuation factor. A value of 0 ("inside the head of the listener") is an invalid value and is forbidden. The default value of the minimum distance is 1.

Parameters
distance New minimum distance of the sound
See Also
getMinDistance, setAttenuation
void sf::SoundSource::setPitch ( float pitch )
inherited

Set the pitch of the sound.

The pitch represents the perceived fundamental frequency of a sound; thus you can make a sound more acute or grave by changing its pitch. A side effect of changing the pitch is to modify the playing speed of the sound as well. The default value for the pitch is 1.

Parameters
pitch New pitch to apply to the sound
See Also
getPitch
void sf::SoundStream::setPlayingOffset ( Time timeOffset )

Change the current playing position of the stream.

The playing position can be changed when the stream is either paused or playing.

Parameters
timeOffset New playing position, from the beginning of the stream
See Also
getPlayingOffset
void sf::SoundSource::setPosition | ( | float | x,
 |  | float | y,
 |  | float | z
 | ) |  |
inherited

Set the 3D position of the sound in the audio scene.

Only sounds with one channel (mono sounds) can be spatialized. The default position of a sound is (0, 0, 0).

Parameters
x | X coordinate of the position of the sound in the scene
y | Y coordinate of the position of the sound in the scene
z | Z coordinate of the position of the sound in the scene
See Also
getPosition
void sf::SoundSource::setPosition ( const Vector3f & position )
inherited

Set the 3D position of the sound in the audio scene.

Only sounds with one channel (mono sounds) can be spatialized. The default position of a sound is (0, 0, 0).

Parameters
position Position of the sound in the scene
See Also
getPosition
void sf::SoundSource::setRelativeToListener ( bool relative )
inherited

Make the sound's position relative to the listener or absolute.

Making a sound relative to the listener will ensure that it will always be played the same way regardless the position of the listener. This can be useful for non-spatialized sounds, sounds that are produced by the listener, or sounds attached to it. The default value is false (position is absolute).

Parameters
relative True to set the position relative, false to set it absolute
See Also
isRelativeToListener
void sf::SoundSource::setVolume ( float volume )
inherited

Set the volume of the sound.

The volume is a value between 0 (mute) and 100 (full volume). The default value for the volume is 100.

Parameters
volume Volume of the sound
See Also
getVolume
void sf::SoundStream::stop ( )

Stop playing the audio stream.

This function stops the stream if it was playing or paused, and does nothing if it was already stopped. It also resets the playing position (unlike pause()).

See Also
play, pause

Member Data Documentation

unsigned int sf::SoundSource::m_source
protectedinherited

OpenAL source identifier.

Definition at line 263 of file SoundSource.hpp.

The documentation for this class was generated from the following file:
  • SoundStream.hpp


  • sf
  • SoundStream
  • Chunk
Public Attributes | List of all members
sf::SoundStream::Chunk Struct Reference
Audio module

Structure defining a chunk of audio data to stream. More...

#include <SoundStream.hpp>

Public Attributes

const Int16 * | samples
Pointer to the audio samples.
std::size_t | sampleCount
Number of samples pointed by Samples.

Detailed Description

Structure defining a chunk of audio data to stream.

Definition at line 52 of file SoundStream.hpp.

Member Data Documentation

std::size_t sf::SoundStream::Chunk::sampleCount

Number of samples pointed by Samples.

Definition at line 55 of file SoundStream.hpp.

const Int16* sf::SoundStream::Chunk::samples

Pointer to the audio samples.

Definition at line 54 of file SoundStream.hpp.

The documentation for this struct was generated from the following file:
  • SoundStream.hpp


Classes | Enumerations
Graphics module

2D graphics module: sprites, text, shapes, ... More...

Classes

class | sf::CircleShape
Specialized shape representing a circle. More...
class | sf::Color
Utility class for manpulating RGBA colors. More...
class | sf::ConvexShape
Specialized shape representing a convex polygon. More...
class | sf::Drawable
Abstract base class for objects that can be drawn to a render target. More...
class | sf::Font
Class for loading and manipulating character fonts. More...
class | sf::Glyph
Structure describing a glyph. More...
class | sf::Image
Class for loading, manipulating and saving images. More...
class | sf::Rect< T >
Utility class for manipulating 2D axis aligned rectangles. More...
class | sf::RectangleShape
Specialized shape representing a rectangle. More...
class | sf::RenderStates
Define the states used for drawing to a RenderTarget. More...
class | sf::RenderTarget
Base class for all render targets (window, texture, ...) More...
class | sf::RenderTexture
Target for off-screen 2D rendering into a texture. More...
class | sf::RenderWindow
Window that can serve as a target for 2D drawing. More...
class | sf::Shader
Shader class (vertex and fragment) More...
class | sf::Shape
Base class for textured shapes with outline. More...
class | sf::Sprite
Drawable representation of a texture, with its own transformations, color, etc. More...
class | sf::Text
Graphical text that can be drawn to a render target. More...
class | sf::Texture
Image living on the graphics card that can be used for drawing. More...
class | sf::Transform
Define a 3x3 transform matrix. More...
class | sf::Transformable
Decomposed transform defined by a position, a rotation and a scale. More...
class | sf::Vertex
Define a point with color and texture coordinates. More...
class | sf::VertexArray
Define a set of one or more 2D primitives. More...
class | sf::View
2D camera that defines what region is shown on screen More...
struct | sf::Shader::CurrentTextureType
Special type/value that can be passed to setParameter, and that represents the texture of the object being drawn. More...

Enumerations

enum sf::BlendMode {
sf::BlendAlpha,
sf::BlendAdd,
sf::BlendMultiply,
sf::BlendNone
}
Available blending modes for drawing. More...
enum sf::PrimitiveType {
sf::Points,
sf::Lines,
sf::LinesStrip,
sf::Triangles,
sf::TrianglesStrip,
sf::TrianglesFan,
sf::Quads
}
Types of primitives that a sf::VertexArray can render. More...

Detailed Description

2D graphics module: sprites, text, shapes, ...

Enumeration Type Documentation

enum sf::BlendMode

Available blending modes for drawing.

Enumerator:
BlendAlpha

Pixel = Source * Source.a + Dest * (1 - Source.a)

BlendAdd

Pixel = Source + Dest.

BlendMultiply

Pixel = Source * Dest.

BlendNone

Pixel = Source.

Definition at line 35 of file BlendMode.hpp.

enum sf::PrimitiveType

Types of primitives that a sf::VertexArray can render.

Points and lines have no area, therefore their thickness will always be 1 pixel, regarldess the current transform and view.

Enumerator:
Points

List of individual points.

Lines

List of individual lines.

LinesStrip

List of connected lines, a point uses the previous point to form a line.

Triangles

List of individual triangles.

TrianglesStrip

List of connected triangles, a point uses the two previous points to form a triangle.

TrianglesFan

List of connected triangles, a point uses the common center and the previous point to form a triangle.

Quads

List of individual quads.

Definition at line 39 of file PrimitiveType.hpp.


  • sf
  • CircleShape
Public Member Functions | Protected Member Functions | List of all members
sf::CircleShape Class Reference
Graphics module

Specialized shape representing a circle. More...

#include <CircleShape.hpp>

Inheritance diagram for sf::CircleShape:
sf::Shape sf::Drawable sf::Transformable

Public Member Functions

CircleShape (float radius=0, unsigned int pointCount=30)
Default constructor.
void | setRadius (float radius)
Set the radius of the circle.
float | getRadius () const
Get the radius of the circle.
void | setPointCount (unsigned int count)
Set the number of points of the circle.
virtual unsigned int | getPointCount () const
Get the number of points of the shape.
virtual Vector2f | getPoint (unsigned int index) const
Get a point of the shape.
void | setTexture (const Texture *texture, bool resetRect=false)
Change the source texture of the shape.
void | setTextureRect (const IntRect &rect)
Set the sub-rectangle of the texture that the shape will display.
void | setFillColor (const Color &color)
Set the fill color of the shape.
void | setOutlineColor (const Color &color)
Set the outline color of the shape.
void | setOutlineThickness (float thickness)
Set the thickness of the shape's outline.
const Texture * | getTexture () const
Get the source texture of the shape.
const IntRect & | getTextureRect () const
Get the sub-rectangle of the texture displayed by the shape.
const Color & | getFillColor () const
Get the fill color of the shape.
const Color & | getOutlineColor () const
Get the outline color of the shape.
float | getOutlineThickness () const
Get the outline thickness of the shape.
FloatRect | getLocalBounds () const
Get the local bounding rectangle of the entity.
FloatRect | getGlobalBounds () const
Get the global bounding rectangle of the entity.
void | setPosition (float x, float y)
set the position of the object
void | setPosition (const Vector2f &position)
set the position of the object
void | setRotation (float angle)
set the orientation of the object
void | setScale (float factorX, float factorY)
set the scale factors of the object
void | setScale (const Vector2f &factors)
set the scale factors of the object
void | setOrigin (float x, float y)
set the local origin of the object
void | setOrigin (const Vector2f &origin)
set the local origin of the object
const Vector2f & | getPosition () const
get the position of the object
float | getRotation () const
get the orientation of the object
const Vector2f & | getScale () const
get the current scale of the object
const Vector2f & | getOrigin () const
get the local origin of the object
void | move (float offsetX, float offsetY)
Move the object by a given offset.
void | move (const Vector2f &offset)
Move the object by a given offset.
void | rotate (float angle)
Rotate the object.
void | scale (float factorX, float factorY)
Scale the object.
void | scale (const Vector2f &factor)
Scale the object.
const Transform & | getTransform () const
get the combined transform of the object
const Transform & | getInverseTransform () const
get the inverse of the combined transform of the object

Protected Member Functions

void update ()
Recompute the internal geometry of the shape.

Detailed Description

Specialized shape representing a circle.

This class inherits all the functions of sf::Transformable (position, rotation, scale, bounds, ...) as well as the functions of sf::Shape (outline, color, texture, ...).

Usage example:

sf::CircleShape circle;
circle.setRadius(150);
circle.setOutlineColor(sf::Color::Red);
circle.setOutlineThickness(5);
circle.setPosition(10, 20);
...
window.draw(circle);

Since the graphics card can't draw perfect circles, we have to fake them with multiple triangles connected to each other. The "points count" property of sf::CircleShape defines how many of these triangles to use, and therefore defines the quality of the circle.

The number of points can also be used for another purpose; with small numbers you can create any regular polygon shape: equilateral triangle, square, pentagon, hexagon, ...

See Also
sf::Shape, sf::RectangleShape, sf::ConvexShape

Definition at line 41 of file CircleShape.hpp.

Constructor & Destructor Documentation

sf::CircleShape::CircleShape | ( | float | radius = 0,
 |  | unsigned int | pointCount = 30
 | ) |  |
explicit

Default constructor.

Parameters
radius | Radius of the circle
pointCount | Number of points composing the circle

Member Function Documentation

const Color& sf::Shape::getFillColor ( ) const
inherited

Get the fill color of the shape.

Returns
Fill color of the shape
See Also
setFillColor
FloatRect sf::Shape::getGlobalBounds ( ) const
inherited

Get the global bounding rectangle of the entity.

The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the sprite in the global 2D world's coordinate system.

Returns
Global bounding rectangle of the entity
const Transform& sf::Transformable::getInverseTransform ( ) const
inherited

get the inverse of the combined transform of the object

Returns
Inverse of the combined transformations applied to the object
See Also
getTransform
FloatRect sf::Shape::getLocalBounds ( ) const
inherited

Get the local bounding rectangle of the entity.

The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.

Returns
Local bounding rectangle of the entity
const Vector2f& sf::Transformable::getOrigin ( ) const
inherited

get the local origin of the object

Returns
Current origin
See Also
setOrigin
const Color& sf::Shape::getOutlineColor ( ) const
inherited

Get the outline color of the shape.

Returns
Outline color of the shape
See Also
setOutlineColor
float sf::Shape::getOutlineThickness ( ) const
inherited

Get the outline thickness of the shape.

Returns
Outline thickness of the shape
See Also
setOutlineThickness
virtual Vector2f sf::CircleShape::getPoint ( unsigned int index ) const
virtual

Get a point of the shape.

The result is undefined if index is out of the valid range.

Parameters
index Index of the point to get, in range [0 .. getPointCount() - 1]
Returns
Index-th point of the shape

Implements sf::Shape.

virtual unsigned int sf::CircleShape::getPointCount ( ) const
virtual

Get the number of points of the shape.

Returns
Number of points of the shape
See Also
setPointCount

Implements sf::Shape.

const Vector2f& sf::Transformable::getPosition ( ) const
inherited

get the position of the object

Returns
Current position
See Also
setPosition
float sf::CircleShape::getRadius ( ) const

Get the radius of the circle.

Returns
Radius of the circle
See Also
setRadius
float sf::Transformable::getRotation ( ) const
inherited

get the orientation of the object

The rotation is always in the range [0, 360].

Returns
Current rotation, in degrees
See Also
setRotation
const Vector2f& sf::Transformable::getScale ( ) const
inherited

get the current scale of the object

Returns
Current scale factors
See Also
setScale
const Texture* sf::Shape::getTexture ( ) const
inherited

Get the source texture of the shape.

If the shape has no source texture, a NULL pointer is returned. The returned pointer is const, which means that you can't modify the texture when you retrieve it with this function.

Returns
Pointer to the shape's texture
See Also
setTexture
const IntRect& sf::Shape::getTextureRect ( ) const
inherited

Get the sub-rectangle of the texture displayed by the shape.

Returns
Texture rectangle of the shape
See Also
setTextureRect
const Transform& sf::Transformable::getTransform ( ) const
inherited

get the combined transform of the object

Returns
Transform combining the position/rotation/scale/origin of the object
See Also
getInverseTransform
void sf::Transformable::move | ( | float | offsetX,
 |  | float | offsetY
 | ) |  |
inherited

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f pos = object.getPosition();
object.setPosition(pos.x + offsetX, pos.y + offsetY);
Parameters
offsetX | X offset
offsetY | Y offset
See Also
setPosition
void sf::Transformable::move ( const Vector2f & offset )
inherited

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

object.setPosition(object.getPosition() + offset);
Parameters
offset Offset
See Also
setPosition
void sf::Transformable::rotate ( float angle )
inherited

Rotate the object.

This function adds to the current rotation of the object, unlike setRotation which overwrites it. Thus, it is equivalent to the following code:

object.setRotation(object.getRotation() + angle);
Parameters
angle Angle of rotation, in degrees
void sf::Transformable::scale | ( | float | factorX,
 |  | float | factorY
 | ) |  |
inherited

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factorX, scale.y * factorY);
Parameters
factorX | Horizontal scale factor
factorY | Vertical scale factor
See Also
setScale
void sf::Transformable::scale ( const Vector2f & factor )
inherited

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factor.x, scale.y * factor.y);
Parameters
factor Scale factors
See Also
setScale
void sf::Shape::setFillColor ( const Color & color )
inherited

Set the fill color of the shape.

This color is modulated (multiplied) with the shape's texture if any. It can be used to colorize the shape, or change its global opacity. You can use sf::Color::Transparent to make the inside of the shape transparent, and have the outline alone. By default, the shape's fill color is opaque white.

Parameters
color New color of the shape
See Also
getFillColor, setOutlineColor
void sf::Transformable::setOrigin | ( | float | x,
 |  | float | y
 | ) |  |
inherited

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
x | X coordinate of the new origin
y | Y coordinate of the new origin
See Also
getOrigin
void sf::Transformable::setOrigin ( const Vector2f & origin )
inherited

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
origin New origin
See Also
getOrigin
void sf::Shape::setOutlineColor ( const Color & color )
inherited

Set the outline color of the shape.

By default, the shape's outline color is opaque white.

Parameters
color New outline color of the shape
See Also
getOutlineColor, setFillColor
void sf::Shape::setOutlineThickness ( float thickness )
inherited

Set the thickness of the shape's outline.

Note that negative values are allowed (so that the outline expands towards the center of the shape), and using zero disables the outline. By default, the outline thickness is 0.

Parameters
thickness New outline thickness
See Also
getOutlineThickness
void sf::CircleShape::setPointCount ( unsigned int count )

Set the number of points of the circle.

Parameters
count New number of points of the circle
See Also
getPointCount
void sf::Transformable::setPosition | ( | float | x,
 |  | float | y
 | ) |  |
inherited

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
x | X coordinate of the new position
y | Y coordinate of the new position
See Also
move, getPosition
void sf::Transformable::setPosition ( const Vector2f & position )
inherited

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
position New position
See Also
move, getPosition
void sf::CircleShape::setRadius ( float radius )

Set the radius of the circle.

Parameters
radius New radius of the circle
See Also
getRadius
void sf::Transformable::setRotation ( float angle )
inherited

set the orientation of the object

This function completely overwrites the previous rotation. See the rotate function to add an angle based on the previous rotation instead. The default rotation of a transformable object is 0.

Parameters
angle New rotation, in degrees
See Also
rotate, getRotation
void sf::Transformable::setScale | ( | float | factorX,
 |  | float | factorY
 | ) |  |
inherited

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factorX | New horizontal scale factor
factorY | New vertical scale factor
See Also
scale, getScale
void sf::Transformable::setScale ( const Vector2f & factors )
inherited

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factors New scale factors
See Also
scale, getScale
void sf::Shape::setTexture | ( | const Texture * | texture,
 |  | bool | resetRect = false
 | ) |  |
inherited

Change the source texture of the shape.

The texture argument refers to a texture that must exist as long as the shape uses it. Indeed, the shape doesn't store its own copy of the texture, but rather keeps a pointer to the one that you passed to this function. If the source texture is destroyed and the shape tries to use it, the behaviour is undefined. texture can be NULL to disable texturing. If resetRect is true, the TextureRect property of the shape is automatically adjusted to the size of the new texture. If it is false, the texture rect is left unchanged.

Parameters
texture | New texture
resetRect | Should the texture rect be reset to the size of the new texture?
See Also
getTexture, setTextureRect
void sf::Shape::setTextureRect ( const IntRect & rect )
inherited

Set the sub-rectangle of the texture that the shape will display.

The texture rect is useful when you don't want to display the whole texture, but rather a part of it. By default, the texture rect covers the entire texture.

Parameters
rect Rectangle defining the region of the texture to display
See Also
getTextureRect, setTexture
void sf::Shape::update ( )
protectedinherited

Recompute the internal geometry of the shape.

This function must be called by the derived class everytime the shape's points change (ie. the result of either getPointCount or getPoint is different).

The documentation for this class was generated from the following file:
  • CircleShape.hpp


  • sf
  • Color
Public Member Functions | Public Attributes | Static Public Attributes | Related Functions | List of all members
sf::Color Class Reference
Graphics module

Utility class for manpulating RGBA colors. More...

#include <Color.hpp>

Public Member Functions

Color ()
Default constructor.
Color (Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha=255)
Construct the color from its 4 RGBA components.

Public Attributes

Uint8 | r
Red component.
Uint8 | g
Green component.
Uint8 | b
Blue component.
Uint8 | a
Alpha (opacity) component.

Static Public Attributes

static const Color | Black
Black predefined color.
static const Color | White
White predefined color.
static const Color | Red
Red predefined color.
static const Color | Green
Green predefined color.
static const Color | Blue
Blue predefined color.
static const Color | Yellow
Yellow predefined color.
static const Color | Magenta
Magenta predefined color.
static const Color | Cyan
Cyan predefined color.
static const Color | Transparent
Transparent (black) predefined color.

Related Functions

(Note that these are not member functions.)

bool | operator== (const Color &left, const Color &right)
Overload of the == operator.
bool | operator!= (const Color &left, const Color &right)
Overload of the != operator.
Color | operator+ (const Color &left, const Color &right)
Overload of the binary + operator.
Color | operator* (const Color &left, const Color &right)
Overload of the binary * operator.
Color & | operator+= (Color &left, const Color &right)
Overload of the binary += operator.
Color & | operator*= (Color &left, const Color &right)
Overload of the binary *= operator.

Detailed Description

Utility class for manpulating RGBA colors.

sf::Color is a simple color class composed of 4 components:

  • Red
  • Green
  • Blue
  • Alpha (opacity)

Each component is a public member, an unsigned integer in the range [0, 255]. Thus, colors can be constructed and manipulated very easily:

sf::Color color(255, 0, 0); // red
color.r = 0; // make it black
color.b = 128; // make it dark blue

The fourth component of colors, named "alpha", represents the opacity of the color. A color with an alpha value of 255 will be fully opaque, while an alpha value of 0 will make a color fully transparent, whatever the value of the other components is.

The most common colors are already defined as static variables:

sf::Color black = sf::Color::Black;
sf::Color white = sf::Color::White;
sf::Color red = sf::Color::Red;
sf::Color green = sf::Color::Green;
sf::Color blue = sf::Color::Blue;
sf::Color yellow = sf::Color::Yellow;
sf::Color magenta = sf::Color::Magenta;
sf::Color cyan = sf::Color::Cyan;
sf::Color transparent = sf::Color::Transparent;

Colors can also be added and modulated (multiplied) using the overloaded operators + and *.

Definition at line 40 of file Color.hpp.

Constructor & Destructor Documentation

sf::Color::Color ( )

Default constructor.

Constructs an opaque black color. It is equivalent to sf::Color(0, 0, 0, 255).

sf::Color::Color | ( | Uint8 | red,
 |  | Uint8 | green,
 |  | Uint8 | blue,
 |  | Uint8 | alpha = 255
 | ) |  |

Construct the color from its 4 RGBA components.

Parameters
red | Red component (in the range [0, 255])
green | Green component (in the range [0, 255])
blue | Blue component (in the range [0, 255])
alpha | Alpha (opacity) component (in the range [0, 255])

Friends And Related Function Documentation

bool operator!= | ( | const Color & | left,
 |  | const Color & | right
 | ) |  |
related

Overload of the != operator.

This operator compares two colors and check if they are different.

Parameters
left | Left operand
right | Right operand
Returns
True if colors are different, false if they are equal
Color operator* | ( | const Color & | left,
 |  | const Color & | right
 | ) |  |
related

Overload of the binary * operator.

This operator returns the component-wise multiplication (also called "modulation") of two colors. Components are then divided by 255 so that the result is still in the range [0, 255].

Parameters
left | Left operand
right | Right operand
Returns
Result of left * right
Color & operator*= | ( | Color & | left,
 |  | const Color & | right
 | ) |  |
related

Overload of the binary *= operator.

This operator returns the component-wise multiplication (also called "modulation") of two colors, and assigns the result to the left operand. Components are then divided by 255 so that the result is still in the range [0, 255].

Parameters
left | Left operand
right | Right operand
Returns
Reference to left
Color operator+ | ( | const Color & | left,
 |  | const Color & | right
 | ) |  |
related

Overload of the binary + operator.

This operator returns the component-wise sum of two colors. Components that exceed 255 are clamped to 255.

Parameters
left | Left operand
right | Right operand
Returns
Result of left + right
Color & operator+= | ( | Color & | left,
 |  | const Color & | right
 | ) |  |
related

Overload of the binary += operator.

This operator computes the component-wise sum of two colors, and assigns the result to the left operand. Components that exceed 255 are clamped to 255.

Parameters
left | Left operand
right | Right operand
Returns
Reference to left
bool operator== | ( | const Color & | left,
 |  | const Color & | right
 | ) |  |
related

Overload of the == operator.

This operator compares two colors and check if they are equal.

Parameters
left | Left operand
right | Right operand
Returns
True if colors are equal, false if they are different

Member Data Documentation

Uint8 sf::Color::a

Alpha (opacity) component.

Definition at line 83 of file Color.hpp.

Uint8 sf::Color::b

Blue component.

Definition at line 82 of file Color.hpp.

const Color sf::Color::Black
static

Black predefined color.

Definition at line 67 of file Color.hpp.

const Color sf::Color::Blue
static

Blue predefined color.

Definition at line 71 of file Color.hpp.

const Color sf::Color::Cyan
static

Cyan predefined color.

Definition at line 74 of file Color.hpp.

Uint8 sf::Color::g

Green component.

Definition at line 81 of file Color.hpp.

const Color sf::Color::Green
static

Green predefined color.

Definition at line 70 of file Color.hpp.

const Color sf::Color::Magenta
static

Magenta predefined color.

Definition at line 73 of file Color.hpp.

Uint8 sf::Color::r

Red component.

Definition at line 80 of file Color.hpp.

const Color sf::Color::Red
static

Red predefined color.

Definition at line 69 of file Color.hpp.

const Color sf::Color::Transparent
static

Transparent (black) predefined color.

Definition at line 75 of file Color.hpp.

const Color sf::Color::White
static

White predefined color.

Definition at line 68 of file Color.hpp.

const Color sf::Color::Yellow
static

Yellow predefined color.

Definition at line 72 of file Color.hpp.

The documentation for this class was generated from the following file:
  • Color.hpp


  • sf
  • ConvexShape
Public Member Functions | Protected Member Functions | List of all members
sf::ConvexShape Class Reference
Graphics module

Specialized shape representing a convex polygon. More...

#include <ConvexShape.hpp>

Inheritance diagram for sf::ConvexShape:
sf::Shape sf::Drawable sf::Transformable

Public Member Functions

ConvexShape (unsigned int pointCount=0)
Default constructor.
void | setPointCount (unsigned int count)
Set the number of points of the polygon.
virtual unsigned int | getPointCount () const
Get the number of points of the polygon.
void | setPoint (unsigned int index, const Vector2f &point)
Set the position of a point.
virtual Vector2f | getPoint (unsigned int index) const
Get the position of a point.
void | setTexture (const Texture *texture, bool resetRect=false)
Change the source texture of the shape.
void | setTextureRect (const IntRect &rect)
Set the sub-rectangle of the texture that the shape will display.
void | setFillColor (const Color &color)
Set the fill color of the shape.
void | setOutlineColor (const Color &color)
Set the outline color of the shape.
void | setOutlineThickness (float thickness)
Set the thickness of the shape's outline.
const Texture * | getTexture () const
Get the source texture of the shape.
const IntRect & | getTextureRect () const
Get the sub-rectangle of the texture displayed by the shape.
const Color & | getFillColor () const
Get the fill color of the shape.
const Color & | getOutlineColor () const
Get the outline color of the shape.
float | getOutlineThickness () const
Get the outline thickness of the shape.
FloatRect | getLocalBounds () const
Get the local bounding rectangle of the entity.
FloatRect | getGlobalBounds () const
Get the global bounding rectangle of the entity.
void | setPosition (float x, float y)
set the position of the object
void | setPosition (const Vector2f &position)
set the position of the object
void | setRotation (float angle)
set the orientation of the object
void | setScale (float factorX, float factorY)
set the scale factors of the object
void | setScale (const Vector2f &factors)
set the scale factors of the object
void | setOrigin (float x, float y)
set the local origin of the object
void | setOrigin (const Vector2f &origin)
set the local origin of the object
const Vector2f & | getPosition () const
get the position of the object
float | getRotation () const
get the orientation of the object
const Vector2f & | getScale () const
get the current scale of the object
const Vector2f & | getOrigin () const
get the local origin of the object
void | move (float offsetX, float offsetY)
Move the object by a given offset.
void | move (const Vector2f &offset)
Move the object by a given offset.
void | rotate (float angle)
Rotate the object.
void | scale (float factorX, float factorY)
Scale the object.
void | scale (const Vector2f &factor)
Scale the object.
const Transform & | getTransform () const
get the combined transform of the object
const Transform & | getInverseTransform () const
get the inverse of the combined transform of the object

Protected Member Functions

void update ()
Recompute the internal geometry of the shape.

Detailed Description

Specialized shape representing a convex polygon.

This class inherits all the functions of sf::Transformable (position, rotation, scale, bounds, ...) as well as the functions of sf::Shape (outline, color, texture, ...).

It is important to keep in mind that a convex shape must always be... convex, otherwise it may not be drawn correctly. Moreover, the points must be defined in order; using a random order would result in an incorrect shape.

Usage example:

sf::ConvexShape polygon;
polygon.setPointCount(3);
polygon.setPoint(0, sf::Vector2f(0, 0));
polygon.setPoint(1, sf::Vector2f(0, 10));
polygon.setPoint(2, sf::Vector2f(25, 5));
polygon.setOutlineColor(sf::Color::Red);
polygon.setOutlineThickness(5);
polygon.setPosition(10, 20);
...
window.draw(polygon);
See Also
sf::Shape, sf::RectangleShape, sf::CircleShape

Definition at line 42 of file ConvexShape.hpp.

Constructor & Destructor Documentation

sf::ConvexShape::ConvexShape ( unsigned int pointCount = 0 )
explicit

Default constructor.

Parameters
pointCount Number of points of the polygon

Member Function Documentation

const Color& sf::Shape::getFillColor ( ) const
inherited

Get the fill color of the shape.

Returns
Fill color of the shape
See Also
setFillColor
FloatRect sf::Shape::getGlobalBounds ( ) const
inherited

Get the global bounding rectangle of the entity.

The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the sprite in the global 2D world's coordinate system.

Returns
Global bounding rectangle of the entity
const Transform& sf::Transformable::getInverseTransform ( ) const
inherited

get the inverse of the combined transform of the object

Returns
Inverse of the combined transformations applied to the object
See Also
getTransform
FloatRect sf::Shape::getLocalBounds ( ) const
inherited

Get the local bounding rectangle of the entity.

The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.

Returns
Local bounding rectangle of the entity
const Vector2f& sf::Transformable::getOrigin ( ) const
inherited

get the local origin of the object

Returns
Current origin
See Also
setOrigin
const Color& sf::Shape::getOutlineColor ( ) const
inherited

Get the outline color of the shape.

Returns
Outline color of the shape
See Also
setOutlineColor
float sf::Shape::getOutlineThickness ( ) const
inherited

Get the outline thickness of the shape.

Returns
Outline thickness of the shape
See Also
setOutlineThickness
virtual Vector2f sf::ConvexShape::getPoint ( unsigned int index ) const
virtual

Get the position of a point.

The result is undefined if index is out of the valid range.

Parameters
index Index of the point to get, in range [0 .. getPointCount() - 1]
Returns
Position of the index-th point of the polygon
See Also
setPoint

Implements sf::Shape.

virtual unsigned int sf::ConvexShape::getPointCount ( ) const
virtual

Get the number of points of the polygon.

Returns
Number of points of the polygon
See Also
setPointCount

Implements sf::Shape.

const Vector2f& sf::Transformable::getPosition ( ) const
inherited

get the position of the object

Returns
Current position
See Also
setPosition
float sf::Transformable::getRotation ( ) const
inherited

get the orientation of the object

The rotation is always in the range [0, 360].

Returns
Current rotation, in degrees
See Also
setRotation
const Vector2f& sf::Transformable::getScale ( ) const
inherited

get the current scale of the object

Returns
Current scale factors
See Also
setScale
const Texture* sf::Shape::getTexture ( ) const
inherited

Get the source texture of the shape.

If the shape has no source texture, a NULL pointer is returned. The returned pointer is const, which means that you can't modify the texture when you retrieve it with this function.

Returns
Pointer to the shape's texture
See Also
setTexture
const IntRect& sf::Shape::getTextureRect ( ) const
inherited

Get the sub-rectangle of the texture displayed by the shape.

Returns
Texture rectangle of the shape
See Also
setTextureRect
const Transform& sf::Transformable::getTransform ( ) const
inherited

get the combined transform of the object

Returns
Transform combining the position/rotation/scale/origin of the object
See Also
getInverseTransform
void sf::Transformable::move | ( | float | offsetX,
 |  | float | offsetY
 | ) |  |
inherited

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f pos = object.getPosition();
object.setPosition(pos.x + offsetX, pos.y + offsetY);
Parameters
offsetX | X offset
offsetY | Y offset
See Also
setPosition
void sf::Transformable::move ( const Vector2f & offset )
inherited

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

object.setPosition(object.getPosition() + offset);
Parameters
offset Offset
See Also
setPosition
void sf::Transformable::rotate ( float angle )
inherited

Rotate the object.

This function adds to the current rotation of the object, unlike setRotation which overwrites it. Thus, it is equivalent to the following code:

object.setRotation(object.getRotation() + angle);
Parameters
angle Angle of rotation, in degrees
void sf::Transformable::scale | ( | float | factorX,
 |  | float | factorY
 | ) |  |
inherited

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factorX, scale.y * factorY);
Parameters
factorX | Horizontal scale factor
factorY | Vertical scale factor
See Also
setScale
void sf::Transformable::scale ( const Vector2f & factor )
inherited

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factor.x, scale.y * factor.y);
Parameters
factor Scale factors
See Also
setScale
void sf::Shape::setFillColor ( const Color & color )
inherited

Set the fill color of the shape.

This color is modulated (multiplied) with the shape's texture if any. It can be used to colorize the shape, or change its global opacity. You can use sf::Color::Transparent to make the inside of the shape transparent, and have the outline alone. By default, the shape's fill color is opaque white.

Parameters
color New color of the shape
See Also
getFillColor, setOutlineColor
void sf::Transformable::setOrigin | ( | float | x,
 |  | float | y
 | ) |  |
inherited

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
x | X coordinate of the new origin
y | Y coordinate of the new origin
See Also
getOrigin
void sf::Transformable::setOrigin ( const Vector2f & origin )
inherited

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
origin New origin
See Also
getOrigin
void sf::Shape::setOutlineColor ( const Color & color )
inherited

Set the outline color of the shape.

By default, the shape's outline color is opaque white.

Parameters
color New outline color of the shape
See Also
getOutlineColor, setFillColor
void sf::Shape::setOutlineThickness ( float thickness )
inherited

Set the thickness of the shape's outline.

Note that negative values are allowed (so that the outline expands towards the center of the shape), and using zero disables the outline. By default, the outline thickness is 0.

Parameters
thickness New outline thickness
See Also
getOutlineThickness
void sf::ConvexShape::setPoint | ( | unsigned int | index,
 |  | const Vector2f & | point
 | ) |  |

Set the position of a point.

Don't forget that the polygon must remain convex, and the points need to stay ordered! setPointCount must be called first in order to set the total number of points. The result is undefined if index is out of the valid range.

Parameters
index | Index of the point to change, in range [0 .. getPointCount() - 1]
point | New position of the point
See Also
getPoint
void sf::ConvexShape::setPointCount ( unsigned int count )

Set the number of points of the polygon.

count must be greater than 2 to define a valid shape.

Parameters
count New number of points of the polygon
See Also
getPointCount
void sf::Transformable::setPosition | ( | float | x,
 |  | float | y
 | ) |  |
inherited

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
x | X coordinate of the new position
y | Y coordinate of the new position
See Also
move, getPosition
void sf::Transformable::setPosition ( const Vector2f & position )
inherited

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
position New position
See Also
move, getPosition
void sf::Transformable::setRotation ( float angle )
inherited

set the orientation of the object

This function completely overwrites the previous rotation. See the rotate function to add an angle based on the previous rotation instead. The default rotation of a transformable object is 0.

Parameters
angle New rotation, in degrees
See Also
rotate, getRotation
void sf::Transformable::setScale | ( | float | factorX,
 |  | float | factorY
 | ) |  |
inherited

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factorX | New horizontal scale factor
factorY | New vertical scale factor
See Also
scale, getScale
void sf::Transformable::setScale ( const Vector2f & factors )
inherited

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factors New scale factors
See Also
scale, getScale
void sf::Shape::setTexture | ( | const Texture * | texture,
 |  | bool | resetRect = false
 | ) |  |
inherited

Change the source texture of the shape.

The texture argument refers to a texture that must exist as long as the shape uses it. Indeed, the shape doesn't store its own copy of the texture, but rather keeps a pointer to the one that you passed to this function. If the source texture is destroyed and the shape tries to use it, the behaviour is undefined. texture can be NULL to disable texturing. If resetRect is true, the TextureRect property of the shape is automatically adjusted to the size of the new texture. If it is false, the texture rect is left unchanged.

Parameters
texture | New texture
resetRect | Should the texture rect be reset to the size of the new texture?
See Also
getTexture, setTextureRect
void sf::Shape::setTextureRect ( const IntRect & rect )
inherited

Set the sub-rectangle of the texture that the shape will display.

The texture rect is useful when you don't want to display the whole texture, but rather a part of it. By default, the texture rect covers the entire texture.

Parameters
rect Rectangle defining the region of the texture to display
See Also
getTextureRect, setTexture
void sf::Shape::update ( )
protectedinherited

Recompute the internal geometry of the shape.

This function must be called by the derived class everytime the shape's points change (ie. the result of either getPointCount or getPoint is different).

The documentation for this class was generated from the following file:
  • ConvexShape.hpp


  • sf
  • Drawable
Public Member Functions | Protected Member Functions | Friends | List of all members
sf::Drawable Class Referenceabstract
Graphics module

Abstract base class for objects that can be drawn to a render target. More...

#include <Drawable.hpp>

Inheritance diagram for sf::Drawable:
sf::Shape sf::Sprite sf::Text sf::VertexArray sf::CircleShape sf::ConvexShape sf::RectangleShape

Public Member Functions

virtual ~Drawable ()
Virtual destructor.

Protected Member Functions

virtual void draw (RenderTarget &target, RenderStates states) const =0
Draw the object to a render target.

Friends

class RenderTarget

Detailed Description

Abstract base class for objects that can be drawn to a render target.

sf::Drawable is a very simple base class that allows objects of derived classes to be drawn to a sf::RenderTarget.

All you have to do in your derived class is to override the draw virtual function.

Note that inheriting from sf::Drawable is not mandatory, but it allows this nice syntax "window.draw(object)" rather than "object.draw(window)", which is more consistent with other SFML classes.

Example:

class MyDrawable : public sf::Drawable
{
public :
...
private :
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
{
// You can draw other high-level objects
target.draw(m_sprite, states);
// ... or use the low-level API
states.texture = &m_texture;
target.draw(m_vertices, states);
// ... or draw with OpenGL directly
glBegin(GL_QUADS);
...
glEnd();
}
sf::Sprite m_sprite;
sf::Texture m_texture;
sf::VertexArray m_vertices;
};
See Also
sf::RenderTarget

Definition at line 44 of file Drawable.hpp.

Constructor & Destructor Documentation

virtual sf::Drawable::~Drawable ( )
inlinevirtual

Virtual destructor.

Definition at line 52 of file Drawable.hpp.

Member Function Documentation

virtual void sf::Drawable::draw | ( | RenderTarget & | target,
 |  | RenderStates | states
 | ) |  | const
 protectedpure virtual

Draw the object to a render target.

This is a pure virtual function that has to be implemented by the derived class to define how the drawable should be drawn.

Parameters
target | Render target to draw to
states | Current render states
The documentation for this class was generated from the following file:
  • Drawable.hpp


  • sf
  • Font
Classes | Public Member Functions | List of all members
sf::Font Class Reference
Graphics module

Class for loading and manipulating character fonts. More...

#include <Font.hpp>

Public Member Functions

Font ()
Default constructor.
Font (const Font &copy)
Copy constructor.
~Font ()
Destructor.
bool | loadFromFile (const std::string &filename)
Load the font from a file.
bool | loadFromMemory (const void *data, std::size_t sizeInBytes)
Load the font from a file in memory.
bool | loadFromStream (InputStream &stream)
Load the font from a custom stream.
const Glyph & | getGlyph (Uint32 codePoint, unsigned int characterSize, bool bold) const
Retrieve a glyph of the font.
int | getKerning (Uint32 first, Uint32 second, unsigned int characterSize) const
Get the kerning offset of two glyphs.
int | getLineSpacing (unsigned int characterSize) const
Get the line spacing.
const Texture & | getTexture (unsigned int characterSize) const
Retrieve the texture containing the loaded glyphs of a certain size.
Font & | operator= (const Font &right)
Overload of assignment operator.

Detailed Description

Class for loading and manipulating character fonts.

Fonts can be loaded from a file, from memory or from a custom stream, and supports the most common types of fonts.

See the loadFromFile function for the complete list of supported formats.

Once it is loaded, a sf::Font instance provides three types of information about the font:

  • Global metrics, such as the line spacing
  • Per-glyph metrics, such as bounding box or kerning
  • Pixel representation of glyphs

Fonts alone are not very useful: they hold the font data but cannot make anything useful of it. To do so you need to use the sf::Text class, which is able to properly output text with several options such as character size, style, color, position, rotation, etc. This separation allows more flexibility and better performances: indeed a sf::Font is a heavy resource, and any operation on it is slow (often too slow for real-time applications). On the other side, a sf::Text is a lightweight object which can combine the glyphs data and metrics of a sf::Font to display any text on a render target. Note that it is also possible to bind several sf::Text instances to the same sf::Font.

It is important to note that the sf::Text instance doesn't copy the font that it uses, it only keeps a reference to it. Thus, a sf::Font must not be destructed while it is used by a sf::Text (i.e. never write a function that uses a local sf::Font instance for creating a text).

Usage example:

// Declare a new font
sf::Font font;
// Load it from a file
if (!font.loadFromFile("arial.ttf"))
{
// error...
}
// Create a text which uses our font
sf::Text text1;
text1.setFont(font);
text1.setCharacterSize(30);
text1.setStyle(sf::Text::Regular);
// Create another text using the same font, but with different parameters
sf::Text text2;
text2.setFont(font);
text2.setCharacterSize(50);
text1.setStyle(sf::Text::Italic);

Apart from loading font files, and passing them to instances of sf::Text, you should normally not have to deal directly with this class. However, it may be useful to access the font metrics or rasterized glyphs for advanced usage.

See Also
sf::Text

Definition at line 50 of file Font.hpp.

Constructor & Destructor Documentation

sf::Font::Font ( )

Default constructor.

This constructor defines an empty font

sf::Font::Font ( const Font & copy )

Copy constructor.

Parameters
copy Instance to copy
sf::Font::~Font ( )

Destructor.

Cleans up all the internal resources used by the font

Member Function Documentation

const Glyph& sf::Font::getGlyph | ( | Uint32 | codePoint,
 |  | unsigned int | characterSize,
 |  | bool | bold
 | ) |  | const

Retrieve a glyph of the font.

Parameters
codePoint | Unicode code point of the character to get
characterSize | Reference character size
bold | Retrieve the bold version or the regular one?
Returns
The glyph corresponding to codePoint and characterSize
int sf::Font::getKerning | ( | Uint32 | first,
 |  | Uint32 | second,
 |  | unsigned int | characterSize
 | ) |  | const

Get the kerning offset of two glyphs.

The kerning is an extra offset (negative) to apply between two glyphs when rendering them, to make the pair look more "natural". For example, the pair "AV" have a special kerning to make them closer than other characters. Most of the glyphs pairs have a kerning offset of zero, though.

Parameters
first | Unicode code point of the first character
second | Unicode code point of the second character
characterSize | Reference character size
Returns
Kerning value for first and second, in pixels
int sf::Font::getLineSpacing ( unsigned int characterSize ) const

Get the line spacing.

Line spacing is the vertical offset to apply between two consecutive lines of text.

Parameters
characterSize Reference character size
Returns
Line spacing, in pixels
const Texture& sf::Font::getTexture ( unsigned int characterSize ) const

Retrieve the texture containing the loaded glyphs of a certain size.

The contents of the returned texture changes as more glyphs are requested, thus it is not very relevant. It is mainly used internally by sf::Text.

Parameters
characterSize Reference character size
Returns
Texture containing the glyphs of the requested size
bool sf::Font::loadFromFile ( const std::string & filename )

Load the font from a file.

The supported font formats are: TrueType, Type 1, CFF, OpenType, SFNT, X11 PCF, Windows FNT, BDF, PFR and Type 42. Note that this function know nothing about the standard fonts installed on the user's system, thus you can't load them directly.

Parameters
filename Path of the font file to load
Returns
True if loading succeeded, false if it failed
See Also
loadFromMemory, loadFromStream
bool sf::Font::loadFromMemory | ( | const void * | data,
 |  | std::size_t | sizeInBytes
 | ) |  |

Load the font from a file in memory.

The supported font formats are: TrueType, Type 1, CFF, OpenType, SFNT, X11 PCF, Windows FNT, BDF, PFR and Type 42. Warning: SFML cannot preload all the font data in this function, so the buffer pointed by data has to remain valid as long as the font is used.

Parameters
data | Pointer to the file data in memory
sizeInBytes | Size of the data to load, in bytes
Returns
True if loading succeeded, false if it failed
See Also
loadFromFile, loadFromStream
bool sf::Font::loadFromStream ( InputStream & stream )

Load the font from a custom stream.

The supported font formats are: TrueType, Type 1, CFF, OpenType, SFNT, X11 PCF, Windows FNT, BDF, PFR and Type 42. Warning: SFML cannot preload all the font data in this function, so the contents of stream have to remain valid as long as the font is used.

Parameters
stream Source stream to read from
Returns
True if loading succeeded, false if it failed
See Also
loadFromFile, loadFromMemory
Font& sf::Font::operator= ( const Font & right )

Overload of assignment operator.

Parameters
right Instance to assign
Returns
Reference to self
The documentation for this class was generated from the following file:
  • Font.hpp


  • sf
  • Glyph
Public Member Functions | Public Attributes | List of all members
sf::Glyph Class Reference
Graphics module

Structure describing a glyph. More...

#include <Glyph.hpp>

Public Member Functions

Glyph ()
Default constructor.

Public Attributes

int advance
Offset to move horizontically to the next character.
IntRect bounds
Bounding rectangle of the glyph, in coordinates relative to the baseline.
IntRect textureRect
Texture coordinates of the glyph inside the font's texture.

Detailed Description

Structure describing a glyph.

A glyph is the visual representation of a character.

The sf::Glyph structure provides the information needed to handle the glyph:

  • its coordinates in the font's texture
  • its bounding rectangle
  • the offset to apply to get the starting position of the next glyph
See Also
sf::Font

Definition at line 41 of file Glyph.hpp.

Constructor & Destructor Documentation

sf::Glyph::Glyph ( )
inline

Default constructor.

Definition at line 49 of file Glyph.hpp.

Member Data Documentation

int sf::Glyph::advance

Offset to move horizontically to the next character.

Definition at line 54 of file Glyph.hpp.

IntRect sf::Glyph::bounds

Bounding rectangle of the glyph, in coordinates relative to the baseline.

Definition at line 55 of file Glyph.hpp.

IntRect sf::Glyph::textureRect

Texture coordinates of the glyph inside the font's texture.

Definition at line 56 of file Glyph.hpp.

The documentation for this class was generated from the following file:
  • Glyph.hpp


  • sf
  • Image
Public Member Functions | List of all members
sf::Image Class Reference
Graphics module

Class for loading, manipulating and saving images. More...

#include <Image.hpp>

Public Member Functions

Image ()
Default constructor.
void | create (unsigned int width, unsigned int height, const Color &color=Color(0, 0, 0))
Create the image and fill it with a unique color.
void | create (unsigned int width, unsigned int height, const Uint8 *pixels)
Create the image from an array of pixels.
bool | loadFromFile (const std::string &filename)
Load the image from a file on disk.
bool | loadFromMemory (const void *data, std::size_t size)
Load the image from a file in memory.
bool | loadFromStream (InputStream &stream)
Load the image from a custom stream.
bool | saveToFile (const std::string &filename) const
Save the image to a file on disk.
Vector2u | getSize () const
Return the size (width and height) of the image.
void | createMaskFromColor (const Color &color, Uint8 alpha=0)
Create a transparency mask from a specified color-key.
void | copy (const Image &source, unsigned int destX, unsigned int destY, const IntRect &sourceRect=IntRect(0, 0, 0, 0), bool applyAlpha=false)
Copy pixels from another image onto this one.
void | setPixel (unsigned int x, unsigned int y, const Color &color)
Change the color of a pixel.
Color | getPixel (unsigned int x, unsigned int y) const
Get the color of a pixel.
const Uint8 * | getPixelsPtr () const
Get a read-only pointer to the array of pixels.
void | flipHorizontally ()
Flip the image horizontally (left <-> right)
void | flipVertically ()
Flip the image vertically (top <-> bottom)

Detailed Description

Class for loading, manipulating and saving images.

sf::Image is an abstraction to manipulate images as bidimensional arrays of pixels.

The class provides functions to load, read, write and save pixels, as well as many other useful functions.

sf::Image can handle a unique internal representation of pixels, which is RGBA 32 bits. This means that a pixel must be composed of 8 bits red, green, blue and alpha channels – just like a sf::Color. All the functions that return an array of pixels follow this rule, and all parameters that you pass to sf::Image functions (such as loadFromPixels) must use this representation as well.

A sf::Image can be copied, but it is a heavy resource and if possible you should always use [const] references to pass or return them to avoid useless copies.

Usage example:

// Load an image file from a file
sf::Image background;
if (!background.loadFromFile("background.jpg"))
return -1;
// Create a 20x20 image filled with black color
sf::Image image;
image.create(20, 20, sf::Color::Black);
// Copy image1 on image2 at position (10, 10)
image.copy(background, 10, 10);
// Make the top-left pixel transparent
sf::Color color = image.getPixel(0, 0);
color.a = 0;
image.setPixel(0, 0, color);
// Save the image to a file
if (!image.saveToFile("result.png"))
return -1;
See Also
sf::Texture

Definition at line 46 of file Image.hpp.

Constructor & Destructor Documentation

sf::Image::Image ( )

Default constructor.

Creates an empty image.

Member Function Documentation

void sf::Image::copy | ( | const Image & | source,
 |  | unsigned int | destX,
 |  | unsigned int | destY,
 |  | const IntRect & | sourceRect = IntRect(0, 0, 0, 0),
 |  | bool | applyAlpha = false
 | ) |  |

Copy pixels from another image onto this one.

This function does a slow pixel copy and should not be used intensively. It can be used to prepare a complex static image from several others, but if you need this kind of feature in real-time you'd better use sf::RenderTexture.

If sourceRect is empty, the whole image is copied. If applyAlpha is set to true, the transparency of source pixels is applied. If it is false, the pixels are copied unchanged with their alpha value.

Parameters
source | Source image to copy
destX | X coordinate of the destination position
destY | Y coordinate of the destination position
sourceRect | Sub-rectangle of the source image to copy
applyAlpha | Should the copy take in account the source transparency?
void sf::Image::create | ( | unsigned int | width,
 |  | unsigned int | height,
 |  | const Color & | color = Color(0, 0, 0)
 | ) |  |

Create the image and fill it with a unique color.

Parameters
width | Width of the image
height | Height of the image
color | Fill color
void sf::Image::create | ( | unsigned int | width,
 |  | unsigned int | height,
 |  | const Uint8 * | pixels
 | ) |  |

Create the image from an array of pixels.

The pixel array is assumed to contain 32-bits RGBA pixels, and have the given width and height. If not, this is an undefined behaviour. If pixels is null, an empty image is created.

Parameters
width | Width of the image
height | Height of the image
pixels | Array of pixels to copy to the image
void sf::Image::createMaskFromColor | ( | const Color & | color,
 |  | Uint8 | alpha = 0
 | ) |  |

Create a transparency mask from a specified color-key.

This function sets the alpha value of every pixel matching the given color to alpha (0 by default), so that they become transparent.

Parameters
color | Color to make transparent
alpha | Alpha value to assign to transparent pixels
void sf::Image::flipHorizontally ( )

Flip the image horizontally (left <-> right)

void sf::Image::flipVertically ( )

Flip the image vertically (top <-> bottom)

Color sf::Image::getPixel | ( | unsigned int | x,
 |  | unsigned int | y
 | ) |  | const

Get the color of a pixel.

This function doesn't check the validity of the pixel coordinates, using out-of-range values will result in an undefined behaviour.

Parameters
x | X coordinate of pixel to get
y | Y coordinate of pixel to get
Returns
Color of the pixel at coordinates (x, y)
See Also
setPixel
const Uint8* sf::Image::getPixelsPtr ( ) const

Get a read-only pointer to the array of pixels.

The returned value points to an array of RGBA pixels made of 8 bits integers components. The size of the array is width * height * 4 (getSize().x * getSize().y * 4). Warning: the returned pointer may become invalid if you modify the image, so you should never store it for too long. If the image is empty, a null pointer is returned.

Returns
Read-only pointer to the array of pixels
Vector2u sf::Image::getSize ( ) const

Return the size (width and height) of the image.

Returns
Size of the image, in pixels
bool sf::Image::loadFromFile ( const std::string & filename )

Load the image from a file on disk.

The supported image formats are bmp, png, tga, jpg, gif, psd, hdr and pic. Some format options are not supported, like progressive jpeg. If this function fails, the image is left unchanged.

Parameters
filename Path of the image file to load
Returns
True if loading was successful
See Also
loadFromMemory, loadFromStream, saveToFile
bool sf::Image::loadFromMemory | ( | const void * | data,
 |  | std::size_t | size
 | ) |  |

Load the image from a file in memory.

The supported image formats are bmp, png, tga, jpg, gif, psd, hdr and pic. Some format options are not supported, like progressive jpeg. If this function fails, the image is left unchanged.

Parameters
data | Pointer to the file data in memory
size | Size of the data to load, in bytes
Returns
True if loading was successful
See Also
loadFromFile, loadFromStream
bool sf::Image::loadFromStream ( InputStream & stream )

Load the image from a custom stream.

The supported image formats are bmp, png, tga, jpg, gif, psd, hdr and pic. Some format options are not supported, like progressive jpeg. If this function fails, the image is left unchanged.

Parameters
stream Source stream to read from
Returns
True if loading was successful
See Also
loadFromFile, loadFromMemory
bool sf::Image::saveToFile ( const std::string & filename ) const

Save the image to a file on disk.

The format of the image is automatically deduced from the extension. The supported image formats are bmp, png, tga and jpg. The destination file is overwritten if it already exists. This function fails if the image is empty.

Parameters
filename Path of the file to save
Returns
True if saving was successful
See Also
create, loadFromFile, loadFromMemory
void sf::Image::setPixel | ( | unsigned int | x,
 |  | unsigned int | y,
 |  | const Color & | color
 | ) |  |

Change the color of a pixel.

This function doesn't check the validity of the pixel coordinates, using out-of-range values will result in an undefined behaviour.

Parameters
x | X coordinate of pixel to change
y | Y coordinate of pixel to change
color | New color of the pixel
See Also
getPixel
The documentation for this class was generated from the following file:
  • Image.hpp


  • sf
  • Rect
Public Member Functions | Public Attributes | Related Functions | List of all members
sf::Rect< T > Class Template Reference
Graphics module

Utility class for manipulating 2D axis aligned rectangles. More...

#include <Rect.hpp>

Public Member Functions

Rect ()
Default constructor.
Rect (T rectLeft, T rectTop, T rectWidth, T rectHeight)
Construct the rectangle from its coordinates.
Rect (const Vector2< T > &position, const Vector2< T > &size)
Construct the rectangle from position and size.
template<typename U >
Rect (const Rect< U > &rectangle)
Construct the rectangle from another type of rectangle.
bool | contains (T x, T y) const
Check if a point is inside the rectangle's area.
bool | contains (const Vector2< T > &point) const
Check if a point is inside the rectangle's area.
bool | intersects (const Rect< T > &rectangle) const
Check the intersection between two rectangles.
bool | intersects (const Rect< T > &rectangle, Rect< T > &intersection) const
Check the intersection between two rectangles.
template<typename T >
Rect (T rectLeft, T rectTop, T rectWidth, T rectHeight)
template<typename T >
Rect (const Vector2< T > &position, const Vector2< T > &size)
template<typename U >
Rect (const Rect< U > &rectangle)

Public Attributes

T | left
Left coordinate of the rectangle.
T | top
Top coordinate of the rectangle.
T | width
Width of the rectangle.
T | height
Height of the rectangle.

Related Functions

(Note that these are not member functions.)

template<typename T >
bool | operator== (const Rect< T > &left, const Rect< T > &right)
Overload of binary operator ==.
template<typename T >
bool | operator!= (const Rect< T > &left, const Rect< T > &right)
Overload of binary operator !=.

Detailed Description

template<typename T>
class sf::Rect< T >

Utility class for manipulating 2D axis aligned rectangles.

A rectangle is defined by its top-left corner and its size.

It is a very simple class defined for convenience, so its member variables (left, top, width and height) are public and can be accessed directly, just like the vector classes (Vector2 and Vector3).

To keep things simple, sf::Rect doesn't define functions to emulate the properties that are not directly members (such as right, bottom, center, etc.), it rather only provides intersection functions.

sf::Rect uses the usual rules for its boundaries:

  • The left and top edges are included in the rectangle's area
  • The right (left + width) and bottom (top + height) edges are excluded from the rectangle's area

This means that sf::IntRect(0, 0, 1, 1) and sf::IntRect(1, 1, 1, 1) don't intersect.

sf::Rect is a template and may be used with any numeric type, but for simplicity the instanciations used by SFML are typedefed:

  • sf::Rect<int> is sf::IntRect
  • sf::Rect<float> is sf::FloatRect

So that you don't have to care about the template syntax.

Usage example:

// Define a rectangle, located at (0, 0) with a size of 20x5
sf::IntRect r1(0, 0, 20, 5);
// Define another rectangle, located at (4, 2) with a size of 18x10
sf::Vector2i position(4, 2);
sf::Vector2i size(18, 10);
sf::IntRect r2(position, size);
// Test intersections with the point (3, 1)
bool b1 = r1.contains(3, 1); // true
bool b2 = r2.contains(3, 1); // false
// Test the intersection between r1 and r2
sf::IntRect result;
bool b3 = r1.intersects(r2, result); // true
// result == (4, 2, 16, 3)

Definition at line 42 of file Rect.hpp.

Constructor & Destructor Documentation

template<typename T>
sf::Rect< T >::Rect ( )

Default constructor.

Creates an empty rectangle (it is equivalent to calling Rect(0, 0, 0, 0)).

template<typename T>
sf::Rect< T >::Rect | ( | T | rectLeft,
 |  | T | rectTop,
 |  | T | rectWidth,
 |  | T | rectHeight
 | ) |  |

Construct the rectangle from its coordinates.

Be careful, the last two parameters are the width and height, not the right and bottom coordinates!

Parameters
rectLeft | Left coordinate of the rectangle
rectTop | Top coordinate of the rectangle
rectWidth | Width of the rectangle
rectHeight | Height of the rectangle
template<typename T>
sf::Rect< T >::Rect | ( | const Vector2< T > & | position,
 |  | const Vector2< T > & | size
 | ) |  |

Construct the rectangle from position and size.

Be careful, the last parameter is the size, not the bottom-right corner!

Parameters
position | Position of the top-left corner of the rectangle
size | Size of the rectangle
template<typename T>
template<typename U >
sf::Rect< T >::Rect ( const Rect< U > & rectangle )
explicit

Construct the rectangle from another type of rectangle.

This constructor doesn't replace the copy constructor, it's called only when U != T. A call to this constructor will fail to compile if U is not convertible to T.

Parameters
rectangle Rectangle to convert

Member Function Documentation

template<typename T>
bool sf::Rect< T >::contains | ( | T | x,
 |  | T | y
 | ) |  | const

Check if a point is inside the rectangle's area.

Parameters
x | X coordinate of the point to test
y | Y coordinate of the point to test
Returns
True if the point is inside, false otherwise
See Also
intersects
template<typename T>
bool sf::Rect< T >::contains ( const Vector2< T > & point ) const

Check if a point is inside the rectangle's area.

Parameters
point Point to test
Returns
True if the point is inside, false otherwise
See Also
intersects
template<typename T>
bool sf::Rect< T >::intersects ( const Rect< T > & rectangle ) const

Check the intersection between two rectangles.

Parameters
rectangle Rectangle to test
Returns
True if rectangles overlap, false otherwise
See Also
contains
template<typename T>
bool sf::Rect< T >::intersects | ( | const Rect< T > & | rectangle,
 |  | Rect< T > & | intersection
 | ) |  | const

Check the intersection between two rectangles.

This overload returns the overlapped rectangle in the intersection parameter.

Parameters
rectangle | Rectangle to test
intersection | Rectangle to be filled with the intersection
Returns
True if rectangles overlap, false otherwise
See Also
contains

Friends And Related Function Documentation

template<typename T >
bool operator!= | ( | const Rect< T > & | left,
 |  | const Rect< T > & | right
 | ) |  |
related

Overload of binary operator !=.

This operator compares strict difference between two rectangles.

Parameters
left | Left operand (a rectangle)
right | Right operand (a rectangle)
Returns
True if left is not equal to right
template<typename T >
bool operator== | ( | const Rect< T > & | left,
 |  | const Rect< T > & | right
 | ) |  |
related

Overload of binary operator ==.

This operator compares strict equality between two rectangles.

Parameters
left | Left operand (a rectangle)
right | Right operand (a rectangle)
Returns
True if left is equal to right

Member Data Documentation

template<typename T>
T sf::Rect< T >::height

Height of the rectangle.

Definition at line 154 of file Rect.hpp.

template<typename T>
T sf::Rect< T >::left

Left coordinate of the rectangle.

Definition at line 151 of file Rect.hpp.

template<typename T>
T sf::Rect< T >::top

Top coordinate of the rectangle.

Definition at line 152 of file Rect.hpp.

template<typename T>
T sf::Rect< T >::width

Width of the rectangle.

Definition at line 153 of file Rect.hpp.

The documentation for this class was generated from the following files:
  • Rect.hpp
  • Rect.inl


  • sf
  • RectangleShape
Public Member Functions | Protected Member Functions | List of all members
sf::RectangleShape Class Reference
Graphics module

Specialized shape representing a rectangle. More...

#include <RectangleShape.hpp>

Inheritance diagram for sf::RectangleShape:
sf::Shape sf::Drawable sf::Transformable

Public Member Functions

RectangleShape (const Vector2f &size=Vector2f(0, 0))
Default constructor.
void | setSize (const Vector2f &size)
Set the size of the rectangle.
const Vector2f & | getSize () const
Get the size of the rectangle.
virtual unsigned int | getPointCount () const
Get the number of points defining the shape.
virtual Vector2f | getPoint (unsigned int index) const
Get a point of the shape.
void | setTexture (const Texture *texture, bool resetRect=false)
Change the source texture of the shape.
void | setTextureRect (const IntRect &rect)
Set the sub-rectangle of the texture that the shape will display.
void | setFillColor (const Color &color)
Set the fill color of the shape.
void | setOutlineColor (const Color &color)
Set the outline color of the shape.
void | setOutlineThickness (float thickness)
Set the thickness of the shape's outline.
const Texture * | getTexture () const
Get the source texture of the shape.
const IntRect & | getTextureRect () const
Get the sub-rectangle of the texture displayed by the shape.
const Color & | getFillColor () const
Get the fill color of the shape.
const Color & | getOutlineColor () const
Get the outline color of the shape.
float | getOutlineThickness () const
Get the outline thickness of the shape.
FloatRect | getLocalBounds () const
Get the local bounding rectangle of the entity.
FloatRect | getGlobalBounds () const
Get the global bounding rectangle of the entity.
void | setPosition (float x, float y)
set the position of the object
void | setPosition (const Vector2f &position)
set the position of the object
void | setRotation (float angle)
set the orientation of the object
void | setScale (float factorX, float factorY)
set the scale factors of the object
void | setScale (const Vector2f &factors)
set the scale factors of the object
void | setOrigin (float x, float y)
set the local origin of the object
void | setOrigin (const Vector2f &origin)
set the local origin of the object
const Vector2f & | getPosition () const
get the position of the object
float | getRotation () const
get the orientation of the object
const Vector2f & | getScale () const
get the current scale of the object
const Vector2f & | getOrigin () const
get the local origin of the object
void | move (float offsetX, float offsetY)
Move the object by a given offset.
void | move (const Vector2f &offset)
Move the object by a given offset.
void | rotate (float angle)
Rotate the object.
void | scale (float factorX, float factorY)
Scale the object.
void | scale (const Vector2f &factor)
Scale the object.
const Transform & | getTransform () const
get the combined transform of the object
const Transform & | getInverseTransform () const
get the inverse of the combined transform of the object

Protected Member Functions

void update ()
Recompute the internal geometry of the shape.

Detailed Description

Specialized shape representing a rectangle.

This class inherits all the functions of sf::Transformable (position, rotation, scale, bounds, ...) as well as the functions of sf::Shape (outline, color, texture, ...).

Usage example:

sf::RectangleShape rectangle;
rectangle.setSize(sf::Vector2f(100, 50));
rectangle.setOutlineColor(sf::Color::Red);
rectangle.setOutlineThickness(5);
rectangle.setPosition(10, 20);
...
window.draw(rectangle);
See Also
sf::Shape, sf::CircleShape, sf::ConvexShape

Definition at line 41 of file RectangleShape.hpp.

Constructor & Destructor Documentation

sf::RectangleShape::RectangleShape ( const Vector2f & size = Vector2f(0, 0) )
explicit

Default constructor.

Parameters
size Size of the rectangle

Member Function Documentation

const Color& sf::Shape::getFillColor ( ) const
inherited

Get the fill color of the shape.

Returns
Fill color of the shape
See Also
setFillColor
FloatRect sf::Shape::getGlobalBounds ( ) const
inherited

Get the global bounding rectangle of the entity.

The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the sprite in the global 2D world's coordinate system.

Returns
Global bounding rectangle of the entity
const Transform& sf::Transformable::getInverseTransform ( ) const
inherited

get the inverse of the combined transform of the object

Returns
Inverse of the combined transformations applied to the object
See Also
getTransform
FloatRect sf::Shape::getLocalBounds ( ) const
inherited

Get the local bounding rectangle of the entity.

The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.

Returns
Local bounding rectangle of the entity
const Vector2f& sf::Transformable::getOrigin ( ) const
inherited

get the local origin of the object

Returns
Current origin
See Also
setOrigin
const Color& sf::Shape::getOutlineColor ( ) const
inherited

Get the outline color of the shape.

Returns
Outline color of the shape
See Also
setOutlineColor
float sf::Shape::getOutlineThickness ( ) const
inherited

Get the outline thickness of the shape.

Returns
Outline thickness of the shape
See Also
setOutlineThickness
virtual Vector2f sf::RectangleShape::getPoint ( unsigned int index ) const
virtual

Get a point of the shape.

The result is undefined if index is out of the valid range.

Parameters
index Index of the point to get, in range [0 .. getPointCount() - 1]
Returns
Index-th point of the shape

Implements sf::Shape.

virtual unsigned int sf::RectangleShape::getPointCount ( ) const
virtual

Get the number of points defining the shape.

Returns
Number of points of the shape

Implements sf::Shape.

const Vector2f& sf::Transformable::getPosition ( ) const
inherited

get the position of the object

Returns
Current position
See Also
setPosition
float sf::Transformable::getRotation ( ) const
inherited

get the orientation of the object

The rotation is always in the range [0, 360].

Returns
Current rotation, in degrees
See Also
setRotation
const Vector2f& sf::Transformable::getScale ( ) const
inherited

get the current scale of the object

Returns
Current scale factors
See Also
setScale
const Vector2f& sf::RectangleShape::getSize ( ) const

Get the size of the rectangle.

Returns
Size of the rectangle
See Also
setSize
const Texture* sf::Shape::getTexture ( ) const
inherited

Get the source texture of the shape.

If the shape has no source texture, a NULL pointer is returned. The returned pointer is const, which means that you can't modify the texture when you retrieve it with this function.

Returns
Pointer to the shape's texture
See Also
setTexture
const IntRect& sf::Shape::getTextureRect ( ) const
inherited

Get the sub-rectangle of the texture displayed by the shape.

Returns
Texture rectangle of the shape
See Also
setTextureRect
const Transform& sf::Transformable::getTransform ( ) const
inherited

get the combined transform of the object

Returns
Transform combining the position/rotation/scale/origin of the object
See Also
getInverseTransform
void sf::Transformable::move | ( | float | offsetX,
 |  | float | offsetY
 | ) |  |
inherited

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f pos = object.getPosition();
object.setPosition(pos.x + offsetX, pos.y + offsetY);
Parameters
offsetX | X offset
offsetY | Y offset
See Also
setPosition
void sf::Transformable::move ( const Vector2f & offset )
inherited

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

object.setPosition(object.getPosition() + offset);
Parameters
offset Offset
See Also
setPosition
void sf::Transformable::rotate ( float angle )
inherited

Rotate the object.

This function adds to the current rotation of the object, unlike setRotation which overwrites it. Thus, it is equivalent to the following code:

object.setRotation(object.getRotation() + angle);
Parameters
angle Angle of rotation, in degrees
void sf::Transformable::scale | ( | float | factorX,
 |  | float | factorY
 | ) |  |
inherited

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factorX, scale.y * factorY);
Parameters
factorX | Horizontal scale factor
factorY | Vertical scale factor
See Also
setScale
void sf::Transformable::scale ( const Vector2f & factor )
inherited

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factor.x, scale.y * factor.y);
Parameters
factor Scale factors
See Also
setScale
void sf::Shape::setFillColor ( const Color & color )
inherited

Set the fill color of the shape.

This color is modulated (multiplied) with the shape's texture if any. It can be used to colorize the shape, or change its global opacity. You can use sf::Color::Transparent to make the inside of the shape transparent, and have the outline alone. By default, the shape's fill color is opaque white.

Parameters
color New color of the shape
See Also
getFillColor, setOutlineColor
void sf::Transformable::setOrigin | ( | float | x,
 |  | float | y
 | ) |  |
inherited

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
x | X coordinate of the new origin
y | Y coordinate of the new origin
See Also
getOrigin
void sf::Transformable::setOrigin ( const Vector2f & origin )
inherited

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
origin New origin
See Also
getOrigin
void sf::Shape::setOutlineColor ( const Color & color )
inherited

Set the outline color of the shape.

By default, the shape's outline color is opaque white.

Parameters
color New outline color of the shape
See Also
getOutlineColor, setFillColor
void sf::Shape::setOutlineThickness ( float thickness )
inherited

Set the thickness of the shape's outline.

Note that negative values are allowed (so that the outline expands towards the center of the shape), and using zero disables the outline. By default, the outline thickness is 0.

Parameters
thickness New outline thickness
See Also
getOutlineThickness
void sf::Transformable::setPosition | ( | float | x,
 |  | float | y
 | ) |  |
inherited

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
x | X coordinate of the new position
y | Y coordinate of the new position
See Also
move, getPosition
void sf::Transformable::setPosition ( const Vector2f & position )
inherited

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
position New position
See Also
move, getPosition
void sf::Transformable::setRotation ( float angle )
inherited

set the orientation of the object

This function completely overwrites the previous rotation. See the rotate function to add an angle based on the previous rotation instead. The default rotation of a transformable object is 0.

Parameters
angle New rotation, in degrees
See Also
rotate, getRotation
void sf::Transformable::setScale | ( | float | factorX,
 |  | float | factorY
 | ) |  |
inherited

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factorX | New horizontal scale factor
factorY | New vertical scale factor
See Also
scale, getScale
void sf::Transformable::setScale ( const Vector2f & factors )
inherited

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factors New scale factors
See Also
scale, getScale
void sf::RectangleShape::setSize ( const Vector2f & size )

Set the size of the rectangle.

Parameters
size New size of the rectangle
See Also
getSize
void sf::Shape::setTexture | ( | const Texture * | texture,
 |  | bool | resetRect = false
 | ) |  |
inherited

Change the source texture of the shape.

The texture argument refers to a texture that must exist as long as the shape uses it. Indeed, the shape doesn't store its own copy of the texture, but rather keeps a pointer to the one that you passed to this function. If the source texture is destroyed and the shape tries to use it, the behaviour is undefined. texture can be NULL to disable texturing. If resetRect is true, the TextureRect property of the shape is automatically adjusted to the size of the new texture. If it is false, the texture rect is left unchanged.

Parameters
texture | New texture
resetRect | Should the texture rect be reset to the size of the new texture?
See Also
getTexture, setTextureRect
void sf::Shape::setTextureRect ( const IntRect & rect )
inherited

Set the sub-rectangle of the texture that the shape will display.

The texture rect is useful when you don't want to display the whole texture, but rather a part of it. By default, the texture rect covers the entire texture.

Parameters
rect Rectangle defining the region of the texture to display
See Also
getTextureRect, setTexture
void sf::Shape::update ( )
protectedinherited

Recompute the internal geometry of the shape.

This function must be called by the derived class everytime the shape's points change (ie. the result of either getPointCount or getPoint is different).

The documentation for this class was generated from the following file:
  • RectangleShape.hpp


  • sf
  • RenderStates
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
sf::RenderStates Class Reference
Graphics module

Define the states used for drawing to a RenderTarget. More...

#include <RenderStates.hpp>

Public Member Functions

RenderStates ()
Default constructor.
RenderStates (BlendMode theBlendMode)
Construct a default set of render states with a custom blend mode.
RenderStates (const Transform &theTransform)
Construct a default set of render states with a custom transform.
RenderStates (const Texture *theTexture)
Construct a default set of render states with a custom texture.
RenderStates (const Shader *theShader)
Construct a default set of render states with a custom shader.
RenderStates (BlendMode theBlendMode, const Transform &theTransform, const Texture *theTexture, const Shader *theShader)
Construct a set of render states with all its attributes.

Public Attributes

BlendMode blendMode
Blending mode.
Transform transform
Transform.
const Texture * | texture
Texture.
const Shader * | shader
Shader.

Static Public Attributes

static const RenderStates Default
Special instance holding the default render states.

Detailed Description

Define the states used for drawing to a RenderTarget.

There are four global states that can be applied to the drawn objects:

  • the blend mode: how pixels of the object are blended with the background
  • the transform: how the object is positioned/rotated/scaled
  • the texture: what image is mapped to the object
  • the shader: what custom effect is applied to the object

High-level objects such as sprites or text force some of these states when they are drawn. For example, a sprite will set its own texture, so that you don't have to care about it when drawing the sprite.

The transform is a special case: sprites, texts and shapes (and it's a good idea to do it with your own drawable classes too) combine their transform with the one that is passed in the RenderStates structure. So that you can use a "global" transform on top of each object's transform.

Most objects, especially high-level drawables, can be drawn directly without defining render states explicitely – the default set of states is ok in most cases.

window.Draw(sprite);

If you want to use a single specific render state, for example a shader, you can pass it directly to the Draw function: sf::RenderStates has an implicit one-argument constructor for each state.

window.draw(sprite, shader);

When you're inside the Draw function of a drawable object (inherited from sf::Drawable), you can either pass the render states unmodified, or change some of them. For example, a transformable object will combine the current transform with its own transform. A sprite will set its texture. Etc.

See Also
sf::RenderTarget, sf::Drawable

Definition at line 45 of file RenderStates.hpp.

Constructor & Destructor Documentation

sf::RenderStates::RenderStates ( )

Default constructor.

Constructing a default set of render states is equivalent to using sf::RenderStates::Default. The default set defines:

  • the BlendAlpha blend mode
  • the identity transform
  • a null texture
  • a null shader
sf::RenderStates::RenderStates ( BlendMode theBlendMode )

Construct a default set of render states with a custom blend mode.

Parameters
theBlendMode Blend mode to use
sf::RenderStates::RenderStates ( const Transform & theTransform )

Construct a default set of render states with a custom transform.

Parameters
theTransform Transform to use
sf::RenderStates::RenderStates ( const Texture * theTexture )

Construct a default set of render states with a custom texture.

Parameters
theTexture Texture to use
sf::RenderStates::RenderStates ( const Shader * theShader )

Construct a default set of render states with a custom shader.

Parameters
theShader Shader to use
sf::RenderStates::RenderStates | ( | BlendMode | theBlendMode,
 |  | const Transform & | theTransform,
 |  | const Texture * | theTexture,
 |  | const Shader * | theShader
 | ) |  |

Construct a set of render states with all its attributes.

Parameters
theBlendMode | Blend mode to use
theTransform | Transform to use
theTexture | Texture to use
theShader | Shader to use

Member Data Documentation

BlendMode sf::RenderStates::blendMode

Blending mode.

Definition at line 115 of file RenderStates.hpp.

const RenderStates sf::RenderStates::Default
static

Special instance holding the default render states.

Definition at line 110 of file RenderStates.hpp.

const Shader* sf::RenderStates::shader

Shader.

Definition at line 118 of file RenderStates.hpp.

const Texture* sf::RenderStates::texture

Texture.

Definition at line 117 of file RenderStates.hpp.

Transform sf::RenderStates::transform

Transform.

Definition at line 116 of file RenderStates.hpp.

The documentation for this class was generated from the following file:
  • RenderStates.hpp


  • sf
  • RenderTarget
Classes | Public Member Functions | Protected Member Functions | List of all members
sf::RenderTarget Class Referenceabstract
Graphics module

Base class for all render targets (window, texture, ...) More...

#include <RenderTarget.hpp>

Inheritance diagram for sf::RenderTarget:
sf::NonCopyable sf::RenderTexture sf::RenderWindow

Public Member Functions

virtual | ~RenderTarget ()
Destructor.
void | clear (const Color &color=Color(0, 0, 0, 255))
Clear the entire target with a single color.
void | setView (const View &view)
Change the current active view.
const View & | getView () const
Get the view currently in use in the render target.
const View & | getDefaultView () const
Get the default view of the render target.
IntRect | getViewport (const View &view) const
Get the viewport of a view, applied to this render target.
Vector2f | mapPixelToCoords (const Vector2i &point) const
Convert a point from target coordinates to world coordinates, using the current view.
Vector2f | mapPixelToCoords (const Vector2i &point, const View &view) const
Convert a point from target coordinates to world coordinates.
Vector2i | mapCoordsToPixel (const Vector2f &point) const
Convert a point from world coordinates to target coordinates, using the current view.
Vector2i | mapCoordsToPixel (const Vector2f &point, const View &view) const
Convert a point from world coordinates to target coordinates.
void | draw (const Drawable &drawable, const RenderStates &states=RenderStates::Default)
Draw a drawable object to the render-target.
void | draw (const Vertex *vertices, unsigned int vertexCount, PrimitiveType type, const RenderStates &states=RenderStates::Default)
Draw primitives defined by an array of vertices.
virtual Vector2u | getSize () const =0
Return the size of the rendering region of the target.
void | pushGLStates ()
Save the current OpenGL render states and matrices.
void | popGLStates ()
Restore the previously saved OpenGL render states and matrices.
void | resetGLStates ()
Reset the internal OpenGL states so that the target is ready for drawing.

Protected Member Functions

RenderTarget ()
Default constructor.
void initialize ()
Performs the common initialization step after creation.

Detailed Description

Base class for all render targets (window, texture, ...)

sf::RenderTarget defines the common behaviour of all the 2D render targets usable in the graphics module.

It makes it possible to draw 2D entities like sprites, shapes, text without using any OpenGL command directly.

A sf::RenderTarget is also able to use views (sf::View), which are a kind of 2D cameras. With views you can globally scroll, rotate or zoom everything that is drawn, without having to transform every single entity. See the documentation of sf::View for more details and sample pieces of code about this class.

On top of that, render targets are still able to render direct OpenGL stuff. It is even possible to mix together OpenGL calls and regular SFML drawing commands. When doing so, make sure that OpenGL states are not messed up by calling the pushGLStates/popGLStates functions.

See Also
sf::RenderWindow, sf::RenderTexture, sf::View

Definition at line 51 of file RenderTarget.hpp.

Constructor & Destructor Documentation

virtual sf::RenderTarget::~RenderTarget ( )
virtual

Destructor.

sf::RenderTarget::RenderTarget ( )
protected

Default constructor.

Member Function Documentation

void sf::RenderTarget::clear ( const Color & color = Color(0, 0, 0, 255) )

Clear the entire target with a single color.

This function is usually called once every frame, to clear the previous contents of the target.

Parameters
color Fill color to use to clear the render target
void sf::RenderTarget::draw | ( | const Drawable & | drawable,
 |  | const RenderStates & | states = RenderStates::Default
 | ) |  |

Draw a drawable object to the render-target.

Parameters
drawable | Object to draw
states | Render states to use for drawing
void sf::RenderTarget::draw | ( | const Vertex * | vertices,
 |  | unsigned int | vertexCount,
 |  | PrimitiveType | type,
 |  | const RenderStates & | states = RenderStates::Default
 | ) |  |

Draw primitives defined by an array of vertices.

Parameters
vertices | Pointer to the vertices
vertexCount | Number of vertices in the array
type | Type of primitives to draw
states | Render states to use for drawing
const View& sf::RenderTarget::getDefaultView ( ) const

Get the default view of the render target.

The default view has the initial size of the render target, and never changes after the target has been created.

Returns
The default view of the render target
See Also
setView, getView
virtual Vector2u sf::RenderTarget::getSize ( ) const
pure virtual

Return the size of the rendering region of the target.

Returns
Size in pixels

Implemented in sf::RenderTexture, and sf::RenderWindow.

const View& sf::RenderTarget::getView ( ) const

Get the view currently in use in the render target.

Returns
The view object that is currently used
See Also
setView, getDefaultView
IntRect sf::RenderTarget::getViewport ( const View & view ) const

Get the viewport of a view, applied to this render target.

The viewport is defined in the view as a ratio, this function simply applies this ratio to the current dimensions of the render target to calculate the pixels rectangle that the viewport actually covers in the target.

Parameters
view The view for which we want to compute the viewport
Returns
Viewport rectangle, expressed in pixels
void sf::RenderTarget::initialize ( )
protected

Performs the common initialization step after creation.

The derived classes must call this function after the target is created and ready for drawing.

Vector2i sf::RenderTarget::mapCoordsToPixel ( const Vector2f & point ) const

Convert a point from world coordinates to target coordinates, using the current view.

This function is an overload of the mapCoordsToPixel function that implicitely uses the current view. It is equivalent to:

target.mapCoordsToPixel(point, target.getView());
Parameters
point Point to convert
Returns
The converted point, in target coordinates (pixels)
See Also
mapPixelToCoords
Vector2i sf::RenderTarget::mapCoordsToPixel | ( | const Vector2f & | point,
 |  | const View & | view
 | ) |  | const

Convert a point from world coordinates to target coordinates.

This function finds the pixel of the render-target that matches the given 2D point. In other words, it goes through the same process as the graphics card, to compute the final position of a rendered point.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (150, 75) in your 2D world may map to the pixel (10, 50) of your render-target – if the view is translated by (140, 25).

This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-target.

Parameters
point | Point to convert
view | The view to use for converting the point
Returns
The converted point, in target coordinates (pixels)
See Also
mapPixelToCoords
Vector2f sf::RenderTarget::mapPixelToCoords ( const Vector2i & point ) const

Convert a point from target coordinates to world coordinates, using the current view.

This function is an overload of the mapPixelToCoords function that implicitely uses the current view. It is equivalent to:

target.mapPixelToCoords(point, target.getView());
Parameters
point Pixel to convert
Returns
The converted point, in "world" coordinates
See Also
mapCoordsToPixel
Vector2f sf::RenderTarget::mapPixelToCoords | ( | const Vector2i & | point,
 |  | const View & | view
 | ) |  | const

Convert a point from target coordinates to world coordinates.

This function finds the 2D position that matches the given pixel of the render-target. In other words, it does the inverse of what the graphics card does, to find the initial position of a rendered pixel.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (10, 50) in your render-target may map to the point (150, 75) in your 2D world – if the view is translated by (140, 25).

For render-windows, this function is typically used to find which point (or object) is located below the mouse cursor.

This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-target.

Parameters
point | Pixel to convert
view | The view to use for converting the point
Returns
The converted point, in "world" units
See Also
mapCoordsToPixel
void sf::RenderTarget::popGLStates ( )

Restore the previously saved OpenGL render states and matrices.

See the description of pushGLStates to get a detailed description of these functions.

See Also
pushGLStates
void sf::RenderTarget::pushGLStates ( )

Save the current OpenGL render states and matrices.

This function can be used when you mix SFML drawing and direct OpenGL rendering. Combined with PopGLStates, it ensures that:

  • SFML's internal states are not messed up by your OpenGL code
  • your OpenGL states are not modified by a call to a SFML function

More specifically, it must be used around code that calls Draw functions. Example:

// OpenGL code here...
window.pushGLStates();
window.draw(...);
window.draw(...);
window.popGLStates();
// OpenGL code here...

Note that this function is quite expensive: it saves all the possible OpenGL states and matrices, even the ones you don't care about. Therefore it should be used wisely. It is provided for convenience, but the best results will be achieved if you handle OpenGL states yourself (because you know which states have really changed, and need to be saved and restored). Take a look at the ResetGLStates function if you do so.

See Also
popGLStates
void sf::RenderTarget::resetGLStates ( )

Reset the internal OpenGL states so that the target is ready for drawing.

This function can be used when you mix SFML drawing and direct OpenGL rendering, if you choose not to use pushGLStates/popGLStates. It makes sure that all OpenGL states needed by SFML are set, so that subsequent draw() calls will work as expected.

Example:

// OpenGL code here...
glPushAttrib(...);
window.resetGLStates();
window.draw(...);
window.draw(...);
glPopAttrib(...);
// OpenGL code here...
void sf::RenderTarget::setView ( const View & view )

Change the current active view.

The view is like a 2D camera, it controls which part of the 2D scene is visible, and how it is viewed in the render-target. The new view will affect everything that is drawn, until another view is set. The render target keeps its own copy of the view object, so it is not necessary to keep the original one alive after calling this function. To restore the original view of the target, you can pass the result of getDefaultView() to this function.

Parameters
view New view to use
See Also
getView, getDefaultView
The documentation for this class was generated from the following file:
  • RenderTarget.hpp


  • sf
  • RenderTexture
Public Member Functions | Protected Member Functions | List of all members
sf::RenderTexture Class Reference
Graphics module

Target for off-screen 2D rendering into a texture. More...

#include <RenderTexture.hpp>

Inheritance diagram for sf::RenderTexture:
sf::RenderTarget sf::NonCopyable

Public Member Functions

RenderTexture ()
Default constructor.
virtual | ~RenderTexture ()
Destructor.
bool | create (unsigned int width, unsigned int height, bool depthBuffer=false)
Create the render-texture.
void | setSmooth (bool smooth)
Enable or disable texture smoothing.
bool | isSmooth () const
Tell whether the smooth filtering is enabled or not.
void | setRepeated (bool repeated)
Enable or disable texture repeating.
bool | isRepeated () const
Tell whether the texture is repeated or not.
bool | setActive (bool active=true)
Activate of deactivate the render-texture for rendering.
void | display ()
Update the contents of the target texture.
virtual Vector2u | getSize () const
Return the size of the rendering region of the texture.
const Texture & | getTexture () const
Get a read-only reference to the target texture.
void | clear (const Color &color=Color(0, 0, 0, 255))
Clear the entire target with a single color.
void | setView (const View &view)
Change the current active view.
const View & | getView () const
Get the view currently in use in the render target.
const View & | getDefaultView () const
Get the default view of the render target.
IntRect | getViewport (const View &view) const
Get the viewport of a view, applied to this render target.
Vector2f | mapPixelToCoords (const Vector2i &point) const
Convert a point from target coordinates to world coordinates, using the current view.
Vector2f | mapPixelToCoords (const Vector2i &point, const View &view) const
Convert a point from target coordinates to world coordinates.
Vector2i | mapCoordsToPixel (const Vector2f &point) const
Convert a point from world coordinates to target coordinates, using the current view.
Vector2i | mapCoordsToPixel (const Vector2f &point, const View &view) const
Convert a point from world coordinates to target coordinates.
void | draw (const Drawable &drawable, const RenderStates &states=RenderStates::Default)
Draw a drawable object to the render-target.
void | draw (const Vertex *vertices, unsigned int vertexCount, PrimitiveType type, const RenderStates &states=RenderStates::Default)
Draw primitives defined by an array of vertices.
void | pushGLStates ()
Save the current OpenGL render states and matrices.
void | popGLStates ()
Restore the previously saved OpenGL render states and matrices.
void | resetGLStates ()
Reset the internal OpenGL states so that the target is ready for drawing.

Protected Member Functions

void initialize ()
Performs the common initialization step after creation.

Detailed Description

Target for off-screen 2D rendering into a texture.

sf::RenderTexture is the little brother of sf::RenderWindow.

It implements the same 2D drawing and OpenGL-related functions (see their base class sf::RenderTarget for more details), the difference is that the result is stored in an off-screen texture rather than being show in a window.

Rendering to a texture can be useful in a variety of situations:

  • precomputing a complex static texture (like a level's background from multiple tiles)
  • applying post-effects to the whole scene with shaders
  • creating a sprite from a 3D object rendered with OpenGL
  • etc.

Usage example:

// Create a new render-window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
// Create a new render-texture
sf::RenderTexture texture;
if (!texture.create(500, 500))
return -1;
// The main loop
while (window.isOpen())
{
// Event processing
// ...
// Clear the whole texture with red color
texture.clear(sf::Color::Red);
// Draw stuff to the texture
texture.draw(sprite); // sprite is a sf::Sprite
texture.draw(shape); // shape is a sf::Shape
texture.draw(text); // text is a sf::Text
// We're done drawing to the texture
texture.display();
// Now we start rendering to the window, clear it first
window.clear();
// Draw the texture
sf::Sprite sprite(texture.getTexture());
window.draw(sprite);
// End the current frame and display its contents on screen
window.display();
}

Like sf::RenderWindow, sf::RenderTexture is still able to render direct OpenGL stuff. It is even possible to mix together OpenGL calls and regular SFML drawing commands. If you need a depth buffer for 3D rendering, don't forget to request it when calling RenderTexture::create.

See Also
sf::RenderTarget, sf::RenderWindow, sf::View, sf::Texture

Definition at line 47 of file RenderTexture.hpp.

Constructor & Destructor Documentation

sf::RenderTexture::RenderTexture ( )

Default constructor.

Constructs an empty, invalid render-texture. You must call create to have a valid render-texture.

See Also
create
virtual sf::RenderTexture::~RenderTexture ( )
virtual

Destructor.

Member Function Documentation

void sf::RenderTarget::clear ( const Color & color = Color(0, 0, 0, 255) )
inherited

Clear the entire target with a single color.

This function is usually called once every frame, to clear the previous contents of the target.

Parameters
color Fill color to use to clear the render target
bool sf::RenderTexture::create | ( | unsigned int | width,
 |  | unsigned int | height,
 |  | bool | depthBuffer = false
 | ) |  |

Create the render-texture.

Before calling this function, the render-texture is in an invalid state, thus it is mandatory to call it before doing anything with the render-texture. The last parameter, depthBuffer, is useful if you want to use the render-texture for 3D OpenGL rendering that requires a depth-buffer. Otherwise it is unnecessary, and you should leave this parameter to false (which is its default value).

Parameters
width | Width of the render-texture
height | Height of the render-texture
depthBuffer | Do you want this render-texture to have a depth buffer?
Returns
True if creation has been successful
void sf::RenderTexture::display ( )

Update the contents of the target texture.

This function updates the target texture with what has been drawn so far. Like for windows, calling this function is mandatory at the end of rendering. Not calling it may leave the texture in an undefined state.

void sf::RenderTarget::draw | ( | const Drawable & | drawable,
 |  | const RenderStates & | states = RenderStates::Default
 | ) |  |
inherited

Draw a drawable object to the render-target.

Parameters
drawable | Object to draw
states | Render states to use for drawing
void sf::RenderTarget::draw | ( | const Vertex * | vertices,
 |  | unsigned int | vertexCount,
 |  | PrimitiveType | type,
 |  | const RenderStates & | states = RenderStates::Default
 | ) |  |
inherited

Draw primitives defined by an array of vertices.

Parameters
vertices | Pointer to the vertices
vertexCount | Number of vertices in the array
type | Type of primitives to draw
states | Render states to use for drawing
const View& sf::RenderTarget::getDefaultView ( ) const
inherited

Get the default view of the render target.

The default view has the initial size of the render target, and never changes after the target has been created.

Returns
The default view of the render target
See Also
setView, getView
virtual Vector2u sf::RenderTexture::getSize ( ) const
virtual

Return the size of the rendering region of the texture.

The returned value is the size that you passed to the create function.

Returns
Size in pixels

Implements sf::RenderTarget.

const Texture& sf::RenderTexture::getTexture ( ) const

Get a read-only reference to the target texture.

After drawing to the render-texture and calling Display, you can retrieve the updated texture using this function, and draw it using a sprite (for example). The internal sf::Texture of a render-texture is always the same instance, so that it is possible to call this function once and keep a reference to the texture even after it is modified.

Returns
Const reference to the texture
const View& sf::RenderTarget::getView ( ) const
inherited

Get the view currently in use in the render target.

Returns
The view object that is currently used
See Also
setView, getDefaultView
IntRect sf::RenderTarget::getViewport ( const View & view ) const
inherited

Get the viewport of a view, applied to this render target.

The viewport is defined in the view as a ratio, this function simply applies this ratio to the current dimensions of the render target to calculate the pixels rectangle that the viewport actually covers in the target.

Parameters
view The view for which we want to compute the viewport
Returns
Viewport rectangle, expressed in pixels
void sf::RenderTarget::initialize ( )
protectedinherited

Performs the common initialization step after creation.

The derived classes must call this function after the target is created and ready for drawing.

bool sf::RenderTexture::isRepeated ( ) const

Tell whether the texture is repeated or not.

Returns
True if texture is repeated
See Also
setRepeated
bool sf::RenderTexture::isSmooth ( ) const

Tell whether the smooth filtering is enabled or not.

Returns
True if texture smoothing is enabled
See Also
setSmooth
Vector2i sf::RenderTarget::mapCoordsToPixel ( const Vector2f & point ) const
inherited

Convert a point from world coordinates to target coordinates, using the current view.

This function is an overload of the mapCoordsToPixel function that implicitely uses the current view. It is equivalent to:

target.mapCoordsToPixel(point, target.getView());
Parameters
point Point to convert
Returns
The converted point, in target coordinates (pixels)
See Also
mapPixelToCoords
Vector2i sf::RenderTarget::mapCoordsToPixel | ( | const Vector2f & | point,
 |  | const View & | view
 | ) |  | const
 inherited

Convert a point from world coordinates to target coordinates.

This function finds the pixel of the render-target that matches the given 2D point. In other words, it goes through the same process as the graphics card, to compute the final position of a rendered point.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (150, 75) in your 2D world may map to the pixel (10, 50) of your render-target – if the view is translated by (140, 25).

This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-target.

Parameters
point | Point to convert
view | The view to use for converting the point
Returns
The converted point, in target coordinates (pixels)
See Also
mapPixelToCoords
Vector2f sf::RenderTarget::mapPixelToCoords ( const Vector2i & point ) const
inherited

Convert a point from target coordinates to world coordinates, using the current view.

This function is an overload of the mapPixelToCoords function that implicitely uses the current view. It is equivalent to:

target.mapPixelToCoords(point, target.getView());
Parameters
point Pixel to convert
Returns
The converted point, in "world" coordinates
See Also
mapCoordsToPixel
Vector2f sf::RenderTarget::mapPixelToCoords | ( | const Vector2i & | point,
 |  | const View & | view
 | ) |  | const
 inherited

Convert a point from target coordinates to world coordinates.

This function finds the 2D position that matches the given pixel of the render-target. In other words, it does the inverse of what the graphics card does, to find the initial position of a rendered pixel.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (10, 50) in your render-target may map to the point (150, 75) in your 2D world – if the view is translated by (140, 25).

For render-windows, this function is typically used to find which point (or object) is located below the mouse cursor.

This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-target.

Parameters
point | Pixel to convert
view | The view to use for converting the point
Returns
The converted point, in "world" units
See Also
mapCoordsToPixel
void sf::RenderTarget::popGLStates ( )
inherited

Restore the previously saved OpenGL render states and matrices.

See the description of pushGLStates to get a detailed description of these functions.

See Also
pushGLStates
void sf::RenderTarget::pushGLStates ( )
inherited

Save the current OpenGL render states and matrices.

This function can be used when you mix SFML drawing and direct OpenGL rendering. Combined with PopGLStates, it ensures that:

  • SFML's internal states are not messed up by your OpenGL code
  • your OpenGL states are not modified by a call to a SFML function

More specifically, it must be used around code that calls Draw functions. Example:

// OpenGL code here...
window.pushGLStates();
window.draw(...);
window.draw(...);
window.popGLStates();
// OpenGL code here...

Note that this function is quite expensive: it saves all the possible OpenGL states and matrices, even the ones you don't care about. Therefore it should be used wisely. It is provided for convenience, but the best results will be achieved if you handle OpenGL states yourself (because you know which states have really changed, and need to be saved and restored). Take a look at the ResetGLStates function if you do so.

See Also
popGLStates
void sf::RenderTarget::resetGLStates ( )
inherited

Reset the internal OpenGL states so that the target is ready for drawing.

This function can be used when you mix SFML drawing and direct OpenGL rendering, if you choose not to use pushGLStates/popGLStates. It makes sure that all OpenGL states needed by SFML are set, so that subsequent draw() calls will work as expected.

Example:

// OpenGL code here...
glPushAttrib(...);
window.resetGLStates();
window.draw(...);
window.draw(...);
glPopAttrib(...);
// OpenGL code here...
bool sf::RenderTexture::setActive ( bool active = true )

Activate of deactivate the render-texture for rendering.

This function makes the render-texture's context current for future OpenGL rendering operations (so you shouldn't care about it if you're not doing direct OpenGL stuff). Only one context can be current in a thread, so if you want to draw OpenGL geometry to another render target (like a RenderWindow) don't forget to activate it again.

Parameters
active True to activate, false to deactivate
Returns
True if operation was successful, false otherwise
void sf::RenderTexture::setRepeated ( bool repeated )

Enable or disable texture repeating.

This function is similar to Texture::setRepeated. This parameter is disabled by default.

Parameters
repeated True to enable repeating, false to disable it
See Also
isRepeated
void sf::RenderTexture::setSmooth ( bool smooth )

Enable or disable texture smoothing.

This function is similar to Texture::setSmooth. This parameter is disabled by default.

Parameters
smooth True to enable smoothing, false to disable it
See Also
isSmooth
void sf::RenderTarget::setView ( const View & view )
inherited

Change the current active view.

The view is like a 2D camera, it controls which part of the 2D scene is visible, and how it is viewed in the render-target. The new view will affect everything that is drawn, until another view is set. The render target keeps its own copy of the view object, so it is not necessary to keep the original one alive after calling this function. To restore the original view of the target, you can pass the result of getDefaultView() to this function.

Parameters
view New view to use
See Also
getView, getDefaultView
The documentation for this class was generated from the following file:
  • RenderTexture.hpp


  • sf
  • RenderWindow
Public Member Functions | Protected Member Functions | List of all members
sf::RenderWindow Class Reference
Graphics module

Window that can serve as a target for 2D drawing. More...

#include <RenderWindow.hpp>

Inheritance diagram for sf::RenderWindow:
sf::Window sf::RenderTarget sf::GlResource sf::NonCopyable sf::NonCopyable

Public Member Functions

RenderWindow ()
Default constructor.
RenderWindow (VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings())
Construct a new window.
RenderWindow (WindowHandle handle, const ContextSettings &settings=ContextSettings())
Construct the window from an existing control.
virtual | ~RenderWindow ()
Destructor.
virtual Vector2u | getSize () const
Get the size of the rendering region of the window.
Image | capture () const
Copy the current contents of the window to an image.
void | create (VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings())
Create (or recreate) the window.
void | create (WindowHandle handle, const ContextSettings &settings=ContextSettings())
Create (or recreate) the window from an existing control.
void | close ()
Close the window and destroy all the attached resources.
bool | isOpen () const
Tell whether or not the window is open.
const ContextSettings & | getSettings () const
Get the settings of the OpenGL context of the window.
bool | pollEvent (Event &event)
Pop the event on top of the event queue, if any, and return it.
bool | waitEvent (Event &event)
Wait for an event and return it.
Vector2i | getPosition () const
Get the position of the window.
void | setPosition (const Vector2i &position)
Change the position of the window on screen.
void | setSize (const Vector2u size)
Change the size of the rendering region of the window.
void | setTitle (const String &title)
Change the title of the window.
void | setIcon (unsigned int width, unsigned int height, const Uint8 *pixels)
Change the window's icon.
void | setVisible (bool visible)
Show or hide the window.
void | setVerticalSyncEnabled (bool enabled)
Enable or disable vertical synchronization.
void | setMouseCursorVisible (bool visible)
Show or hide the mouse cursor.
void | setKeyRepeatEnabled (bool enabled)
Enable or disable automatic key-repeat.
void | setFramerateLimit (unsigned int limit)
Limit the framerate to a maximum fixed frequency.
void | setJoystickThreshold (float threshold)
Change the joystick threshold.
bool | setActive (bool active=true) const
Activate or deactivate the window as the current target for OpenGL rendering.
void | display ()
Display on screen what has been rendered to the window so far.
WindowHandle | getSystemHandle () const
Get the OS-specific handle of the window.
void | clear (const Color &color=Color(0, 0, 0, 255))
Clear the entire target with a single color.
void | setView (const View &view)
Change the current active view.
const View & | getView () const
Get the view currently in use in the render target.
const View & | getDefaultView () const
Get the default view of the render target.
IntRect | getViewport (const View &view) const
Get the viewport of a view, applied to this render target.
Vector2f | mapPixelToCoords (const Vector2i &point) const
Convert a point from target coordinates to world coordinates, using the current view.
Vector2f | mapPixelToCoords (const Vector2i &point, const View &view) const
Convert a point from target coordinates to world coordinates.
Vector2i | mapCoordsToPixel (const Vector2f &point) const
Convert a point from world coordinates to target coordinates, using the current view.
Vector2i | mapCoordsToPixel (const Vector2f &point, const View &view) const
Convert a point from world coordinates to target coordinates.
void | draw (const Drawable &drawable, const RenderStates &states=RenderStates::Default)
Draw a drawable object to the render-target.
void | draw (const Vertex *vertices, unsigned int vertexCount, PrimitiveType type, const RenderStates &states=RenderStates::Default)
Draw primitives defined by an array of vertices.
void | pushGLStates ()
Save the current OpenGL render states and matrices.
void | popGLStates ()
Restore the previously saved OpenGL render states and matrices.
void | resetGLStates ()
Reset the internal OpenGL states so that the target is ready for drawing.

Protected Member Functions

virtual void | onCreate ()
Function called after the window has been created.
virtual void | onResize ()
Function called after the window has been resized.
void | initialize ()
Performs the common initialization step after creation.

Detailed Description

Window that can serve as a target for 2D drawing.

sf::RenderWindow is the main class of the Graphics module.

It defines an OS window that can be painted using the other classes of the graphics module.

sf::RenderWindow is derived from sf::Window, thus it inherits all its features: events, window management, OpenGL rendering, etc. See the documentation of sf::Window for a more complete description of all these features, as well as code examples.

On top of that, sf::RenderWindow adds more features related to 2D drawing with the graphics module (see its base class sf::RenderTarget for more details). Here is a typical rendering and event loop with a sf::RenderWindow:

// Declare and create a new render-window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
// Limit the framerate to 60 frames per second (this step is optional)
window.setFramerateLimit(60);
// The main loop - ends as soon as the window is closed
while (window.isOpen())
{
// Event processing
sf::Event event;
while (window.pollEvent(event))
{
// Request for closing the window
if (event.type == sf::Event::Closed)
window.close();
}
// Clear the whole window before rendering a new frame
window.clear();
// Draw some graphical entities
window.draw(sprite);
window.draw(circle);
window.draw(text);
// End the current frame and display its contents on screen
window.display();
}

Like sf::Window, sf::RenderWindow is still able to render direct OpenGL stuff. It is even possible to mix together OpenGL calls and regular SFML drawing commands.

// Create the render window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML OpenGL");
// Create a sprite and a text to display
sf::Sprite sprite;
sf::Text text;
...
// Perform OpenGL initializations
glMatrixMode(GL_PROJECTION);
...
// Start the rendering loop
while (window.isOpen())
{
// Process events
...
// Draw a background sprite
window.pushGLStates();
window.draw(sprite);
window.popGLStates();
// Draw a 3D object using OpenGL
glBegin(GL_QUADS);
glVertex3f(...);
...
glEnd();
// Draw text on top of the 3D object
window.pushGLStates();
window.draw(text);
window.popGLStates();
// Finally, display the rendered frame on screen
window.display();
}
See Also
sf::Window, sf::RenderTarget, sf::RenderTexture, sf::View

Definition at line 44 of file RenderWindow.hpp.

Constructor & Destructor Documentation

sf::RenderWindow::RenderWindow ( )

Default constructor.

This constructor doesn't actually create the window, use the other constructors or call "create" to do so.

sf::RenderWindow::RenderWindow | ( | VideoMode | mode,
 |  | const String & | title,
 |  | Uint32 | style = Style::Default,
 |  | const ContextSettings & | settings = ContextSettings()
 | ) |  |

Construct a new window.

This constructor creates the window with the size and pixel depth defined in mode. An optional style can be passed to customize the look and behaviour of the window (borders, title bar, resizable, closable, ...).

The fourth parameter is an optional structure specifying advanced OpenGL context settings such as antialiasing, depth-buffer bits, etc. You shouldn't care about these parameters for a regular usage of the graphics module.

Parameters
mode | Video mode to use (defines the width, height and depth of the rendering area of the window)
title | Title of the window
style | Window style
settings | Additional settings for the underlying OpenGL context
sf::RenderWindow::RenderWindow | ( | WindowHandle | handle,
 |  | const ContextSettings & | settings = ContextSettings()
 | ) |  |
explicit

Construct the window from an existing control.

Use this constructor if you want to create an SFML rendering area into an already existing control.

The fourth parameter is an optional structure specifying advanced OpenGL context settings such as antialiasing, depth-buffer bits, etc. You shouldn't care about these parameters for a regular usage of the graphics module.

Parameters
handle | Platform-specific handle of the control
settings | Additional settings for the underlying OpenGL context
virtual sf::RenderWindow::~RenderWindow ( )
virtual

Destructor.

Closes the window and free all the resources attached to it.

Member Function Documentation

Image sf::RenderWindow::capture ( ) const

Copy the current contents of the window to an image.

This is a slow operation, whose main purpose is to make screenshots of the application. If you want to update an image with the contents of the window and then use it for drawing, you should rather use a sf::Texture and its update(Window&) function. You can also draw things directly to a texture with the sf::RenderTexture class.

Returns
Image containing the captured contents
void sf::RenderTarget::clear ( const Color & color = Color(0, 0, 0, 255) )
inherited

Clear the entire target with a single color.

This function is usually called once every frame, to clear the previous contents of the target.

Parameters
color Fill color to use to clear the render target
void sf::Window::close ( )
inherited

Close the window and destroy all the attached resources.

After calling this function, the sf::Window instance remains valid and you can call create() to recreate the window. All other functions such as pollEvent() or display() will still work (i.e. you don't have to test isOpen() every time), and will have no effect on closed windows.

void sf::Window::create | ( | VideoMode | mode,
 |  | const String & | title,
 |  | Uint32 | style = Style::Default,
 |  | const ContextSettings & | settings = ContextSettings()
 | ) |  |
inherited

Create (or recreate) the window.

If the window was already created, it closes it first. If style contains Style::Fullscreen, then mode must be a valid video mode.

Parameters
mode | Video mode to use (defines the width, height and depth of the rendering area of the window)
title | Title of the window
style | Window style
settings | Additional settings for the underlying OpenGL context
void sf::Window::create | ( | WindowHandle | handle,
 |  | const ContextSettings & | settings = ContextSettings()
 | ) |  |
inherited

Create (or recreate) the window from an existing control.

Use this function if you want to create an OpenGL rendering area into an already existing control. If the window was already created, it closes it first.

Parameters
handle | Platform-specific handle of the control
settings | Additional settings for the underlying OpenGL context
void sf::Window::display ( )
inherited

Display on screen what has been rendered to the window so far.

This function is typically called after all OpenGL rendering has been done for the current frame, in order to show it on screen.

void sf::RenderTarget::draw | ( | const Drawable & | drawable,
 |  | const RenderStates & | states = RenderStates::Default
 | ) |  |
inherited

Draw a drawable object to the render-target.

Parameters
drawable | Object to draw
states | Render states to use for drawing
void sf::RenderTarget::draw | ( | const Vertex * | vertices,
 |  | unsigned int | vertexCount,
 |  | PrimitiveType | type,
 |  | const RenderStates & | states = RenderStates::Default
 | ) |  |
inherited

Draw primitives defined by an array of vertices.

Parameters
vertices | Pointer to the vertices
vertexCount | Number of vertices in the array
type | Type of primitives to draw
states | Render states to use for drawing
const View& sf::RenderTarget::getDefaultView ( ) const
inherited

Get the default view of the render target.

The default view has the initial size of the render target, and never changes after the target has been created.

Returns
The default view of the render target
See Also
setView, getView
Vector2i sf::Window::getPosition ( ) const
inherited

Get the position of the window.

Returns
Position of the window, in pixels
See Also
setPosition
const ContextSettings& sf::Window::getSettings ( ) const
inherited

Get the settings of the OpenGL context of the window.

Note that these settings may be different from what was passed to the constructor or the create() function, if one or more settings were not supported. In this case, SFML chose the closest match.

Returns
Structure containing the OpenGL context settings
virtual Vector2u sf::RenderWindow::getSize ( ) const
virtual

Get the size of the rendering region of the window.

The size doesn't include the titlebar and borders of the window.

Returns
Size in pixels

Implements sf::RenderTarget.

WindowHandle sf::Window::getSystemHandle ( ) const
inherited

Get the OS-specific handle of the window.

The type of the returned handle is sf::WindowHandle, which is a typedef to the handle type defined by the OS. You shouldn't need to use this function, unless you have very specific stuff to implement that SFML doesn't support, or implement a temporary workaround until a bug is fixed.

Returns
System handle of the window
const View& sf::RenderTarget::getView ( ) const
inherited

Get the view currently in use in the render target.

Returns
The view object that is currently used
See Also
setView, getDefaultView
IntRect sf::RenderTarget::getViewport ( const View & view ) const
inherited

Get the viewport of a view, applied to this render target.

The viewport is defined in the view as a ratio, this function simply applies this ratio to the current dimensions of the render target to calculate the pixels rectangle that the viewport actually covers in the target.

Parameters
view The view for which we want to compute the viewport
Returns
Viewport rectangle, expressed in pixels
void sf::RenderTarget::initialize ( )
protectedinherited

Performs the common initialization step after creation.

The derived classes must call this function after the target is created and ready for drawing.

bool sf::Window::isOpen ( ) const
inherited

Tell whether or not the window is open.

This function returns whether or not the window exists. Note that a hidden window (setVisible(false)) is open (therefore this function would return true).

Returns
True if the window is open, false if it has been closed
Vector2i sf::RenderTarget::mapCoordsToPixel ( const Vector2f & point ) const
inherited

Convert a point from world coordinates to target coordinates, using the current view.

This function is an overload of the mapCoordsToPixel function that implicitely uses the current view. It is equivalent to:

target.mapCoordsToPixel(point, target.getView());
Parameters
point Point to convert
Returns
The converted point, in target coordinates (pixels)
See Also
mapPixelToCoords
Vector2i sf::RenderTarget::mapCoordsToPixel | ( | const Vector2f & | point,
 |  | const View & | view
 | ) |  | const
 inherited

Convert a point from world coordinates to target coordinates.

This function finds the pixel of the render-target that matches the given 2D point. In other words, it goes through the same process as the graphics card, to compute the final position of a rendered point.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (150, 75) in your 2D world may map to the pixel (10, 50) of your render-target – if the view is translated by (140, 25).

This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-target.

Parameters
point | Point to convert
view | The view to use for converting the point
Returns
The converted point, in target coordinates (pixels)
See Also
mapPixelToCoords
Vector2f sf::RenderTarget::mapPixelToCoords ( const Vector2i & point ) const
inherited

Convert a point from target coordinates to world coordinates, using the current view.

This function is an overload of the mapPixelToCoords function that implicitely uses the current view. It is equivalent to:

target.mapPixelToCoords(point, target.getView());
Parameters
point Pixel to convert
Returns
The converted point, in "world" coordinates
See Also
mapCoordsToPixel
Vector2f sf::RenderTarget::mapPixelToCoords | ( | const Vector2i & | point,
 |  | const View & | view
 | ) |  | const
 inherited

Convert a point from target coordinates to world coordinates.

This function finds the 2D position that matches the given pixel of the render-target. In other words, it does the inverse of what the graphics card does, to find the initial position of a rendered pixel.

Initially, both coordinate systems (world units and target pixels) match perfectly. But if you define a custom view or resize your render-target, this assertion is not true anymore, ie. a point located at (10, 50) in your render-target may map to the point (150, 75) in your 2D world – if the view is translated by (140, 25).

For render-windows, this function is typically used to find which point (or object) is located below the mouse cursor.

This version uses a custom view for calculations, see the other overload of the function if you want to use the current view of the render-target.

Parameters
point | Pixel to convert
view | The view to use for converting the point
Returns
The converted point, in "world" units
See Also
mapCoordsToPixel
virtual void sf::RenderWindow::onCreate ( )
protectedvirtual

Function called after the window has been created.

This function is called so that derived classes can perform their own specific initialization as soon as the window is created.

Reimplemented from sf::Window.

virtual void sf::RenderWindow::onResize ( )
protectedvirtual

Function called after the window has been resized.

This function is called so that derived classes can perform custom actions when the size of the window changes.

Reimplemented from sf::Window.

bool sf::Window::pollEvent ( Event & event )
inherited

Pop the event on top of the event queue, if any, and return it.

This function is not blocking: if there's no pending event then it will return false and leave event unmodified. Note that more than one event may be present in the event queue, thus you should always call this function in a loop to make sure that you process every pending event.

sf::Event event;
while (window.pollEvent(event))
{
// process event...
}
Parameters
event Event to be returned
Returns
True if an event was returned, or false if the event queue was empty
See Also
waitEvent
void sf::RenderTarget::popGLStates ( )
inherited

Restore the previously saved OpenGL render states and matrices.

See the description of pushGLStates to get a detailed description of these functions.

See Also
pushGLStates
void sf::RenderTarget::pushGLStates ( )
inherited

Save the current OpenGL render states and matrices.

This function can be used when you mix SFML drawing and direct OpenGL rendering. Combined with PopGLStates, it ensures that:

  • SFML's internal states are not messed up by your OpenGL code
  • your OpenGL states are not modified by a call to a SFML function

More specifically, it must be used around code that calls Draw functions. Example:

// OpenGL code here...
window.pushGLStates();
window.draw(...);
window.draw(...);
window.popGLStates();
// OpenGL code here...

Note that this function is quite expensive: it saves all the possible OpenGL states and matrices, even the ones you don't care about. Therefore it should be used wisely. It is provided for convenience, but the best results will be achieved if you handle OpenGL states yourself (because you know which states have really changed, and need to be saved and restored). Take a look at the ResetGLStates function if you do so.

See Also
popGLStates
void sf::RenderTarget::resetGLStates ( )
inherited

Reset the internal OpenGL states so that the target is ready for drawing.

This function can be used when you mix SFML drawing and direct OpenGL rendering, if you choose not to use pushGLStates/popGLStates. It makes sure that all OpenGL states needed by SFML are set, so that subsequent draw() calls will work as expected.

Example:

// OpenGL code here...
glPushAttrib(...);
window.resetGLStates();
window.draw(...);
window.draw(...);
glPopAttrib(...);
// OpenGL code here...
bool sf::Window::setActive ( bool active = true ) const
inherited

Activate or deactivate the window as the current target for OpenGL rendering.

A window is active only on the current thread, if you want to make it active on another thread you have to deactivate it on the previous thread first if it was active. Only one window can be active on a thread at a time, thus the window previously active (if any) automatically gets deactivated.

Parameters
active True to activate, false to deactivate
Returns
True if operation was successful, false otherwise
void sf::Window::setFramerateLimit ( unsigned int limit )
inherited

Limit the framerate to a maximum fixed frequency.

If a limit is set, the window will use a small delay after each call to display() to ensure that the current frame lasted long enough to match the framerate limit. SFML will try to match the given limit as much as it can, but since it internally uses sf::sleep, whose precision depends on the underlying OS, the results may be a little unprecise as well (for example, you can get 65 FPS when requesting 60).

Parameters
limit Framerate limit, in frames per seconds (use 0 to disable limit)
void sf::Window::setIcon | ( | unsigned int | width,
 |  | unsigned int | height,
 |  | const Uint8 * | pixels
 | ) |  |
inherited

Change the window's icon.

pixels must be an array of width x height pixels in 32-bits RGBA format.

The OS default icon is used by default.

Parameters
width | Icon's width, in pixels
height | Icon's height, in pixels
pixels | Pointer to the array of pixels in memory
See Also
setTitle
void sf::Window::setJoystickThreshold ( float threshold )
inherited

Change the joystick threshold.

The joystick threshold is the value below which no JoystickMoved event will be generated.

The threshold value is 0.1 by default.

Parameters
threshold New threshold, in the range [0, 100]
void sf::Window::setKeyRepeatEnabled ( bool enabled )
inherited

Enable or disable automatic key-repeat.

If key repeat is enabled, you will receive repeated KeyPressed events while keeping a key pressed. If it is disabled, you will only get a single event when the key is pressed.

Key repeat is enabled by default.

Parameters
enabled True to enable, false to disable
void sf::Window::setMouseCursorVisible ( bool visible )
inherited

Show or hide the mouse cursor.

The mouse cursor is visible by default.

Parameters
visible True to show the mouse cursor, false to hide it
void sf::Window::setPosition ( const Vector2i & position )
inherited

Change the position of the window on screen.

This function only works for top-level windows (i.e. it will be ignored for windows created from the handle of a child window/control).

Parameters
position New position, in pixels
See Also
getPosition
void sf::Window::setSize ( const Vector2u size )
inherited

Change the size of the rendering region of the window.

Parameters
size New size, in pixels
See Also
getSize
void sf::Window::setTitle ( const String & title )
inherited

Change the title of the window.

Parameters
title New title
See Also
setIcon
void sf::Window::setVerticalSyncEnabled ( bool enabled )
inherited

Enable or disable vertical synchronization.

Activating vertical synchronization will limit the number of frames displayed to the refresh rate of the monitor. This can avoid some visual artifacts, and limit the framerate to a good value (but not constant across different computers).

Vertical synchronization is disabled by default.

Parameters
enabled True to enable v-sync, false to deactivate it
void sf::RenderTarget::setView ( const View & view )
inherited

Change the current active view.

The view is like a 2D camera, it controls which part of the 2D scene is visible, and how it is viewed in the render-target. The new view will affect everything that is drawn, until another view is set. The render target keeps its own copy of the view object, so it is not necessary to keep the original one alive after calling this function. To restore the original view of the target, you can pass the result of getDefaultView() to this function.

Parameters
view New view to use
See Also
getView, getDefaultView
void sf::Window::setVisible ( bool visible )
inherited

Show or hide the window.

The window is shown by default.

Parameters
visible True to show the window, false to hide it
bool sf::Window::waitEvent ( Event & event )
inherited

Wait for an event and return it.

This function is blocking: if there's no pending event then it will wait until an event is received. After this function returns (and no error occured), the event object is always valid and filled properly. This function is typically used when you have a thread that is dedicated to events handling: you want to make this thread sleep as long as no new event is received.

sf::Event event;
if (window.waitEvent(event))
{
// process event...
}
Parameters
event Event to be returned
Returns
False if any error occured
See Also
pollEvent
The documentation for this class was generated from the following file:
  • RenderWindow.hpp


  • sf
  • Shader
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | List of all members
sf::Shader Class Reference
Graphics module

Shader class (vertex and fragment) More...

#include <Shader.hpp>

Inheritance diagram for sf::Shader:
sf::GlResource sf::NonCopyable

Classes

struct CurrentTextureType
Special type/value that can be passed to setParameter, and that represents the texture of the object being drawn. More...

Public Types

enum Type {
Vertex,
Fragment
}
Types of shaders. More...

Public Member Functions

Shader ()
Default constructor.
~Shader ()
Destructor.
bool | loadFromFile (const std::string &filename, Type type)
Load either the vertex or fragment shader from a file.
bool | loadFromFile (const std::string &vertexShaderFilename, const std::string &fragmentShaderFilename)
Load both the vertex and fragment shaders from files.
bool | loadFromMemory (const std::string &shader, Type type)
Load either the vertex or fragment shader from a source code in memory.
bool | loadFromMemory (const std::string &vertexShader, const std::string &fragmentShader)
Load both the vertex and fragment shaders from source codes in memory.
bool | loadFromStream (InputStream &stream, Type type)
Load either the vertex or fragment shader from a custom stream.
bool | loadFromStream (InputStream &vertexShaderStream, InputStream &fragmentShaderStream)
Load both the vertex and fragment shaders from custom streams.
void | setParameter (const std::string &name, float x)
Change a float parameter of the shader.
void | setParameter (const std::string &name, float x, float y)
Change a 2-components vector parameter of the shader.
void | setParameter (const std::string &name, float x, float y, float z)
Change a 3-components vector parameter of the shader.
void | setParameter (const std::string &name, float x, float y, float z, float w)
Change a 4-components vector parameter of the shader.
void | setParameter (const std::string &name, const Vector2f &vector)
Change a 2-components vector parameter of the shader.
void | setParameter (const std::string &name, const Vector3f &vector)
Change a 3-components vector parameter of the shader.
void | setParameter (const std::string &name, const Color &color)
Change a color parameter of the shader.
void | setParameter (const std::string &name, const sf::Transform &transform)
Change a matrix parameter of the shader.
void | setParameter (const std::string &name, const Texture &texture)
Change a texture parameter of the shader.
void | setParameter (const std::string &name, CurrentTextureType)
Change a texture parameter of the shader.

Static Public Member Functions

static void | bind (const Shader *shader)
Bind a shader for rendering.
static bool | isAvailable ()
Tell whether or not the system supports shaders.

Static Public Attributes

static CurrentTextureType CurrentTexture

Static Private Member Functions

static void ensureGlContext ()
Make sure that a valid OpenGL context exists in the current thread.

Detailed Description

Shader class (vertex and fragment)

Shaders are programs written using a specific language, executed directly by the graphics card and allowing to apply real-time operations to the rendered entities.

There are two kinds of shaders:

  • Vertex shaders, that process vertices
  • Fragment (pixel) shaders, that process pixels

A sf::Shader can be composed of either a vertex shader alone, a fragment shader alone, or both combined (see the variants of the load functions).

Shaders are written in GLSL, which is a C-like language dedicated to OpenGL shaders. You'll probably need to learn its basics before writing your own shaders for SFML.

Like any C/C++ program, a shader has its own variables that you can set from your C++ application. sf::Shader handles 5 different types of variables:

  • floats
  • vectors (2, 3 or 4 components)
  • colors
  • textures
  • transforms (matrices)

The value of the variables can be changed at any time with the various overloads of the setParameter function:

shader.setParameter("offset", 2.f);
shader.setParameter("point", 0.5f, 0.8f, 0.3f);
shader.setParameter("color", sf::Color(128, 50, 255));
shader.setParameter("matrix", transform); // transform is a sf::Transform
shader.setParameter("overlay", texture); // texture is a sf::Texture
shader.setParameter("texture", sf::Shader::CurrentTexture);

The special Shader::CurrentTexture argument maps the given texture variable to the current texture of the object being drawn (which cannot be known in advance).

To apply a shader to a drawable, you must pass it as an additional parameter to the Draw function:

window.draw(sprite, &shader);

... which is in fact just a shortcut for this:

sf::RenderStates states;
states.shader = &shader;
window.draw(sprite, states);

In the code above we pass a pointer to the shader, because it may be null (which means "no shader").

Shaders can be used on any drawable, but some combinations are not interesting. For example, using a vertex shader on a sf::Sprite is limited because there are only 4 vertices, the sprite would have to be subdivided in order to apply wave effects. Another bad example is a fragment shader with sf::Text: the texture of the text is not the actual text that you see on screen, it is a big texture containing all the characters of the font in an arbitrary order; thus, texture lookups on pixels other than the current one may not give you the expected result.

Shaders can also be used to apply global post-effects to the current contents of the target (like the old sf::PostFx class in SFML 1). This can be done in two different ways:

  • draw everything to a sf::RenderTexture, then draw it to the main target using the shader
  • draw everything directly to the main target, then use sf::Texture::update(Window&) to copy its contents to a texture and draw it to the main target using the shader

The first technique is more optimized because it doesn't involve retrieving the target's pixels to system memory, but the second one doesn't impact the rendering process and can be easily inserted anywhere without impacting all the code.

Like sf::Texture that can be used as a raw OpenGL texture, sf::Shader can also be used directly as a raw shader for custom OpenGL geometry.

sf::Shader::bind(&shader);
... render OpenGL geometry ...
sf::Shader::bind(NULL);

Definition at line 51 of file Shader.hpp.

Member Enumeration Documentation

enum sf::Shader::Type

Types of shaders.

Enumerator:
Vertex

Vertex shader.

Fragment

Fragment (pixel) shader.

Definition at line 59 of file Shader.hpp.

Constructor & Destructor Documentation

sf::Shader::Shader ( )

Default constructor.

This constructor creates an invalid shader.

sf::Shader::~Shader ( )

Destructor.

Member Function Documentation

static void sf::Shader::bind ( const Shader * shader )
static

Bind a shader for rendering.

This function is not part of the graphics API, it mustn't be used when drawing SFML entities. It must be used only if you mix sf::Shader with OpenGL code.

sf::Shader s1, s2;
...
sf::Shader::bind(&s1);
// draw OpenGL stuff that use s1...
sf::Shader::bind(&s2);
// draw OpenGL stuff that use s2...
sf::Shader::bind(NULL);
// draw OpenGL stuff that use no shader...
Parameters
shader Shader to bind, can be null to use no shader
static bool sf::Shader::isAvailable ( )
static

Tell whether or not the system supports shaders.

This function should always be called before using the shader features. If it returns false, then any attempt to use sf::Shader will fail.

Returns
True if shaders are supported, false otherwise
bool sf::Shader::loadFromFile | ( | const std::string & | filename,
 |  | Type | type
 | ) |  |

Load either the vertex or fragment shader from a file.

This function loads a single shader, either vertex or fragment, identified by the second argument. The source must be a text file containing a valid shader in GLSL language. GLSL is a C-like language dedicated to OpenGL shaders; you'll probably need to read a good documentation for it before writing your own shaders.

Parameters
filename | Path of the vertex or fragment shader file to load
type | Type of shader (vertex or fragment)
Returns
True if loading succeeded, false if it failed
See Also
loadFromMemory, loadFromStream
bool sf::Shader::loadFromFile | ( | const std::string & | vertexShaderFilename,
 |  | const std::string & | fragmentShaderFilename
 | ) |  |

Load both the vertex and fragment shaders from files.

This function loads both the vertex and the fragment shaders. If one of them fails to load, the shader is left empty (the valid shader is unloaded). The sources must be text files containing valid shaders in GLSL language. GLSL is a C-like language dedicated to OpenGL shaders; you'll probably need to read a good documentation for it before writing your own shaders.

Parameters
vertexShaderFilename | Path of the vertex shader file to load
fragmentShaderFilename | Path of the fragment shader file to load
Returns
True if loading succeeded, false if it failed
See Also
loadFromMemory, loadFromStream
bool sf::Shader::loadFromMemory | ( | const std::string & | shader,
 |  | Type | type
 | ) |  |

Load either the vertex or fragment shader from a source code in memory.

This function loads a single shader, either vertex or fragment, identified by the second argument. The source code must be a valid shader in GLSL language. GLSL is a C-like language dedicated to OpenGL shaders; you'll probably need to read a good documentation for it before writing your own shaders.

Parameters
shader | String containing the source code of the shader
type | Type of shader (vertex or fragment)
Returns
True if loading succeeded, false if it failed
See Also
loadFromFile, loadFromStream
bool sf::Shader::loadFromMemory | ( | const std::string & | vertexShader,
 |  | const std::string & | fragmentShader
 | ) |  |

Load both the vertex and fragment shaders from source codes in memory.

This function loads both the vertex and the fragment shaders. If one of them fails to load, the shader is left empty (the valid shader is unloaded). The sources must be valid shaders in GLSL language. GLSL is a C-like language dedicated to OpenGL shaders; you'll probably need to read a good documentation for it before writing your own shaders.

Parameters
vertexShader | String containing the source code of the vertex shader
fragmentShader | String containing the source code of the fragment shader
Returns
True if loading succeeded, false if it failed
See Also
loadFromFile, loadFromStream
bool sf::Shader::loadFromStream | ( | InputStream & | stream,
 |  | Type | type
 | ) |  |

Load either the vertex or fragment shader from a custom stream.

This function loads a single shader, either vertex or fragment, identified by the second argument. The source code must be a valid shader in GLSL language. GLSL is a C-like language dedicated to OpenGL shaders; you'll probably need to read a good documentation for it before writing your own shaders.

Parameters
stream | Source stream to read from
type | Type of shader (vertex or fragment)
Returns
True if loading succeeded, false if it failed
See Also
loadFromFile, loadFromMemory
bool sf::Shader::loadFromStream | ( | InputStream & | vertexShaderStream,
 |  | InputStream & | fragmentShaderStream
 | ) |  |

Load both the vertex and fragment shaders from custom streams.

This function loads both the vertex and the fragment shaders. If one of them fails to load, the shader is left empty (the valid shader is unloaded). The source codes must be valid shaders in GLSL language. GLSL is a C-like language dedicated to OpenGL shaders; you'll probably need to read a good documentation for it before writing your own shaders.

Parameters
vertexShaderStream | Source stream to read the vertex shader from
fragmentShaderStream | Source stream to read the fragment shader from
Returns
True if loading succeeded, false if it failed
See Also
loadFromFile, loadFromMemory
void sf::Shader::setParameter | ( | const std::string & | name,
 |  | float | x
 | ) |  |

Change a float parameter of the shader.

name is the name of the variable to change in the shader. The corresponding parameter in the shader must be a float (float GLSL type).

Example:

uniform float myparam; // this is the variable in the shader
shader.setParameter("myparam", 5.2f);
Parameters
name | Name of the parameter in the shader
x | Value to assign
void sf::Shader::setParameter | ( | const std::string & | name,
 |  | float | x,
 |  | float | y
 | ) |  |

Change a 2-components vector parameter of the shader.

name is the name of the variable to change in the shader. The corresponding parameter in the shader must be a 2x1 vector (vec2 GLSL type).

Example:

uniform vec2 myparam; // this is the variable in the shader
shader.setParameter("myparam", 5.2f, 6.0f);
Parameters
name | Name of the parameter in the shader
x | First component of the value to assign
y | Second component of the value to assign
void sf::Shader::setParameter | ( | const std::string & | name,
 |  | float | x,
 |  | float | y,
 |  | float | z
 | ) |  |

Change a 3-components vector parameter of the shader.

name is the name of the variable to change in the shader. The corresponding parameter in the shader must be a 3x1 vector (vec3 GLSL type).

Example:

uniform vec3 myparam; // this is the variable in the shader
shader.setParameter("myparam", 5.2f, 6.0f, -8.1f);
Parameters
name | Name of the parameter in the shader
x | First component of the value to assign
y | Second component of the value to assign
z | Third component of the value to assign
void sf::Shader::setParameter | ( | const std::string & | name,
 |  | float | x,
 |  | float | y,
 |  | float | z,
 |  | float | w
 | ) |  |

Change a 4-components vector parameter of the shader.

name is the name of the variable to change in the shader. The corresponding parameter in the shader must be a 4x1 vector (vec4 GLSL type).

Example:

uniform vec4 myparam; // this is the variable in the shader
shader.setParameter("myparam", 5.2f, 6.0f, -8.1f, 0.4f);
Parameters
name | Name of the parameter in the shader
x | First component of the value to assign
y | Second component of the value to assign
z | Third component of the value to assign
w | Fourth component of the value to assign
void sf::Shader::setParameter | ( | const std::string & | name,
 |  | const Vector2f & | vector
 | ) |  |

Change a 2-components vector parameter of the shader.

name is the name of the variable to change in the shader. The corresponding parameter in the shader must be a 2x1 vector (vec2 GLSL type).

Example:

uniform vec2 myparam; // this is the variable in the shader
shader.setParameter("myparam", sf::Vector2f(5.2f, 6.0f));
Parameters
name | Name of the parameter in the shader
vector | Vector to assign
void sf::Shader::setParameter | ( | const std::string & | name,
 |  | const Vector3f & | vector
 | ) |  |

Change a 3-components vector parameter of the shader.

name is the name of the variable to change in the shader. The corresponding parameter in the shader must be a 3x1 vector (vec3 GLSL type).

Example:

uniform vec3 myparam; // this is the variable in the shader
shader.setParameter("myparam", sf::Vector3f(5.2f, 6.0f, -8.1f));
Parameters
name | Name of the parameter in the shader
vector | Vector to assign
void sf::Shader::setParameter | ( | const std::string & | name,
 |  | const Color & | color
 | ) |  |

Change a color parameter of the shader.

name is the name of the variable to change in the shader. The corresponding parameter in the shader must be a 4x1 vector (vec4 GLSL type).

It is important to note that the components of the color are normalized before being passed to the shader. Therefore, they are converted from range [0 .. 255] to range [0 .. 1]. For example, a sf::Color(255, 125, 0, 255) will be transformed to a vec4(1.0, 0.5, 0.0, 1.0) in the shader.

Example:

uniform vec4 color; // this is the variable in the shader
shader.setParameter("color", sf::Color(255, 128, 0, 255));
Parameters
name | Name of the parameter in the shader
color | Color to assign
void sf::Shader::setParameter | ( | const std::string & | name,
 |  | const sf::Transform & | transform
 | ) |  |

Change a matrix parameter of the shader.

name is the name of the variable to change in the shader. The corresponding parameter in the shader must be a 4x4 matrix (mat4 GLSL type).

Example:

uniform mat4 matrix; // this is the variable in the shader
sf::Transform transform;
transform.translate(5, 10);
shader.setParameter("matrix", transform);
Parameters
name | Name of the parameter in the shader
transform | Transform to assign
void sf::Shader::setParameter | ( | const std::string & | name,
 |  | const Texture & | texture
 | ) |  |

Change a texture parameter of the shader.

name is the name of the variable to change in the shader. The corresponding parameter in the shader must be a 2D texture (sampler2D GLSL type).

Example:

uniform sampler2D the_texture; // this is the variable in the shader
sf::Texture texture;
...
shader.setParameter("the_texture", texture);

It is important to note that texture must remain alive as long as the shader uses it, no copy is made internally.

To use the texture of the object being draw, which cannot be known in advance, you can pass the special value sf::Shader::CurrentTexture:

shader.setParameter("the_texture", sf::Shader::CurrentTexture).
Parameters
name | Name of the texture in the shader
texture | Texture to assign
void sf::Shader::setParameter | ( | const std::string & | name,
 |  | CurrentTextureType |
 | ) |  |

Change a texture parameter of the shader.

This overload maps a shader texture variable to the texture of the object being drawn, which cannot be known in advance. The second argument must be sf::Shader::CurrentTexture. The corresponding parameter in the shader must be a 2D texture (sampler2D GLSL type).

Example:

uniform sampler2D current; // this is the variable in the shader
shader.setParameter("current", sf::Shader::CurrentTexture);
Parameters
name Name of the texture in the shader
The documentation for this class was generated from the following file:
  • Shader.hpp


  • sf
  • Shape
Public Member Functions | Protected Member Functions | List of all members
sf::Shape Class Referenceabstract
Graphics module

Base class for textured shapes with outline. More...

#include <Shape.hpp>

Inheritance diagram for sf::Shape:
sf::Drawable sf::Transformable sf::CircleShape sf::ConvexShape sf::RectangleShape

Public Member Functions

virtual | ~Shape ()
Virtual destructor.
void | setTexture (const Texture *texture, bool resetRect=false)
Change the source texture of the shape.
void | setTextureRect (const IntRect &rect)
Set the sub-rectangle of the texture that the shape will display.
void | setFillColor (const Color &color)
Set the fill color of the shape.
void | setOutlineColor (const Color &color)
Set the outline color of the shape.
void | setOutlineThickness (float thickness)
Set the thickness of the shape's outline.
const Texture * | getTexture () const
Get the source texture of the shape.
const IntRect & | getTextureRect () const
Get the sub-rectangle of the texture displayed by the shape.
const Color & | getFillColor () const
Get the fill color of the shape.
const Color & | getOutlineColor () const
Get the outline color of the shape.
float | getOutlineThickness () const
Get the outline thickness of the shape.
virtual unsigned int | getPointCount () const =0
Get the total number of points of the shape.
virtual Vector2f | getPoint (unsigned int index) const =0
Get a point of the shape.
FloatRect | getLocalBounds () const
Get the local bounding rectangle of the entity.
FloatRect | getGlobalBounds () const
Get the global bounding rectangle of the entity.
void | setPosition (float x, float y)
set the position of the object
void | setPosition (const Vector2f &position)
set the position of the object
void | setRotation (float angle)
set the orientation of the object
void | setScale (float factorX, float factorY)
set the scale factors of the object
void | setScale (const Vector2f &factors)
set the scale factors of the object
void | setOrigin (float x, float y)
set the local origin of the object
void | setOrigin (const Vector2f &origin)
set the local origin of the object
const Vector2f & | getPosition () const
get the position of the object
float | getRotation () const
get the orientation of the object
const Vector2f & | getScale () const
get the current scale of the object
const Vector2f & | getOrigin () const
get the local origin of the object
void | move (float offsetX, float offsetY)
Move the object by a given offset.
void | move (const Vector2f &offset)
Move the object by a given offset.
void | rotate (float angle)
Rotate the object.
void | scale (float factorX, float factorY)
Scale the object.
void | scale (const Vector2f &factor)
Scale the object.
const Transform & | getTransform () const
get the combined transform of the object
const Transform & | getInverseTransform () const
get the inverse of the combined transform of the object

Protected Member Functions

Shape ()
Default constructor.
void update ()
Recompute the internal geometry of the shape.

Detailed Description

Base class for textured shapes with outline.

sf::Shape is a drawable class that allows to define and display a custom convex shape on a render target.

It's only an abstract base, it needs to be specialized for concrete types of shapes (circle, rectangle, convex polygon, star, ...).

In addition to the attributes provided by the specialized shape classes, a shape always has the following attributes:

  • a texture
  • a texture rectangle
  • a fill color
  • an outline color
  • an outline thickness

Each feature is optional, and can be disabled easily:

  • the texture can be null
  • the fill/outline colors can be sf::Color::Transparent
  • the outline thickness can be zero

You can write your own derived shape class, there are only two virtual functions to override:

  • getPointCount must return the number of points of the shape
  • getPoint must return the points of the shape
See Also
sf::RectangleShape, sf::CircleShape, sf::ConvexShape, sf::Transformable

Definition at line 44 of file Shape.hpp.

Constructor & Destructor Documentation

virtual sf::Shape::~Shape ( )
virtual

Virtual destructor.

sf::Shape::Shape ( )
protected

Default constructor.

Member Function Documentation

const Color& sf::Shape::getFillColor ( ) const

Get the fill color of the shape.

Returns
Fill color of the shape
See Also
setFillColor
FloatRect sf::Shape::getGlobalBounds ( ) const

Get the global bounding rectangle of the entity.

The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the sprite in the global 2D world's coordinate system.

Returns
Global bounding rectangle of the entity
const Transform& sf::Transformable::getInverseTransform ( ) const
inherited

get the inverse of the combined transform of the object

Returns
Inverse of the combined transformations applied to the object
See Also
getTransform
FloatRect sf::Shape::getLocalBounds ( ) const

Get the local bounding rectangle of the entity.

The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.

Returns
Local bounding rectangle of the entity
const Vector2f& sf::Transformable::getOrigin ( ) const
inherited

get the local origin of the object

Returns
Current origin
See Also
setOrigin
const Color& sf::Shape::getOutlineColor ( ) const

Get the outline color of the shape.

Returns
Outline color of the shape
See Also
setOutlineColor
float sf::Shape::getOutlineThickness ( ) const

Get the outline thickness of the shape.

Returns
Outline thickness of the shape
See Also
setOutlineThickness
virtual Vector2f sf::Shape::getPoint ( unsigned int index ) const
pure virtual

Get a point of the shape.

The result is undefined if index is out of the valid range.

Parameters
index Index of the point to get, in range [0 .. getPointCount() - 1]
Returns
Index-th point of the shape
See Also
getPointCount

Implemented in sf::ConvexShape, sf::CircleShape, and sf::RectangleShape.

virtual unsigned int sf::Shape::getPointCount ( ) const
pure virtual

Get the total number of points of the shape.

Returns
Number of points of the shape
See Also
getPoint

Implemented in sf::CircleShape, sf::RectangleShape, and sf::ConvexShape.

const Vector2f& sf::Transformable::getPosition ( ) const
inherited

get the position of the object

Returns
Current position
See Also
setPosition
float sf::Transformable::getRotation ( ) const
inherited

get the orientation of the object

The rotation is always in the range [0, 360].

Returns
Current rotation, in degrees
See Also
setRotation
const Vector2f& sf::Transformable::getScale ( ) const
inherited

get the current scale of the object

Returns
Current scale factors
See Also
setScale
const Texture* sf::Shape::getTexture ( ) const

Get the source texture of the shape.

If the shape has no source texture, a NULL pointer is returned. The returned pointer is const, which means that you can't modify the texture when you retrieve it with this function.

Returns
Pointer to the shape's texture
See Also
setTexture
const IntRect& sf::Shape::getTextureRect ( ) const

Get the sub-rectangle of the texture displayed by the shape.

Returns
Texture rectangle of the shape
See Also
setTextureRect
const Transform& sf::Transformable::getTransform ( ) const
inherited

get the combined transform of the object

Returns
Transform combining the position/rotation/scale/origin of the object
See Also
getInverseTransform
void sf::Transformable::move | ( | float | offsetX,
 |  | float | offsetY
 | ) |  |
inherited

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f pos = object.getPosition();
object.setPosition(pos.x + offsetX, pos.y + offsetY);
Parameters
offsetX | X offset
offsetY | Y offset
See Also
setPosition
void sf::Transformable::move ( const Vector2f & offset )
inherited

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

object.setPosition(object.getPosition() + offset);
Parameters
offset Offset
See Also
setPosition
void sf::Transformable::rotate ( float angle )
inherited

Rotate the object.

This function adds to the current rotation of the object, unlike setRotation which overwrites it. Thus, it is equivalent to the following code:

object.setRotation(object.getRotation() + angle);
Parameters
angle Angle of rotation, in degrees
void sf::Transformable::scale | ( | float | factorX,
 |  | float | factorY
 | ) |  |
inherited

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factorX, scale.y * factorY);
Parameters
factorX | Horizontal scale factor
factorY | Vertical scale factor
See Also
setScale
void sf::Transformable::scale ( const Vector2f & factor )
inherited

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factor.x, scale.y * factor.y);
Parameters
factor Scale factors
See Also
setScale
void sf::Shape::setFillColor ( const Color & color )

Set the fill color of the shape.

This color is modulated (multiplied) with the shape's texture if any. It can be used to colorize the shape, or change its global opacity. You can use sf::Color::Transparent to make the inside of the shape transparent, and have the outline alone. By default, the shape's fill color is opaque white.

Parameters
color New color of the shape
See Also
getFillColor, setOutlineColor
void sf::Transformable::setOrigin | ( | float | x,
 |  | float | y
 | ) |  |
inherited

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
x | X coordinate of the new origin
y | Y coordinate of the new origin
See Also
getOrigin
void sf::Transformable::setOrigin ( const Vector2f & origin )
inherited

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
origin New origin
See Also
getOrigin
void sf::Shape::setOutlineColor ( const Color & color )

Set the outline color of the shape.

By default, the shape's outline color is opaque white.

Parameters
color New outline color of the shape
See Also
getOutlineColor, setFillColor
void sf::Shape::setOutlineThickness ( float thickness )

Set the thickness of the shape's outline.

Note that negative values are allowed (so that the outline expands towards the center of the shape), and using zero disables the outline. By default, the outline thickness is 0.

Parameters
thickness New outline thickness
See Also
getOutlineThickness
void sf::Transformable::setPosition | ( | float | x,
 |  | float | y
 | ) |  |
inherited

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
x | X coordinate of the new position
y | Y coordinate of the new position
See Also
move, getPosition
void sf::Transformable::setPosition ( const Vector2f & position )
inherited

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
position New position
See Also
move, getPosition
void sf::Transformable::setRotation ( float angle )
inherited

set the orientation of the object

This function completely overwrites the previous rotation. See the rotate function to add an angle based on the previous rotation instead. The default rotation of a transformable object is 0.

Parameters
angle New rotation, in degrees
See Also
rotate, getRotation
void sf::Transformable::setScale | ( | float | factorX,
 |  | float | factorY
 | ) |  |
inherited

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factorX | New horizontal scale factor
factorY | New vertical scale factor
See Also
scale, getScale
void sf::Transformable::setScale ( const Vector2f & factors )
inherited

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factors New scale factors
See Also
scale, getScale
void sf::Shape::setTexture | ( | const Texture * | texture,
 |  | bool | resetRect = false
 | ) |  |

Change the source texture of the shape.

The texture argument refers to a texture that must exist as long as the shape uses it. Indeed, the shape doesn't store its own copy of the texture, but rather keeps a pointer to the one that you passed to this function. If the source texture is destroyed and the shape tries to use it, the behaviour is undefined. texture can be NULL to disable texturing. If resetRect is true, the TextureRect property of the shape is automatically adjusted to the size of the new texture. If it is false, the texture rect is left unchanged.

Parameters
texture | New texture
resetRect | Should the texture rect be reset to the size of the new texture?
See Also
getTexture, setTextureRect
void sf::Shape::setTextureRect ( const IntRect & rect )

Set the sub-rectangle of the texture that the shape will display.

The texture rect is useful when you don't want to display the whole texture, but rather a part of it. By default, the texture rect covers the entire texture.

Parameters
rect Rectangle defining the region of the texture to display
See Also
getTextureRect, setTexture
void sf::Shape::update ( )
protected

Recompute the internal geometry of the shape.

This function must be called by the derived class everytime the shape's points change (ie. the result of either getPointCount or getPoint is different).

The documentation for this class was generated from the following file:
  • Shape.hpp


  • sf
  • Sprite
Public Member Functions | List of all members
sf::Sprite Class Reference
Graphics module

Drawable representation of a texture, with its own transformations, color, etc. More...

#include <Sprite.hpp>

Inheritance diagram for sf::Sprite:
sf::Drawable sf::Transformable

Public Member Functions

Sprite ()
Default constructor.
Sprite (const Texture &texture)
Construct the sprite from a source texture.
Sprite (const Texture &texture, const IntRect &rectangle)
Construct the sprite from a sub-rectangle of a source texture.
void | setTexture (const Texture &texture, bool resetRect=false)
Change the source texture of the sprite.
void | setTextureRect (const IntRect &rectangle)
Set the sub-rectangle of the texture that the sprite will display.
void | setColor (const Color &color)
Set the global color of the sprite.
const Texture * | getTexture () const
Get the source texture of the sprite.
const IntRect & | getTextureRect () const
Get the sub-rectangle of the texture displayed by the sprite.
const Color & | getColor () const
Get the global color of the sprite.
FloatRect | getLocalBounds () const
Get the local bounding rectangle of the entity.
FloatRect | getGlobalBounds () const
Get the global bounding rectangle of the entity.
void | setPosition (float x, float y)
set the position of the object
void | setPosition (const Vector2f &position)
set the position of the object
void | setRotation (float angle)
set the orientation of the object
void | setScale (float factorX, float factorY)
set the scale factors of the object
void | setScale (const Vector2f &factors)
set the scale factors of the object
void | setOrigin (float x, float y)
set the local origin of the object
void | setOrigin (const Vector2f &origin)
set the local origin of the object
const Vector2f & | getPosition () const
get the position of the object
float | getRotation () const
get the orientation of the object
const Vector2f & | getScale () const
get the current scale of the object
const Vector2f & | getOrigin () const
get the local origin of the object
void | move (float offsetX, float offsetY)
Move the object by a given offset.
void | move (const Vector2f &offset)
Move the object by a given offset.
void | rotate (float angle)
Rotate the object.
void | scale (float factorX, float factorY)
Scale the object.
void | scale (const Vector2f &factor)
Scale the object.
const Transform & | getTransform () const
get the combined transform of the object
const Transform & | getInverseTransform () const
get the inverse of the combined transform of the object

Detailed Description

Drawable representation of a texture, with its own transformations, color, etc.

sf::Sprite is a drawable class that allows to easily display a texture (or a part of it) on a render target.

It inherits all the functions from sf::Transformable: position, rotation, scale, origin. It also adds sprite-specific properties such as the texture to use, the part of it to display, and some convenience functions to change the overall color of the sprite, or to get its bounding rectangle.

sf::Sprite works in combination with the sf::Texture class, which loads and provides the pixel data of a given texture.

The separation of sf::Sprite and sf::Texture allows more flexibility and better performances: indeed a sf::Texture is a heavy resource, and any operation on it is slow (often too slow for real-time applications). On the other side, a sf::Sprite is a lightweight object which can use the pixel data of a sf::Texture and draw it with its own transformation/color/blending attributes.

It is important to note that the sf::Sprite instance doesn't copy the texture that it uses, it only keeps a reference to it. Thus, a sf::Texture must not be destroyed while it is used by a sf::Sprite (i.e. never write a function that uses a local sf::Texture instance for creating a sprite).

Usage example:

// Declare and load a texture
sf::Texture texture;
texture.loadFromFile("texture.png");
// Create a sprite
sf::Sprite sprite;
sprite.setTexture(texture);
sprite.setTextureRect(sf::IntRect(10, 10, 50, 30));
sprite.setColor(sf::Color(255, 255, 255, 200));
sprite.setPosition(100, 25);
// Draw it
window.draw(sprite);
See Also
sf::Texture, sf::Transformable

Definition at line 47 of file Sprite.hpp.

Constructor & Destructor Documentation

sf::Sprite::Sprite ( )

Default constructor.

Creates an empty sprite with no source texture.

sf::Sprite::Sprite ( const Texture & texture )
explicit

Construct the sprite from a source texture.

Parameters
texture Source texture
See Also
setTexture
sf::Sprite::Sprite | ( | const Texture & | texture,
 |  | const IntRect & | rectangle
 | ) |  |

Construct the sprite from a sub-rectangle of a source texture.

Parameters
texture | Source texture
rectangle | Sub-rectangle of the texture to assign to the sprite
See Also
setTexture, setTextureRect

Member Function Documentation

const Color& sf::Sprite::getColor ( ) const

Get the global color of the sprite.

Returns
Global color of the sprite
See Also
setColor
FloatRect sf::Sprite::getGlobalBounds ( ) const

Get the global bounding rectangle of the entity.

The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the sprite in the global 2D world's coordinate system.

Returns
Global bounding rectangle of the entity
const Transform& sf::Transformable::getInverseTransform ( ) const
inherited

get the inverse of the combined transform of the object

Returns
Inverse of the combined transformations applied to the object
See Also
getTransform
FloatRect sf::Sprite::getLocalBounds ( ) const

Get the local bounding rectangle of the entity.

The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.

Returns
Local bounding rectangle of the entity
const Vector2f& sf::Transformable::getOrigin ( ) const
inherited

get the local origin of the object

Returns
Current origin
See Also
setOrigin
const Vector2f& sf::Transformable::getPosition ( ) const
inherited

get the position of the object

Returns
Current position
See Also
setPosition
float sf::Transformable::getRotation ( ) const
inherited

get the orientation of the object

The rotation is always in the range [0, 360].

Returns
Current rotation, in degrees
See Also
setRotation
const Vector2f& sf::Transformable::getScale ( ) const
inherited

get the current scale of the object

Returns
Current scale factors
See Also
setScale
const Texture* sf::Sprite::getTexture ( ) const

Get the source texture of the sprite.

If the sprite has no source texture, a NULL pointer is returned. The returned pointer is const, which means that you can't modify the texture when you retrieve it with this function.

Returns
Pointer to the sprite's texture
See Also
setTexture
const IntRect& sf::Sprite::getTextureRect ( ) const

Get the sub-rectangle of the texture displayed by the sprite.

Returns
Texture rectangle of the sprite
See Also
setTextureRect
const Transform& sf::Transformable::getTransform ( ) const
inherited

get the combined transform of the object

Returns
Transform combining the position/rotation/scale/origin of the object
See Also
getInverseTransform
void sf::Transformable::move | ( | float | offsetX,
 |  | float | offsetY
 | ) |  |
inherited

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f pos = object.getPosition();
object.setPosition(pos.x + offsetX, pos.y + offsetY);
Parameters
offsetX | X offset
offsetY | Y offset
See Also
setPosition
void sf::Transformable::move ( const Vector2f & offset )
inherited

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

object.setPosition(object.getPosition() + offset);
Parameters
offset Offset
See Also
setPosition
void sf::Transformable::rotate ( float angle )
inherited

Rotate the object.

This function adds to the current rotation of the object, unlike setRotation which overwrites it. Thus, it is equivalent to the following code:

object.setRotation(object.getRotation() + angle);
Parameters
angle Angle of rotation, in degrees
void sf::Transformable::scale | ( | float | factorX,
 |  | float | factorY
 | ) |  |
inherited

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factorX, scale.y * factorY);
Parameters
factorX | Horizontal scale factor
factorY | Vertical scale factor
See Also
setScale
void sf::Transformable::scale ( const Vector2f & factor )
inherited

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factor.x, scale.y * factor.y);
Parameters
factor Scale factors
See Also
setScale
void sf::Sprite::setColor ( const Color & color )

Set the global color of the sprite.

This color is modulated (multiplied) with the sprite's texture. It can be used to colorize the sprite, or change its global opacity. By default, the sprite's color is opaque white.

Parameters
color New color of the sprite
See Also
getColor
void sf::Transformable::setOrigin | ( | float | x,
 |  | float | y
 | ) |  |
inherited

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
x | X coordinate of the new origin
y | Y coordinate of the new origin
See Also
getOrigin
void sf::Transformable::setOrigin ( const Vector2f & origin )
inherited

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
origin New origin
See Also
getOrigin
void sf::Transformable::setPosition | ( | float | x,
 |  | float | y
 | ) |  |
inherited

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
x | X coordinate of the new position
y | Y coordinate of the new position
See Also
move, getPosition
void sf::Transformable::setPosition ( const Vector2f & position )
inherited

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
position New position
See Also
move, getPosition
void sf::Transformable::setRotation ( float angle )
inherited

set the orientation of the object

This function completely overwrites the previous rotation. See the rotate function to add an angle based on the previous rotation instead. The default rotation of a transformable object is 0.

Parameters
angle New rotation, in degrees
See Also
rotate, getRotation
void sf::Transformable::setScale | ( | float | factorX,
 |  | float | factorY
 | ) |  |
inherited

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factorX | New horizontal scale factor
factorY | New vertical scale factor
See Also
scale, getScale
void sf::Transformable::setScale ( const Vector2f & factors )
inherited

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factors New scale factors
See Also
scale, getScale
void sf::Sprite::setTexture | ( | const Texture & | texture,
 |  | bool | resetRect = false
 | ) |  |

Change the source texture of the sprite.

The texture argument refers to a texture that must exist as long as the sprite uses it. Indeed, the sprite doesn't store its own copy of the texture, but rather keeps a pointer to the one that you passed to this function. If the source texture is destroyed and the sprite tries to use it, the behaviour is undefined. If resetRect is true, the TextureRect property of the sprite is automatically adjusted to the size of the new texture. If it is false, the texture rect is left unchanged.

Parameters
texture | New texture
resetRect | Should the texture rect be reset to the size of the new texture?
See Also
getTexture, setTextureRect
void sf::Sprite::setTextureRect ( const IntRect & rectangle )

Set the sub-rectangle of the texture that the sprite will display.

The texture rect is useful when you don't want to display the whole texture, but rather a part of it. By default, the texture rect covers the entire texture.

Parameters
rectangle Rectangle defining the region of the texture to display
See Also
getTextureRect, setTexture
The documentation for this class was generated from the following file:
  • Sprite.hpp


  • sf
  • Text
Public Types | Public Member Functions | List of all members
sf::Text Class Reference
Graphics module

Graphical text that can be drawn to a render target. More...

#include <Text.hpp>

Inheritance diagram for sf::Text:
sf::Drawable sf::Transformable

Public Types

enum Style {
Regular = 0,
Bold = 1 << 0,
Italic = 1 << 1,
Underlined = 1 << 2
}
Enumeration of the string drawing styles. More...

Public Member Functions

Text ()
Default constructor.
Text (const String &string, const Font &font, unsigned int characterSize=30)
Construct the text from a string, font and size.
void | setString (const String &string)
Set the text's string.
void | setFont (const Font &font)
Set the text's font.
void | setCharacterSize (unsigned int size)
Set the character size.
void | setStyle (Uint32 style)
Set the text's style.
void | setColor (const Color &color)
Set the global color of the text.
const String & | getString () const
Get the text's string.
const Font * | getFont () const
Get the text's font.
unsigned int | getCharacterSize () const
Get the character size.
Uint32 | getStyle () const
Get the text's style.
const Color & | getColor () const
Get the global color of the text.
Vector2f | findCharacterPos (std::size_t index) const
Return the position of the index-th character.
FloatRect | getLocalBounds () const
Get the local bounding rectangle of the entity.
FloatRect | getGlobalBounds () const
Get the global bounding rectangle of the entity.
void | setPosition (float x, float y)
set the position of the object
void | setPosition (const Vector2f &position)
set the position of the object
void | setRotation (float angle)
set the orientation of the object
void | setScale (float factorX, float factorY)
set the scale factors of the object
void | setScale (const Vector2f &factors)
set the scale factors of the object
void | setOrigin (float x, float y)
set the local origin of the object
void | setOrigin (const Vector2f &origin)
set the local origin of the object
const Vector2f & | getPosition () const
get the position of the object
float | getRotation () const
get the orientation of the object
const Vector2f & | getScale () const
get the current scale of the object
const Vector2f & | getOrigin () const
get the local origin of the object
void | move (float offsetX, float offsetY)
Move the object by a given offset.
void | move (const Vector2f &offset)
Move the object by a given offset.
void | rotate (float angle)
Rotate the object.
void | scale (float factorX, float factorY)
Scale the object.
void | scale (const Vector2f &factor)
Scale the object.
const Transform & | getTransform () const
get the combined transform of the object
const Transform & | getInverseTransform () const
get the inverse of the combined transform of the object

Detailed Description

Graphical text that can be drawn to a render target.

sf::Text is a drawable class that allows to easily display some text with custom style and color on a render target.

It inherits all the functions from sf::Transformable: position, rotation, scale, origin. It also adds text-specific properties such as the font to use, the character size, the font style (bold, italic, underlined), the global color and the text to display of course. It also provides convenience functions to calculate the graphical size of the text, or to get the global position of a given character.

sf::Text works in combination with the sf::Font class, which loads and provides the glyphs (visual characters) of a given font.

The separation of sf::Font and sf::Text allows more flexibility and better performances: indeed a sf::Font is a heavy resource, and any operation on it is slow (often too slow for real-time applications). On the other side, a sf::Text is a lightweight object which can combine the glyphs data and metrics of a sf::Font to display any text on a render target.

It is important to note that the sf::Text instance doesn't copy the font that it uses, it only keeps a reference to it. Thus, a sf::Font must not be destructed while it is used by a sf::Text (i.e. never write a function that uses a local sf::Font instance for creating a text).

Usage example:

// Declare and load a font
sf::Font font;
font.loadFromFile("arial.ttf");
// Create a text
sf::Text text("hello", font);
text.setCharacterSize(30);
text.setStyle(sf::Text::Bold);
text.setColor(sf::Color::Red);
// Draw it
window.draw(text);
See Also
sf::Font, sf::Transformable

Definition at line 48 of file Text.hpp.

Member Enumeration Documentation

enum sf::Text::Style

Enumeration of the string drawing styles.

Enumerator:
Regular

Regular characters, no style.

Bold

Bold characters.

Italic

Italic characters.

Underlined

Underlined characters.

Definition at line 56 of file Text.hpp.

Constructor & Destructor Documentation

sf::Text::Text ( )

Default constructor.

Creates an empty text.

sf::Text::Text | ( | const String & | string,
 |  | const Font & | font,
 |  | unsigned int | characterSize = 30
 | ) |  |

Construct the text from a string, font and size.

Parameters
string | Text assigned to the string
font | Font used to draw the string
characterSize | Base size of characters, in pixels

Member Function Documentation

Vector2f sf::Text::findCharacterPos ( std::size_t index ) const

Return the position of the index-th character.

This function computes the visual position of a character from its index in the string. The returned position is in global coordinates (translation, rotation, scale and origin are applied). If index is out of range, the position of the end of the string is returned.

Parameters
index Index of the character
Returns
Position of the character
unsigned int sf::Text::getCharacterSize ( ) const

Get the character size.

Returns
Size of the characters, in pixels
See Also
setCharacterSize
const Color& sf::Text::getColor ( ) const

Get the global color of the text.

Returns
Global color of the text
See Also
setColor
const Font* sf::Text::getFont ( ) const

Get the text's font.

If the text has no font attached, a NULL pointer is returned. The returned reference is const, which means that you cannot modify the font when you get it from this function.

Returns
Pointer to the text's font
See Also
setFont
FloatRect sf::Text::getGlobalBounds ( ) const

Get the global bounding rectangle of the entity.

The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the sprite in the global 2D world's coordinate system.

Returns
Global bounding rectangle of the entity
const Transform& sf::Transformable::getInverseTransform ( ) const
inherited

get the inverse of the combined transform of the object

Returns
Inverse of the combined transformations applied to the object
See Also
getTransform
FloatRect sf::Text::getLocalBounds ( ) const

Get the local bounding rectangle of the entity.

The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.

Returns
Local bounding rectangle of the entity
const Vector2f& sf::Transformable::getOrigin ( ) const
inherited

get the local origin of the object

Returns
Current origin
See Also
setOrigin
const Vector2f& sf::Transformable::getPosition ( ) const
inherited

get the position of the object

Returns
Current position
See Also
setPosition
float sf::Transformable::getRotation ( ) const
inherited

get the orientation of the object

The rotation is always in the range [0, 360].

Returns
Current rotation, in degrees
See Also
setRotation
const Vector2f& sf::Transformable::getScale ( ) const
inherited

get the current scale of the object

Returns
Current scale factors
See Also
setScale
const String& sf::Text::getString ( ) const

Get the text's string.

The returned string is a sf::String, which can automatically be converted to standard string types. So, the following lines of code are all valid:

sf::String s1 = text.getString();
std::string s2 = text.getString();
std::wstring s3 = text.getString();
Returns
Text's string
See Also
setString
Uint32 sf::Text::getStyle ( ) const

Get the text's style.

Returns
Text's style
See Also
setStyle
const Transform& sf::Transformable::getTransform ( ) const
inherited

get the combined transform of the object

Returns
Transform combining the position/rotation/scale/origin of the object
See Also
getInverseTransform
void sf::Transformable::move | ( | float | offsetX,
 |  | float | offsetY
 | ) |  |
inherited

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f pos = object.getPosition();
object.setPosition(pos.x + offsetX, pos.y + offsetY);
Parameters
offsetX | X offset
offsetY | Y offset
See Also
setPosition
void sf::Transformable::move ( const Vector2f & offset )
inherited

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

object.setPosition(object.getPosition() + offset);
Parameters
offset Offset
See Also
setPosition
void sf::Transformable::rotate ( float angle )
inherited

Rotate the object.

This function adds to the current rotation of the object, unlike setRotation which overwrites it. Thus, it is equivalent to the following code:

object.setRotation(object.getRotation() + angle);
Parameters
angle Angle of rotation, in degrees
void sf::Transformable::scale | ( | float | factorX,
 |  | float | factorY
 | ) |  |
inherited

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factorX, scale.y * factorY);
Parameters
factorX | Horizontal scale factor
factorY | Vertical scale factor
See Also
setScale
void sf::Transformable::scale ( const Vector2f & factor )
inherited

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factor.x, scale.y * factor.y);
Parameters
factor Scale factors
See Also
setScale
void sf::Text::setCharacterSize ( unsigned int size )

Set the character size.

The default size is 30.

Parameters
size New character size, in pixels
See Also
getCharacterSize
void sf::Text::setColor ( const Color & color )

Set the global color of the text.

By default, the text's color is opaque white.

Parameters
color New color of the text
See Also
getColor
void sf::Text::setFont ( const Font & font )

Set the text's font.

The font argument refers to a font that must exist as long as the text uses it. Indeed, the text doesn't store its own copy of the font, but rather keeps a pointer to the one that you passed to this function. If the font is destroyed and the text tries to use it, the behaviour is undefined.

Parameters
font New font
See Also
getFont
void sf::Transformable::setOrigin | ( | float | x,
 |  | float | y
 | ) |  |
inherited

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
x | X coordinate of the new origin
y | Y coordinate of the new origin
See Also
getOrigin
void sf::Transformable::setOrigin ( const Vector2f & origin )
inherited

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
origin New origin
See Also
getOrigin
void sf::Transformable::setPosition | ( | float | x,
 |  | float | y
 | ) |  |
inherited

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
x | X coordinate of the new position
y | Y coordinate of the new position
See Also
move, getPosition
void sf::Transformable::setPosition ( const Vector2f & position )
inherited

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
position New position
See Also
move, getPosition
void sf::Transformable::setRotation ( float angle )
inherited

set the orientation of the object

This function completely overwrites the previous rotation. See the rotate function to add an angle based on the previous rotation instead. The default rotation of a transformable object is 0.

Parameters
angle New rotation, in degrees
See Also
rotate, getRotation
void sf::Transformable::setScale | ( | float | factorX,
 |  | float | factorY
 | ) |  |
inherited

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factorX | New horizontal scale factor
factorY | New vertical scale factor
See Also
scale, getScale
void sf::Transformable::setScale ( const Vector2f & factors )
inherited

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factors New scale factors
See Also
scale, getScale
void sf::Text::setString ( const String & string )

Set the text's string.

The string argument is a sf::String, which can automatically be constructed from standard string types. So, the following calls are all valid:

text.setString("hello");
text.setString(L"hello");
text.setString(std::string("hello"));
text.setString(std::wstring(L"hello"));

A text's string is empty by default.

Parameters
string New string
See Also
getString
void sf::Text::setStyle ( Uint32 style )

Set the text's style.

You can pass a combination of one or more styles, for example sf::Text::Bold | sf::Text::Italic. The default style is sf::Text::Regular.

Parameters
style New style
See Also
getStyle
The documentation for this class was generated from the following file:
  • Text.hpp


  • sf
  • Texture
Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Friends | List of all members
sf::Texture Class Reference
Graphics module

Image living on the graphics card that can be used for drawing. More...

#include <Texture.hpp>

Inheritance diagram for sf::Texture:
sf::GlResource

Public Types

enum CoordinateType {
Normalized,
Pixels
}
Types of texture coordinates that can be used for rendering. More...

Public Member Functions

Texture ()
Default constructor.
Texture (const Texture &copy)
Copy constructor.
~Texture ()
Destructor.
bool | create (unsigned int width, unsigned int height)
Create the texture.
bool | loadFromFile (const std::string &filename, const IntRect &area=IntRect())
Load the texture from a file on disk.
bool | loadFromMemory (const void *data, std::size_t size, const IntRect &area=IntRect())
Load the texture from a file in memory.
bool | loadFromStream (sf::InputStream &stream, const IntRect &area=IntRect())
Load the texture from a custom stream.
bool | loadFromImage (const Image &image, const IntRect &area=IntRect())
Load the texture from an image.
Vector2u | getSize () const
Return the size of the texture.
Image | copyToImage () const
Copy the texture pixels to an image.
void | update (const Uint8 *pixels)
Update the whole texture from an array of pixels.
void | update (const Uint8 *pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y)
Update a part of the texture from an array of pixels.
void | update (const Image &image)
Update the texture from an image.
void | update (const Image &image, unsigned int x, unsigned int y)
Update a part of the texture from an image.
void | update (const Window &window)
Update the texture from the contents of a window.
void | update (const Window &window, unsigned int x, unsigned int y)
Update a part of the texture from the contents of a window.
void | setSmooth (bool smooth)
Enable or disable the smooth filter.
bool | isSmooth () const
Tell whether the smooth filter is enabled or not.
void | setRepeated (bool repeated)
Enable or disable repeating.
bool | isRepeated () const
Tell whether the texture is repeated or not.
Texture & | operator= (const Texture &right)
Overload of assignment operator.

Static Public Member Functions

static void | bind (const Texture *texture, CoordinateType coordinateType=Normalized)
Bind a texture for rendering.
static unsigned int | getMaximumSize ()
Get the maximum texture size allowed.

Static Private Member Functions

static void ensureGlContext ()
Make sure that a valid OpenGL context exists in the current thread.

Friends

class | RenderTexture
class | RenderTarget

Detailed Description

Image living on the graphics card that can be used for drawing.

sf::Texture stores pixels that can be drawn, with a sprite for example.

A texture lives in the graphics card memory, therefore it is very fast to draw a texture to a render target, or copy a render target to a texture (the graphics card can access both directly).

Being stored in the graphics card memory has some drawbacks. A texture cannot be manipulated as freely as a sf::Image, you need to prepare the pixels first and then upload them to the texture in a single operation (see Texture::update).

sf::Texture makes it easy to convert from/to sf::Image, but keep in mind that these calls require transfers between the graphics card and the central memory, therefore they are slow operations.

A texture can be loaded from an image, but also directly from a file/memory/stream. The necessary shortcuts are defined so that you don't need an image first for the most common cases. However, if you want to perform some modifications on the pixels before creating the final texture, you can load your file to a sf::Image, do whatever you need with the pixels, and then call Texture::loadFromImage.

Since they live in the graphics card memory, the pixels of a texture cannot be accessed without a slow copy first. And they cannot be accessed individually. Therefore, if you need to read the texture's pixels (like for pixel-perfect collisions), it is recommended to store the collision information separately, for example in an array of booleans.

Like sf::Image, sf::Texture can handle a unique internal representation of pixels, which is RGBA 32 bits. This means that a pixel must be composed of 8 bits red, green, blue and alpha channels – just like a sf::Color.

Usage example:

// This example shows the most common use of sf::Texture:
// drawing a sprite
// Load a texture from a file
sf::Texture texture;
if (!texture.loadFromFile("texture.png"))
return -1;
// Assign it to a sprite
sf::Sprite sprite;
sprite.setTexture(texture);
// Draw the textured sprite
window.draw(sprite);
// This example shows another common use of sf::Texture:
// streaming real-time data, like video frames
// Create an empty texture
sf::Texture texture;
if (!texture.create(640, 480))
return -1;
// Create a sprite that will display the texture
sf::Sprite sprite(texture);
while (...) // the main loop
{
...
// update the texture
sf::Uint8* pixels = ...; // get a fresh chunk of pixels (the next frame of a movie, for example)
texture.update(pixels);
// draw it
window.draw(sprite);
...
}

Like sf::Shader that can be used as a raw OpenGL shader, sf::Texture can also be used directly as a raw texture for custom OpenGL geometry.

sf::Texture::bind(&texture);
... render OpenGL geometry ...
sf::Texture::bind(NULL);
See Also
sf::Sprite, sf::Image, sf::RenderTexture

Definition at line 47 of file Texture.hpp.

Member Enumeration Documentation

enum sf::Texture::CoordinateType

Types of texture coordinates that can be used for rendering.

Enumerator:
Normalized

Texture coordinates in range [0 .. 1].

Pixels

Texture coordinates in range [0 .. size].

Definition at line 55 of file Texture.hpp.

Constructor & Destructor Documentation

sf::Texture::Texture ( )

Default constructor.

Creates an empty texture.

sf::Texture::Texture ( const Texture & copy )

Copy constructor.

Parameters
copy instance to copy
sf::Texture::~Texture ( )

Destructor.

Member Function Documentation

static void sf::Texture::bind | ( | const Texture * | texture,
 |  | CoordinateType | coordinateType = Normalized
 | ) |  |
static

Bind a texture for rendering.

This function is not part of the graphics API, it mustn't be used when drawing SFML entities. It must be used only if you mix sf::Texture with OpenGL code.

sf::Texture t1, t2;
...
sf::Texture::bind(&t1);
// draw OpenGL stuff that use t1...
sf::Texture::bind(&t2);
// draw OpenGL stuff that use t2...
sf::Texture::bind(NULL);
// draw OpenGL stuff that use no texture...

The coordinateType argument controls how texture coordinates will be interpreted. If Normalized (the default), they must be in range [0 .. 1], which is the default way of handling texture coordinates with OpenGL. If Pixels, they must be given in pixels (range [0 .. size]). This mode is used internally by the graphics classes of SFML, it makes the definition of texture coordinates more intuitive for the high-level API, users don't need to compute normalized values.

Parameters
texture | Pointer to the texture to bind, can be null to use no texture
coordinateType | Type of texture coordinates to use
Image sf::Texture::copyToImage ( ) const

Copy the texture pixels to an image.

This function performs a slow operation that downloads the texture's pixels from the graphics card and copies them to a new image, potentially applying transformations to pixels if necessary (texture may be padded or flipped).

Returns
Image containing the texture's pixels
See Also
loadFromImage
bool sf::Texture::create | ( | unsigned int | width,
 |  | unsigned int | height
 | ) |  |

Create the texture.

If this function fails, the texture is left unchanged.

Parameters
width | Width of the texture
height | Height of the texture
Returns
True if creation was successful
static unsigned int sf::Texture::getMaximumSize ( )
static

Get the maximum texture size allowed.

This maximum size is defined by the graphics driver. You can expect a value of 512 pixels for low-end graphics card, and up to 8192 pixels or more for newer hardware.

Returns
Maximum size allowed for textures, in pixels
Vector2u sf::Texture::getSize ( ) const

Return the size of the texture.

Returns
Size in pixels
bool sf::Texture::isRepeated ( ) const

Tell whether the texture is repeated or not.

Returns
True if repeat mode is enabled, false if it is disabled
See Also
setRepeated
bool sf::Texture::isSmooth ( ) const

Tell whether the smooth filter is enabled or not.

Returns
True if smoothing is enabled, false if it is disabled
See Also
setSmooth
bool sf::Texture::loadFromFile | ( | const std::string & | filename,
 |  | const IntRect & | area = IntRect()
 | ) |  |

Load the texture from a file on disk.

This function is a shortcut for the following code:

sf::Image image;
image.loadFromFile(filename);
texture.loadFromImage(image, area);

The area argument can be used to load only a sub-rectangle of the whole image. If you want the entire image then leave the default value (which is an empty IntRect). If the area rectangle crosses the bounds of the image, it is adjusted to fit the image size.

The maximum size for a texture depends on the graphics driver and can be retrieved with the getMaximumSize function.

If this function fails, the texture is left unchanged.

Parameters
filename | Path of the image file to load
area | Area of the image to load
Returns
True if loading was successful
See Also
loadFromMemory, loadFromStream, loadFromImage
bool sf::Texture::loadFromImage | ( | const Image & | image,
 |  | const IntRect & | area = IntRect()
 | ) |  |

Load the texture from an image.

The area argument can be used to load only a sub-rectangle of the whole image. If you want the entire image then leave the default value (which is an empty IntRect). If the area rectangle crosses the bounds of the image, it is adjusted to fit the image size.

The maximum size for a texture depends on the graphics driver and can be retrieved with the getMaximumSize function.

If this function fails, the texture is left unchanged.

Parameters
image | Image to load into the texture
area | Area of the image to load
Returns
True if loading was successful
See Also
loadFromFile, loadFromMemory
bool sf::Texture::loadFromMemory | ( | const void * | data,
 |  | std::size_t | size,
 |  | const IntRect & | area = IntRect()
 | ) |  |

Load the texture from a file in memory.

This function is a shortcut for the following code:

sf::Image image;
image.loadFromMemory(data, size);
texture.loadFromImage(image, area);

The area argument can be used to load only a sub-rectangle of the whole image. If you want the entire image then leave the default value (which is an empty IntRect). If the area rectangle crosses the bounds of the image, it is adjusted to fit the image size.

The maximum size for a texture depends on the graphics driver and can be retrieved with the getMaximumSize function.

If this function fails, the texture is left unchanged.

Parameters
data | Pointer to the file data in memory
size | Size of the data to load, in bytes
area | Area of the image to load
Returns
True if loading was successful
See Also
loadFromFile, loadFromStream, loadFromImage
bool sf::Texture::loadFromStream | ( | sf::InputStream & | stream,
 |  | const IntRect & | area = IntRect()
 | ) |  |

Load the texture from a custom stream.

This function is a shortcut for the following code:

sf::Image image;
image.loadFromStream(stream);
texture.loadFromImage(image, area);

The area argument can be used to load only a sub-rectangle of the whole image. If you want the entire image then leave the default value (which is an empty IntRect). If the area rectangle crosses the bounds of the image, it is adjusted to fit the image size.

The maximum size for a texture depends on the graphics driver and can be retrieved with the getMaximumSize function.

If this function fails, the texture is left unchanged.

Parameters
stream | Source stream to read from
area | Area of the image to load
Returns
True if loading was successful
See Also
loadFromFile, loadFromMemory, loadFromImage
Texture& sf::Texture::operator= ( const Texture & right )

Overload of assignment operator.

Parameters
right Instance to assign
Returns
Reference to self
void sf::Texture::setRepeated ( bool repeated )

Enable or disable repeating.

Repeating is involved when using texture coordinates outside the texture rectangle [0, 0, width, height]. In this case, if repeat mode is enabled, the whole texture will be repeated as many times as needed to reach the coordinate (for example, if the X texture coordinate is 3 * width, the texture will be repeated 3 times). If repeat mode is disabled, the "extra space" will instead be filled with border pixels. Warning: on very old graphics cards, white pixels may appear when the texture is repeated. With such cards, repeat mode can be used reliably only if the texture has power-of-two dimensions (such as 256x128). Repeating is disabled by default.

Parameters
repeated True to repeat the texture, false to disable repeating
See Also
isRepeated
void sf::Texture::setSmooth ( bool smooth )

Enable or disable the smooth filter.

When the filter is activated, the texture appears smoother so that pixels are less noticeable. However if you want the texture to look exactly the same as its source file, you should leave it disabled. The smooth filter is disabled by default.

Parameters
smooth True to enable smoothing, false to disable it
See Also
isSmooth
void sf::Texture::update ( const Uint8 * pixels )

Update the whole texture from an array of pixels.

The pixel array is assumed to have the same size as the area rectangle, and to contain 32-bits RGBA pixels.

No additional check is performed on the size of the pixel array, passing invalid arguments will lead to an undefined behaviour.

This function does nothing if pixels is null or if the texture was not previously created.

Parameters
pixels Array of pixels to copy to the texture
void sf::Texture::update | ( | const Uint8 * | pixels,
 |  | unsigned int | width,
 |  | unsigned int | height,
 |  | unsigned int | x,
 |  | unsigned int | y
 | ) |  |

Update a part of the texture from an array of pixels.

The size of the pixel array must match the width and height arguments, and it must contain 32-bits RGBA pixels.

No additional check is performed on the size of the pixel array or the bounds of the area to update, passing invalid arguments will lead to an undefined behaviour.

This function does nothing if pixels is null or if the texture was not previously created.

Parameters
pixels | Array of pixels to copy to the texture
width | Width of the pixel region contained in pixels
height | Height of the pixel region contained in pixels
x | X offset in the texture where to copy the source pixels
y | Y offset in the texture where to copy the source pixels
void sf::Texture::update ( const Image & image )

Update the texture from an image.

Although the source image can be smaller than the texture, this function is usually used for updating the whole texture. The other overload, which has (x, y) additional arguments, is more convenient for updating a sub-area of the texture.

No additional check is performed on the size of the image, passing an image bigger than the texture will lead to an undefined behaviour.

This function does nothing if the texture was not previously created.

Parameters
image Image to copy to the texture
void sf::Texture::update | ( | const Image & | image,
 |  | unsigned int | x,
 |  | unsigned int | y
 | ) |  |

Update a part of the texture from an image.

No additional check is performed on the size of the image, passing an invalid combination of image size and offset will lead to an undefined behaviour.

This function does nothing if the texture was not previously created.

Parameters
image | Image to copy to the texture
x | X offset in the texture where to copy the source image
y | Y offset in the texture where to copy the source image
void sf::Texture::update ( const Window & window )

Update the texture from the contents of a window.

Although the source window can be smaller than the texture, this function is usually used for updating the whole texture. The other overload, which has (x, y) additional arguments, is more convenient for updating a sub-area of the texture.

No additional check is performed on the size of the window, passing a window bigger than the texture will lead to an undefined behaviour.

This function does nothing if either the texture or the window was not previously created.

Parameters
window Window to copy to the texture
void sf::Texture::update | ( | const Window & | window,
 |  | unsigned int | x,
 |  | unsigned int | y
 | ) |  |

Update a part of the texture from the contents of a window.

No additional check is performed on the size of the window, passing an invalid combination of window size and offset will lead to an undefined behaviour.

This function does nothing if either the texture or the window was not previously created.

Parameters
window | Window to copy to the texture
x | X offset in the texture where to copy the source window
y | Y offset in the texture where to copy the source window
The documentation for this class was generated from the following file:
  • Texture.hpp


  • sf
  • Transform
Public Member Functions | Static Public Attributes | Related Functions | List of all members
sf::Transform Class Reference
Graphics module

Define a 3x3 transform matrix. More...

#include <Transform.hpp>

Public Member Functions

Transform ()
Default constructor.
Transform (float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22)
Construct a transform from a 3x3 matrix.
const float * | getMatrix () const
Return the transform as a 4x4 matrix.
Transform | getInverse () const
Return the inverse of the transform.
Vector2f | transformPoint (float x, float y) const
Transform a 2D point.
Vector2f | transformPoint (const Vector2f &point) const
Transform a 2D point.
FloatRect | transformRect (const FloatRect &rectangle) const
Transform a rectangle.
Transform & | combine (const Transform &transform)
Combine the current transform with another one.
Transform & | translate (float x, float y)
Combine the current transform with a translation.
Transform & | translate (const Vector2f &offset)
Combine the current transform with a translation.
Transform & | rotate (float angle)
Combine the current transform with a rotation.
Transform & | rotate (float angle, float centerX, float centerY)
Combine the current transform with a rotation.
Transform & | rotate (float angle, const Vector2f &center)
Combine the current transform with a rotation.
Transform & | scale (float scaleX, float scaleY)
Combine the current transform with a scaling.
Transform & | scale (float scaleX, float scaleY, float centerX, float centerY)
Combine the current transform with a scaling.
Transform & | scale (const Vector2f &factors)
Combine the current transform with a scaling.
Transform & | scale (const Vector2f &factors, const Vector2f &center)
Combine the current transform with a scaling.

Static Public Attributes

static const Transform Identity
The identity transform (does nothing)

Related Functions

(Note that these are not member functions.)

Transform | operator* (const Transform &left, const Transform &right)
Overload of binary operator * to combine two transforms.
Transform & | operator*= (Transform &left, const Transform &right)
Overload of binary operator *= to combine two transforms.
Vector2f | operator* (const Transform &left, const Vector2f &right)
Overload of binary operator * to transform a point.

Detailed Description

Define a 3x3 transform matrix.

A sf::Transform specifies how to translate, rotate, scale, shear, project, whatever things.

In mathematical terms, it defines how to transform a coordinate system into another.

For example, if you apply a rotation transform to a sprite, the result will be a rotated sprite. And anything that is transformed by this rotation transform will be rotated the same way, according to its initial position.

Transforms are typically used for drawing. But they can also be used for any computation that requires to transform points between the local and global coordinate systems of an entity (like collision detection).

Example:

// define a translation transform
sf::Transform translation;
translation.translate(20, 50);
// define a rotation transform
sf::Transform rotation;
rotation.rotate(45);
// combine them
sf::Transform transform = translation * rotation;
// use the result to transform stuff...
sf::Vector2f point = transform.transformPoint(10, 20);
sf::FloatRect rect = transform.transformRect(sf::FloatRect(0, 0, 10, 100));
See Also
sf::Transformable, sf::RenderStates

Definition at line 42 of file Transform.hpp.

Constructor & Destructor Documentation

sf::Transform::Transform ( )

Default constructor.

Creates an identity transform (a transform that does nothing).

sf::Transform::Transform | ( | float | a00,
 |  | float | a01,
 |  | float | a02,
 |  | float | a10,
 |  | float | a11,
 |  | float | a12,
 |  | float | a20,
 |  | float | a21,
 |  | float | a22
 | ) |  |

Construct a transform from a 3x3 matrix.

Parameters
a00 | Element (0, 0) of the matrix
a01 | Element (0, 1) of the matrix
a02 | Element (0, 2) of the matrix
a10 | Element (1, 0) of the matrix
a11 | Element (1, 1) of the matrix
a12 | Element (1, 2) of the matrix
a20 | Element (2, 0) of the matrix
a21 | Element (2, 1) of the matrix
a22 | Element (2, 2) of the matrix

Member Function Documentation

Transform& sf::Transform::combine ( const Transform & transform )

Combine the current transform with another one.

The result is a transform that is equivalent to applying *this followed by transform. Mathematically, it is equivalent to a matrix multiplication.

Parameters
transform Transform to combine with this transform
Returns
Reference to *this
Transform sf::Transform::getInverse ( ) const

Return the inverse of the transform.

If the inverse cannot be computed, an identity transform is returned.

Returns
A new transform which is the inverse of self
const float* sf::Transform::getMatrix ( ) const

Return the transform as a 4x4 matrix.

This function returns a pointer to an array of 16 floats containing the transform elements as a 4x4 matrix, which is directly compatible with OpenGL functions.

sf::Transform transform = ...;
glLoadMatrixf(transform.getMatrix());
Returns
Pointer to a 4x4 matrix
Transform& sf::Transform::rotate ( float angle )

Combine the current transform with a rotation.

This function returns a reference to *this, so that calls can be chained.

sf::Transform transform;
transform.rotate(90).translate(50, 20);
Parameters
angle Rotation angle, in degrees
Returns
Reference to *this
See Also
translate, scale
Transform& sf::Transform::rotate | ( | float | angle,
 |  | float | centerX,
 |  | float | centerY
 | ) |  |

Combine the current transform with a rotation.

The center of rotation is provided for convenience as a second argument, so that you can build rotations around arbitrary points more easily (and efficiently) than the usual translate(-center).rotate(angle).translate(center).

This function returns a reference to *this, so that calls can be chained.

sf::Transform transform;
transform.rotate(90, 8, 3).translate(50, 20);
Parameters
angle | Rotation angle, in degrees
centerX | X coordinate of the center of rotation
centerY | Y coordinate of the center of rotation
Returns
Reference to *this
See Also
translate, scale
Transform& sf::Transform::rotate | ( | float | angle,
 |  | const Vector2f & | center
 | ) |  |

Combine the current transform with a rotation.

The center of rotation is provided for convenience as a second argument, so that you can build rotations around arbitrary points more easily (and efficiently) than the usual translate(-center).rotate(angle).translate(center).

This function returns a reference to *this, so that calls can be chained.

sf::Transform transform;
transform.rotate(90, sf::Vector2f(8, 3)).translate(sf::Vector2f(50, 20));
Parameters
angle | Rotation angle, in degrees
center | Center of rotation
Returns
Reference to *this
See Also
translate, scale
Transform& sf::Transform::scale | ( | float | scaleX,
 |  | float | scaleY
 | ) |  |

Combine the current transform with a scaling.

This function returns a reference to *this, so that calls can be chained.

sf::Transform transform;
transform.scale(2, 1).rotate(45);
Parameters
scaleX | Scaling factor on the X axis
scaleY | Scaling factor on the Y axis
Returns
Reference to *this
See Also
translate, rotate
Transform& sf::Transform::scale | ( | float | scaleX,
 |  | float | scaleY,
 |  | float | centerX,
 |  | float | centerY
 | ) |  |

Combine the current transform with a scaling.

The center of scaling is provided for convenience as a second argument, so that you can build scaling around arbitrary points more easily (and efficiently) than the usual translate(-center).scale(factors).translate(center).

This function returns a reference to *this, so that calls can be chained.

sf::Transform transform;
transform.scale(2, 1, 8, 3).rotate(45);
Parameters
scaleX | Scaling factor on X axis
scaleY | Scaling factor on Y axis
centerX | X coordinate of the center of scaling
centerY | Y coordinate of the center of scaling
Returns
Reference to *this
See Also
translate, rotate
Transform& sf::Transform::scale ( const Vector2f & factors )

Combine the current transform with a scaling.

This function returns a reference to *this, so that calls can be chained.

sf::Transform transform;
transform.scale(sf::Vector2f(2, 1)).rotate(45);
Parameters
factors Scaling factors
Returns
Reference to *this
See Also
translate, rotate
Transform& sf::Transform::scale | ( | const Vector2f & | factors,
 |  | const Vector2f & | center
 | ) |  |

Combine the current transform with a scaling.

The center of scaling is provided for convenience as a second argument, so that you can build scaling around arbitrary points more easily (and efficiently) than the usual translate(-center).scale(factors).translate(center).

This function returns a reference to *this, so that calls can be chained.

sf::Transform transform;
transform.scale(sf::Vector2f(2, 1), sf::Vector2f(8, 3)).rotate(45);
Parameters
factors | Scaling factors
center | Center of scaling
Returns
Reference to *this
See Also
translate, rotate
Vector2f sf::Transform::transformPoint | ( | float | x,
 |  | float | y
 | ) |  | const

Transform a 2D point.

Parameters
x | X coordinate of the point to transform
y | Y coordinate of the point to transform
Returns
Transformed point
Vector2f sf::Transform::transformPoint ( const Vector2f & point ) const

Transform a 2D point.

Parameters
point Point to transform
Returns
Transformed point
FloatRect sf::Transform::transformRect ( const FloatRect & rectangle ) const

Transform a rectangle.

Since SFML doesn't provide support for oriented rectangles, the result of this function is always an axis-aligned rectangle. Which means that if the transform contains a rotation, the bounding rectangle of the transformed rectangle is returned.

Parameters
rectangle Rectangle to transform
Returns
Transformed rectangle
Transform& sf::Transform::translate | ( | float | x,
 |  | float | y
 | ) |  |

Combine the current transform with a translation.

This function returns a reference to *this, so that calls can be chained.

sf::Transform transform;
transform.translate(100, 200).rotate(45);
Parameters
x | Offset to apply on X axis
y | Offset to apply on Y axis
Returns
Reference to *this
See Also
rotate, scale
Transform& sf::Transform::translate ( const Vector2f & offset )

Combine the current transform with a translation.

This function returns a reference to *this, so that calls can be chained.

sf::Transform transform;
transform.translate(sf::Vector2f(100, 200)).rotate(45);
Parameters
offset Translation offset to apply
Returns
Reference to *this
See Also
rotate, scale

Friends And Related Function Documentation

Transform operator* | ( | const Transform & | left,
 |  | const Transform & | right
 | ) |  |
related

Overload of binary operator * to combine two transforms.

This call is equivalent to calling Transform(left).combine(right).

Parameters
left | Left operand (the first transform)
right | Right operand (the second transform)
Returns
New combined transform
Vector2f operator* | ( | const Transform & | left,
 |  | const Vector2f & | right
 | ) |  |
related

Overload of binary operator * to transform a point.

This call is equivalent to calling left.transformPoint(right).

Parameters
left | Left operand (the transform)
right | Right operand (the point to transform)
Returns
New transformed point
Transform & operator*= | ( | Transform & | left,
 |  | const Transform & | right
 | ) |  |
related

Overload of binary operator *= to combine two transforms.

This call is equivalent to calling left.combine(right).

Parameters
left | Left operand (the first transform)
right | Right operand (the second transform)
Returns
The combined transform

Member Data Documentation

const Transform sf::Transform::Identity
static

The identity transform (does nothing)

Definition at line 354 of file Transform.hpp.

The documentation for this class was generated from the following file:
  • Transform.hpp


  • sf
  • Transformable
Public Member Functions | List of all members
sf::Transformable Class Reference
Graphics module

Decomposed transform defined by a position, a rotation and a scale. More...

#include <Transformable.hpp>

Inheritance diagram for sf::Transformable:
sf::Shape sf::Sprite sf::Text sf::CircleShape sf::ConvexShape sf::RectangleShape

Public Member Functions

Transformable ()
Default constructor.
virtual | ~Transformable ()
Virtual destructor.
void | setPosition (float x, float y)
set the position of the object
void | setPosition (const Vector2f &position)
set the position of the object
void | setRotation (float angle)
set the orientation of the object
void | setScale (float factorX, float factorY)
set the scale factors of the object
void | setScale (const Vector2f &factors)
set the scale factors of the object
void | setOrigin (float x, float y)
set the local origin of the object
void | setOrigin (const Vector2f &origin)
set the local origin of the object
const Vector2f & | getPosition () const
get the position of the object
float | getRotation () const
get the orientation of the object
const Vector2f & | getScale () const
get the current scale of the object
const Vector2f & | getOrigin () const
get the local origin of the object
void | move (float offsetX, float offsetY)
Move the object by a given offset.
void | move (const Vector2f &offset)
Move the object by a given offset.
void | rotate (float angle)
Rotate the object.
void | scale (float factorX, float factorY)
Scale the object.
void | scale (const Vector2f &factor)
Scale the object.
const Transform & | getTransform () const
get the combined transform of the object
const Transform & | getInverseTransform () const
get the inverse of the combined transform of the object

Detailed Description

Decomposed transform defined by a position, a rotation and a scale.

This class is provided for convenience, on top of sf::Transform.

sf::Transform, as a low-level class, offers a great level of flexibility but it is not always convenient to manage. Indeed, one can easily combine any kind of operation, such as a translation followed by a rotation followed by a scaling, but once the result transform is built, there's no way to go backward and, let's say, change only the rotation without modifying the translation and scaling. The entire transform must be recomputed, which means that you need to retrieve the initial translation and scale factors as well, and combine them the same way you did before updating the rotation. This is a tedious operation, and it requires to store all the individual components of the final transform.

That's exactly what sf::Transformable was written for: it hides these variables and the composed transform behind an easy to use interface. You can set or get any of the individual components without worrying about the others. It also provides the composed transform (as a sf::Transform), and keeps it up-to-date.

In addition to the position, rotation and scale, sf::Transformable provides an "origin" component, which represents the local origin of the three other components. Let's take an example with a 10x10 pixels sprite. By default, the sprite is positioned/rotated/scaled relatively to its top-left corner, because it is the local point (0, 0). But if we change the origin to be (5, 5), the sprite will be positioned/rotated/scaled around its center instead. And if we set the origin to (10, 10), it will be transformed around its bottom-right corner.

To keep the sf::Transformable class simple, there's only one origin for all the components. You cannot position the sprite relatively to its top-left corner while rotating it around its center, for example. To do such things, use sf::Transform directly.

sf::Transformable can be used as a base class. It is often combined with sf::Drawable – that's what SFML's sprites, texts and shapes do.

class MyEntity : public sf::Transformable, public sf::Drawable
{
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.transform *= getTransform();
target.draw(..., states);
}
};
MyEntity entity;
entity.setPosition(10, 20);
entity.setRotation(45);
window.draw(entity);

It can also be used as a member, if you don't want to use its API directly (because you don't need all its functions, or you have different naming conventions for example).

class MyEntity
{
public :
void SetPosition(const MyVector& v)
{
myTransform.setPosition(v.x(), v.y());
}
void Draw(sf::RenderTarget& target) const
{
target.draw(..., myTransform.getTransform());
}
private :
sf::Transformable myTransform;
};
See Also
sf::Transform

Definition at line 41 of file Transformable.hpp.

Constructor & Destructor Documentation

sf::Transformable::Transformable ( )

Default constructor.

virtual sf::Transformable::~Transformable ( )
virtual

Virtual destructor.

Member Function Documentation

const Transform& sf::Transformable::getInverseTransform ( ) const

get the inverse of the combined transform of the object

Returns
Inverse of the combined transformations applied to the object
See Also
getTransform
const Vector2f& sf::Transformable::getOrigin ( ) const

get the local origin of the object

Returns
Current origin
See Also
setOrigin
const Vector2f& sf::Transformable::getPosition ( ) const

get the position of the object

Returns
Current position
See Also
setPosition
float sf::Transformable::getRotation ( ) const

get the orientation of the object

The rotation is always in the range [0, 360].

Returns
Current rotation, in degrees
See Also
setRotation
const Vector2f& sf::Transformable::getScale ( ) const

get the current scale of the object

Returns
Current scale factors
See Also
setScale
const Transform& sf::Transformable::getTransform ( ) const

get the combined transform of the object

Returns
Transform combining the position/rotation/scale/origin of the object
See Also
getInverseTransform
void sf::Transformable::move | ( | float | offsetX,
 |  | float | offsetY
 | ) |  |

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f pos = object.getPosition();
object.setPosition(pos.x + offsetX, pos.y + offsetY);
Parameters
offsetX | X offset
offsetY | Y offset
See Also
setPosition
void sf::Transformable::move ( const Vector2f & offset )

Move the object by a given offset.

This function adds to the current position of the object, unlike setPosition which overwrites it. Thus, it is equivalent to the following code:

object.setPosition(object.getPosition() + offset);
Parameters
offset Offset
See Also
setPosition
void sf::Transformable::rotate ( float angle )

Rotate the object.

This function adds to the current rotation of the object, unlike setRotation which overwrites it. Thus, it is equivalent to the following code:

object.setRotation(object.getRotation() + angle);
Parameters
angle Angle of rotation, in degrees
void sf::Transformable::scale | ( | float | factorX,
 |  | float | factorY
 | ) |  |

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factorX, scale.y * factorY);
Parameters
factorX | Horizontal scale factor
factorY | Vertical scale factor
See Also
setScale
void sf::Transformable::scale ( const Vector2f & factor )

Scale the object.

This function multiplies the current scale of the object, unlike setScale which overwrites it. Thus, it is equivalent to the following code:

sf::Vector2f scale = object.getScale();
object.setScale(scale.x * factor.x, scale.y * factor.y);
Parameters
factor Scale factors
See Also
setScale
void sf::Transformable::setOrigin | ( | float | x,
 |  | float | y
 | ) |  |

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
x | X coordinate of the new origin
y | Y coordinate of the new origin
See Also
getOrigin
void sf::Transformable::setOrigin ( const Vector2f & origin )

set the local origin of the object

The origin of an object defines the center point for all transformations (position, scale, rotation). The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation). The default origin of a transformable object is (0, 0).

Parameters
origin New origin
See Also
getOrigin
void sf::Transformable::setPosition | ( | float | x,
 |  | float | y
 | ) |  |

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
x | X coordinate of the new position
y | Y coordinate of the new position
See Also
move, getPosition
void sf::Transformable::setPosition ( const Vector2f & position )

set the position of the object

This function completely overwrites the previous position. See the move function to apply an offset based on the previous position instead. The default position of a transformable object is (0, 0).

Parameters
position New position
See Also
move, getPosition
void sf::Transformable::setRotation ( float angle )

set the orientation of the object

This function completely overwrites the previous rotation. See the rotate function to add an angle based on the previous rotation instead. The default rotation of a transformable object is 0.

Parameters
angle New rotation, in degrees
See Also
rotate, getRotation
void sf::Transformable::setScale | ( | float | factorX,
 |  | float | factorY
 | ) |  |

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factorX | New horizontal scale factor
factorY | New vertical scale factor
See Also
scale, getScale
void sf::Transformable::setScale ( const Vector2f & factors )

set the scale factors of the object

This function completely overwrites the previous scale. See the scale function to add a factor based on the previous scale instead. The default scale of a transformable object is (1, 1).

Parameters
factors New scale factors
See Also
scale, getScale
The documentation for this class was generated from the following file:
  • Transformable.hpp


  • sf
  • Vertex
Public Member Functions | Public Attributes | List of all members
sf::Vertex Class Reference
Graphics module

Define a point with color and texture coordinates. More...

#include <Vertex.hpp>

Public Member Functions

Vertex ()
Default constructor.
Vertex (const Vector2f &thePosition)
Construct the vertex from its position.
Vertex (const Vector2f &thePosition, const Color &theColor)
Construct the vertex from its position and color.
Vertex (const Vector2f &thePosition, const Vector2f &theTexCoords)
Construct the vertex from its position and texture coordinates.
Vertex (const Vector2f &thePosition, const Color &theColor, const Vector2f &theTexCoords)
Construct the vertex from its position, color and texture coordinates.

Public Attributes

Vector2f position
2D position of the vertex
Color color
Color of the vertex.
Vector2f texCoords
Coordinates of the texture's pixel to map to the vertex.

Detailed Description

Define a point with color and texture coordinates.

A vertex is an improved point.

It has a position and other extra attributes that will be used for drawing: in SFML, vertices also have a color and a pair of texture coordinates.

The vertex is the building block of drawing. Everything which is visible on screen is made of vertices. They are grouped as 2D primitives (triangles, quads, ...), and these primitives are grouped to create even more complex 2D entities such as sprites, texts, etc.

If you use the graphical entities of SFML (sprite, text, shape) you won't have to deal with vertices directly. But if you want to define your own 2D entities, such as tiled maps or particle systems, using vertices will allow you to get maximum performances.

Example:

// define a 100x100 square, red, with a 10x10 texture mapped on it
sf::Vertex vertices[] =
{
sf::Vertex(sf::Vector2f( 0, 0), sf::Color::Red, sf::Vector2f( 0, 0)),
sf::Vertex(sf::Vector2f( 0, 100), sf::Color::Red, sf::Vector2f( 0, 10)),
sf::Vertex(sf::Vector2f(100, 100), sf::Color::Red, sf::Vector2f(10, 10)),
sf::Vertex(sf::Vector2f(100, 0), sf::Color::Red, sf::Vector2f(10, 0))
};
// draw it
window.draw(vertices, 4, sf::Quads);

Note: although texture coordinates are supposed to be an integer amount of pixels, their type is float because of some buggy graphics drivers that are not able to process integer coordinates correctly.

See Also
sf::VertexArray

Definition at line 42 of file Vertex.hpp.

Constructor & Destructor Documentation

sf::Vertex::Vertex ( )

Default constructor.

sf::Vertex::Vertex ( const Vector2f & thePosition )

Construct the vertex from its position.

The vertex color is white and texture coordinates are (0, 0).

Parameters
thePosition Vertex position
sf::Vertex::Vertex | ( | const Vector2f & | thePosition,
 |  | const Color & | theColor
 | ) |  |

Construct the vertex from its position and color.

The texture coordinates are (0, 0).

Parameters
thePosition | Vertex position
theColor | Vertex color
sf::Vertex::Vertex | ( | const Vector2f & | thePosition,
 |  | const Vector2f & | theTexCoords
 | ) |  |

Construct the vertex from its position and texture coordinates.

The vertex color is white.

Parameters
thePosition | Vertex position
theTexCoords | Vertex texture coordinates
sf::Vertex::Vertex | ( | const Vector2f & | thePosition,
 |  | const Color & | theColor,
 |  | const Vector2f & | theTexCoords
 | ) |  |

Construct the vertex from its position, color and texture coordinates.

Parameters
thePosition | Vertex position
theColor | Vertex color
theTexCoords | Vertex texture coordinates

Member Data Documentation

Color sf::Vertex::color

Color of the vertex.

Definition at line 98 of file Vertex.hpp.

Vector2f sf::Vertex::position

2D position of the vertex

Definition at line 97 of file Vertex.hpp.

Vector2f sf::Vertex::texCoords

Coordinates of the texture's pixel to map to the vertex.

Definition at line 99 of file Vertex.hpp.

The documentation for this class was generated from the following file:
  • Vertex.hpp


  • sf
  • VertexArray
Public Member Functions | List of all members
sf::VertexArray Class Reference
Graphics module

Define a set of one or more 2D primitives. More...

#include <VertexArray.hpp>

Inheritance diagram for sf::VertexArray:
sf::Drawable

Public Member Functions

VertexArray ()
Default constructor.
VertexArray (PrimitiveType type, unsigned int vertexCount=0)
Construct the vertex array with a type and an initial number of vertices.
unsigned int | getVertexCount () const
Return the vertex count.
Vertex & | operator[] (unsigned int index)
Get a read-write access to a vertex by its index.
const Vertex & | operator[] (unsigned int index) const
Get a read-only access to a vertex by its index.
void | clear ()
Clear the vertex array.
void | resize (unsigned int vertexCount)
Resize the vertex array.
void | append (const Vertex &vertex)
Add a vertex to the array.
void | setPrimitiveType (PrimitiveType type)
Set the type of primitives to draw.
PrimitiveType | getPrimitiveType () const
Get the type of primitives drawn by the vertex array.
FloatRect | getBounds () const
Compute the bounding rectangle of the vertex array.

Detailed Description

Define a set of one or more 2D primitives.

sf::VertexArray is a very simple wrapper around a dynamic array of vertices and a primitives type.

It inherits sf::Drawable, but unlike other drawables it is not transformable.

Example:

sf::VertexArray lines(sf::LinesStrip, 4);
lines[0].position = sf::Vector2f(10, 0);
lines[1].position = sf::Vector2f(20, 0);
lines[2].position = sf::Vector2f(30, 5);
lines[3].position = sf::Vector2f(40, 2);
window.draw(lines);
See Also
sf::Vertex

Definition at line 45 of file VertexArray.hpp.

Constructor & Destructor Documentation

sf::VertexArray::VertexArray ( )

Default constructor.

Creates an empty vertex array.

sf::VertexArray::VertexArray | ( | PrimitiveType | type,
 |  | unsigned int | vertexCount = 0
 | ) |  |
explicit

Construct the vertex array with a type and an initial number of vertices.

Parameters
type | Type of primitives
vertexCount | Initial number of vertices in the array

Member Function Documentation

void sf::VertexArray::append ( const Vertex & vertex )

Add a vertex to the array.

Parameters
vertex Vertex to add
void sf::VertexArray::clear ( )

Clear the vertex array.

This function removes all the vertices from the array. It doesn't deallocate the corresponding memory, so that adding new vertices after clearing doesn't involve reallocating all the memory.

FloatRect sf::VertexArray::getBounds ( ) const

Compute the bounding rectangle of the vertex array.

This function returns the axis-aligned rectangle that contains all the vertices of the array.

Returns
Bounding rectangle of the vertex array
PrimitiveType sf::VertexArray::getPrimitiveType ( ) const

Get the type of primitives drawn by the vertex array.

Returns
Primitive type
unsigned int sf::VertexArray::getVertexCount ( ) const

Return the vertex count.

Returns
Number of vertices in the array
Vertex& sf::VertexArray::operator[] ( unsigned int index )

Get a read-write access to a vertex by its index.

This function doesn't check index, it must be in range [0, getVertexCount() - 1]. The behaviour is undefined otherwise.

Parameters
index Index of the vertex to get
Returns
Reference to the index-th vertex
See Also
getVertexCount
const Vertex& sf::VertexArray::operator[] ( unsigned int index ) const

Get a read-only access to a vertex by its index.

This function doesn't check index, it must be in range [0, getVertexCount() - 1]. The behaviour is undefined otherwise.

Parameters
index Index of the vertex to get
Returns
Const reference to the index-th vertex
See Also
getVertexCount
void sf::VertexArray::resize ( unsigned int vertexCount )

Resize the vertex array.

If vertexCount is greater than the current size, the previous vertices are kept and new (default-constructed) vertices are added. If vertexCount is less than the current size, existing vertices are removed from the array.

Parameters
vertexCount New size of the array (number of vertices)
void sf::VertexArray::setPrimitiveType ( PrimitiveType type )

Set the type of primitives to draw.

This function defines how the vertices must be interpreted when it's time to draw them:

  • As points
  • As lines
  • As triangles
  • As quads The default primitive type is sf::Points.
Parameters
type Type of primitive
The documentation for this class was generated from the following file:
  • VertexArray.hpp


  • sf
  • View
Public Member Functions | List of all members
sf::View Class Reference
Graphics module

2D camera that defines what region is shown on screen More...

#include <View.hpp>

Public Member Functions

View ()
Default constructor.
View (const FloatRect &rectangle)
Construct the view from a rectangle.
View (const Vector2f &center, const Vector2f &size)
Construct the view from its center and size.
void | setCenter (float x, float y)
Set the center of the view.
void | setCenter (const Vector2f &center)
Set the center of the view.
void | setSize (float width, float height)
Set the size of the view.
void | setSize (const Vector2f &size)
Set the size of the view.
void | setRotation (float angle)
Set the orientation of the view.
void | setViewport (const FloatRect &viewport)
Set the target viewport.
void | reset (const FloatRect &rectangle)
Reset the view to the given rectangle.
const Vector2f & | getCenter () const
Get the center of the view.
const Vector2f & | getSize () const
Get the size of the view.
float | getRotation () const
Get the current orientation of the view.
const FloatRect & | getViewport () const
Get the target viewport rectangle of the view.
void | move (float offsetX, float offsetY)
Move the view relatively to its current position.
void | move (const Vector2f &offset)
Move the view relatively to its current position.
void | rotate (float angle)
Rotate the view relatively to its current orientation.
void | zoom (float factor)
Resize the view rectangle relatively to its current size.
const Transform & | getTransform () const
Get the projection transform of the view.
const Transform & | getInverseTransform () const
Get the inverse projection transform of the view.

Detailed Description

2D camera that defines what region is shown on screen

sf::View defines a camera in the 2D scene.

This is a very powerful concept: you can scroll, rotate or zoom the entire scene without altering the way that your drawable objects are drawn.

A view is composed of a source rectangle, which defines what part of the 2D scene is shown, and a target viewport, which defines where the contents of the source rectangle will be displayed on the render target (window or texture).

The viewport allows to map the scene to a custom part of the render target, and can be used for split-screen or for displaying a minimap, for example. If the source rectangle has not the same size as the viewport, its contents will be stretched to fit in.

To apply a view, you have to assign it to the render target. Then, every objects drawn in this render target will be affected by the view until you use another view.

Usage example:

sf::RenderWindow window;
sf::View view;
// Initialize the view to a rectangle located at (100, 100) and with a size of 400x200
view.reset(sf::FloatRect(100, 100, 400, 200));
// Rotate it by 45 degrees
view.rotate(45);
// Set its target viewport to be half of the window
view.setViewport(sf::FloatRect(0.f, 0.f, 0.5f, 1.f));
// Apply it
window.setView(view);
// Render stuff
window.draw(someSprite);
// Set the default view back
window.setView(window.getDefaultView());
// Render stuff not affected by the view
window.draw(someText);
See Also
sf::RenderWindow, sf::RenderTexture

Definition at line 43 of file View.hpp.

Constructor & Destructor Documentation

sf::View::View ( )

Default constructor.

This constructor creates a default view of (0, 0, 1000, 1000)

sf::View::View ( const FloatRect & rectangle )
explicit

Construct the view from a rectangle.

Parameters
rectangle Rectangle defining the zone to display
sf::View::View | ( | const Vector2f & | center,
 |  | const Vector2f & | size
 | ) |  |

Construct the view from its center and size.

Parameters
center | Center of the zone to display
size | Size of zone to display

Member Function Documentation

const Vector2f& sf::View::getCenter ( ) const

Get the center of the view.

Returns
Center of the view
See Also
getSize, setCenter
const Transform& sf::View::getInverseTransform ( ) const

Get the inverse projection transform of the view.

This function is meant for internal use only.

Returns
Inverse of the projection transform defining the view
See Also
getTransform
float sf::View::getRotation ( ) const

Get the current orientation of the view.

Returns
Rotation angle of the view, in degrees
See Also
setRotation
const Vector2f& sf::View::getSize ( ) const

Get the size of the view.

Returns
Size of the view
See Also
getCenter, setSize
const Transform& sf::View::getTransform ( ) const

Get the projection transform of the view.

This function is meant for internal use only.

Returns
Projection transform defining the view
See Also
getInverseTransform
const FloatRect& sf::View::getViewport ( ) const

Get the target viewport rectangle of the view.

Returns
Viewport rectangle, expressed as a factor of the target size
See Also
setViewport
void sf::View::move | ( | float | offsetX,
 |  | float | offsetY
 | ) |  |

Move the view relatively to its current position.

Parameters
offsetX | X coordinate of the move offset
offsetY | Y coordinate of the move offset
See Also
setCenter, rotate, zoom
void sf::View::move ( const Vector2f & offset )

Move the view relatively to its current position.

Parameters
offset Move offset
See Also
setCenter, rotate, zoom
void sf::View::reset ( const FloatRect & rectangle )

Reset the view to the given rectangle.

Note that this function resets the rotation angle to 0.

Parameters
rectangle Rectangle defining the zone to display
See Also
setCenter, setSize, setRotation
void sf::View::rotate ( float angle )

Rotate the view relatively to its current orientation.

Parameters
angle Angle to rotate, in degrees
See Also
setRotation, move, zoom
void sf::View::setCenter | ( | float | x,
 |  | float | y
 | ) |  |

Set the center of the view.

Parameters
x | X coordinate of the new center
y | Y coordinate of the new center
See Also
setSize, getCenter
void sf::View::setCenter ( const Vector2f & center )

Set the center of the view.

Parameters
center New center
See Also
setSize, getCenter
void sf::View::setRotation ( float angle )

Set the orientation of the view.

The default rotation of a view is 0 degree.

Parameters
angle New angle, in degrees
See Also
getRotation
void sf::View::setSize | ( | float | width,
 |  | float | height
 | ) |  |

Set the size of the view.

Parameters
width | New width of the view
height | New height of the view
See Also
setCenter, getCenter
void sf::View::setSize ( const Vector2f & size )

Set the size of the view.

Parameters
size New size
See Also
setCenter, getCenter
void sf::View::setViewport ( const FloatRect & viewport )

Set the target viewport.

The viewport is the rectangle into which the contents of the view are displayed, expressed as a factor (between 0 and 1) of the size of the RenderTarget to which the view is applied. For example, a view which takes the left side of the target would be defined with View.setViewport(sf::FloatRect(0, 0, 0.5, 1)). By default, a view has a viewport which covers the entire target.

Parameters
viewport New viewport rectangle
See Also
getViewport
void sf::View::zoom ( float factor )

Resize the view rectangle relatively to its current size.

Resizing the view simulates a zoom, as the zone displayed on screen grows or shrinks. factor is a multiplier:

  • 1 keeps the size unchanged
  • > 1 makes the view bigger (objects appear smaller)
  • < 1 makes the view smaller (objects appear bigger)
Parameters
factor Zoom factor to apply
See Also
setSize, move, rotate
The documentation for this class was generated from the following file:
  • View.hpp


  • sf
  • Shader
  • CurrentTextureType
sf::Shader::CurrentTextureType Struct Reference
Graphics module

Special type/value that can be passed to setParameter, and that represents the texture of the object being drawn. More...

#include <Shader.hpp>

Detailed Description

Special type/value that can be passed to setParameter, and that represents the texture of the object being drawn.

Definition at line 70 of file Shader.hpp.

The documentation for this struct was generated from the following file:
  • Shader.hpp


Classes
Network module

Socket-based communication, utilities and higher-level network protocols (HTTP, FTP). More...

Classes

class | sf::Ftp
A FTP client. More...
class | sf::Http
A HTTP client. More...
class | sf::IpAddress
Encapsulate an IPv4 network address. More...
class | sf::Packet
Utility class to build blocks of data to transfer over the network. More...
class | sf::Socket
Base class for all the socket types. More...
class | sf::SocketSelector
Multiplexer that allows to read from multiple sockets. More...
class | sf::TcpListener
Socket that listens to new TCP connections. More...
class | sf::TcpSocket
Specialized socket using the TCP protocol. More...
class | sf::UdpSocket
Specialized socket using the UDP protocol. More...
class | sf::Ftp::DirectoryResponse
Specialization of FTP response returning a directory. More...
class | sf::Ftp::ListingResponse
Specialization of FTP response returning a filename lisiting. More...
class | sf::Ftp::Response
Define a FTP response. More...
class | sf::Http::Request
Define a HTTP request. More...
class | sf::Http::Response
Define a HTTP response. More...

Detailed Description

Socket-based communication, utilities and higher-level network protocols (HTTP, FTP).


  • sf
  • Ftp
Classes | Public Types | Public Member Functions | Friends | List of all members
sf::Ftp Class Reference
Network module

A FTP client. More...

#include <Ftp.hpp>

Inheritance diagram for sf::Ftp:
sf::NonCopyable

Classes

class | DirectoryResponse
Specialization of FTP response returning a directory. More...
class | ListingResponse
Specialization of FTP response returning a filename lisiting. More...
class | Response
Define a FTP response. More...

Public Types

enum TransferMode {
Binary,
Ascii,
Ebcdic
}
Enumeration of transfer modes. More...

Public Member Functions

~Ftp ()
Destructor.
Response | connect (const IpAddress &server, unsigned short port=21, Time timeout=Time::Zero)
Connect to the specified FTP server.
Response disconnect ()
Close the connection with the server.
Response login ()
Log in using an anonymous account.
Response | login (const std::string &name, const std::string &password)
Log in using a username and a password.
Response keepAlive ()
Send a null command to keep the connection alive.
DirectoryResponse getWorkingDirectory ()
Get the current working directory.
ListingResponse | getDirectoryListing (const std::string &directory="")
Get the contents of the given directory.
Response | changeDirectory (const std::string &directory)
Change the current working directory.
Response parentDirectory ()
Go to the parent directory of the current one.
Response | createDirectory (const std::string &name)
Create a new directory.
Response | deleteDirectory (const std::string &name)
Remove an existing directory.
Response | renameFile (const std::string &file, const std::string &newName)
Rename an existing file.
Response | deleteFile (const std::string &name)
Remove an existing file.
Response | download (const std::string &remoteFile, const std::string &localPath, TransferMode mode=Binary)
Download a file from the server.
Response | upload (const std::string &localFile, const std::string &remotePath, TransferMode mode=Binary)
Upload a file to the server.

Friends

class DataChannel

Detailed Description

A FTP client.

sf::Ftp is a very simple FTP client that allows you to communicate with a FTP server.

The FTP protocol allows you to manipulate a remote file system (list files, upload, download, create, remove, ...).

Using the FTP client consists of 4 parts:

  • Connecting to the FTP server
  • Logging in (either as a registered user or anonymously)
  • Sending commands to the server
  • Disconnecting (this part can be done implicitely by the destructor)

Every command returns a FTP response, which contains the status code as well as a message from the server. Some commands such as getWorkingDirectory and getDirectoryListing return additional data, and use a class derived from sf::Ftp::Response to provide this data.

All commands, especially upload and download, may take some time to complete. This is important to know if you don't want to block your application while the server is completing the task.

Usage example:

// Create a new FTP client
sf::Ftp ftp;
// Connect to the server
sf::Ftp::Response response = ftp.connect("ftp://ftp.myserver.com");
if (response.isOk())
std::cout << "Connected" << std::endl;
// Log in
response = ftp.login("laurent", "dF6Zm89D");
if (response.isOk())
std::cout << "Logged in" << std::endl;
// Print the working directory
sf::Ftp::DirectoryResponse directory = ftp.getWorkingDirectory();
if (directory.isOk())
std::cout << "Working directory: " << directory.getDirectory() << std::endl;
// Create a new directory
response = ftp.createDirectory("files");
if (response.isOk())
std::cout << "Created new directory" << std::endl;
// Upload a file to this new directory
response = ftp.upload("local-path/file.txt", "files", sf::Ftp::Ascii);
if (response.isOk())
std::cout << "File uploaded" << std::endl;
// Disconnect from the server (optional)
ftp.disconnect();

Definition at line 47 of file Ftp.hpp.

Member Enumeration Documentation

enum sf::Ftp::TransferMode

Enumeration of transfer modes.

Enumerator:
Binary

Binary mode (file is transfered as a sequence of bytes)

Ascii

Text mode using ASCII encoding.

Ebcdic

Text mode using EBCDIC encoding.

Definition at line 55 of file Ftp.hpp.

Constructor & Destructor Documentation

sf::Ftp::~Ftp ( )

Destructor.

Automatically closes the connection with the server if it is still opened.

Member Function Documentation

Response sf::Ftp::changeDirectory ( const std::string & directory )

Change the current working directory.

The new directory must be relative to the current one.

Parameters
directory New working directory
Returns
Server response to the request
See Also
getWorkingDirectory, getDirectoryListing, parentDirectory
Response sf::Ftp::connect | ( | const IpAddress & | server,
 |  | unsigned short | port = 21,
 |  | Time | timeout = Time::Zero
 | ) |  |

Connect to the specified FTP server.

The port has a default value of 21, which is the standard port used by the FTP protocol. You shouldn't use a different value, unless you really know what you do. This function tries to connect to the server so it may take a while to complete, especially if the server is not reachable. To avoid blocking your application for too long, you can use a timeout. The default value, Time::Zero, means that the system timeout will be used (which is usually pretty long).

Parameters
server | Name or address of the FTP server to connect to
port | Port used for the connection
timeout | Maximum time to wait
Returns
Server response to the request
See Also
disconnect
Response sf::Ftp::createDirectory ( const std::string & name )

Create a new directory.

The new directory is created as a child of the current working directory.

Parameters
name Name of the directory to create
Returns
Server response to the request
See Also
deleteDirectory
Response sf::Ftp::deleteDirectory ( const std::string & name )

Remove an existing directory.

The directory to remove must be relative to the current working directory. Use this function with caution, the directory will be removed permanently!

Parameters
name Name of the directory to remove
Returns
Server response to the request
See Also
createDirectory
Response sf::Ftp::deleteFile ( const std::string & name )

Remove an existing file.

The file name must be relative to the current working directory. Use this function with caution, the file will be removed permanently!

Parameters
name File to remove
Returns
Server response to the request
See Also
renameFile
Response sf::Ftp::disconnect ( )

Close the connection with the server.

Returns
Server response to the request
See Also
connect
Response sf::Ftp::download | ( | const std::string & | remoteFile,
 |  | const std::string & | localPath,
 |  | TransferMode | mode = Binary
 | ) |  |

Download a file from the server.

The filename of the distant file is relative to the current working directory of the server, and the local destination path is relative to the current directory of your application.

Parameters
remoteFile | Filename of the distant file to download
localPath | Where to put to file on the local computer
mode | Transfer mode
Returns
Server response to the request
See Also
upload
ListingResponse sf::Ftp::getDirectoryListing ( const std::string & directory = "" )

Get the contents of the given directory.

This function retrieves the sub-directories and files contained in the given directory. It is not recursive. The directory parameter is relative to the current working directory.

Parameters
directory Directory to list
Returns
Server response to the request
See Also
getWorkingDirectory, changeDirectory, parentDirectory
DirectoryResponse sf::Ftp::getWorkingDirectory ( )

Get the current working directory.

The working directory is the root path for subsequent operations involving directories and/or filenames.

Returns
Server response to the request
See Also
getDirectoryListing, changeDirectory, parentDirectory
Response sf::Ftp::keepAlive ( )

Send a null command to keep the connection alive.

This command is useful because the server may close the connection automatically if no command is sent.

Returns
Server response to the request
Response sf::Ftp::login ( )

Log in using an anonymous account.

Logging in is mandatory after connecting to the server. Users that are not logged in cannot perform any operation.

Returns
Server response to the request
Response sf::Ftp::login | ( | const std::string & | name,
 |  | const std::string & | password
 | ) |  |

Log in using a username and a password.

Logging in is mandatory after connecting to the server. Users that are not logged in cannot perform any operation.

Parameters
name | User name
password | Password
Returns
Server response to the request
Response sf::Ftp::parentDirectory ( )

Go to the parent directory of the current one.

Returns
Server response to the request
See Also
getWorkingDirectory, getDirectoryListing, changeDirectory
Response sf::Ftp::renameFile | ( | const std::string & | file,
 |  | const std::string & | newName
 | ) |  |

Rename an existing file.

The filenames must be relative to the current working directory.

Parameters
file | File to rename
newName | New name of the file
Returns
Server response to the request
See Also
deleteFile
Response sf::Ftp::upload | ( | const std::string & | localFile,
 |  | const std::string & | remotePath,
 |  | TransferMode | mode = Binary
 | ) |  |

Upload a file to the server.

The name of the local file is relative to the current working directory of your application, and the remote path is relative to the current directory of the FTP server.

Parameters
localFile | Path of the local file to upload
remotePath | Where to put to file on the server
mode | Transfer mode
Returns
Server response to the request
See Also
download
The documentation for this class was generated from the following file:
  • Ftp.hpp


  • sf
  • Http
Classes | Public Member Functions | List of all members
sf::Http Class Reference
Network module

A HTTP client. More...

#include <Http.hpp>

Inheritance diagram for sf::Http:
sf::NonCopyable

Classes

class | Request
Define a HTTP request. More...
class | Response
Define a HTTP response. More...

Public Member Functions

Http ()
Default constructor.
Http (const std::string &host, unsigned short port=0)
Construct the HTTP client with the target host.
void | setHost (const std::string &host, unsigned short port=0)
Set the target host.
Response | sendRequest (const Request &request, Time timeout=Time::Zero)
Send a HTTP request and return the server's response.

Detailed Description

A HTTP client.

sf::Http is a very simple HTTP client that allows you to communicate with a web server.

You can retrieve web pages, send data to an interactive resource, download a remote file, etc.

The HTTP client is split into 3 classes:

  • sf::Http::Request
  • sf::Http::Response
  • sf::Http

sf::Http::Request builds the request that will be sent to the server. A request is made of:

  • a method (what you want to do)
  • a target URI (usually the name of the web page or file)
  • one or more header fields (options that you can pass to the server)
  • an optional body (for POST requests)

sf::Http::Response parse the response from the web server and provides getters to read them. The response contains:

  • a status code
  • header fields (that may be answers to the ones that you requested)
  • a body, which contains the contents of the requested resource

sf::Http provides a simple function, SendRequest, to send a sf::Http::Request and return the corresponding sf::Http::Response from the server.

Usage example:

// Create a new HTTP client
sf::Http http;
// We'll work on http://www.sfml-dev.org
http.setHost("http://www.sfml-dev.org");
// Prepare a request to get the 'features.php' page
sf::Http::Request request("features.php");
// Send the request
sf::Http::Response response = http.sendRequest(request);
// Check the status code and display the result
sf::Http::Response::Status status = response.getStatus();
if (status == sf::Http::Response::Ok)
{
std::cout << response.getBody() << std::endl;
}
else
{
std::cout << "Error " << status << std::endl;
}

Definition at line 46 of file Http.hpp.

Constructor & Destructor Documentation

sf::Http::Http ( )

Default constructor.

sf::Http::Http | ( | const std::string & | host,
 |  | unsigned short | port = 0
 | ) |  |

Construct the HTTP client with the target host.

This is equivalent to calling setHost(host, port). The port has a default value of 0, which means that the HTTP client will use the right port according to the protocol used (80 for HTTP, 443 for HTTPS). You should leave it like this unless you really need a port other than the standard one, or use an unknown protocol.

Parameters
host | Web server to connect to
port | Port to use for connection

Member Function Documentation

Response sf::Http::sendRequest | ( | const Request & | request,
 |  | Time | timeout = Time::Zero
 | ) |  |

Send a HTTP request and return the server's response.

You must have a valid host before sending a request (see setHost). Any missing mandatory header field in the request will be added with an appropriate value. Warning: this function waits for the server's response and may not return instantly; use a thread if you don't want to block your application, or use a timeout to limit the time to wait. A value of Time::Zero means that the client will use the system defaut timeout (which is usually pretty long).

Parameters
request | Request to send
timeout | Maximum time to wait
Returns
Server's response
void sf::Http::setHost | ( | const std::string & | host,
 |  | unsigned short | port = 0
 | ) |  |

Set the target host.

This function just stores the host address and port, it doesn't actually connect to it until you send a request. The port has a default value of 0, which means that the HTTP client will use the right port according to the protocol used (80 for HTTP, 443 for HTTPS). You should leave it like this unless you really need a port other than the standard one, or use an unknown protocol.

Parameters
host | Web server to connect to
port | Port to use for connection
The documentation for this class was generated from the following file:
  • Http.hpp


  • sf
  • IpAddress
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
sf::IpAddress Class Reference
Network module

Encapsulate an IPv4 network address. More...

#include <IpAddress.hpp>

Public Member Functions

IpAddress ()
Default constructor.
IpAddress (const std::string &address)
Construct the address from a string.
IpAddress (const char *address)
Construct the address from a string.
IpAddress (Uint8 byte0, Uint8 byte1, Uint8 byte2, Uint8 byte3)
Construct the address from 4 bytes.
IpAddress (Uint32 address)
Construct the address from a 32-bits integer.
std::string | toString () const
Get a string representation of the address.
Uint32 | toInteger () const
Get an integer representation of the address.

Static Public Member Functions

static IpAddress | getLocalAddress ()
Get the computer's local address.
static IpAddress | getPublicAddress (Time timeout=Time::Zero)
Get the computer's public address.

Static Public Attributes

static const IpAddress | None
Value representing an empty/invalid address.
static const IpAddress | LocalHost
The "localhost" address (for connecting a computer to itself locally)
static const IpAddress | Broadcast
The "broadcast" address (for sending UDP messages to everyone on a local network)

Detailed Description

Encapsulate an IPv4 network address.

sf::IpAddress is a utility class for manipulating network addresses.

It provides a set a implicit constructors and conversion functions to easily build or transform an IP address from/to various representations.

Usage example:

sf::IpAddress a0; // an invalid address
sf::IpAddress a1 = sf::IpAddress::None; // an invalid address (same as a0)
sf::IpAddress a2("127.0.0.1"); // the local host address
sf::IpAddress a3 = sf::IpAddress::Broadcast; // the broadcast address
sf::IpAddress a4(192, 168, 1, 56); // a local address
sf::IpAddress a5("my_computer"); // a local address created from a network name
sf::IpAddress a6("89.54.1.169"); // a distant address
sf::IpAddress a7("www.google.com"); // a distant address created from a network name
sf::IpAddress a8 = sf::IpAddress::getLocalAddress(); // my address on the local network
sf::IpAddress a9 = sf::IpAddress::getPublicAddress(); // my address on the internet

Note that sf::IpAddress currently doesn't support IPv6 nor other types of network addresses.

Definition at line 44 of file IpAddress.hpp.

Constructor & Destructor Documentation

sf::IpAddress::IpAddress ( )

Default constructor.

This constructor creates an empty (invalid) address

sf::IpAddress::IpAddress ( const std::string & address )

Construct the address from a string.

Here address can be either a decimal address (ex: "192.168.1.56") or a network name (ex: "localhost").

Parameters
address IP address or network name
sf::IpAddress::IpAddress ( const char * address )

Construct the address from a string.

Here address can be either a decimal address (ex: "192.168.1.56") or a network name (ex: "localhost"). This is equivalent to the constructor taking a std::string parameter, it is defined for convenience so that the implicit conversions from literal strings to IpAddress work.

Parameters
address IP address or network name
sf::IpAddress::IpAddress | ( | Uint8 | byte0,
 |  | Uint8 | byte1,
 |  | Uint8 | byte2,
 |  | Uint8 | byte3
 | ) |  |

Construct the address from 4 bytes.

Calling IpAddress(a, b, c, d) is equivalent to calling IpAddress("a.b.c.d"), but safer as it doesn't have to parse a string to get the address components.

Parameters
byte0 | First byte of the address
byte1 | Second byte of the address
byte2 | Third byte of the address
byte3 | Fourth byte of the address
sf::IpAddress::IpAddress ( Uint32 address )
explicit

Construct the address from a 32-bits integer.

This constructor uses the internal representation of the address directly. It should be used for optimization purposes, and only if you got that representation from IpAddress::ToInteger().

Parameters
address 4 bytes of the address packed into a 32-bits integer
See Also
toInteger

Member Function Documentation

static IpAddress sf::IpAddress::getLocalAddress ( )
static

Get the computer's local address.

The local address is the address of the computer from the LAN point of view, i.e. something like 192.168.1.56. It is meaningful only for communications over the local network. Unlike getPublicAddress, this function is fast and may be used safely anywhere.

Returns
Local IP address of the computer
See Also
getPublicAddress
static IpAddress sf::IpAddress::getPublicAddress ( Time timeout = Time::Zero )
static

Get the computer's public address.

The public address is the address of the computer from the internet point of view, i.e. something like 89.54.1.169. It is necessary for communications over the world wide web. The only way to get a public address is to ask it to a distant website; as a consequence, this function depends on both your network connection and the server, and may be very slow. You should use it as few as possible. Because this function depends on the network connection and on a distant server, you may use a time limit if you don't want your program to be possibly stuck waiting in case there is a problem; this limit is deactivated by default.

Parameters
timeout Maximum time to wait
Returns
Public IP address of the computer
See Also
getLocalAddress
Uint32 sf::IpAddress::toInteger ( ) const

Get an integer representation of the address.

The returned number is the internal representation of the address, and should be used for optimization purposes only (like sending the address through a socket). The integer produced by this function can then be converted back to a sf::IpAddress with the proper constructor.

Returns
32-bits unsigned integer representation of the address
See Also
toString
std::string sf::IpAddress::toString ( ) const

Get a string representation of the address.

The returned string is the decimal representation of the IP address (like "192.168.1.56"), even if it was constructed from a host name.

Returns
String representation of the address
See Also
toInteger

Member Data Documentation

const IpAddress sf::IpAddress::Broadcast
static

The "broadcast" address (for sending UDP messages to everyone on a local network)

Definition at line 186 of file IpAddress.hpp.

const IpAddress sf::IpAddress::LocalHost
static

The "localhost" address (for connecting a computer to itself locally)

Definition at line 185 of file IpAddress.hpp.

const IpAddress sf::IpAddress::None
static

Value representing an empty/invalid address.

Definition at line 184 of file IpAddress.hpp.

The documentation for this class was generated from the following file:
  • IpAddress.hpp


  • sf
  • Packet
Public Member Functions | Protected Member Functions | Friends | List of all members
sf::Packet Class Reference
Network module

Utility class to build blocks of data to transfer over the network. More...

#include <Packet.hpp>

Public Member Functions

Packet ()
Default constructor.
virtual | ~Packet ()
Virtual destructor.
void | append (const void *data, std::size_t sizeInBytes)
Append data to the end of the packet.
void | clear ()
Clear the packet.
const void * | getData () const
Get a pointer to the data contained in the packet.
std::size_t | getDataSize () const
Get the size of the data contained in the packet.
bool | endOfPacket () const
Tell if the reading position has reached the end of the packet.
operator BoolType () const
Test the validity of the packet, for reading.
Packet & | operator>> (bool &data)
Overloads of operator >> to read data from the packet.
Packet & | operator>> (Int8 &data)
Packet & | operator>> (Uint8 &data)
Packet & | operator>> (Int16 &data)
Packet & | operator>> (Uint16 &data)
Packet & | operator>> (Int32 &data)
Packet & | operator>> (Uint32 &data)
Packet & | operator>> (float &data)
Packet & | operator>> (double &data)
Packet & | operator>> (char *data)
Packet & | operator>> (std::string &data)
Packet & | operator>> (wchar_t *data)
Packet & | operator>> (std::wstring &data)
Packet & | operator>> (String &data)
Packet & | operator<< (bool data)
Overloads of operator << to write data into the packet.
Packet & | operator<< (Int8 data)
Packet & | operator<< (Uint8 data)
Packet & | operator<< (Int16 data)
Packet & | operator<< (Uint16 data)
Packet & | operator<< (Int32 data)
Packet & | operator<< (Uint32 data)
Packet & | operator<< (float data)
Packet & | operator<< (double data)
Packet & | operator<< (const char *data)
Packet & | operator<< (const std::string &data)
Packet & | operator<< (const wchar_t *data)
Packet & | operator<< (const std::wstring &data)
Packet & | operator<< (const String &data)

Protected Member Functions

virtual const void * | onSend (std::size_t &size)
Called before the packet is sent over the network.
virtual void | onReceive (const void *data, std::size_t size)
Called after the packet is received over the network.

Friends

class | TcpSocket
class | UdpSocket

Detailed Description

Utility class to build blocks of data to transfer over the network.

Packets provide a safe and easy way to serialize data, in order to send it over the network using sockets (sf::TcpSocket, sf::UdpSocket).

Packets solve 2 fundamental problems that arise when transfering data over the network:

  • data is interpreted correctly according to the endianness
  • the bounds of the packet are preserved (one send == one receive)

The sf::Packet class provides both input and output modes. It is designed to follow the behaviour of standard C++ streams, using operators >> and << to extract and insert data.

It is recommended to use only fixed-size types (like sf::Int32, etc.), to avoid possible differences between the sender and the receiver. Indeed, the native C++ types may have different sizes on two platforms and your data may be corrupted if that happens.

Usage example:

sf::Uint32 x = 24;
std::string s = "hello";
double d = 5.89;
// Group the variables to send into a packet
sf::Packet packet;
packet << x << s << d;
// Send it over the network (socket is a valid sf::TcpSocket)
socket.send(packet);
-----------------------------------------------------------------
// Receive the packet at the other end
sf::Packet packet;
socket.receive(packet);
// Extract the variables contained in the packet
sf::Uint32 x;
std::string s;
double d;
if (packet >> x >> s >> d)
{
// Data extracted successfully...
}

Packets have built-in operator >> and << overloads for standard types:

  • bool
  • fixed-size integer types (sf::Int8/16/32, sf::Uint8/16/32)
  • floating point numbers (float, double)
  • string types (char*, wchar_t*, std::string, std::wstring, sf::String)

Like standard streams, it is also possible to define your own overloads of operators >> and << in order to handle your custom types.

struct MyStruct
{
float number;
sf::Int8 integer;
std::string str;
};
sf::Packet& operator <<(sf::Packet& packet, const MyStruct& m)
{
return packet << m.number << m.integer << m.str;
}
sf::Packet& operator >>(sf::Packet& packet, MyStruct& m)
{
return packet >> m.number >> m.integer >> m.str;
}

Packets also provide an extra feature that allows to apply custom transformations to the data before it is sent, and after it is received. This is typically used to handle automatic compression or encryption of the data. This is achieved by inheriting from sf::Packet, and overriding the onSend and onReceive functions.

Here is an example:

class ZipPacket : public sf::Packet
{
virtual const void* onSend(std::size_t& size)
{
const void* srcData = getData();
std::size_t srcSize = getDataSize();
return MySuperZipFunction(srcData, srcSize, &size);
}
virtual void onReceive(const void* data, std::size_t size)
{
std::size_t dstSize;
const void* dstData = MySuperUnzipFunction(data, size, &dstSize);
append(dstData, dstSize);
}
};
// Use like regular packets:
ZipPacket packet;
packet << x << s << d;
...
See Also
sf::TcpSocket, sf::UdpSocket

Definition at line 47 of file Packet.hpp.

Constructor & Destructor Documentation

sf::Packet::Packet ( )

Default constructor.

Creates an empty packet.

virtual sf::Packet::~Packet ( )
virtual

Virtual destructor.

Member Function Documentation

void sf::Packet::append | ( | const void * | data,
 |  | std::size_t | sizeInBytes
 | ) |  |

Append data to the end of the packet.

Parameters
data | Pointer to the sequence of bytes to append
sizeInBytes | Number of bytes to append
See Also
clear
void sf::Packet::clear ( )

Clear the packet.

After calling Clear, the packet is empty.

See Also
append
bool sf::Packet::endOfPacket ( ) const

Tell if the reading position has reached the end of the packet.

This function is useful to know if there is some data left to be read, without actually reading it.

Returns
True if all data was read, false otherwise
See Also
operator bool
const void* sf::Packet::getData ( ) const

Get a pointer to the data contained in the packet.

Warning: the returned pointer may become invalid after you append data to the packet, therefore it should never be stored. The return pointer is NULL if the packet is empty.

Returns
Pointer to the data
See Also
getDataSize
std::size_t sf::Packet::getDataSize ( ) const

Get the size of the data contained in the packet.

This function returns the number of bytes pointed to by what getData returns.

Returns
Data size, in bytes
See Also
getData
virtual void sf::Packet::onReceive | ( | const void * | data,
 |  | std::size_t | size
 | ) |  |
protectedvirtual

Called after the packet is received over the network.

This function can be defined by derived classes to transform the data after it is received; this can be used for uncompression, decryption, etc. The function receives a pointer to the received data, and must fill the packet with the transformed bytes. The default implementation fills the packet directly without transforming the data.

Parameters
data | Pointer to the received bytes
size | Number of bytes
See Also
onSend
virtual const void* sf::Packet::onSend ( std::size_t & size )
protectedvirtual

Called before the packet is sent over the network.

This function can be defined by derived classes to transform the data before it is sent; this can be used for compression, encryption, etc. The function must return a pointer to the modified data, as well as the number of bytes pointed. The default implementation provides the packet's data without transforming it.

Parameters
size Variable to fill with the size of data to send
Returns
Pointer to the array of bytes to send
See Also
onReceive
sf::Packet::operator BoolType ( ) const

Test the validity of the packet, for reading.

This operator allows to test the packet as a boolean variable, to check if a reading operation was successful.

A packet will be in an invalid state if it has no more data to read.

This behaviour is the same as standard C++ streams.

Usage example:

float x;
packet >> x;
if (packet)
{
// ok, x was extracted successfully
}
// -- or --
float x;
if (packet >> x)
{
// ok, x was extracted successfully
}

Don't focus on the return type, it's equivalent to bool but it disallows unwanted implicit conversions to integer or pointer types.

Returns
True if last data extraction from packet was successful
See Also
endOfPacket
Packet& sf::Packet::operator<< ( bool data )

Overloads of operator << to write data into the packet.

Packet& sf::Packet::operator>> ( bool & data )

Overloads of operator >> to read data from the packet.

The documentation for this class was generated from the following file:
  • Packet.hpp


  • sf
  • Socket
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Friends | List of all members
sf::Socket Class Reference
Network module

Base class for all the socket types. More...

#include <Socket.hpp>

Inheritance diagram for sf::Socket:
sf::NonCopyable sf::TcpListener sf::TcpSocket sf::UdpSocket

Public Types

enum Status {
Done,
NotReady,
Disconnected,
Error
}
Status codes that may be returned by socket functions. More...
enum { AnyPort = 0 }
Some special values used by sockets. More...

Public Member Functions

virtual | ~Socket ()
Destructor.
void | setBlocking (bool blocking)
Set the blocking state of the socket.
bool | isBlocking () const
Tell whether the socket is in blocking or non-blocking mode.

Protected Types

enum Type {
Tcp,
Udp
}
Types of protocols that the socket can use. More...

Protected Member Functions

Socket (Type type)
Default constructor.
SocketHandle | getHandle () const
Return the internal handle of the socket.
void | create ()
Create the internal representation of the socket.
void | create (SocketHandle handle)
Create the internal representation of the socket from a socket handle.
void | close ()
Close the socket gracefully.

Friends

class SocketSelector

Detailed Description

Base class for all the socket types.

This class mainly defines internal stuff to be used by derived classes.

The only public features that it defines, and which is therefore common to all the socket classes, is the blocking state. All sockets can be set as blocking or non-blocking.

In blocking mode, socket functions will hang until the operation completes, which means that the entire program (well, in fact the current thread if you use multiple ones) will be stuck waiting for your socket operation to complete.

In non-blocking mode, all the socket functions will return immediately. If the socket is not ready to complete the requested operation, the function simply returns the proper status code (Socket::NotReady).

The default mode, which is blocking, is the one that is generally used, in combination with threads or selectors. The non-blocking mode is rather used in real-time applications that run an endless loop that can poll the socket often enough, and cannot afford blocking this loop.

See Also
sf::TcpListener, sf::TcpSocket, sf::UdpSocket

Definition at line 45 of file Socket.hpp.

Member Enumeration Documentation

anonymous enum

Some special values used by sockets.

Enumerator:
AnyPort

Special value that tells the system to pick any available port.

Definition at line 65 of file Socket.hpp.

enum sf::Socket::Status

Status codes that may be returned by socket functions.

Enumerator:
Done

The socket has sent / received the data.

NotReady

The socket is not ready to send / receive data yet.

Disconnected

The TCP socket has been disconnected.

Error

An unexpected error happened.

Definition at line 53 of file Socket.hpp.

enum sf::Socket::Type
protected

Types of protocols that the socket can use.

Enumerator:
Tcp

TCP protocol.

Udp

UDP protocol.

Definition at line 113 of file Socket.hpp.

Constructor & Destructor Documentation

virtual sf::Socket::~Socket ( )
virtual

Destructor.

sf::Socket::Socket ( Type type )
protected

Default constructor.

This constructor can only be accessed by derived classes.

Parameters
type Type of the socket (TCP or UDP)

Member Function Documentation

void sf::Socket::close ( )
protected

Close the socket gracefully.

This function can only be accessed by derived classes.

void sf::Socket::create ( )
protected

Create the internal representation of the socket.

This function can only be accessed by derived classes.

void sf::Socket::create ( SocketHandle handle )
protected

Create the internal representation of the socket from a socket handle.

This function can only be accessed by derived classes.

Parameters
handle OS-specific handle of the socket to wrap
SocketHandle sf::Socket::getHandle ( ) const
protected

Return the internal handle of the socket.

The returned handle may be invalid if the socket was not created yet (or already destroyed). This function can only be accessed by derived classes.

Returns
The internal (OS-specific) handle of the socket
bool sf::Socket::isBlocking ( ) const

Tell whether the socket is in blocking or non-blocking mode.

Returns
True if the socket is blocking, false otherwise
See Also
setBlocking
void sf::Socket::setBlocking ( bool blocking )

Set the blocking state of the socket.

In blocking mode, calls will not return until they have completed their task. For example, a call to Receive in blocking mode won't return until some data was actually received. In non-blocking mode, calls will always return immediately, using the return code to signal whether there was data available or not. By default, all sockets are blocking.

Parameters
blocking True to set the socket as blocking, false for non-blocking
See Also
isBlocking
The documentation for this class was generated from the following file:
  • Socket.hpp


  • sf
  • SocketSelector
Public Member Functions | List of all members
sf::SocketSelector Class Reference
Network module

Multiplexer that allows to read from multiple sockets. More...

#include <SocketSelector.hpp>

Public Member Functions

SocketSelector ()
Default constructor.
SocketSelector (const SocketSelector &copy)
Copy constructor.
~SocketSelector ()
Destructor.
void | add (Socket &socket)
Add a new socket to the selector.
void | remove (Socket &socket)
Remove a socket from the selector.
void | clear ()
Remove all the sockets stored in the selector.
bool | wait (Time timeout=Time::Zero)
Wait until one or more sockets are ready to receive.
bool | isReady (Socket &socket) const
Test a socket to know if it is ready to receive data.
SocketSelector & | operator= (const SocketSelector &right)
Overload of assignment operator.

Detailed Description

Multiplexer that allows to read from multiple sockets.

Socket selectors provide a way to wait until some data is available on a set of sockets, instead of just one.

This is convenient when you have multiple sockets that may possibly receive data, but you don't know which one will be ready first. In particular, it avoids to use a thread for each socket; with selectors, a single thread can handle all the sockets.

All types of sockets can be used in a selector:

  • sf::TcpListener
  • sf::TcpSocket
  • sf::UdpSocket

A selector doesn't store its own copies of the sockets (socket classes are not copyable anyway), it simply keeps a reference to the original sockets that you pass to the "add" function. Therefore, you can't use the selector as a socket container, you must store them oustide and make sure that they are alive as long as they are used in the selector.

Using a selector is simple:

  • populate the selector with all the sockets that you want to observe
  • make it wait until there is data available on any of the sockets
  • test each socket to find out which ones are ready

Usage example:

// Create a socket to listen to new connections
sf::TcpListener listener;
listener.listen(55001);
// Create a list to store the future clients
std::list<sf::TcpSocket*> clients;
// Create a selector
sf::SocketSelector selector;
// Add the listener to the selector
selector.add(listener);
// Endless loop that waits for new connections
while (running)
{
// Make the selector wait for data on any socket
if (selector.wait())
{
// Test the listener
if (selector.isReady(listener))
{
// The listener is ready: there is a pending connection
sf::TcpSocket* client = new sf::TcpSocket;
if (listener.accept(*client) == sf::Socket::Done)
{
// Add the new client to the clients list
clients.push_back(client);
// Add the new client to the selector so that we will
// be notified when he sends something
selector.add(*client);
}
else
{
// Error, we won't get a new connection, delete the socket
delete client;
}
}
else
{
// The listener socket is not ready, test all other sockets (the clients)
for (std::list<sf::TcpSocket*>::iterator it = clients.begin(); it != clients.end(); ++it)
{
sf::TcpSocket& client = **it;
if (selector.isReady(client))
{
// The client has sent some data, we can receive it
sf::Packet packet;
if (client.receive(packet) == sf::Socket::Done)
{
...
}
}
}
}
}
}
See Also
sf::Socket

Definition at line 43 of file SocketSelector.hpp.

Constructor & Destructor Documentation

sf::SocketSelector::SocketSelector ( )

Default constructor.

sf::SocketSelector::SocketSelector ( const SocketSelector & copy )

Copy constructor.

Parameters
copy Instance to copy
sf::SocketSelector::~SocketSelector ( )

Destructor.

Member Function Documentation

void sf::SocketSelector::add ( Socket & socket )

Add a new socket to the selector.

This function keeps a weak reference to the socket, so you have to make sure that the socket is not destroyed while it is stored in the selector. This function does nothing if the socket is not valid.

Parameters
socket Reference to the socket to add
See Also
remove, clear
void sf::SocketSelector::clear ( )

Remove all the sockets stored in the selector.

This function doesn't destroy any instance, it simply removes all the references that the selector has to external sockets.

See Also
add, remove
bool sf::SocketSelector::isReady ( Socket & socket ) const

Test a socket to know if it is ready to receive data.

This function must be used after a call to Wait, to know which sockets are ready to receive data. If a socket is ready, a call to receive will never block because we know that there is data available to read. Note that if this function returns true for a TcpListener, this means that it is ready to accept a new connection.

Parameters
socket Socket to test
Returns
True if the socket is ready to read, false otherwise
See Also
isReady
SocketSelector& sf::SocketSelector::operator= ( const SocketSelector & right )

Overload of assignment operator.

Parameters
right Instance to assign
Returns
Reference to self
void sf::SocketSelector::remove ( Socket & socket )

Remove a socket from the selector.

This function doesn't destroy the socket, it simply removes the reference that the selector has to it.

Parameters
socket Reference to the socket to remove
See Also
add, clear
bool sf::SocketSelector::wait ( Time timeout = Time::Zero )

Wait until one or more sockets are ready to receive.

This function returns as soon as at least one socket has some data available to be received. To know which sockets are ready, use the isReady function. If you use a timeout and no socket is ready before the timeout is over, the function returns false.

Parameters
timeout Maximum time to wait, (use Time::Zero for infinity)
Returns
True if there are sockets ready, false otherwise
See Also
isReady
The documentation for this class was generated from the following file:
  • SocketSelector.hpp


  • sf
  • TcpListener
Public Types | Public Member Functions | Protected Types | Protected Member Functions | List of all members
sf::TcpListener Class Reference
Network module

Socket that listens to new TCP connections. More...

#include <TcpListener.hpp>

Inheritance diagram for sf::TcpListener:
sf::Socket sf::NonCopyable

Public Types

enum Status {
Done,
NotReady,
Disconnected,
Error
}
Status codes that may be returned by socket functions. More...
enum { AnyPort = 0 }
Some special values used by sockets. More...

Public Member Functions

TcpListener ()
Default constructor.
unsigned short | getLocalPort () const
Get the port to which the socket is bound locally.
Status | listen (unsigned short port)
Start listening for connections.
void | close ()
Stop listening and close the socket.
Status | accept (TcpSocket &socket)
Accept a new connection.
void | setBlocking (bool blocking)
Set the blocking state of the socket.
bool | isBlocking () const
Tell whether the socket is in blocking or non-blocking mode.

Protected Types

enum Type {
Tcp,
Udp
}
Types of protocols that the socket can use. More...

Protected Member Functions

SocketHandle | getHandle () const
Return the internal handle of the socket.
void | create ()
Create the internal representation of the socket.
void | create (SocketHandle handle)
Create the internal representation of the socket from a socket handle.

Detailed Description

Socket that listens to new TCP connections.

A listener socket is a special type of socket that listens to a given port and waits for connections on that port.

This is all it can do.

When a new connection is received, you must call accept and the listener returns a new instance of sf::TcpSocket that is properly initialized and can be used to communicate with the new client.

Listener sockets are specific to the TCP protocol, UDP sockets are connectionless and can therefore communicate directly. As a consequence, a listener socket will always return the new connections as sf::TcpSocket instances.

A listener is automatically closed on destruction, like all other types of socket. However if you want to stop listening before the socket is destroyed, you can call its close() function.

Usage example:

// Create a listener socket and make it wait for new
// connections on port 55001
sf::TcpListener listener;
listener.listen(55001);
// Endless loop that waits for new connections
while (running)
{
sf::TcpSocket client;
if (listener.accept(client) == sf::Socket::Done)
{
// A new client just connected!
std::cout << "New connection received from " << client.getRemoteAddress() << std::endl;
doSomethingWith(client);
}
}
See Also
sf::TcpSocket, sf::Socket

Definition at line 43 of file TcpListener.hpp.

Member Enumeration Documentation

anonymous enum
inherited

Some special values used by sockets.

Enumerator:
AnyPort

Special value that tells the system to pick any available port.

Definition at line 65 of file Socket.hpp.

enum sf::Socket::Status
inherited

Status codes that may be returned by socket functions.

Enumerator:
Done

The socket has sent / received the data.

NotReady

The socket is not ready to send / receive data yet.

Disconnected

The TCP socket has been disconnected.

Error

An unexpected error happened.

Definition at line 53 of file Socket.hpp.

enum sf::Socket::Type
protectedinherited

Types of protocols that the socket can use.

Enumerator:
Tcp

TCP protocol.

Udp

UDP protocol.

Definition at line 113 of file Socket.hpp.

Constructor & Destructor Documentation

sf::TcpListener::TcpListener ( )

Default constructor.

Member Function Documentation

Status sf::TcpListener::accept ( TcpSocket & socket )

Accept a new connection.

If the socket is in blocking mode, this function will not return until a connection is actually received.

Parameters
socket Socket that will hold the new connection
Returns
Status code
See Also
listen
void sf::TcpListener::close ( )

Stop listening and close the socket.

This function gracefully stops the listener. If the socket is not listening, this function has no effect.

See Also
listen
void sf::Socket::create ( )
protectedinherited

Create the internal representation of the socket.

This function can only be accessed by derived classes.

void sf::Socket::create ( SocketHandle handle )
protectedinherited

Create the internal representation of the socket from a socket handle.

This function can only be accessed by derived classes.

Parameters
handle OS-specific handle of the socket to wrap
SocketHandle sf::Socket::getHandle ( ) const
protectedinherited

Return the internal handle of the socket.

The returned handle may be invalid if the socket was not created yet (or already destroyed). This function can only be accessed by derived classes.

Returns
The internal (OS-specific) handle of the socket
unsigned short sf::TcpListener::getLocalPort ( ) const

Get the port to which the socket is bound locally.

If the socket is not listening to a port, this function returns 0.

Returns
Port to which the socket is bound
See Also
listen
bool sf::Socket::isBlocking ( ) const
inherited

Tell whether the socket is in blocking or non-blocking mode.

Returns
True if the socket is blocking, false otherwise
See Also
setBlocking
Status sf::TcpListener::listen ( unsigned short port )

Start listening for connections.

This functions makes the socket listen to the specified port, waiting for new connections. If the socket was previously listening to another port, it will be stopped first and bound to the new port.

Parameters
port Port to listen for new connections
Returns
Status code
See Also
accept, close
void sf::Socket::setBlocking ( bool blocking )
inherited

Set the blocking state of the socket.

In blocking mode, calls will not return until they have completed their task. For example, a call to Receive in blocking mode won't return until some data was actually received. In non-blocking mode, calls will always return immediately, using the return code to signal whether there was data available or not. By default, all sockets are blocking.

Parameters
blocking True to set the socket as blocking, false for non-blocking
See Also
isBlocking
The documentation for this class was generated from the following file:
  • TcpListener.hpp


  • sf
  • TcpSocket
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Friends | List of all members
sf::TcpSocket Class Reference
Network module

Specialized socket using the TCP protocol. More...

#include <TcpSocket.hpp>

Inheritance diagram for sf::TcpSocket:
sf::Socket sf::NonCopyable

Public Types

enum Status {
Done,
NotReady,
Disconnected,
Error
}
Status codes that may be returned by socket functions. More...
enum { AnyPort = 0 }
Some special values used by sockets. More...

Public Member Functions

TcpSocket ()
Default constructor.
unsigned short | getLocalPort () const
Get the port to which the socket is bound locally.
IpAddress | getRemoteAddress () const
Get the address of the connected peer.
unsigned short | getRemotePort () const
Get the port of the connected peer to which the socket is connected.
Status | connect (const IpAddress &remoteAddress, unsigned short remotePort, Time timeout=Time::Zero)
Connect the socket to a remote peer.
void | disconnect ()
Disconnect the socket from its remote peer.
Status | send (const void *data, std::size_t size)
Send raw data to the remote peer.
Status | receive (void *data, std::size_t size, std::size_t &received)
Receive raw data from the remote peer.
Status | send (Packet &packet)
Send a formatted packet of data to the remote peer.
Status | receive (Packet &packet)
Receive a formatted packet of data from the remote peer.
void | setBlocking (bool blocking)
Set the blocking state of the socket.
bool | isBlocking () const
Tell whether the socket is in blocking or non-blocking mode.

Protected Types

enum Type {
Tcp,
Udp
}
Types of protocols that the socket can use. More...

Protected Member Functions

SocketHandle | getHandle () const
Return the internal handle of the socket.
void | create ()
Create the internal representation of the socket.
void | create (SocketHandle handle)
Create the internal representation of the socket from a socket handle.
void | close ()
Close the socket gracefully.

Friends

class TcpListener

Detailed Description

Specialized socket using the TCP protocol.

TCP is a connected protocol, which means that a TCP socket can only communicate with the host it is connected to.

It can't send or receive anything if it is not connected.

The TCP protocol is reliable but adds a slight overhead. It ensures that your data will always be received in order and without errors (no data corrupted, lost or duplicated).

When a socket is connected to a remote host, you can retrieve informations about this host with the getRemoteAddress and getRemotePort functions. You can also get the local port to which the socket is bound (which is automatically chosen when the socket is connected), with the getLocalPort function.

Sending and receiving data can use either the low-level or the high-level functions. The low-level functions process a raw sequence of bytes, and cannot ensure that one call to Send will exactly match one call to Receive at the other end of the socket.

The high-level interface uses packets (see sf::Packet), which are easier to use and provide more safety regarding the data that is exchanged. You can look at the sf::Packet class to get more details about how they work.

The socket is automatically disconnected when it is destroyed, but if you want to explicitely close the connection while the socket instance is still alive, you can call disconnect.

Usage example:

// ----- The client -----
// Create a socket and connect it to 192.168.1.50 on port 55001
sf::TcpSocket socket;
socket.connect("192.168.1.50", 55001);
// Send a message to the connected host
std::string message = "Hi, I am a client";
socket.send(message.c_str(), message.size() + 1);
// Receive an answer from the server
char buffer[1024];
std::size_t received = 0;
socket.receive(buffer, sizeof(buffer), received);
std::cout << "The server said: " << buffer << std::endl;
// ----- The server -----
// Create a listener to wait for incoming connections on port 55001
sf::TcpListener listener;
listener.listen(55001);
// Wait for a connection
sf::TcpSocket socket;
listener.accept(socket);
std::cout << "New client connected: " << socket.getRemoteAddress() << std::endl;
// Receive a message from the client
char buffer[1024];
std::size_t received = 0;
socket.receive(buffer, sizeof(buffer), received);
std::cout << "The client said: " << buffer << std::endl;
// Send an answer
std::string message = "Welcome, client";
socket.send(message.c_str(), message.size() + 1);
See Also
sf::Socket, sf::UdpSocket, sf::Packet

Definition at line 46 of file TcpSocket.hpp.

Member Enumeration Documentation

anonymous enum
inherited

Some special values used by sockets.

Enumerator:
AnyPort

Special value that tells the system to pick any available port.

Definition at line 65 of file Socket.hpp.

enum sf::Socket::Status
inherited

Status codes that may be returned by socket functions.

Enumerator:
Done

The socket has sent / received the data.

NotReady

The socket is not ready to send / receive data yet.

Disconnected

The TCP socket has been disconnected.

Error

An unexpected error happened.

Definition at line 53 of file Socket.hpp.

enum sf::Socket::Type
protectedinherited

Types of protocols that the socket can use.

Enumerator:
Tcp

TCP protocol.

Udp

UDP protocol.

Definition at line 113 of file Socket.hpp.

Constructor & Destructor Documentation

sf::TcpSocket::TcpSocket ( )

Default constructor.

Member Function Documentation

void sf::Socket::close ( )
protectedinherited

Close the socket gracefully.

This function can only be accessed by derived classes.

Status sf::TcpSocket::connect | ( | const IpAddress & | remoteAddress,
 |  | unsigned short | remotePort,
 |  | Time | timeout = Time::Zero
 | ) |  |

Connect the socket to a remote peer.

In blocking mode, this function may take a while, especially if the remote peer is not reachable. The last parameter allows you to stop trying to connect after a given timeout. If the socket was previously connected, it is first disconnected.

Parameters
remoteAddress | Address of the remote peer
remotePort | Port of the remote peer
timeout | Optional maximum time to wait
Returns
Status code
See Also
disconnect
void sf::Socket::create ( )
protectedinherited

Create the internal representation of the socket.

This function can only be accessed by derived classes.

void sf::Socket::create ( SocketHandle handle )
protectedinherited

Create the internal representation of the socket from a socket handle.

This function can only be accessed by derived classes.

Parameters
handle OS-specific handle of the socket to wrap
void sf::TcpSocket::disconnect ( )

Disconnect the socket from its remote peer.

This function gracefully closes the connection. If the socket is not connected, this function has no effect.

See Also
connect
SocketHandle sf::Socket::getHandle ( ) const
protectedinherited

Return the internal handle of the socket.

The returned handle may be invalid if the socket was not created yet (or already destroyed). This function can only be accessed by derived classes.

Returns
The internal (OS-specific) handle of the socket
unsigned short sf::TcpSocket::getLocalPort ( ) const

Get the port to which the socket is bound locally.

If the socket is not connected, this function returns 0.

Returns
Port to which the socket is bound
See Also
connect, getRemotePort
IpAddress sf::TcpSocket::getRemoteAddress ( ) const

Get the address of the connected peer.

It the socket is not connected, this function returns sf::IpAddress::None.

Returns
Address of the remote peer
See Also
getRemotePort
unsigned short sf::TcpSocket::getRemotePort ( ) const

Get the port of the connected peer to which the socket is connected.

If the socket is not connected, this function returns 0.

Returns
Remote port to which the socket is connected
See Also
getRemoteAddress
bool sf::Socket::isBlocking ( ) const
inherited

Tell whether the socket is in blocking or non-blocking mode.

Returns
True if the socket is blocking, false otherwise
See Also
setBlocking
Status sf::TcpSocket::receive | ( | void * | data,
 |  | std::size_t | size,
 |  | std::size_t & | received
 | ) |  |

Receive raw data from the remote peer.

In blocking mode, this function will wait until some bytes are actually received. This function will fail if the socket is not connected.

Parameters
data | Pointer to the array to fill with the received bytes
size | Maximum number of bytes that can be received
received | This variable is filled with the actual number of bytes received
Returns
Status code
See Also
send
Status sf::TcpSocket::receive ( Packet & packet )

Receive a formatted packet of data from the remote peer.

In blocking mode, this function will wait until the whole packet has been received. This function will fail if the socket is not connected.

Parameters
packet Packet to fill with the received data
Returns
Status code
See Also
send
Status sf::TcpSocket::send | ( | const void * | data,
 |  | std::size_t | size
 | ) |  |

Send raw data to the remote peer.

This function will fail if the socket is not connected.

Parameters
data | Pointer to the sequence of bytes to send
size | Number of bytes to send
Returns
Status code
See Also
receive
Status sf::TcpSocket::send ( Packet & packet )

Send a formatted packet of data to the remote peer.

This function will fail if the socket is not connected.

Parameters
packet Packet to send
Returns
Status code
See Also
receive
void sf::Socket::setBlocking ( bool blocking )
inherited

Set the blocking state of the socket.

In blocking mode, calls will not return until they have completed their task. For example, a call to Receive in blocking mode won't return until some data was actually received. In non-blocking mode, calls will always return immediately, using the return code to signal whether there was data available or not. By default, all sockets are blocking.

Parameters
blocking True to set the socket as blocking, false for non-blocking
See Also
isBlocking
The documentation for this class was generated from the following file:
  • TcpSocket.hpp


  • sf
  • UdpSocket
Public Types | Public Member Functions | Protected Types | Protected Member Functions | List of all members
sf::UdpSocket Class Reference
Network module

Specialized socket using the UDP protocol. More...

#include <UdpSocket.hpp>

Inheritance diagram for sf::UdpSocket:
sf::Socket sf::NonCopyable

Public Types

enum | { MaxDatagramSize = 65507 }
enum Status {
Done,
NotReady,
Disconnected,
Error
}
Status codes that may be returned by socket functions. More...
enum | { AnyPort = 0 }
Some special values used by sockets. More...

Public Member Functions

UdpSocket ()
Default constructor.
unsigned short | getLocalPort () const
Get the port to which the socket is bound locally.
Status | bind (unsigned short port)
Bind the socket to a specific port.
void | unbind ()
Unbind the socket from the local port to which it is bound.
Status | send (const void *data, std::size_t size, const IpAddress &remoteAddress, unsigned short remotePort)
Send raw data to a remote peer.
Status | receive (void *data, std::size_t size, std::size_t &received, IpAddress &remoteAddress, unsigned short &remotePort)
Receive raw data from a remote peer.
Status | send (Packet &packet, const IpAddress &remoteAddress, unsigned short remotePort)
Send a formatted packet of data to a remote peer.
Status | receive (Packet &packet, IpAddress &remoteAddress, unsigned short &remotePort)
Receive a formatted packet of data from a remote peer.
void | setBlocking (bool blocking)
Set the blocking state of the socket.
bool | isBlocking () const
Tell whether the socket is in blocking or non-blocking mode.

Protected Types

enum Type {
Tcp,
Udp
}
Types of protocols that the socket can use. More...

Protected Member Functions

SocketHandle | getHandle () const
Return the internal handle of the socket.
void | create ()
Create the internal representation of the socket.
void | create (SocketHandle handle)
Create the internal representation of the socket from a socket handle.
void | close ()
Close the socket gracefully.

Detailed Description

Specialized socket using the UDP protocol.

A UDP socket is a connectionless socket.

Instead of connecting once to a remote host, like TCP sockets, it can send to and receive from any host at any time.

It is a datagram protocol: bounded blocks of data (datagrams) are transfered over the network rather than a continuous stream of data (TCP). Therefore, one call to send will always match one call to receive (if the datagram is not lost), with the same data that was sent.

The UDP protocol is lightweight but unreliable. Unreliable means that datagrams may be duplicated, be lost or arrive reordered. However, if a datagram arrives, its data is guaranteed to be valid.

UDP is generally used for real-time communication (audio or video streaming, real-time games, etc.) where speed is crucial and lost data doesn't matter much.

Sending and receiving data can use either the low-level or the high-level functions. The low-level functions process a raw sequence of bytes, whereas the high-level interface uses packets (see sf::Packet), which are easier to use and provide more safety regarding the data that is exchanged. You can look at the sf::Packet class to get more details about how they work.

It is important to note that UdpSocket is unable to send datagrams bigger than MaxDatagramSize. In this case, it returns an error and doesn't send anything. This applies to both raw data and packets. Indeed, even packets are unable to split and recompose data, due to the unreliability of the protocol (dropped, mixed or duplicated datagrams may lead to a big mess when trying to recompose a packet).

If the socket is bound to a port, it is automatically unbound from it when the socket is destroyed. However, you can unbind the socket explicitely with the Unbind function if necessary, to stop receiving messages or make the port available for other sockets.

Usage example:

// ----- The client -----
// Create a socket and bind it to the port 55001
sf::UdpSocket socket;
socket.bind(55001);
// Send a message to 192.168.1.50 on port 55002
std::string message = "Hi, I am " + sf::IpAddress::getLocalAddress().toString();
socket.send(message.c_str(), message.size() + 1, "192.168.1.50", 55002);
// Receive an answer (most likely from 192.168.1.50, but could be anyone else)
char buffer[1024];
std::size_t received = 0;
sf::IpAddress sender;
unsigned short port;
socket.receive(buffer, sizeof(buffer), received, sender, port);
std::cout << sender.ToString() << " said: " << buffer << std::endl;
// ----- The server -----
// Create a socket and bind it to the port 55002
sf::UdpSocket socket;
socket.bind(55002);
// Receive a message from anyone
char buffer[1024];
std::size_t received = 0;
sf::IpAddress sender;
unsigned short port;
socket.receive(buffer, sizeof(buffer), received, sender, port);
std::cout << sender.ToString() << " said: " << buffer << std::endl;
// Send an answer
std::string message = "Welcome " + sender.toString();
socket.send(message.c_str(), message.size() + 1, sender, port);
See Also
sf::Socket, sf::TcpSocket, sf::Packet

Definition at line 45 of file UdpSocket.hpp.

Member Enumeration Documentation

anonymous enum
inherited

Some special values used by sockets.

Enumerator:
AnyPort

Special value that tells the system to pick any available port.

Definition at line 65 of file Socket.hpp.

anonymous enum
Enumerator:
MaxDatagramSize

The maximum number of bytes that can be sent in a single UDP datagram.

Definition at line 52 of file UdpSocket.hpp.

enum sf::Socket::Status
inherited

Status codes that may be returned by socket functions.

Enumerator:
Done

The socket has sent / received the data.

NotReady

The socket is not ready to send / receive data yet.

Disconnected

The TCP socket has been disconnected.

Error

An unexpected error happened.

Definition at line 53 of file Socket.hpp.

enum sf::Socket::Type
protectedinherited

Types of protocols that the socket can use.

Enumerator:
Tcp

TCP protocol.

Udp

UDP protocol.

Definition at line 113 of file Socket.hpp.

Constructor & Destructor Documentation

sf::UdpSocket::UdpSocket ( )

Default constructor.

Member Function Documentation

Status sf::UdpSocket::bind ( unsigned short port )

Bind the socket to a specific port.

Binding the socket to a port is necessary for being able to receive data on that port. You can use the special value Socket::AnyPort to tell the system to automatically pick an available port, and then call getLocalPort to retrieve the chosen port.

Parameters
port Port to bind the socket to
Returns
Status code
See Also
unbind, getLocalPort
void sf::Socket::close ( )
protectedinherited

Close the socket gracefully.

This function can only be accessed by derived classes.

void sf::Socket::create ( )
protectedinherited

Create the internal representation of the socket.

This function can only be accessed by derived classes.

void sf::Socket::create ( SocketHandle handle )
protectedinherited

Create the internal representation of the socket from a socket handle.

This function can only be accessed by derived classes.

Parameters
handle OS-specific handle of the socket to wrap
SocketHandle sf::Socket::getHandle ( ) const
protectedinherited

Return the internal handle of the socket.

The returned handle may be invalid if the socket was not created yet (or already destroyed). This function can only be accessed by derived classes.

Returns
The internal (OS-specific) handle of the socket
unsigned short sf::UdpSocket::getLocalPort ( ) const

Get the port to which the socket is bound locally.

If the socket is not bound to a port, this function returns 0.

Returns
Port to which the socket is bound
See Also
bind
bool sf::Socket::isBlocking ( ) const
inherited

Tell whether the socket is in blocking or non-blocking mode.

Returns
True if the socket is blocking, false otherwise
See Also
setBlocking
Status sf::UdpSocket::receive | ( | void * | data,
 |  | std::size_t | size,
 |  | std::size_t & | received,
 |  | IpAddress & | remoteAddress,
 |  | unsigned short & | remotePort
 | ) |  |

Receive raw data from a remote peer.

In blocking mode, this function will wait until some bytes are actually received. Be careful to use a buffer which is large enough for the data that you intend to receive, if it is too small then an error will be returned and all the data will be lost.

Parameters
data | Pointer to the array to fill with the received bytes
size | Maximum number of bytes that can be received
received | This variable is filled with the actual number of bytes received
remoteAddress | Address of the peer that sent the data
remotePort | Port of the peer that sent the data
Returns
Status code
See Also
send
Status sf::UdpSocket::receive | ( | Packet & | packet,
 |  | IpAddress & | remoteAddress,
 |  | unsigned short & | remotePort
 | ) |  |

Receive a formatted packet of data from a remote peer.

In blocking mode, this function will wait until the whole packet has been received.

Parameters
packet | Packet to fill with the received data
remoteAddress | Address of the peer that sent the data
remotePort | Port of the peer that sent the data
Returns
Status code
See Also
send
Status sf::UdpSocket::send | ( | const void * | data,
 |  | std::size_t | size,
 |  | const IpAddress & | remoteAddress,
 |  | unsigned short | remotePort
 | ) |  |

Send raw data to a remote peer.

Make sure that size is not greater than UdpSocket::MaxDatagramSize, otherwise this function will fail and no data will be sent.

Parameters
data | Pointer to the sequence of bytes to send
size | Number of bytes to send
remoteAddress | Address of the receiver
remotePort | Port of the receiver to send the data to
Returns
Status code
See Also
receive
Status sf::UdpSocket::send | ( | Packet & | packet,
 |  | const IpAddress & | remoteAddress,
 |  | unsigned short | remotePort
 | ) |  |

Send a formatted packet of data to a remote peer.

Make sure that the packet size is not greater than UdpSocket::MaxDatagramSize, otherwise this function will fail and no data will be sent.

Parameters
packet | Packet to send
remoteAddress | Address of the receiver
remotePort | Port of the receiver to send the data to
Returns
Status code
See Also
receive
void sf::Socket::setBlocking ( bool blocking )
inherited

Set the blocking state of the socket.

In blocking mode, calls will not return until they have completed their task. For example, a call to Receive in blocking mode won't return until some data was actually received. In non-blocking mode, calls will always return immediately, using the return code to signal whether there was data available or not. By default, all sockets are blocking.

Parameters
blocking True to set the socket as blocking, false for non-blocking
See Also
isBlocking
void sf::UdpSocket::unbind ( )

Unbind the socket from the local port to which it is bound.

The port that the socket was previously using is immediately available after this function is called. If the socket is not bound to a port, this function has no effect.

See Also
bind
The documentation for this class was generated from the following file:
  • UdpSocket.hpp


  • sf
  • Ftp
  • DirectoryResponse
Public Types | Public Member Functions | List of all members
sf::Ftp::DirectoryResponse Class Reference
Network module

Specialization of FTP response returning a directory. More...

#include <Ftp.hpp>

Inheritance diagram for sf::Ftp::DirectoryResponse:
sf::Ftp::Response

Public Types

enum Status {
RestartMarkerReply = 110,
ServiceReadySoon = 120,
DataConnectionAlreadyOpened = 125,
OpeningDataConnection = 150,
Ok = 200,
PointlessCommand = 202,
SystemStatus = 211,
DirectoryStatus = 212,
FileStatus = 213,
HelpMessage = 214,
SystemType = 215,
ServiceReady = 220,
ClosingConnection = 221,
DataConnectionOpened = 225,
ClosingDataConnection = 226,
EnteringPassiveMode = 227,
LoggedIn = 230,
FileActionOk = 250,
DirectoryOk = 257,
NeedPassword = 331,
NeedAccountToLogIn = 332,
NeedInformation = 350,
ServiceUnavailable = 421,
DataConnectionUnavailable = 425,
TransferAborted = 426,
FileActionAborted = 450,
LocalError = 451,
InsufficientStorageSpace = 452,
CommandUnknown = 500,
ParametersUnknown = 501,
CommandNotImplemented = 502,
BadCommandSequence = 503,
ParameterNotImplemented = 504,
NotLoggedIn = 530,
NeedAccountToStore = 532,
FileUnavailable = 550,
PageTypeUnknown = 551,
NotEnoughMemory = 552,
FilenameNotAllowed = 553,
InvalidResponse = 1000,
ConnectionFailed = 1001,
ConnectionClosed = 1002,
InvalidFile = 1003
}
Status codes possibly returned by a FTP response. More...

Public Member Functions

DirectoryResponse (const Response &response)
Default constructor.
const std::string & | getDirectory () const
Get the directory returned in the response.
bool | isOk () const
Check if the status code means a success.
Status | getStatus () const
Get the status code of the response.
const std::string & | getMessage () const
Get the full message contained in the response.

Detailed Description

Specialization of FTP response returning a directory.

Definition at line 188 of file Ftp.hpp.

Member Enumeration Documentation

enum sf::Ftp::Response::Status
inherited

Status codes possibly returned by a FTP response.

Enumerator:
RestartMarkerReply

Restart marker reply.

ServiceReadySoon

Service ready in N minutes.

DataConnectionAlreadyOpened

Data connection already opened, transfer starting.

OpeningDataConnection

File status ok, about to open data connection.

Ok

Command ok.

PointlessCommand

Command not implemented.

SystemStatus

System status, or system help reply.

DirectoryStatus

Directory status.

FileStatus

File status.

HelpMessage

Help message.

SystemType

NAME system type, where NAME is an official system name from the list in the Assigned Numbers document.

ServiceReady

Service ready for new user.

ClosingConnection

Service closing control connection.

DataConnectionOpened

Data connection open, no transfer in progress.

ClosingDataConnection

Closing data connection, requested file action successful.

EnteringPassiveMode

Entering passive mode.

LoggedIn

User logged in, proceed. Logged out if appropriate.

FileActionOk

Requested file action ok.

DirectoryOk

PATHNAME created.

NeedPassword

User name ok, need password.

NeedAccountToLogIn

Need account for login.

NeedInformation

Requested file action pending further information.

ServiceUnavailable

Service not available, closing control connection.

DataConnectionUnavailable

Can't open data connection.

TransferAborted

Connection closed, transfer aborted.

FileActionAborted

Requested file action not taken.

LocalError

Requested action aborted, local error in processing.

InsufficientStorageSpace

Requested action not taken; insufficient storage space in system, file unavailable.

CommandUnknown

Syntax error, command unrecognized.

ParametersUnknown

Syntax error in parameters or arguments.

CommandNotImplemented

Command not implemented.

BadCommandSequence

Bad sequence of commands.

ParameterNotImplemented

Command not implemented for that parameter.

NotLoggedIn

Not logged in.

NeedAccountToStore

Need account for storing files.

FileUnavailable

Requested action not taken, file unavailable.

PageTypeUnknown

Requested action aborted, page type unknown.

NotEnoughMemory

Requested file action aborted, exceeded storage allocation.

FilenameNotAllowed

Requested action not taken, file name not allowed.

InvalidResponse

Response is not a valid FTP one.

ConnectionFailed

Connection with server failed.

ConnectionClosed

Connection with server closed.

InvalidFile

Invalid file to upload / download.

Definition at line 74 of file Ftp.hpp.

Constructor & Destructor Documentation

sf::Ftp::DirectoryResponse::DirectoryResponse ( const Response & response )

Default constructor.

Parameters
response Source response

Member Function Documentation

const std::string& sf::Ftp::DirectoryResponse::getDirectory ( ) const

Get the directory returned in the response.

Returns
Directory name
const std::string& sf::Ftp::Response::getMessage ( ) const
inherited

Get the full message contained in the response.

Returns
The response message
Status sf::Ftp::Response::getStatus ( ) const
inherited

Get the status code of the response.

Returns
Status code
bool sf::Ftp::Response::isOk ( ) const
inherited

Check if the status code means a success.

This function is defined for convenience, it is equivalent to testing if the status code is < 400.

Returns
True if the status is a success, false if it is a failure
The documentation for this class was generated from the following file:
  • Ftp.hpp


  • sf
  • Ftp
  • ListingResponse
Public Types | Public Member Functions | List of all members
sf::Ftp::ListingResponse Class Reference
Network module

Specialization of FTP response returning a filename lisiting. More...

#include <Ftp.hpp>

Inheritance diagram for sf::Ftp::ListingResponse:
sf::Ftp::Response

Public Types

enum Status {
RestartMarkerReply = 110,
ServiceReadySoon = 120,
DataConnectionAlreadyOpened = 125,
OpeningDataConnection = 150,
Ok = 200,
PointlessCommand = 202,
SystemStatus = 211,
DirectoryStatus = 212,
FileStatus = 213,
HelpMessage = 214,
SystemType = 215,
ServiceReady = 220,
ClosingConnection = 221,
DataConnectionOpened = 225,
ClosingDataConnection = 226,
EnteringPassiveMode = 227,
LoggedIn = 230,
FileActionOk = 250,
DirectoryOk = 257,
NeedPassword = 331,
NeedAccountToLogIn = 332,
NeedInformation = 350,
ServiceUnavailable = 421,
DataConnectionUnavailable = 425,
TransferAborted = 426,
FileActionAborted = 450,
LocalError = 451,
InsufficientStorageSpace = 452,
CommandUnknown = 500,
ParametersUnknown = 501,
CommandNotImplemented = 502,
BadCommandSequence = 503,
ParameterNotImplemented = 504,
NotLoggedIn = 530,
NeedAccountToStore = 532,
FileUnavailable = 550,
PageTypeUnknown = 551,
NotEnoughMemory = 552,
FilenameNotAllowed = 553,
InvalidResponse = 1000,
ConnectionFailed = 1001,
ConnectionClosed = 1002,
InvalidFile = 1003
}
Status codes possibly returned by a FTP response. More...

Public Member Functions

ListingResponse (const Response &response, const std::vector< char > &data)
Default constructor.
const std::vector< std::string > & | getListing () const
Return the array of directory/file names.
bool | isOk () const
Check if the status code means a success.
Status | getStatus () const
Get the status code of the response.
const std::string & | getMessage () const
Get the full message contained in the response.

Detailed Description

Specialization of FTP response returning a filename lisiting.

Definition at line 221 of file Ftp.hpp.

Member Enumeration Documentation

enum sf::Ftp::Response::Status
inherited

Status codes possibly returned by a FTP response.

Enumerator:
RestartMarkerReply

Restart marker reply.

ServiceReadySoon

Service ready in N minutes.

DataConnectionAlreadyOpened

Data connection already opened, transfer starting.

OpeningDataConnection

File status ok, about to open data connection.

Ok

Command ok.

PointlessCommand

Command not implemented.

SystemStatus

System status, or system help reply.

DirectoryStatus

Directory status.

FileStatus

File status.

HelpMessage

Help message.

SystemType

NAME system type, where NAME is an official system name from the list in the Assigned Numbers document.

ServiceReady

Service ready for new user.

ClosingConnection

Service closing control connection.

DataConnectionOpened

Data connection open, no transfer in progress.

ClosingDataConnection

Closing data connection, requested file action successful.

EnteringPassiveMode

Entering passive mode.

LoggedIn

User logged in, proceed. Logged out if appropriate.

FileActionOk

Requested file action ok.

DirectoryOk

PATHNAME created.

NeedPassword

User name ok, need password.

NeedAccountToLogIn

Need account for login.

NeedInformation

Requested file action pending further information.

ServiceUnavailable

Service not available, closing control connection.

DataConnectionUnavailable

Can't open data connection.

TransferAborted

Connection closed, transfer aborted.

FileActionAborted

Requested file action not taken.

LocalError

Requested action aborted, local error in processing.

InsufficientStorageSpace

Requested action not taken; insufficient storage space in system, file unavailable.

CommandUnknown

Syntax error, command unrecognized.

ParametersUnknown

Syntax error in parameters or arguments.

CommandNotImplemented

Command not implemented.

BadCommandSequence

Bad sequence of commands.

ParameterNotImplemented

Command not implemented for that parameter.

NotLoggedIn

Not logged in.

NeedAccountToStore

Need account for storing files.

FileUnavailable

Requested action not taken, file unavailable.

PageTypeUnknown

Requested action aborted, page type unknown.

NotEnoughMemory

Requested file action aborted, exceeded storage allocation.

FilenameNotAllowed

Requested action not taken, file name not allowed.

InvalidResponse

Response is not a valid FTP one.

ConnectionFailed

Connection with server failed.

ConnectionClosed

Connection with server closed.

InvalidFile

Invalid file to upload / download.

Definition at line 74 of file Ftp.hpp.

Constructor & Destructor Documentation

sf::Ftp::ListingResponse::ListingResponse | ( | const Response & | response,
 |  | const std::vector< char > & | data
 | ) |  |

Default constructor.

Parameters
response | Source response
data | Data containing the raw listing

Member Function Documentation

const std::vector<std::string>& sf::Ftp::ListingResponse::getListing ( ) const

Return the array of directory/file names.

Returns
Array containing the requested listing
const std::string& sf::Ftp::Response::getMessage ( ) const
inherited

Get the full message contained in the response.

Returns
The response message
Status sf::Ftp::Response::getStatus ( ) const
inherited

Get the status code of the response.

Returns
Status code
bool sf::Ftp::Response::isOk ( ) const
inherited

Check if the status code means a success.

This function is defined for convenience, it is equivalent to testing if the status code is < 400.

Returns
True if the status is a success, false if it is a failure
The documentation for this class was generated from the following file:
  • Ftp.hpp


  • sf
  • Ftp
  • Response
Public Types | Public Member Functions | List of all members
sf::Ftp::Response Class Reference
Network module

Define a FTP response. More...

#include <Ftp.hpp>

Inheritance diagram for sf::Ftp::Response:
sf::Ftp::DirectoryResponse sf::Ftp::ListingResponse

Public Types

enum Status {
RestartMarkerReply = 110,
ServiceReadySoon = 120,
DataConnectionAlreadyOpened = 125,
OpeningDataConnection = 150,
Ok = 200,
PointlessCommand = 202,
SystemStatus = 211,
DirectoryStatus = 212,
FileStatus = 213,
HelpMessage = 214,
SystemType = 215,
ServiceReady = 220,
ClosingConnection = 221,
DataConnectionOpened = 225,
ClosingDataConnection = 226,
EnteringPassiveMode = 227,
LoggedIn = 230,
FileActionOk = 250,
DirectoryOk = 257,
NeedPassword = 331,
NeedAccountToLogIn = 332,
NeedInformation = 350,
ServiceUnavailable = 421,
DataConnectionUnavailable = 425,
TransferAborted = 426,
FileActionAborted = 450,
LocalError = 451,
InsufficientStorageSpace = 452,
CommandUnknown = 500,
ParametersUnknown = 501,
CommandNotImplemented = 502,
BadCommandSequence = 503,
ParameterNotImplemented = 504,
NotLoggedIn = 530,
NeedAccountToStore = 532,
FileUnavailable = 550,
PageTypeUnknown = 551,
NotEnoughMemory = 552,
FilenameNotAllowed = 553,
InvalidResponse = 1000,
ConnectionFailed = 1001,
ConnectionClosed = 1002,
InvalidFile = 1003
}
Status codes possibly returned by a FTP response. More...

Public Member Functions

Response (Status code=InvalidResponse, const std::string &message="")
Default constructor.
bool | isOk () const
Check if the status code means a success.
Status | getStatus () const
Get the status code of the response.
const std::string & | getMessage () const
Get the full message contained in the response.

Detailed Description

Define a FTP response.

Definition at line 66 of file Ftp.hpp.

Member Enumeration Documentation

enum sf::Ftp::Response::Status

Status codes possibly returned by a FTP response.

Enumerator:
RestartMarkerReply

Restart marker reply.

ServiceReadySoon

Service ready in N minutes.

DataConnectionAlreadyOpened

Data connection already opened, transfer starting.

OpeningDataConnection

File status ok, about to open data connection.

Ok

Command ok.

PointlessCommand

Command not implemented.

SystemStatus

System status, or system help reply.

DirectoryStatus

Directory status.

FileStatus

File status.

HelpMessage

Help message.

SystemType

NAME system type, where NAME is an official system name from the list in the Assigned Numbers document.

ServiceReady

Service ready for new user.

ClosingConnection

Service closing control connection.

DataConnectionOpened

Data connection open, no transfer in progress.

ClosingDataConnection

Closing data connection, requested file action successful.

EnteringPassiveMode

Entering passive mode.

LoggedIn

User logged in, proceed. Logged out if appropriate.

FileActionOk

Requested file action ok.

DirectoryOk

PATHNAME created.

NeedPassword

User name ok, need password.

NeedAccountToLogIn

Need account for login.

NeedInformation

Requested file action pending further information.

ServiceUnavailable

Service not available, closing control connection.

DataConnectionUnavailable

Can't open data connection.

TransferAborted

Connection closed, transfer aborted.

FileActionAborted

Requested file action not taken.

LocalError

Requested action aborted, local error in processing.

InsufficientStorageSpace

Requested action not taken; insufficient storage space in system, file unavailable.

CommandUnknown

Syntax error, command unrecognized.

ParametersUnknown

Syntax error in parameters or arguments.

CommandNotImplemented

Command not implemented.

BadCommandSequence

Bad sequence of commands.

ParameterNotImplemented

Command not implemented for that parameter.

NotLoggedIn

Not logged in.

NeedAccountToStore

Need account for storing files.

FileUnavailable

Requested action not taken, file unavailable.

PageTypeUnknown

Requested action aborted, page type unknown.

NotEnoughMemory

Requested file action aborted, exceeded storage allocation.

FilenameNotAllowed

Requested action not taken, file name not allowed.

InvalidResponse

Response is not a valid FTP one.

ConnectionFailed

Connection with server failed.

ConnectionClosed

Connection with server closed.

InvalidFile

Invalid file to upload / download.

Definition at line 74 of file Ftp.hpp.

Constructor & Destructor Documentation

sf::Ftp::Response::Response | ( | Status | code = InvalidResponse,
 |  | const std::string & | message = ""
 | ) |  |
explicit

Default constructor.

This constructor is used by the FTP client to build the response.

Parameters
code | Response status code
message | Response message

Member Function Documentation

const std::string& sf::Ftp::Response::getMessage ( ) const

Get the full message contained in the response.

Returns
The response message
Status sf::Ftp::Response::getStatus ( ) const

Get the status code of the response.

Returns
Status code
bool sf::Ftp::Response::isOk ( ) const

Check if the status code means a success.

This function is defined for convenience, it is equivalent to testing if the status code is < 400.

Returns
True if the status is a success, false if it is a failure
The documentation for this class was generated from the following file:
  • Ftp.hpp


  • sf
  • Http
  • Request
Public Types | Public Member Functions | Friends | List of all members
sf::Http::Request Class Reference
Network module

Define a HTTP request. More...

#include <Http.hpp>

Public Types

enum Method {
Get,
Post,
Head
}
Enumerate the available HTTP methods for a request. More...

Public Member Functions

Request (const std::string &uri="/", Method method=Get, const std::string &body="")
Default constructor.
void | setField (const std::string &field, const std::string &value)
Set the value of a field.
void | setMethod (Method method)
Set the request method.
void | setUri (const std::string &uri)
Set the requested URI.
void | setHttpVersion (unsigned int major, unsigned int minor)
Set the HTTP version for the request.
void | setBody (const std::string &body)
Set the body of the request.

Friends

class Http

Detailed Description

Define a HTTP request.

Definition at line 54 of file Http.hpp.

Member Enumeration Documentation

enum sf::Http::Request::Method

Enumerate the available HTTP methods for a request.

Enumerator:
Get

Request in get mode, standard method to retrieve a page.

Post

Request in post mode, usually to send data to a page.

Head

Request a page's header only.

Definition at line 62 of file Http.hpp.

Constructor & Destructor Documentation

sf::Http::Request::Request | ( | const std::string & | uri = "/",
 |  | Method | method = Get,
 |  | const std::string & | body = ""
 | ) |  |

Default constructor.

This constructor creates a GET request, with the root URI ("/") and an empty body.

Parameters
uri | Target URI
method | Method to use for the request
body | Content of the request's body

Member Function Documentation

void sf::Http::Request::setBody ( const std::string & body )

Set the body of the request.

The body of a request is optional and only makes sense for POST requests. It is ignored for all other methods. The body is empty by default.

Parameters
body Content of the body
void sf::Http::Request::setField | ( | const std::string & | field,
 |  | const std::string & | value
 | ) |  |

Set the value of a field.

The field is created if it doesn't exist. The name of the field is case insensitive. By default, a request doesn't contain any field (but the mandatory fields are added later by the HTTP client when sending the request).

Parameters
field | Name of the field to set
value | Value of the field
void sf::Http::Request::setHttpVersion | ( | unsigned int | major,
 |  | unsigned int | minor
 | ) |  |

Set the HTTP version for the request.

The HTTP version is 1.0 by default.

Parameters
major | Major HTTP version number
minor | Minor HTTP version number
void sf::Http::Request::setMethod ( Method method )

Set the request method.

See the Method enumeration for a complete list of all the availale methods. The method is Http::Request::Get by default.

Parameters
method Method to use for the request
void sf::Http::Request::setUri ( const std::string & uri )

Set the requested URI.

The URI is the resource (usually a web page or a file) that you want to get or post. The URI is "/" (the root page) by default.

Parameters
uri URI to request, relative to the host
The documentation for this class was generated from the following file:
  • Http.hpp


  • sf
  • Http
  • Response
Public Types | Public Member Functions | Friends | List of all members
sf::Http::Response Class Reference
Network module

Define a HTTP response. More...

#include <Http.hpp>

Public Types

enum Status {
Ok = 200,
Created = 201,
Accepted = 202,
NoContent = 204,
ResetContent = 205,
PartialContent = 206,
MultipleChoices = 300,
MovedPermanently = 301,
MovedTemporarily = 302,
NotModified = 304,
BadRequest = 400,
Unauthorized = 401,
Forbidden = 403,
NotFound = 404,
RangeNotSatisfiable = 407,
InternalServerError = 500,
NotImplemented = 501,
BadGateway = 502,
ServiceNotAvailable = 503,
GatewayTimeout = 504,
VersionNotSupported = 505,
InvalidResponse = 1000,
ConnectionFailed = 1001
}
Enumerate all the valid status codes for a response. More...

Public Member Functions

Response ()
Default constructor.
const std::string & | getField (const std::string &field) const
Get the value of a field.
Status | getStatus () const
Get the response status code.
unsigned int | getMajorHttpVersion () const
Get the major HTTP version number of the response.
unsigned int | getMinorHttpVersion () const
Get the minor HTTP version number of the response.
const std::string & | getBody () const
Get the body of the response.

Friends

class Http

Detailed Description

Define a HTTP response.

Definition at line 191 of file Http.hpp.

Member Enumeration Documentation

enum sf::Http::Response::Status

Enumerate all the valid status codes for a response.

Enumerator:
Ok

Most common code returned when operation was successful.

Created

The resource has successfully been created.

Accepted

The request has been accepted, but will be processed later by the server.

NoContent

The server didn't send any data in return.

ResetContent

The server informs the client that it should clear the view (form) that caused the request to be sent.

PartialContent

The server has sent a part of the resource, as a response to a partial GET request.

MultipleChoices

The requested page can be accessed from several locations.

MovedPermanently

The requested page has permanently moved to a new location.

MovedTemporarily

The requested page has temporarily moved to a new location.

NotModified

For conditionnal requests, means the requested page hasn't changed and doesn't need to be refreshed.

BadRequest

The server couldn't understand the request (syntax error)

Unauthorized

The requested page needs an authentification to be accessed.

Forbidden

The requested page cannot be accessed at all, even with authentification.

NotFound

The requested page doesn't exist.

RangeNotSatisfiable

The server can't satisfy the partial GET request (with a "Range" header field)

InternalServerError

The server encountered an unexpected error.

NotImplemented

The server doesn't implement a requested feature.

BadGateway

The gateway server has received an error from the source server.

ServiceNotAvailable

The server is temporarily unavailable (overloaded, in maintenance, ...)

GatewayTimeout

The gateway server couldn't receive a response from the source server.

VersionNotSupported

The server doesn't support the requested HTTP version.

InvalidResponse

Response is not a valid HTTP one.

ConnectionFailed

Connection with server failed.

Definition at line 199 of file Http.hpp.

Constructor & Destructor Documentation

sf::Http::Response::Response ( )

Default constructor.

Constructs an empty response.

Member Function Documentation

const std::string& sf::Http::Response::getBody ( ) const

Get the body of the response.

The body of a response may contain:

  • the requested page (for GET requests)
  • a response from the server (for POST requests)
  • nothing (for HEAD requests)
  • an error message (in case of an error)
Returns
The response body
const std::string& sf::Http::Response::getField ( const std::string & field ) const

Get the value of a field.

If the field field is not found in the response header, the empty string is returned. This function uses case-insensitive comparisons.

Parameters
field Name of the field to get
Returns
Value of the field, or empty string if not found
unsigned int sf::Http::Response::getMajorHttpVersion ( ) const

Get the major HTTP version number of the response.

Returns
Major HTTP version number
See Also
getMinorHttpVersion
unsigned int sf::Http::Response::getMinorHttpVersion ( ) const

Get the minor HTTP version number of the response.

Returns
Minor HTTP version number
See Also
getMajorHttpVersion
Status sf::Http::Response::getStatus ( ) const

Get the response status code.

The status code should be the first thing to be checked after receiving a response, it defines whether it is a success, a failure or anything else (see the Status enumeration).

Returns
Status code of the response
The documentation for this class was generated from the following file:
  • Http.hpp


Classes | Functions
System module

Base module of SFML, defining various utilities. More...

Classes

class | sf::Clock
Utility class that measures the elapsed time. More...
class | sf::InputStream
Abstract class for custom file input streams. More...
class | sf::Lock
Automatic wrapper for locking and unlocking mutexes. More...
class | sf::Mutex
Blocks concurrent access to shared resources from multiple threads. More...
class | sf::NonCopyable
Utility class that makes any derived class non-copyable. More...
class | sf::String
Utility string class that automatically handles conversions between types and encodings. More...
class | sf::Thread
Utility class to manipulate threads. More...
class | sf::ThreadLocal
Defines variables with thread-local storage. More...
class | sf::ThreadLocalPtr< T >
Pointer to a thread-local variable. More...
class | sf::Time
Represents a time value. More...
class | sf::Utf
Utility class providing generic functions for UTF conversions. More...
class | sf::Vector2< T >
Utility template class for manipulating 2-dimensional vectors. More...
class | sf::Vector3< T >
Utility template class for manipulating 3-dimensional vectors. More...

Functions

void | sf::sleep (Time duration)
Make the current thread sleep for a given duration.
std::ostream & | sf::err ()
Standard stream used by SFML to output warnings and errors.

Detailed Description

Base module of SFML, defining various utilities.

It provides vector classes, unicode strings and conversion functions, threads and mutexes, timing classes.

Function Documentation

sf::err ( )

Standard stream used by SFML to output warnings and errors.

By default, sf::err() outputs to the same location as std::cerr, (-> the stderr descriptor) which is the console if there's one available.

It is a standard std::ostream instance, so it supports all the insertion operations defined by the STL (operator <<, manipulators, etc.).

sf::err() can be redirected to write to another output, independantly of std::cerr, by using the rdbuf() function provided by the std::ostream class.

Example:

// Redirect to a file
std::ofstream file("sfml-log.txt");
std::streambuf* previous = sf::err().rdbuf(file.rdbuf());
// Redirect to nothing
sf::err().rdbuf(NULL);
// Restore the original output
sf::err().rdbuf(previous);
void sf::sleep ( Time duration )

Make the current thread sleep for a given duration.

sf::sleep is the best way to block a program or one of its threads, as it doesn't consume any CPU power.

Parameters
duration Time to sleep


  • sf
  • Clock
Public Member Functions | List of all members
sf::Clock Class Reference
System module

Utility class that measures the elapsed time. More...

#include <Clock.hpp>

Public Member Functions

Clock ()
Default constructor.
Time getElapsedTime () const
Get the elapsed time.
Time restart ()
Restart the clock.

Detailed Description

Utility class that measures the elapsed time.

sf::Clock is a lightweight class for measuring time.

Its provides the most precise time that the underlying OS can achieve (generally microseconds or nanoseconds). It also ensures monotonicity, which means that the returned time can never go backward, even if the system time is changed.

Usage example:

sf::Clock clock;
...
Time time1 = clock.getElapsedTime();
...
Time time2 = clock.restart();

The sf::Time value returned by the clock can then be converted to a number of seconds, milliseconds or even microseconds.

See Also
sf::Time

Definition at line 41 of file Clock.hpp.

Constructor & Destructor Documentation

sf::Clock::Clock ( )

Default constructor.

The clock starts automatically after being constructed.

Member Function Documentation

Time sf::Clock::getElapsedTime ( ) const

Get the elapsed time.

This function returns the time elapsed since the last call to restart() (or the construction of the instance if restart() has not been called).

Returns
Time elapsed
Time sf::Clock::restart ( )

Restart the clock.

This function puts the time counter back to zero. It also returns the time elapsed since the clock was started.

Returns
Time elapsed
The documentation for this class was generated from the following file:
  • Clock.hpp


  • sf
  • InputStream
Public Member Functions | List of all members
sf::InputStream Class Referenceabstract
System module

Abstract class for custom file input streams. More...

#include <InputStream.hpp>

Public Member Functions

virtual | ~InputStream ()
Virtual destructor.
virtual Int64 | read (void *data, Int64 size)=0
Read data from the stream.
virtual Int64 | seek (Int64 position)=0
Change the current reading position.
virtual Int64 | tell ()=0
Get the current reading position in the stream.
virtual Int64 | getSize ()=0
Return the size of the stream.

Detailed Description

Abstract class for custom file input streams.

This class allows users to define their own file input sources from which SFML can load resources.

SFML resource classes like sf::Texture and sf::SoundBuffer provide loadFromFile and loadFromMemory functions, which read data from conventional sources. However, if you have data coming from a different source (over a network, embedded, encrypted, compressed, etc) you can derive your own class from sf::InputStream and load SFML resources with their loadFromStream function.

Usage example:

// custom stream class that reads from inside a zip file
class ZipStream : public sf::InputStream
{
public :
ZipStream(std::string archive);
bool open(std::string filename);
Int64 read(void* data, Int64 size);
Int64 seek(Int64 position);
Int64 tell();
Int64 getSize();
private :
...
};
// now you can load textures...
sf::Texture texture;
ZipStream stream("resources.zip");
stream.open("images/img.png");
texture.loadFromStream(stream);
// musics...
sf::Music music;
ZipStream stream("resources.zip");
stream.open("musics/msc.ogg");
music.openFromStream(stream);
// etc.

Definition at line 40 of file InputStream.hpp.

Constructor & Destructor Documentation

virtual sf::InputStream::~InputStream ( )
inlinevirtual

Virtual destructor.

Definition at line 48 of file InputStream.hpp.

Member Function Documentation

virtual Int64 sf::InputStream::getSize ( )
pure virtual

Return the size of the stream.

Returns
The total number of bytes available in the stream, or -1 on error
virtual Int64 sf::InputStream::read | ( | void * | data,
 |  | Int64 | size
 | ) |  |
pure virtual

Read data from the stream.

After reading, the stream's reading position must be advanced by the amount of bytes read.

Parameters
data | Buffer where to copy the read data
size | Desired number of bytes to read
Returns
The number of bytes actually read, or -1 on error
virtual Int64 sf::InputStream::seek ( Int64 position )
pure virtual

Change the current reading position.

Parameters
position The position to seek to, from the beginning
Returns
The position actually sought to, or -1 on error
virtual Int64 sf::InputStream::tell ( )
pure virtual

Get the current reading position in the stream.

Returns
The current position, or -1 on error.
The documentation for this class was generated from the following file:
  • InputStream.hpp


  • sf
  • Lock
Public Member Functions | List of all members
sf::Lock Class Reference
System module

Automatic wrapper for locking and unlocking mutexes. More...

#include <Lock.hpp>

Inheritance diagram for sf::Lock:
sf::NonCopyable

Public Member Functions

Lock (Mutex &mutex)
Construct the lock with a target mutex.
~Lock ()
Destructor.

Detailed Description

Automatic wrapper for locking and unlocking mutexes.

sf::Lock is a RAII wrapper for sf::Mutex.

By unlocking it in its destructor, it ensures that the mutex will always be released when the current scope (most likely a function) ends. This is even more important when an exception or an early return statement can interrupt the execution flow of the function.

For maximum robustness, sf::Lock should always be used to lock/unlock a mutex.

Usage example:

sf::Mutex mutex;
void function()
{
sf::Lock lock(mutex); // mutex is now locked
functionThatMayThrowAnException(); // mutex is unlocked if this function throws
if (someCondition)
return; // mutex is unlocked
} // mutex is unlocked

Because the mutex is not explicitely unlocked in the code, it may remain locked longer than needed. If the region of the code that needs to be protected by the mutex is not the entire function, a good practice is to create a smaller, inner scope so that the lock is limited to this part of the code.

sf::Mutex mutex;
void function()
{
{
sf::Lock lock(mutex);
codeThatRequiresProtection();
} // mutex is unlocked here
codeThatDoesntCareAboutTheMutex();
}

Having a mutex locked longer than required is a bad practice which can lead to bad performances. Don't forget that when a mutex is locked, other threads may be waiting doing nothing until it is released.

See Also
sf::Mutex

Definition at line 43 of file Lock.hpp.

Constructor & Destructor Documentation

sf::Lock::Lock ( Mutex & mutex )
explicit

Construct the lock with a target mutex.

The mutex passed to sf::Lock is automatically locked.

Parameters
mutex Mutex to lock
sf::Lock::~Lock ( )

Destructor.

The destructor of sf::Lock automatically unlocks its mutex.

The documentation for this class was generated from the following file:
  • Lock.hpp


  • sf
  • Mutex
Public Member Functions | List of all members
sf::Mutex Class Reference
System module

Blocks concurrent access to shared resources from multiple threads. More...

#include <Mutex.hpp>

Inheritance diagram for sf::Mutex:
sf::NonCopyable

Public Member Functions

Mutex ()
Default constructor.
~Mutex ()
Destructor.
void | lock ()
Lock the mutex.
void | unlock ()
Unlock the mutex.

Detailed Description

Blocks concurrent access to shared resources from multiple threads.

Mutex stands for "MUTual EXclusion".

A mutex is a synchronization object, used when multiple threads are involved.

When you want to protect a part of the code from being accessed simultaneously by multiple threads, you typically use a mutex. When a thread is locked by a mutex, any other thread trying to lock it will be blocked until the mutex is released by the thread that locked it. This way, you can allow only one thread at a time to access a critical region of your code.

Usage example:

Database database; // this is a critical resource that needs some protection
sf::Mutex mutex;
void thread1()
{
mutex.lock(); // this call will block the thread if the mutex is already locked by thread2
database.write(...);
mutex.unlock(); // if thread2 was waiting, it will now be unblocked
}
void thread2()
{
mutex.lock(); // this call will block the thread if the mutex is already locked by thread1
database.write(...);
mutex.unlock(); // if thread1 was waiting, it will now be unblocked
}

Be very careful with mutexes. A bad usage can lead to bad problems, like deadlocks (two threads are waiting for each other and the application is globally stuck).

To make the usage of mutexes more robust, particularly in environments where exceptions can be thrown, you should use the helper class sf::Lock to lock/unlock mutexes.

SFML mutexes are recursive, which means that you can lock a mutex multiple times in the same thread without creating a deadlock. In this case, the first call to lock() behaves as usual, and the following ones have no effect. However, you must call unlock() exactly as many times as you called lock(). If you don't, the mutex won't be released.

See Also
sf::Lock

Definition at line 47 of file Mutex.hpp.

Constructor & Destructor Documentation

sf::Mutex::Mutex ( )

Default constructor.

sf::Mutex::~Mutex ( )

Destructor.

Member Function Documentation

void sf::Mutex::lock ( )

Lock the mutex.

If the mutex is already locked in another thread, this call will block the execution until the mutex is released.

See Also
unlock
void sf::Mutex::unlock ( )

Unlock the mutex.

See Also
lock
The documentation for this class was generated from the following file:
  • Mutex.hpp


  • sf
  • NonCopyable
Protected Member Functions | List of all members
sf::NonCopyable Class Reference
System module

Utility class that makes any derived class non-copyable. More...

#include <NonCopyable.hpp>

Inheritance diagram for sf::NonCopyable:
sf::Context sf::Ftp sf::Http sf::Lock sf::Mutex sf::RenderTarget sf::Shader sf::Socket sf::Thread sf::ThreadLocal sf::Window

Protected Member Functions

NonCopyable ()
Default constructor.

Detailed Description

Utility class that makes any derived class non-copyable.

This class makes its instances non-copyable, by explicitely disabling its copy constructor and its assignment operator.

To create a non-copyable class, simply inherit from sf::NonCopyable.

The type of inheritance (public or private) doesn't matter, the copy constructor and assignment operator are declared private in sf::NonCopyable so they will end up being inaccessible in both cases. Thus you can use a shorter syntax for inheriting from it (see below).

Usage example:

class MyNonCopyableClass : sf::NonCopyable
{
...
};

Deciding whether the instances of a class can be copied or not is a very important design choice. You are strongly encouraged to think about it before writing a class, and to use sf::NonCopyable when necessary to prevent many potential future errors when using it. This is also a very important indication to users of your class.

Definition at line 41 of file NonCopyable.hpp.

Constructor & Destructor Documentation

sf::NonCopyable::NonCopyable ( )
inlineprotected

Default constructor.

Because this class has a copy constructor, the compiler will not automatically generate the default constructor. That's why we must define it explicitely.

Definition at line 53 of file NonCopyable.hpp.

The documentation for this class was generated from the following file:
  • NonCopyable.hpp


  • sf
  • String
Public Types | Public Member Functions | Static Public Attributes | Friends | Related Functions | List of all members
sf::String Class Reference
System module

Utility string class that automatically handles conversions between types and encodings. More...

#include <String.hpp>

Public Types

typedef std::basic_string
< Uint32 >::iterator 		Iterator
Iterator type.
typedef std::basic_string
< Uint32 >::const_iterator 		ConstIterator
Constant iterator type.

Public Member Functions

String ()
Default constructor.
String (char ansiChar, const std::locale &locale=std::locale())
Construct from a single ANSI character and a locale.
String (wchar_t wideChar)
Construct from single wide character.
String (Uint32 utf32Char)
Construct from single UTF-32 character.
String (const char *ansiString, const std::locale &locale=std::locale())
Construct from a null-terminated C-style ANSI string and a locale.
String (const std::string &ansiString, const std::locale &locale=std::locale())
Construct from an ANSI string and a locale.
String (const wchar_t *wideString)
Construct from null-terminated C-style wide string.
String (const std::wstring &wideString)
Construct from a wide string.
String (const Uint32 *utf32String)
Construct from a null-terminated C-style UTF-32 string.
String (const std::basic_string< Uint32 > &utf32String)
Construct from an UTF-32 string.
String (const String &copy)
Copy constructor.
operator std::string () const
Implicit cast operator to std::string (ANSI string)
operator std::wstring () const
Implicit cast operator to std::wstring (wide string)
std::string | toAnsiString (const std::locale &locale=std::locale()) const
Convert the unicode string to an ANSI string.
std::wstring | toWideString () const
Convert the unicode string to a wide string.
String & | operator= (const String &right)
Overload of assignment operator.
String & | operator+= (const String &right)
Overload of += operator to append an UTF-32 string.
Uint32 | operator[] (std::size_t index) const
Overload of [] operator to access a character by its position.
Uint32 & | operator[] (std::size_t index)
Overload of [] operator to access a character by its position.
void | clear ()
Clear the string.
std::size_t | getSize () const
Get the size of the string.
bool | isEmpty () const
Check whether the string is empty or not.
void | erase (std::size_t position, std::size_t count=1)
Erase one or more characters from the string.
void | insert (std::size_t position, const String &str)
Insert one or more characters into the string.
std::size_t | find (const String &str, std::size_t start=0) const
Find a sequence of one or more characters in the string.
const Uint32 * | getData () const
Get a pointer to the C-style array of characters.
Iterator begin ()
Return an iterator to the beginning of the string.
ConstIterator | begin () const
Return an iterator to the beginning of the string.
Iterator end ()
Return an iterator to the beginning of the string.
ConstIterator | end () const
Return an iterator to the beginning of the string.

Static Public Attributes

static const std::size_t InvalidPos
Represents an invalid position in the string.

Friends

bool | operator== (const String &left, const String &right)
bool | operator< (const String &left, const String &right)

Related Functions

(Note that these are not member functions.)

bool | operator== (const String &left, const String &right)
Overload of == operator to compare two UTF-32 strings.
bool | operator!= (const String &left, const String &right)
Overload of != operator to compare two UTF-32 strings.
bool | operator< (const String &left, const String &right)
Overload of < operator to compare two UTF-32 strings.
bool | operator> (const String &left, const String &right)
Overload of > operator to compare two UTF-32 strings.
bool | operator<= (const String &left, const String &right)
Overload of <= operator to compare two UTF-32 strings.
bool | operator>= (const String &left, const String &right)
Overload of >= operator to compare two UTF-32 strings.
String | operator+ (const String &left, const String &right)
Overload of binary + operator to concatenate two strings.

Detailed Description

Utility string class that automatically handles conversions between types and encodings.

sf::String is a utility string class defined mainly for convenience.

It is a Unicode string (implemented using UTF-32), thus it can store any character in the world (european, chinese, arabic, hebrew, etc.).

It automatically handles conversions from/to ANSI and wide strings, so that you can work with standard string classes and still be compatible with functions taking a sf::String.

sf::String s;
std::string s1 = s; // automatically converted to ANSI string
std::wstring s2 = s; // automatically converted to wide string
s = "hello"; // automatically converted from ANSI string
s = L"hello"; // automatically converted from wide string
s += 'a'; // automatically converted from ANSI string
s += L'a'; // automatically converted from wide string

Conversions involving ANSI strings use the default user locale. However it is possible to use a custom locale if necessary:

std::locale locale;
sf::String s;
...
std::string s1 = s.toAnsiString(locale);
s = sf::String("hello", locale);

sf::String defines the most important functions of the standard std::string class: removing, random access, iterating, appending, comparing, etc. However it is a simple class provided for convenience, and you may have to consider using a more optimized class if your program requires complex string handling. The automatic conversion functions will then take care of converting your string to sf::String whenever SFML requires it.

Please note that SFML also defines a low-level, generic interface for Unicode handling, see the sf::Utf classes.

Definition at line 43 of file String.hpp.

Member Typedef Documentation

typedef std::basic_string<Uint32>::const_iterator sf::String::ConstIterator

Constant iterator type.

Definition at line 51 of file String.hpp.

typedef std::basic_string<Uint32>::iterator sf::String::Iterator

Iterator type.

Definition at line 50 of file String.hpp.

Constructor & Destructor Documentation

sf::String::String ( )

Default constructor.

This constructor creates an empty string.

sf::String::String | ( | char | ansiChar,
 |  | const std::locale & | locale = std::locale()
 | ) |  |

Construct from a single ANSI character and a locale.

The source character is converted to UTF-32 according to the given locale.

Parameters
ansiChar | ANSI character to convert
locale | Locale to use for conversion
sf::String::String ( wchar_t wideChar )

Construct from single wide character.

Parameters
wideChar Wide character to convert
sf::String::String ( Uint32 utf32Char )

Construct from single UTF-32 character.

Parameters
utf32Char UTF-32 character to convert
sf::String::String | ( | const char * | ansiString,
 |  | const std::locale & | locale = std::locale()
 | ) |  |

Construct from a null-terminated C-style ANSI string and a locale.

The source string is converted to UTF-32 according to the given locale.

Parameters
ansiString | ANSI string to convert
locale | Locale to use for conversion
sf::String::String | ( | const std::string & | ansiString,
 |  | const std::locale & | locale = std::locale()
 | ) |  |

Construct from an ANSI string and a locale.

The source string is converted to UTF-32 according to the given locale.

Parameters
ansiString | ANSI string to convert
locale | Locale to use for conversion
sf::String::String ( const wchar_t * wideString )

Construct from null-terminated C-style wide string.

Parameters
wideString Wide string to convert
sf::String::String ( const std::wstring & wideString )

Construct from a wide string.

Parameters
wideString Wide string to convert
sf::String::String ( const Uint32 * utf32String )

Construct from a null-terminated C-style UTF-32 string.

Parameters
utf32String UTF-32 string to assign
sf::String::String ( const std::basic_string< Uint32 > & utf32String )

Construct from an UTF-32 string.

Parameters
utf32String UTF-32 string to assign
sf::String::String ( const String & copy )

Copy constructor.

Parameters
copy Instance to copy

Member Function Documentation

Iterator sf::String::begin ( )

Return an iterator to the beginning of the string.

Returns
Read-write iterator to the beginning of the string characters
See Also
end
ConstIterator sf::String::begin ( ) const

Return an iterator to the beginning of the string.

Returns
Read-only iterator to the beginning of the string characters
See Also
end
void sf::String::clear ( )

Clear the string.

This function removes all the characters from the string.

See Also
isEmpty, erase
Iterator sf::String::end ( )

Return an iterator to the beginning of the string.

The end iterator refers to 1 position past the last character; thus it represents an invalid character and should never be accessed.

Returns
Read-write iterator to the end of the string characters
See Also
begin
ConstIterator sf::String::end ( ) const

Return an iterator to the beginning of the string.

The end iterator refers to 1 position past the last character; thus it represents an invalid character and should never be accessed.

Returns
Read-only iterator to the end of the string characters
See Also
begin
void sf::String::erase | ( | std::size_t | position,
 |  | std::size_t | count = 1
 | ) |  |

Erase one or more characters from the string.

This function removes a sequence of count characters starting from position.

Parameters
position | Position of the first character to erase
count | Number of characters to erase
std::size_t sf::String::find | ( | const String & | str,
 |  | std::size_t | start = 0
 | ) |  | const

Find a sequence of one or more characters in the string.

This function searches for the characters of str into the string, starting from start.

Parameters
str | Characters to find
start | Where to begin searching
Returns
Position of str in the string, or String::InvalidPos if not found
const Uint32* sf::String::getData ( ) const

Get a pointer to the C-style array of characters.

This functions provides a read-only access to a null-terminated C-style representation of the string. The returned pointer is temporary and is meant only for immediate use, thus it is not recommended to store it.

Returns
Read-only pointer to the array of characters
std::size_t sf::String::getSize ( ) const

Get the size of the string.

Returns
Number of characters in the string
See Also
isEmpty
void sf::String::insert | ( | std::size_t | position,
 |  | const String & | str
 | ) |  |

Insert one or more characters into the string.

This function inserts the characters of str into the string, starting from position.

Parameters
position | Position of insertion
str | Characters to insert
bool sf::String::isEmpty ( ) const

Check whether the string is empty or not.

Returns
True if the string is empty (i.e. contains no character)
See Also
clear, getSize
sf::String::operator std::string ( ) const

Implicit cast operator to std::string (ANSI string)

The current global locale is used for conversion. If you want to explicitely specify a locale, see toAnsiString. Characters that do not fit in the target encoding are discarded from the returned string. This operator is defined for convenience, and is equivalent to calling toAnsiString().

Returns
Converted ANSI string
See Also
toAnsiString, operator std::wstring
sf::String::operator std::wstring ( ) const

Implicit cast operator to std::wstring (wide string)

Characters that do not fit in the target encoding are discarded from the returned string. This operator is defined for convenience, and is equivalent to calling toWideString().

Returns
Converted wide string
See Also
toWideString, operator std::string
String& sf::String::operator+= ( const String & right )

Overload of += operator to append an UTF-32 string.

Parameters
right String to append
Returns
Reference to self
String& sf::String::operator= ( const String & right )

Overload of assignment operator.

Parameters
right Instance to assign
Returns
Reference to self
Uint32 sf::String::operator[] ( std::size_t index ) const

Overload of [] operator to access a character by its position.

This function provides read-only access to characters. Note: this function doesn't throw if index is out of range.

Parameters
index Index of the character to get
Returns
Character at position index
Uint32& sf::String::operator[] ( std::size_t index )

Overload of [] operator to access a character by its position.

This function provides read and write access to characters. Note: this function doesn't throw if index is out of range.

Parameters
index Index of the character to get
Returns
Reference to the character at position index
std::string sf::String::toAnsiString ( const std::locale & locale = std::locale() ) const

Convert the unicode string to an ANSI string.

The UTF-32 string is converted to an ANSI string in the encoding defined by locale. Characters that do not fit in the target encoding are discarded from the returned string.

Parameters
locale Locale to use for conversion
Returns
Converted ANSI string
See Also
toWideString, operator std::string
std::wstring sf::String::toWideString ( ) const

Convert the unicode string to a wide string.

Characters that do not fit in the target encoding are discarded from the returned string.

Returns
Converted wide string
See Also
toAnsiString, operator std::wstring

Friends And Related Function Documentation

bool operator!= | ( | const String & | left,
 |  | const String & | right
 | ) |  |
related

Overload of != operator to compare two UTF-32 strings.

Parameters
left | Left operand (a string)
right | Right operand (a string)
Returns
True if both strings are different
String operator+ | ( | const String & | left,
 |  | const String & | right
 | ) |  |
related

Overload of binary + operator to concatenate two strings.

Parameters
left | Left operand (a string)
right | Right operand (a string)
Returns
Concatenated string
bool operator< | ( | const String & | left,
 |  | const String & | right
 | ) |  |
related

Overload of < operator to compare two UTF-32 strings.

Parameters
left | Left operand (a string)
right | Right operand (a string)
Returns
True if left is alphabetically lesser than right
bool operator<= | ( | const String & | left,
 |  | const String & | right
 | ) |  |
related

Overload of <= operator to compare two UTF-32 strings.

Parameters
left | Left operand (a string)
right | Right operand (a string)
Returns
True if left is alphabetically lesser or equal than right
bool operator== | ( | const String & | left,
 |  | const String & | right
 | ) |  |
related

Overload of == operator to compare two UTF-32 strings.

Parameters
left | Left operand (a string)
right | Right operand (a string)
Returns
True if both strings are equal
bool operator> | ( | const String & | left,
 |  | const String & | right
 | ) |  |
related

Overload of > operator to compare two UTF-32 strings.

Parameters
left | Left operand (a string)
right | Right operand (a string)
Returns
True if left is alphabetically greater than right
bool operator>= | ( | const String & | left,
 |  | const String & | right
 | ) |  |
related

Overload of >= operator to compare two UTF-32 strings.

Parameters
left | Left operand (a string)
right | Right operand (a string)
Returns
True if left is alphabetically greater or equal than right

Member Data Documentation

const std::size_t sf::String::InvalidPos
static

Represents an invalid position in the string.

Definition at line 56 of file String.hpp.

The documentation for this class was generated from the following file:
  • String.hpp


  • sf
  • Thread
Public Member Functions | List of all members
sf::Thread Class Reference
System module

Utility class to manipulate threads. More...

#include <Thread.hpp>

Inheritance diagram for sf::Thread:
sf::NonCopyable

Public Member Functions

template<typename F >
Thread (F function)
Construct the thread from a functor with no argument.
template<typename F , typename A >
Thread (F function, A argument)
Construct the thread from a functor with an argument.
template<typename C >
Thread (void(C::*function)(), C *object)
Construct the thread from a member function and an object.
~Thread ()
Destructor.
void | launch ()
Run the thread.
void | wait ()
Wait until the thread finishes.
void | terminate ()
Terminate the thread.
template<typename F >
Thread (F functor)
template<typename F , typename A >
Thread (F function, A argument)
template<typename C >
Thread (void(C::*function)(), C *object)

Detailed Description

Utility class to manipulate threads.

Threads provide a way to run multiple parts of the code in parallel.

When you launch a new thread, the execution is split and both the new thread and the caller run in parallel.

To use a sf::Thread, you construct it directly with the function to execute as the entry point of the thread. sf::Thread has multiple template constructors, which means that you can use several types of entry points:

  • non-member functions with no argument
  • non-member functions with one argument of any type
  • functors with no argument (this one is particularly useful for compatibility with boost/std::bind)
  • functors with one argument of any type
  • member functions from any class with no argument

The function argument, if any, is copied in the sf::Thread instance, as well as the functor (if the corresponding constructor is used). Class instances, however, are passed by pointer so you must make sure that the object won't be destroyed while the thread is still using it.

The thread ends when its function is terminated. If the owner sf::Thread instance is destroyed before the thread is finished, the destructor will wait (see wait())

Usage examples:

// example 1: non member function with one argument
void threadFunc(int argument)
{
...
}
sf::Thread thread(&threadFunc, 5);
thread.launch(); // start the thread (internally calls threadFunc(5))
// example 2: member function
class Task
{
public :
void run()
{
...
}
};
Task task;
sf::Thread thread(&Task::run, &task);
thread.launch(); // start the thread (internally calls task.run())
// example 3: functor
struct Task
{
void operator()()
{
...
}
};
sf::Thread thread(Task());
thread.launch(); // start the thread (internally calls operator() on the Task instance)

Creating parallel threads of execution can be dangerous: all threads inside the same process share the same memory space, which means that you may end up accessing the same variable from multiple threads at the same time. To prevent this kind of situations, you can use mutexes (see sf::Mutex).

See Also
sf::Mutex

Definition at line 48 of file Thread.hpp.

Constructor & Destructor Documentation

template<typename F >
sf::Thread::Thread ( F function )

Construct the thread from a functor with no argument.

This constructor works for function objects, as well as free function.

Use this constructor for this kind of function:

void function();
// --- or ----
struct Functor
{
void operator()();
};

Note: this does not run the thread, use Launch().

Parameters
function Functor or free function to use as the entry point of the thread
template<typename F , typename A >
sf::Thread::Thread | ( | F | function,
 |  | A | argument
 | ) |  |

Construct the thread from a functor with an argument.

This constructor works for function objects, as well as free function. It is a template, which means that the argument can have any type (int, std::string, void*, Toto, ...).

Use this constructor for this kind of function:

void function(int arg);
// --- or ----
struct Functor
{
void operator()(std::string arg);
};

Note: this does not run the thread, use Launch().

Parameters
function | Functor or free function to use as the entry point of the thread
argument | argument to forward to the function
template<typename C >
sf::Thread::Thread | ( | void(C::*)() | function,
 |  | C * | object
 | ) |  |

Construct the thread from a member function and an object.

This constructor is template, which means that you can use it with any class. Use this constructor for this kind of function:

class MyClass
{
public :
void function();
};

Note: this does not run the thread, use Launch().

Parameters
function | Entry point of the thread
object | Pointer to the object to use
sf::Thread::~Thread ( )

Destructor.

This destructor calls Wait(), so that the internal thread cannot survive after its sf::Thread instance is destroyed.

Member Function Documentation

void sf::Thread::launch ( )

Run the thread.

This function starts the entry point passed to the thread's constructor, and returns immediately. After this function returns, the thread's function is running in parallel to the calling code.

void sf::Thread::terminate ( )

Terminate the thread.

This function immediately stops the thread, without waiting for its function to finish. Terminating a thread with this function is not safe, and can lead to local variables not being destroyed on some operating systems. You should rather try to make the thread function terminate by itself.

void sf::Thread::wait ( )

Wait until the thread finishes.

This function will block the execution until the thread's function ends. Warning: if the thread function never ends, the calling thread will block forever. If this function is called from its owner thread, it returns without doing anything.

The documentation for this class was generated from the following files:
  • Thread.hpp
  • Thread.inl


  • sf
  • ThreadLocal
Public Member Functions | List of all members
sf::ThreadLocal Class Reference
System module

Defines variables with thread-local storage. More...

#include <ThreadLocal.hpp>

Inheritance diagram for sf::ThreadLocal:
sf::NonCopyable sf::ThreadLocalPtr< T >

Public Member Functions

ThreadLocal (void *value=NULL)
Default constructor.
~ThreadLocal ()
Destructor.
void | setValue (void *value)
Set the thread-specific value of the variable.
void * | getValue () const
Retrieve the thread-specific value of the variable.

Detailed Description

Defines variables with thread-local storage.

This class manipulates void* parameters and thus is not appropriate for strongly-typed variables.

You should rather use the sf::ThreadLocalPtr template class.

Definition at line 47 of file ThreadLocal.hpp.

Constructor & Destructor Documentation

sf::ThreadLocal::ThreadLocal ( void * value = NULL )

Default constructor.

Parameters
value Optional value to initalize the variable
sf::ThreadLocal::~ThreadLocal ( )

Destructor.

Member Function Documentation

void* sf::ThreadLocal::getValue ( ) const

Retrieve the thread-specific value of the variable.

Returns
Value of the variable for the current thread
void sf::ThreadLocal::setValue ( void * value )

Set the thread-specific value of the variable.

Parameters
value Value of the variable for the current thread
The documentation for this class was generated from the following file:
  • ThreadLocal.hpp


  • sf
  • ThreadLocalPtr
Public Member Functions | Private Member Functions | List of all members
sf::ThreadLocalPtr< T > Class Template Reference
System module

Pointer to a thread-local variable. More...

#include <ThreadLocalPtr.hpp>

Inheritance diagram for sf::ThreadLocalPtr< T >:
sf::ThreadLocal

Public Member Functions

ThreadLocalPtr (T *value=NULL)
Default constructor.
T & | operator* () const
Overload of unary operator *.
T * | operator-> () const
Overload of operator ->
operator T * () const
Cast operator to implicitely convert the pointer to its raw pointer type (T*)
ThreadLocalPtr< T > & | operator= (T *value)
Assignment operator for a raw pointer parameter.
ThreadLocalPtr< T > & | operator= (const ThreadLocalPtr< T > &right)
Assignment operator for a ThreadLocalPtr parameter.

Private Member Functions

void | setValue (void *value)
Set the thread-specific value of the variable.
void * | getValue () const
Retrieve the thread-specific value of the variable.

Detailed Description

template<typename T>
class sf::ThreadLocalPtr< T >

Pointer to a thread-local variable.

sf::ThreadLocalPtr is a type-safe wrapper for storing pointers to thread-local variables.

A thread-local variable holds a different value for each different thread, unlike normal variable that are shared.

Its usage is completely transparent, so that it is similar to manipulating the raw pointer directly (like any smart pointer).

Usage example:

MyClass object1;
MyClass object2;
sf::ThreadLocalPtr<MyClass> objectPtr;
void thread1()
{
objectPtr = &object1; // doesn't impact thread2
...
}
void thread2()
{
objectPtr = &object2; // doesn't impact thread1
...
}
int main()
{
// Create and launch the two threads
sf::Thread t1(&thread1);
sf::Thread t2(&thread2);
t1.launch();
t2.launch();
return 0;
}

ThreadLocalPtr is designed for internal use; however you can use it if you feel like it fits well your implementation.

Definition at line 41 of file ThreadLocalPtr.hpp.

Constructor & Destructor Documentation

template<typename T >
sf::ThreadLocalPtr< T >::ThreadLocalPtr ( T * value = NULL )

Default constructor.

Parameters
value Optional value to initalize the variable

Definition at line 30 of file ThreadLocalPtr.inl.

Member Function Documentation

template<typename T >
sf::ThreadLocalPtr< T >::operator T * ( ) const

Cast operator to implicitely convert the pointer to its raw pointer type (T*)

Returns
Pointer to the actual object

Definition at line 54 of file ThreadLocalPtr.inl.

template<typename T >
T & sf::ThreadLocalPtr< T >::operator* ( ) const

Overload of unary operator *.

Like raw pointers, applying the * operator returns a reference to the pointed object.

Returns
Reference to the pointed object

Definition at line 38 of file ThreadLocalPtr.inl.

template<typename T >
T * sf::ThreadLocalPtr< T >::operator-> ( ) const

Overload of operator ->

Like raw pointers, applying the -> operator returns the pointed object.

Returns
Pointed object

Definition at line 46 of file ThreadLocalPtr.inl.

template<typename T >
ThreadLocalPtr< T > & sf::ThreadLocalPtr< T >::operator= ( T * value )

Assignment operator for a raw pointer parameter.

Parameters
value Pointer to assign
Returns
Reference to self

Definition at line 62 of file ThreadLocalPtr.inl.

template<typename T >
ThreadLocalPtr< T > & sf::ThreadLocalPtr< T >::operator= ( const ThreadLocalPtr< T > & right )

Assignment operator for a ThreadLocalPtr parameter.

Parameters
right ThreadLocalPtr to assign
Returns
Reference to self

Definition at line 71 of file ThreadLocalPtr.inl.

The documentation for this class was generated from the following files:
  • ThreadLocalPtr.hpp
  • ThreadLocalPtr.inl


  • sf
  • Time
Public Member Functions | Static Public Attributes | Friends | Related Functions | List of all members
sf::Time Class Reference
System module

Represents a time value. More...

#include <Time.hpp>

Public Member Functions

Time ()
Default constructor.
float | asSeconds () const
Return the time value as a number of seconds.
Int32 | asMilliseconds () const
Return the time value as a number of milliseconds.
Int64 | asMicroseconds () const
Return the time value as a number of microseconds.

Static Public Attributes

static const Time Zero
Predefined "zero" time value.

Friends

Time | seconds (float)
Time | milliseconds (Int32)
Time | microseconds (Int64)

Related Functions

(Note that these are not member functions.)

Time | seconds (float amount)
Construct a time value from a number of seconds.
Time | milliseconds (Int32 amount)
Construct a time value from a number of milliseconds.
Time | microseconds (Int64 amount)
Construct a time value from a number of microseconds.
bool | operator== (Time left, Time right)
Overload of == operator to compare two time values.
bool | operator!= (Time left, Time right)
Overload of != operator to compare two time values.
bool | operator< (Time left, Time right)
Overload of < operator to compare two time values.
bool | operator> (Time left, Time right)
Overload of > operator to compare two time values.
bool | operator<= (Time left, Time right)
Overload of <= operator to compare two time values.
bool | operator>= (Time left, Time right)
Overload of >= operator to compare two time values.
Time | operator- (Time right)
Overload of unary - operator to negate a time value.
Time | operator+ (Time left, Time right)
Overload of binary + operator to add two time values.
Time & | operator+= (Time &left, Time right)
Overload of binary += operator to add/assign two time values.
Time | operator- (Time left, Time right)
Overload of binary - operator to subtract two time values.
Time & | operator-= (Time &left, Time right)
Overload of binary -= operator to subtract/assign two time values.
Time | operator* (Time left, float right)
Overload of binary * operator to scale a time value.
Time | operator* (Time left, Int64 right)
Overload of binary * operator to scale a time value.
Time | operator* (float left, Time right)
Overload of binary * operator to scale a time value.
Time | operator* (Int64 left, Time right)
Overload of binary * operator to scale a time value.
Time & | operator*= (Time &left, float right)
Overload of binary *= operator to scale/assign a time value.
Time & | operator*= (Time &left, Int64 right)
Overload of binary *= operator to scale/assign a time value.
Time | operator/ (Time left, float right)
Overload of binary / operator to scale a time value.
Time | operator/ (Time left, Int64 right)
Overload of binary / operator to scale a time value.
Time & | operator/= (Time &left, float right)
Overload of binary /= operator to scale/assign a time value.
Time & | operator/= (Time &left, Int64 right)
Overload of binary /= operator to scale/assign a time value.

Detailed Description

Represents a time value.

sf::Time encapsulates a time value in a flexible way.

It allows to define a time value either as a number of seconds, milliseconds or microseconds. It also works the other way round: you can read a time value as either a number of seconds, milliseconds or microseconds.

By using such a flexible interface, the API doesn't impose any fixed type or resolution for time values, and let the user choose its own favorite representation.

Time values support the usual mathematical operations: you can add or subtract two times, multiply or divide a time by a number, compare two times, etc.

Since they represent a time span and not an absolute time value, times can also be negative.

Usage example:

sf::Time t1 = sf::seconds(0.1f);
Int32 milli = t1.asMilliseconds(); // 100
sf::Time t2 = sf::milliseconds(30);
Int64 micro = t2.asMicroseconds(); // 30000
sf::Time t3 = sf::microseconds(-800000);
float sec = t3.asSeconds(); // -0.8
void update(sf::Time elapsed)
{
position += speed * elapsed.asSeconds();
}
update(sf::milliseconds(100));
See Also
sf::Clock

Definition at line 40 of file Time.hpp.

Constructor & Destructor Documentation

sf::Time::Time ( )

Default constructor.

Sets the time value to zero.

Member Function Documentation

Int64 sf::Time::asMicroseconds ( ) const

Return the time value as a number of microseconds.

Returns
Time in microseconds
See Also
asSeconds, asMilliseconds
Int32 sf::Time::asMilliseconds ( ) const

Return the time value as a number of milliseconds.

Returns
Time in milliseconds
See Also
asSeconds, asMicroseconds
float sf::Time::asSeconds ( ) const

Return the time value as a number of seconds.

Returns
Time in seconds
See Also
asMilliseconds, asMicroseconds

Friends And Related Function Documentation

Time microseconds ( Int64 amount )
related

Construct a time value from a number of microseconds.

Parameters
amount Number of microseconds
Returns
Time value constructed from the amount of microseconds
See Also
seconds, milliseconds
Time milliseconds ( Int32 amount )
related

Construct a time value from a number of milliseconds.

Parameters
amount Number of milliseconds
Returns
Time value constructed from the amount of milliseconds
See Also
seconds, microseconds
bool operator!= | ( | Time | left,
 |  | Time | right
 | ) |  |
related

Overload of != operator to compare two time values.

Parameters
left | Left operand (a time)
right | Right operand (a time)
Returns
True if both time values are different
Time operator* | ( | Time | left,
 |  | float | right
 | ) |  |
related

Overload of binary * operator to scale a time value.

Parameters
left | Left operand (a time)
right | Right operand (a number)
Returns
left multiplied by right
Time operator* | ( | Time | left,
 |  | Int64 | right
 | ) |  |
related

Overload of binary * operator to scale a time value.

Parameters
left | Left operand (a time)
right | Right operand (a number)
Returns
left multiplied by right
Time operator* | ( | float | left,
 |  | Time | right
 | ) |  |
related

Overload of binary * operator to scale a time value.

Parameters
left | Left operand (a number)
right | Right operand (a time)
Returns
left multiplied by right
Time operator* | ( | Int64 | left,
 |  | Time | right
 | ) |  |
related

Overload of binary * operator to scale a time value.

Parameters
left | Left operand (a number)
right | Right operand (a time)
Returns
left multiplied by right
Time & operator*= | ( | Time & | left,
 |  | float | right
 | ) |  |
related

Overload of binary *= operator to scale/assign a time value.

Parameters
left | Left operand (a time)
right | Right operand (a number)
Returns
left multiplied by right
Time & operator*= | ( | Time & | left,
 |  | Int64 | right
 | ) |  |
related

Overload of binary *= operator to scale/assign a time value.

Parameters
left | Left operand (a time)
right | Right operand (a number)
Returns
left multiplied by right
Time operator+ | ( | Time | left,
 |  | Time | right
 | ) |  |
related

Overload of binary + operator to add two time values.

Parameters
left | Left operand (a time)
right | Right operand (a time)
Returns
Sum of the two times values
Time & operator+= | ( | Time & | left,
 |  | Time | right
 | ) |  |
related

Overload of binary += operator to add/assign two time values.

Parameters
left | Left operand (a time)
right | Right operand (a time)
Returns
Sum of the two times values
Time operator- ( Time right )
related

Overload of unary - operator to negate a time value.

Parameters
right Right operand (a time)
Returns
Opposite of the time value
Time operator- | ( | Time | left,
 |  | Time | right
 | ) |  |
related

Overload of binary - operator to subtract two time values.

Parameters
left | Left operand (a time)
right | Right operand (a time)
Returns
Difference of the two times values
Time & operator-= | ( | Time & | left,
 |  | Time | right
 | ) |  |
related

Overload of binary -= operator to subtract/assign two time values.

Parameters
left | Left operand (a time)
right | Right operand (a time)
Returns
Difference of the two times values
Time operator/ | ( | Time | left,
 |  | float | right
 | ) |  |
related

Overload of binary / operator to scale a time value.

Parameters
left | Left operand (a time)
right | Right operand (a number)
Returns
left divided by right
Time operator/ | ( | Time | left,
 |  | Int64 | right
 | ) |  |
related

Overload of binary / operator to scale a time value.

Parameters
left | Left operand (a time)
right | Right operand (a number)
Returns
left divided by right
Time & operator/= | ( | Time & | left,
 |  | float | right
 | ) |  |
related

Overload of binary /= operator to scale/assign a time value.

Parameters
left | Left operand (a time)
right | Right operand (a number)
Returns
left divided by right
Time & operator/= | ( | Time & | left,
 |  | Int64 | right
 | ) |  |
related

Overload of binary /= operator to scale/assign a time value.

Parameters
left | Left operand (a time)
right | Right operand (a number)
Returns
left divided by right
bool operator< | ( | Time | left,
 |  | Time | right
 | ) |  |
related

Overload of < operator to compare two time values.

Parameters
left | Left operand (a time)
right | Right operand (a time)
Returns
True if left is lesser than right
bool operator<= | ( | Time | left,
 |  | Time | right
 | ) |  |
related

Overload of <= operator to compare two time values.

Parameters
left | Left operand (a time)
right | Right operand (a time)
Returns
True if left is lesser or equal than right
bool operator== | ( | Time | left,
 |  | Time | right
 | ) |  |
related

Overload of == operator to compare two time values.

Parameters
left | Left operand (a time)
right | Right operand (a time)
Returns
True if both time values are equal
bool operator> | ( | Time | left,
 |  | Time | right
 | ) |  |
related

Overload of > operator to compare two time values.

Parameters
left | Left operand (a time)
right | Right operand (a time)
Returns
True if left is greater than right
bool operator>= | ( | Time | left,
 |  | Time | right
 | ) |  |
related

Overload of >= operator to compare two time values.

Parameters
left | Left operand (a time)
right | Right operand (a time)
Returns
True if left is greater or equal than right
Time seconds ( float amount )
related

Construct a time value from a number of seconds.

Parameters
amount Number of seconds
Returns
Time value constructed from the amount of seconds
See Also
milliseconds, microseconds

Member Data Documentation

const Time sf::Time::Zero
static

Predefined "zero" time value.

Definition at line 85 of file Time.hpp.

The documentation for this class was generated from the following file:
  • Time.hpp


  • sf
  • Utf
sf::Utf Class Reference
System module

Utility class providing generic functions for UTF conversions. More...

#include <Utf.hpp>

Detailed Description

Utility class providing generic functions for UTF conversions.

sf::Utf is a low-level, generic interface for counting, iterating, encoding and decoding Unicode characters and strings. It is able to handle ANSI, wide, latin-1, UTF-8, UTF-16 and UTF-32 encodings.

sf::Utf<X> functions are all static, these classes are not meant to be instanciated. All the functions are template, so that you can use any character / string type for a given encoding.

It has 3 specializations:

  • sf::Utf<8> (typedef'd to sf::Utf8)
  • sf::Utf<16> (typedef'd to sf::Utf16)
  • sf::Utf<32> (typedef'd to sf::Utf32)
The documentation for this class was generated from the following file:
  • Utf.hpp


  • sf
  • Vector2
Public Member Functions | Public Attributes | Related Functions | List of all members
sf::Vector2< T > Class Template Reference
System module

Utility template class for manipulating 2-dimensional vectors. More...

#include <Vector2.hpp>

Public Member Functions

Vector2 ()
Default constructor.
Vector2 (T X, T Y)
Construct the vector from its coordinates.
template<typename U >
Vector2 (const Vector2< U > &vector)
Construct the vector from another type of vector.
template<typename T >
Vector2 (T X, T Y)
template<typename U >
Vector2 (const Vector2< U > &vector)

Public Attributes

T | x
X coordinate of the vector.
T | y
Y coordinate of the vector.

Related Functions

(Note that these are not member functions.)

template<typename T >
Vector2< T > | operator- (const Vector2< T > &right)
Overload of unary operator -.
template<typename T >
Vector2< T > & | operator+= (Vector2< T > &left, const Vector2< T > &right)
Overload of binary operator +=.
template<typename T >
Vector2< T > & | operator-= (Vector2< T > &left, const Vector2< T > &right)
Overload of binary operator -=.
template<typename T >
Vector2< T > | operator+ (const Vector2< T > &left, const Vector2< T > &right)
Overload of binary operator +.
template<typename T >
Vector2< T > | operator- (const Vector2< T > &left, const Vector2< T > &right)
Overload of binary operator -.
template<typename T >
Vector2< T > | operator* (const Vector2< T > &left, T right)
Overload of binary operator *.
template<typename T >
Vector2< T > | operator* (T left, const Vector2< T > &right)
Overload of binary operator *.
template<typename T >
Vector2< T > & | operator*= (Vector2< T > &left, T right)
Overload of binary operator *=.
template<typename T >
Vector2< T > | operator/ (const Vector2< T > &left, T right)
Overload of binary operator /.
template<typename T >
Vector2< T > & | operator/= (Vector2< T > &left, T right)
Overload of binary operator /=.
template<typename T >
bool | operator== (const Vector2< T > &left, const Vector2< T > &right)
Overload of binary operator ==.
template<typename T >
bool | operator!= (const Vector2< T > &left, const Vector2< T > &right)
Overload of binary operator !=.

Detailed Description

template<typename T>
class sf::Vector2< T >

Utility template class for manipulating 2-dimensional vectors.

sf::Vector2 is a simple class that defines a mathematical vector with two coordinates (x and y).

It can be used to represent anything that has two dimensions: a size, a point, a velocity, etc.

The template parameter T is the type of the coordinates. It can be any type that supports arithmetic operations (+, -, /, *) and comparisons (==, !=), for example int or float.

You generally don't have to care about the templated form (sf::Vector2<T>), the most common specializations have special typedefs:

  • sf::Vector2<float> is sf::Vector2f
  • sf::Vector2<int> is sf::Vector2i
  • sf::Vector2<unsigned int> is sf::Vector2u

The sf::Vector2 class has a small and simple interface, its x and y members can be accessed directly (there's no accessor like setX(), getX()) and it contains no mathematical function like dot product, cross product, length, etc.

Usage example:

sf::Vector2f v1(16.5f, 24.f);
v1.x = 18.2f;
float y = v1.y;
sf::Vector2f v2 = v1 * 5.f;
sf::Vector2f v3;
v3 = v1 + v2;
bool different = (v2 != v3);

Note: for 3-dimensional vectors, see sf::Vector3.

Definition at line 37 of file Vector2.hpp.

Constructor & Destructor Documentation

template<typename T>
sf::Vector2< T >::Vector2 ( )

Default constructor.

Creates a Vector2(0, 0).

template<typename T>
sf::Vector2< T >::Vector2 | ( | T | X,
 |  | T | Y
 | ) |  |

Construct the vector from its coordinates.

Parameters
X | X coordinate
Y | Y coordinate
template<typename T>
template<typename U >
sf::Vector2< T >::Vector2 ( const Vector2< U > & vector )
explicit

Construct the vector from another type of vector.

This constructor doesn't replace the copy constructor, it's called only when U != T. A call to this constructor will fail to compile if U is not convertible to T.

Parameters
vector Vector to convert

Friends And Related Function Documentation

template<typename T >
bool operator!= | ( | const Vector2< T > & | left,
 |  | const Vector2< T > & | right
 | ) |  |
related

Overload of binary operator !=.

This operator compares strict difference between two vectors.

Parameters
left | Left operand (a vector)
right | Right operand (a vector)
Returns
True if left is not equal to right
template<typename T >
Vector2< T > operator* | ( | const Vector2< T > & | left,
 |  | T | right
 | ) |  |
related

Overload of binary operator *.

Parameters
left | Left operand (a vector)
right | Right operand (a scalar value)
Returns
Memberwise multiplication by right
template<typename T >
Vector2< T > operator* | ( | T | left,
 |  | const Vector2< T > & | right
 | ) |  |
related

Overload of binary operator *.

Parameters
left | Left operand (a scalar value)
right | Right operand (a vector)
Returns
Memberwise multiplication by left
template<typename T >
Vector2< T > & operator*= | ( | Vector2< T > & | left,
 |  | T | right
 | ) |  |
related

Overload of binary operator *=.

This operator performs a memberwise multiplication by right, and assigns the result to left.

Parameters
left | Left operand (a vector)
right | Right operand (a scalar value)
Returns
Reference to left
template<typename T >
Vector2< T > operator+ | ( | const Vector2< T > & | left,
 |  | const Vector2< T > & | right
 | ) |  |
related

Overload of binary operator +.

Parameters
left | Left operand (a vector)
right | Right operand (a vector)
Returns
Memberwise addition of both vectors
template<typename T >
Vector2< T > & operator+= | ( | Vector2< T > & | left,
 |  | const Vector2< T > & | right
 | ) |  |
related

Overload of binary operator +=.

This operator performs a memberwise addition of both vectors, and assigns the result to left.

Parameters
left | Left operand (a vector)
right | Right operand (a vector)
Returns
Reference to left
template<typename T >
Vector2< T > operator- ( const Vector2< T > & right )
related

Overload of unary operator -.

Parameters
right Vector to negate
Returns
Memberwise opposite of the vector
template<typename T >
Vector2< T > operator- | ( | const Vector2< T > & | left,
 |  | const Vector2< T > & | right
 | ) |  |
related

Overload of binary operator -.

Parameters
left | Left operand (a vector)
right | Right operand (a vector)
Returns
Memberwise subtraction of both vectors
template<typename T >
Vector2< T > & operator-= | ( | Vector2< T > & | left,
 |  | const Vector2< T > & | right
 | ) |  |
related

Overload of binary operator -=.

This operator performs a memberwise subtraction of both vectors, and assigns the result to left.

Parameters
left | Left operand (a vector)
right | Right operand (a vector)
Returns
Reference to left
template<typename T >
Vector2< T > operator/ | ( | const Vector2< T > & | left,
 |  | T | right
 | ) |  |
related

Overload of binary operator /.

Parameters
left | Left operand (a vector)
right | Right operand (a scalar value)
Returns
Memberwise division by right
template<typename T >
Vector2< T > & operator/= | ( | Vector2< T > & | left,
 |  | T | right
 | ) |  |
related

Overload of binary operator /=.

This operator performs a memberwise division by right, and assigns the result to left.

Parameters
left | Left operand (a vector)
right | Right operand (a scalar value)
Returns
Reference to left
template<typename T >
bool operator== | ( | const Vector2< T > & | left,
 |  | const Vector2< T > & | right
 | ) |  |
related

Overload of binary operator ==.

This operator compares strict equality between two vectors.

Parameters
left | Left operand (a vector)
right | Right operand (a vector)
Returns
True if left is equal to right

Member Data Documentation

template<typename T>
T sf::Vector2< T >::x

X coordinate of the vector.

Definition at line 75 of file Vector2.hpp.

template<typename T>
T sf::Vector2< T >::y

Y coordinate of the vector.

Definition at line 76 of file Vector2.hpp.

The documentation for this class was generated from the following files:
  • Vector2.hpp
  • Vector2.inl


  • sf
  • Vector3
Public Member Functions | Public Attributes | Related Functions | List of all members
sf::Vector3< T > Class Template Reference
System module

Utility template class for manipulating 3-dimensional vectors. More...

#include <Vector3.hpp>

Public Member Functions

Vector3 ()
Default constructor.
Vector3 (T X, T Y, T Z)
Construct the vector from its coordinates.
template<typename U >
Vector3 (const Vector3< U > &vector)
Construct the vector from another type of vector.
template<typename T >
Vector3 (T X, T Y, T Z)
template<typename U >
Vector3 (const Vector3< U > &vector)

Public Attributes

T | x
X coordinate of the vector.
T | y
Y coordinate of the vector.
T | z
Z coordinate of the vector.

Related Functions

(Note that these are not member functions.)

template<typename T >
Vector3< T > | operator- (const Vector3< T > &left)
Overload of unary operator -.
template<typename T >
Vector3< T > & | operator+= (Vector3< T > &left, const Vector3< T > &right)
Overload of binary operator +=.
template<typename T >
Vector3< T > & | operator-= (Vector3< T > &left, const Vector3< T > &right)
Overload of binary operator -=.
template<typename T >
Vector3< T > | operator+ (const Vector3< T > &left, const Vector3< T > &right)
Overload of binary operator +.
template<typename T >
Vector3< T > | operator- (const Vector3< T > &left, const Vector3< T > &right)
Overload of binary operator -.
template<typename T >
Vector3< T > | operator* (const Vector3< T > &left, T right)
Overload of binary operator *.
template<typename T >
Vector3< T > | operator* (T left, const Vector3< T > &right)
Overload of binary operator *.
template<typename T >
Vector3< T > & | operator*= (Vector3< T > &left, T right)
Overload of binary operator *=.
template<typename T >
Vector3< T > | operator/ (const Vector3< T > &left, T right)
Overload of binary operator /.
template<typename T >
Vector3< T > & | operator/= (Vector3< T > &left, T right)
Overload of binary operator /=.
template<typename T >
bool | operator== (const Vector3< T > &left, const Vector3< T > &right)
Overload of binary operator ==.
template<typename T >
bool | operator!= (const Vector3< T > &left, const Vector3< T > &right)
Overload of binary operator !=.

Detailed Description

template<typename T>
class sf::Vector3< T >

Utility template class for manipulating 3-dimensional vectors.

sf::Vector3 is a simple class that defines a mathematical vector with three coordinates (x, y and z).

It can be used to represent anything that has three dimensions: a size, a point, a velocity, etc.

The template parameter T is the type of the coordinates. It can be any type that supports arithmetic operations (+, -, /, *) and comparisons (==, !=), for example int or float.

You generally don't have to care about the templated form (sf::Vector3<T>), the most common specializations have special typedefs:

  • sf::Vector3<float> is sf::Vector3f
  • sf::Vector3<int> is sf::Vector3i

The sf::Vector3 class has a small and simple interface, its x and y members can be accessed directly (there's no accessor like setX(), getX()) and it contains no mathematical function like dot product, cross product, length, etc.

Usage example:

sf::Vector3f v1(16.5f, 24.f, -8.2f);
v1.x = 18.2f;
float y = v1.y;
float z = v1.z;
sf::Vector3f v2 = v1 * 5.f;
sf::Vector3f v3;
v3 = v1 + v2;
bool different = (v2 != v3);

Note: for 2-dimensional vectors, see sf::Vector2.

Definition at line 37 of file Vector3.hpp.

Constructor & Destructor Documentation

template<typename T>
sf::Vector3< T >::Vector3 ( )

Default constructor.

Creates a Vector3(0, 0, 0).

template<typename T>
sf::Vector3< T >::Vector3 | ( | T | X,
 |  | T | Y,
 |  | T | Z
 | ) |  |

Construct the vector from its coordinates.

Parameters
X | X coordinate
Y | Y coordinate
Z | Z coordinate
template<typename T>
template<typename U >
sf::Vector3< T >::Vector3 ( const Vector3< U > & vector )
explicit

Construct the vector from another type of vector.

This constructor doesn't replace the copy constructor, it's called only when U != T. A call to this constructor will fail to compile if U is not convertible to T.

Parameters
vector Vector to convert

Friends And Related Function Documentation

template<typename T >
bool operator!= | ( | const Vector3< T > & | left,
 |  | const Vector3< T > & | right
 | ) |  |
related

Overload of binary operator !=.

This operator compares strict difference between two vectors.

Parameters
left | Left operand (a vector)
right | Right operand (a vector)
Returns
True if left is not equal to right
template<typename T >
Vector3< T > operator* | ( | const Vector3< T > & | left,
 |  | T | right
 | ) |  |
related

Overload of binary operator *.

Parameters
left | Left operand (a vector)
right | Right operand (a scalar value)
Returns
Memberwise multiplication by right
template<typename T >
Vector3< T > operator* | ( | T | left,
 |  | const Vector3< T > & | right
 | ) |  |
related

Overload of binary operator *.

Parameters
left | Left operand (a scalar value)
right | Right operand (a vector)
Returns
Memberwise multiplication by left
template<typename T >
Vector3< T > & operator*= | ( | Vector3< T > & | left,
 |  | T | right
 | ) |  |
related

Overload of binary operator *=.

This operator performs a memberwise multiplication by right, and assigns the result to left.

Parameters
left | Left operand (a vector)
right | Right operand (a scalar value)
Returns
Reference to left
template<typename T >
Vector3< T > operator+ | ( | const Vector3< T > & | left,
 |  | const Vector3< T > & | right
 | ) |  |
related

Overload of binary operator +.

Parameters
left | Left operand (a vector)
right | Right operand (a vector)
Returns
Memberwise addition of both vectors
template<typename T >
Vector3< T > & operator+= | ( | Vector3< T > & | left,
 |  | const Vector3< T > & | right
 | ) |  |
related

Overload of binary operator +=.

This operator performs a memberwise addition of both vectors, and assigns the result to left.

Parameters
left | Left operand (a vector)
right | Right operand (a vector)
Returns
Reference to left
template<typename T >
Vector3< T > operator- ( const Vector3< T > & left )
related

Overload of unary operator -.

Parameters
left Vector to negate
Returns
Memberwise opposite of the vector
template<typename T >
Vector3< T > operator- | ( | const Vector3< T > & | left,
 |  | const Vector3< T > & | right
 | ) |  |
related

Overload of binary operator -.

Parameters
left | Left operand (a vector)
right | Right operand (a vector)
Returns
Memberwise subtraction of both vectors
template<typename T >
Vector3< T > & operator-= | ( | Vector3< T > & | left,
 |  | const Vector3< T > & | right
 | ) |  |
related

Overload of binary operator -=.

This operator performs a memberwise subtraction of both vectors, and assigns the result to left.

Parameters
left | Left operand (a vector)
right | Right operand (a vector)
Returns
Reference to left
template<typename T >
Vector3< T > operator/ | ( | const Vector3< T > & | left,
 |  | T | right
 | ) |  |
related

Overload of binary operator /.

Parameters
left | Left operand (a vector)
right | Right operand (a scalar value)
Returns
Memberwise division by right
template<typename T >
Vector3< T > & operator/= | ( | Vector3< T > & | left,
 |  | T | right
 | ) |  |
related

Overload of binary operator /=.

This operator performs a memberwise division by right, and assigns the result to left.

Parameters
left | Left operand (a vector)
right | Right operand (a scalar value)
Returns
Reference to left
template<typename T >
bool operator== | ( | const Vector3< T > & | left,
 |  | const Vector3< T > & | right
 | ) |  |
related

Overload of binary operator ==.

This operator compares strict equality between two vectors.

Parameters
left | Left operand (a vector)
right | Right operand (a vector)
Returns
True if left is equal to right

Member Data Documentation

template<typename T>
T sf::Vector3< T >::x

X coordinate of the vector.

Definition at line 76 of file Vector3.hpp.

template<typename T>
T sf::Vector3< T >::y

Y coordinate of the vector.

Definition at line 77 of file Vector3.hpp.

template<typename T>
T sf::Vector3< T >::z

Z coordinate of the vector.

Definition at line 78 of file Vector3.hpp.

The documentation for this class was generated from the following files:
  • Vector3.hpp
  • Vector3.inl


Classes | Enumerations
Window module

Provides OpenGL-based windows, and abstractions for events and input handling. More...

Classes

class | sf::Context
Class holding a valid drawing context. More...
class | sf::ContextSettings
Structure defining the settings of the OpenGL context attached to a window. More...
class | sf::Event
Defines a system event and its parameters. More...
class | sf::GlResource
Base class for classes that require an OpenGL context. More...
class | sf::Joystick
Give access to the real-time state of the joysticks. More...
class | sf::Keyboard
Give access to the real-time state of the keyboard. More...
class | sf::Mouse
Give access to the real-time state of the mouse. More...
class | sf::VideoMode
VideoMode defines a video mode (width, height, bpp) More...
class | sf::Window
Window that serves as a target for OpenGL rendering. More...
struct | sf::Event::JoystickButtonEvent
Joystick buttons events parameters (JoystickButtonPressed, JoystickButtonReleased) More...
struct | sf::Event::JoystickConnectEvent
Joystick connection events parameters (JoystickConnected, JoystickDisconnected) More...
struct | sf::Event::JoystickMoveEvent
Joystick axis move event parameters (JoystickMoved) More...
struct | sf::Event::KeyEvent
Keyboard event parameters (KeyPressed, KeyReleased) More...
struct | sf::Event::MouseButtonEvent
Mouse buttons events parameters (MouseButtonPressed, MouseButtonReleased) More...
struct | sf::Event::MouseMoveEvent
Mouse move event parameters (MouseMoved) More...
struct | sf::Event::MouseWheelEvent
Mouse wheel events parameters (MouseWheelMoved) More...
struct | sf::Event::SizeEvent
Size events parameters (Resized) More...
struct | sf::Event::TextEvent
Text event parameters (TextEntered) More...

Enumerations

enum {
sf::Style::None = 0,
sf::Style::Titlebar = 1 << 0,
sf::Style::Resize = 1 << 1,
sf::Style::Close = 1 << 2,
sf::Style::Fullscreen = 1 << 3,
sf::Style::Default = Titlebar | Resize | Close
}
Enumeration of the window styles. More...

Detailed Description

Provides OpenGL-based windows, and abstractions for events and input handling.

Enumeration Type Documentation

anonymous enum

Enumeration of the window styles.

Enumerator:
None

No border / title bar (this flag and all others are mutually exclusive)

Titlebar

Title bar + fixed border.

Resize

Titlebar + resizable border + maximize button.

Close

Titlebar + close button.

Fullscreen

Fullscreen mode (this flag and all others are mutually exclusive)

Default

Default window style.

Definition at line 38 of file WindowStyle.hpp.


  • sf
  • Context
Public Member Functions | Static Private Member Functions | List of all members
sf::Context Class Reference
Window module

Class holding a valid drawing context. More...

#include <Context.hpp>

Inheritance diagram for sf::Context:
sf::GlResource sf::NonCopyable

Public Member Functions

Context ()
Default constructor.
~Context ()
Destructor.
bool setActive (bool active)
Activate or deactivate explicitely the context.
Context (const ContextSettings &settings, unsigned int width, unsigned int height)
Construct a in-memory context.

Static Private Member Functions

static void ensureGlContext ()
Make sure that a valid OpenGL context exists in the current thread.

Detailed Description

Class holding a valid drawing context.

If you need to make OpenGL calls without having an active window (like in a thread), you can use an instance of this class to get a valid context.

Having a valid context is necessary for every OpenGL call.

Note that a context is only active in its current thread, if you create a new thread it will have no valid context by default.

To use a sf::Context instance, just construct it and let it live as long as you need a valid context. No explicit activation is needed, all it has to do is to exist. Its destructor will take care of deactivating and freeing all the attached resources.

Usage example:

void threadFunction(void*)
{
sf::Context context;
// from now on, you have a valid context
// you can make OpenGL calls
glClear(GL_DEPTH_BUFFER_BIT);
}
// the context is automatically deactivated and destroyed
// by the sf::Context destructor

Definition at line 48 of file Context.hpp.

Constructor & Destructor Documentation

sf::Context::Context ( )

Default constructor.

The constructor creates and activates the context

sf::Context::~Context ( )

Destructor.

The desctructor deactivates and destroys the context

sf::Context::Context | ( | const ContextSettings & | settings,
 |  | unsigned int | width,
 |  | unsigned int | height
 | ) |  |

Construct a in-memory context.

This constructor is for internal use, you don't need to bother with it.

Parameters
settings | Creation parameters
width | Back buffer width
height | Back buffer height

Member Function Documentation

bool sf::Context::setActive ( bool active )

Activate or deactivate explicitely the context.

Parameters
active True to activate, false to deactivate
Returns
True on success, false on failure
The documentation for this class was generated from the following file:
  • Context.hpp


  • sf
  • ContextSettings
Public Member Functions | Public Attributes | List of all members
sf::ContextSettings Class Reference
Window module

Structure defining the settings of the OpenGL context attached to a window. More...

#include <ContextSettings.hpp>

Public Member Functions

ContextSettings (unsigned int depth=0, unsigned int stencil=0, unsigned int antialiasing=0, unsigned int major=2, unsigned int minor=0)
Default constructor.

Public Attributes

unsigned int | depthBits
Bits of the depth buffer.
unsigned int | stencilBits
Bits of the stencil buffer.
unsigned int | antialiasingLevel
Level of antialiasing.
unsigned int | majorVersion
Major number of the context version to create.
unsigned int | minorVersion
Minor number of the context version to create.

Detailed Description

Structure defining the settings of the OpenGL context attached to a window.

ContextSettings allows to define several advanced settings of the OpenGL context attached to a window.

All these settings have no impact on the regular SFML rendering (graphics module) – except the anti-aliasing level, so you may need to use this structure only if you're using SFML as a windowing system for custom OpenGL rendering.

The depthBits and stencilBits members define the number of bits per pixel requested for the (respectively) depth and stencil buffers.

antialiasingLevel represents the requested number of multisampling levels for anti-aliasing.

majorVersion and minorVersion define the version of the OpenGL context that you want. Only versions greater or equal to 3.0 are relevant; versions lesser than 3.0 are all handled the same way (i.e. you can use any version < 3.0 if you don't want an OpenGL 3 context).

Please note that these values are only a hint. No failure will be reported if one or more of these values are not supported by the system; instead, SFML will try to find the closest valid match. You can then retrieve the settings that the window actually used to create its context, with Window::getSettings().

Definition at line 36 of file ContextSettings.hpp.

Constructor & Destructor Documentation

sf::ContextSettings::ContextSettings | ( | unsigned int | depth = 0,
 |  | unsigned int | stencil = 0,
 |  | unsigned int | antialiasing = 0,
 |  | unsigned int | major = 2,
 |  | unsigned int | minor = 0
 | ) |  |
inlineexplicit

Default constructor.

Parameters
depth | Depth buffer bits
stencil | Stencil buffer bits
antialiasing | Antialiasing level
major | Major number of the context version
minor | Minor number of the context version

Definition at line 48 of file ContextSettings.hpp.

Member Data Documentation

unsigned int sf::ContextSettings::antialiasingLevel

Level of antialiasing.

Definition at line 62 of file ContextSettings.hpp.

unsigned int sf::ContextSettings::depthBits

Bits of the depth buffer.

Definition at line 60 of file ContextSettings.hpp.

unsigned int sf::ContextSettings::majorVersion

Major number of the context version to create.

Definition at line 63 of file ContextSettings.hpp.

unsigned int sf::ContextSettings::minorVersion

Minor number of the context version to create.

Definition at line 64 of file ContextSettings.hpp.

unsigned int sf::ContextSettings::stencilBits

Bits of the stencil buffer.

Definition at line 61 of file ContextSettings.hpp.

The documentation for this class was generated from the following file:
  • ContextSettings.hpp


  • sf
  • Event
Classes | Public Types | Public Attributes | List of all members
sf::Event Class Reference
Window module

Defines a system event and its parameters. More...

#include <Event.hpp>

Classes

struct | JoystickButtonEvent
Joystick buttons events parameters (JoystickButtonPressed, JoystickButtonReleased) More...
struct | JoystickConnectEvent
Joystick connection events parameters (JoystickConnected, JoystickDisconnected) More...
struct | JoystickMoveEvent
Joystick axis move event parameters (JoystickMoved) More...
struct | KeyEvent
Keyboard event parameters (KeyPressed, KeyReleased) More...
struct | MouseButtonEvent
Mouse buttons events parameters (MouseButtonPressed, MouseButtonReleased) More...
struct | MouseMoveEvent
Mouse move event parameters (MouseMoved) More...
struct | MouseWheelEvent
Mouse wheel events parameters (MouseWheelMoved) More...
struct | SizeEvent
Size events parameters (Resized) More...
struct | TextEvent
Text event parameters (TextEntered) More...

Public Types

enum EventType {
Closed,
Resized,
LostFocus,
GainedFocus,
TextEntered,
KeyPressed,
KeyReleased,
MouseWheelMoved,
MouseButtonPressed,
MouseButtonReleased,
MouseMoved,
MouseEntered,
MouseLeft,
JoystickButtonPressed,
JoystickButtonReleased,
JoystickMoved,
JoystickConnected,
JoystickDisconnected,
Count
}
Enumeration of the different types of events. More...

Public Attributes

EventType type
Type of the event.
union {
SizeEvent size
Size event parameters (Event::Resized)
KeyEvent key
Key event parameters (Event::KeyPressed, Event::KeyReleased)
TextEvent text
Text event parameters (Event::TextEntered)
MouseMoveEvent mouseMove
Mouse move event parameters (Event::MouseMoved)
MouseButtonEvent mouseButton
Mouse button event parameters (Event::MouseButtonPressed, Event::MouseButtonReleased)
MouseWheelEvent mouseWheel
Mouse wheel event parameters (Event::MouseWheelMoved)
JoystickMoveEvent joystickMove
Joystick move event parameters (Event::JoystickMoved)
JoystickButtonEvent joystickButton
Joystick button event parameters (Event::JoystickButtonPressed, Event::JoystickButtonReleased)
JoystickConnectEvent joystickConnect
Joystick (dis)connect event parameters (Event::JoystickConnected, Event::JoystickDisconnected)
};

Detailed Description

Defines a system event and its parameters.

sf::Event holds all the informations about a system event that just happened.

Events are retrieved using the sf::Window::pollEvent and sf::Window::waitEvent functions.

A sf::Event instance contains the type of the event (mouse moved, key pressed, window closed, ...) as well as the details about this particular event. Please note that the event parameters are defined in a union, which means that only the member matching the type of the event will be properly filled; all other members will have undefined values and must not be read if the type of the event doesn't match. For example, if you received a KeyPressed event, then you must read the event.key member, all other members such as event.MouseMove or event.text will have undefined values.

Usage example:

sf::Event event;
while (window.pollEvent(event))
{
// Request for closing the window
if (event.type == sf::Event::Closed)
window.close();
// The escape key was pressed
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
window.close();
// The window was resized
if (event.type == sf::Event::Resized)
doSomethingWithTheNewSize(event.size.width, event.size.height);
// etc ...
}

Definition at line 43 of file Event.hpp.

Member Enumeration Documentation

enum sf::Event::EventType

Enumeration of the different types of events.

Enumerator:
Closed

The window requested to be closed (no data)

Resized

The window was resized (data in event.size)

LostFocus

The window lost the focus (no data)

GainedFocus

The window gained the focus (no data)

TextEntered

A character was entered (data in event.text)

KeyPressed

A key was pressed (data in event.key)

KeyReleased

A key was released (data in event.key)

MouseWheelMoved

The mouse wheel was scrolled (data in event.mouseWheel)

MouseButtonPressed

A mouse button was pressed (data in event.mouseButton)

MouseButtonReleased

A mouse button was released (data in event.mouseButton)

MouseMoved

The mouse cursor moved (data in event.mouseMove)

MouseEntered

The mouse cursor entered the area of the window (no data)

MouseLeft

The mouse cursor left the area of the window (no data)

JoystickButtonPressed

A joystick button was pressed (data in event.joystickButton)

JoystickButtonReleased

A joystick button was released (data in event.joystickButton)

JoystickMoved

The joystick moved along an axis (data in event.joystickMove)

JoystickConnected

A joystick was connected (data in event.joystickConnect)

JoystickDisconnected

A joystick was disconnected (data in event.joystickConnect)

Count

Keep last – the total number of event types.

Definition at line 148 of file Event.hpp.

Member Data Documentation

JoystickButtonEvent sf::Event::joystickButton

Joystick button event parameters (Event::JoystickButtonPressed, Event::JoystickButtonReleased)

Definition at line 186 of file Event.hpp.

JoystickConnectEvent sf::Event::joystickConnect

Joystick (dis)connect event parameters (Event::JoystickConnected, Event::JoystickDisconnected)

Definition at line 187 of file Event.hpp.

JoystickMoveEvent sf::Event::joystickMove

Joystick move event parameters (Event::JoystickMoved)

Definition at line 185 of file Event.hpp.

KeyEvent sf::Event::key

Key event parameters (Event::KeyPressed, Event::KeyReleased)

Definition at line 180 of file Event.hpp.

MouseButtonEvent sf::Event::mouseButton

Mouse button event parameters (Event::MouseButtonPressed, Event::MouseButtonReleased)

Definition at line 183 of file Event.hpp.

MouseMoveEvent sf::Event::mouseMove

Mouse move event parameters (Event::MouseMoved)

Definition at line 182 of file Event.hpp.

MouseWheelEvent sf::Event::mouseWheel

Mouse wheel event parameters (Event::MouseWheelMoved)

Definition at line 184 of file Event.hpp.

SizeEvent sf::Event::size

Size event parameters (Event::Resized)

Definition at line 179 of file Event.hpp.

TextEvent sf::Event::text

Text event parameters (Event::TextEntered)

Definition at line 181 of file Event.hpp.

EventType sf::Event::type

Type of the event.

Definition at line 175 of file Event.hpp.

The documentation for this class was generated from the following file:
  • Event.hpp


  • sf
  • GlResource
Protected Member Functions | Static Protected Member Functions | List of all members
sf::GlResource Class Reference
Window module

Base class for classes that require an OpenGL context. More...

#include <GlResource.hpp>

Inheritance diagram for sf::GlResource:
sf::Context sf::Shader sf::Texture sf::Window sf::RenderWindow

Protected Member Functions

GlResource ()
Default constructor.
~GlResource ()
Destructor.

Static Protected Member Functions

static void ensureGlContext ()
Make sure that a valid OpenGL context exists in the current thread.

Detailed Description

Base class for classes that require an OpenGL context.

This class is for internal use only, it must be the base of every class that requires a valid OpenGL context in order to work.

Definition at line 40 of file GlResource.hpp.

Constructor & Destructor Documentation

sf::GlResource::GlResource ( )
protected

Default constructor.

sf::GlResource::~GlResource ( )
protected

Destructor.

Member Function Documentation

static void sf::GlResource::ensureGlContext ( )
staticprotected

Make sure that a valid OpenGL context exists in the current thread.

The documentation for this class was generated from the following file:
  • GlResource.hpp


  • sf
  • Joystick
Public Types | Static Public Member Functions | List of all members
sf::Joystick Class Reference
Window module

Give access to the real-time state of the joysticks. More...

#include <Joystick.hpp>

Public Types

enum {
Count = 8,
ButtonCount = 32,
AxisCount = 8
}
Constants related to joysticks capabilities. More...
enum Axis {
X,
Y,
Z,
R,
U,
V,
PovX,
PovY
}
Axes supported by SFML joysticks. More...

Static Public Member Functions

static bool | isConnected (unsigned int joystick)
Check if a joystick is connected.
static unsigned int | getButtonCount (unsigned int joystick)
Return the number of buttons supported by a joystick.
static bool | hasAxis (unsigned int joystick, Axis axis)
Check if a joystick supports a given axis.
static bool | isButtonPressed (unsigned int joystick, unsigned int button)
Check if a joystick button is pressed.
static float | getAxisPosition (unsigned int joystick, Axis axis)
Get the current position of a joystick axis.
static void | update ()
Update the states of all joysticks.

Detailed Description

Give access to the real-time state of the joysticks.

sf::Joystick provides an interface to the state of the joysticks.

It only contains static functions, so it's not meant to be instanciated. Instead, each joystick is identified by an index that is passed to the functions of this class.

This class allows users to query the state of joysticks at any time and directly, without having to deal with a window and its events. Compared to the JoystickMoved, JoystickButtonPressed and JoystickButtonReleased events, sf::Joystick can retrieve the state of axes and buttons of joysticks at any time (you don't need to store and update a boolean on your side in order to know if a button is pressed or released), and you always get the real state of joysticks, even if they are moved, pressed or released when your window is out of focus and no event is triggered.

SFML supports:

  • 8 joysticks (sf::Joystick::Count)
  • 32 buttons per joystick (sf::Joystick::ButtonCount)
  • 8 axes per joystick (sf::Joystick::AxisCount)

Unlike the keyboard or mouse, the state of joysticks is sometimes not directly available (depending on the OS), therefore an update() function must be called in order to update the current state of joysticks. When you have a window with event handling, this is done automatically, you don't need to call anything. But if you have no window, or if you want to check joysticks state before creating one, you must call sf::Joystick::update explicitely.

Usage example:

// Is joystick #0 connected?
bool connected = sf::Joystick::isConnected(0);
// How many buttons does joystick #0 support?
unsigned int buttons = sf::Joystick::getButtonCount(0);
// Does joystick #0 define a X axis?
bool hasX = sf::Joystick::hasAxis(0, sf::Joystick::X);
// Is button #2 pressed on joystick #0?
bool pressed = sf::Joystick::isButtonPressed(0, 2);
// What's the current position of the Y axis on joystick #0?
float position = sf::Joystick::getAxisPosition(0, sf::Joystick::Y);
See Also
sf::Keyboard, sf::Mouse

Definition at line 40 of file Joystick.hpp.

Member Enumeration Documentation

anonymous enum

Constants related to joysticks capabilities.

Enumerator:
Count

Maximum number of supported joysticks.

ButtonCount

Maximum number of supported buttons.

AxisCount

Maximum number of supported axes.

Definition at line 48 of file Joystick.hpp.

enum sf::Joystick::Axis

Axes supported by SFML joysticks.

Enumerator:
X

The X axis.

Y

The Y axis.

Z

The Z axis.

R

The R axis.

U

The U axis.

V

The V axis.

PovX

The X axis of the point-of-view hat.

PovY

The Y axis of the point-of-view hat.

Definition at line 59 of file Joystick.hpp.

Member Function Documentation

static float sf::Joystick::getAxisPosition | ( | unsigned int | joystick,
 |  | Axis | axis
 | ) |  |
static

Get the current position of a joystick axis.

If the joystick is not connected, this function returns 0.

Parameters
joystick | Index of the joystick
axis | Axis to check
Returns
Current position of the axis, in range [-100 .. 100]
static unsigned int sf::Joystick::getButtonCount ( unsigned int joystick )
static

Return the number of buttons supported by a joystick.

If the joystick is not connected, this function returns 0.

Parameters
joystick Index of the joystick
Returns
Number of buttons supported by the joystick
static bool sf::Joystick::hasAxis | ( | unsigned int | joystick,
 |  | Axis | axis
 | ) |  |
static

Check if a joystick supports a given axis.

If the joystick is not connected, this function returns false.

Parameters
joystick | Index of the joystick
axis | Axis to check
Returns
True if the joystick supports the axis, false otherwise
static bool sf::Joystick::isButtonPressed | ( | unsigned int | joystick,
 |  | unsigned int | button
 | ) |  |
static

Check if a joystick button is pressed.

If the joystick is not connected, this function returns false.

Parameters
joystick | Index of the joystick
button | Button to check
Returns
True if the button is pressed, false otherwise
static bool sf::Joystick::isConnected ( unsigned int joystick )
static

Check if a joystick is connected.

Parameters
joystick Index of the joystick to check
Returns
True if the joystick is connected, false otherwise
static void sf::Joystick::update ( )
static

Update the states of all joysticks.

This function is used internally by SFML, so you normally don't have to call it explicitely. However, you may need to call it if you have no window yet (or no window at all): in this case the joysticks states are not updated automatically.

The documentation for this class was generated from the following file:
  • Joystick.hpp


  • sf
  • Keyboard
Public Types | Static Public Member Functions | List of all members
sf::Keyboard Class Reference
Window module

Give access to the real-time state of the keyboard. More...

#include <Keyboard.hpp>

Public Types

enum Key {
Unknown = -1,
A = 0,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
Num0,
Num1,
Num2,
Num3,
Num4,
Num5,
Num6,
Num7,
Num8,
Num9,
Escape,
LControl,
LShift,
LAlt,
LSystem,
RControl,
RShift,
RAlt,
RSystem,
Menu,
LBracket,
RBracket,
SemiColon,
Comma,
Period,
Quote,
Slash,
BackSlash,
Tilde,
Equal,
Dash,
Space,
Return,
BackSpace,
Tab,
PageUp,
PageDown,
End,
Home,
Insert,
Delete,
Add,
Subtract,
Multiply,
Divide,
Left,
Right,
Up,
Down,
Numpad0,
Numpad1,
Numpad2,
Numpad3,
Numpad4,
Numpad5,
Numpad6,
Numpad7,
Numpad8,
Numpad9,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
Pause,
KeyCount
}
Key codes. More...

Static Public Member Functions

static bool isKeyPressed (Key key)
Check if a key is pressed.

Detailed Description

Give access to the real-time state of the keyboard.

sf::Keyboard provides an interface to the state of the keyboard.

It only contains static functions (a single keyboard is assumed), so it's not meant to be instanciated.

This class allows users to query the keyboard state at any time and directly, without having to deal with a window and its events. Compared to the KeyPressed and KeyReleased events, sf::Keyboard can retrieve the state of a key at any time (you don't need to store and update a boolean on your side in order to know if a key is pressed or released), and you always get the real state of the keyboard, even if keys are pressed or released when your window is out of focus and no event is triggered.

Usage example:

if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
// move left...
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
// move right...
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
{
// quit...
}
See Also
sf::Joystick, sf::Mouse

Definition at line 40 of file Keyboard.hpp.

Member Enumeration Documentation

enum sf::Keyboard::Key

Key codes.

Enumerator:
Unknown

Unhandled key.

A

The A key.

B

The B key.

C

The C key.

D

The D key.

E

The E key.

F

The F key.

G

The G key.

H

The H key.

I

The I key.

J

The J key.

K

The K key.

L

The L key.

M

The M key.

N

The N key.

O

The O key.

P

The P key.

Q

The Q key.

R

The R key.

S

The S key.

T

The T key.

U

The U key.

V

The V key.

W

The W key.

X

The X key.

Y

The Y key.

Z

The Z key.

Num0

The 0 key.

Num1

The 1 key.

Num2

The 2 key.

Num3

The 3 key.

Num4

The 4 key.

Num5

The 5 key.

Num6

The 6 key.

Num7

The 7 key.

Num8

The 8 key.

Num9

The 9 key.

Escape

The Escape key.

LControl

The left Control key.

LShift

The left Shift key.

LAlt

The left Alt key.

LSystem

The left OS specific key: window (Windows and Linux), apple (MacOS X), ...

RControl

The right Control key.

RShift

The right Shift key.

RAlt

The right Alt key.

RSystem

The right OS specific key: window (Windows and Linux), apple (MacOS X), ...

Menu

The Menu key.

LBracket

The [ key.

RBracket

The ] key.

SemiColon

The ; key.

Comma

The , key.

Period

The . key.

Quote

The ' key.

Slash

The / key.

BackSlash

The \ key.

Tilde

The ~ key.

Equal

The = key.

Dash

The - key.

Space

The Space key.

Return

The Return key.

BackSpace

The Backspace key.

Tab

The Tabulation key.

PageUp

The Page up key.

PageDown

The Page down key.

End

The End key.

Home

The Home key.

Insert

The Insert key.

Delete

The Delete key.

Add

The + key.

Subtract

The - key.

Multiply

The * key.

Divide

The / key.

Left

Left arrow.

Right

Right arrow.

Up

Up arrow.

Down

Down arrow.

Numpad0

The numpad 0 key.

Numpad1

The numpad 1 key.

Numpad2

The numpad 2 key.

Numpad3

The numpad 3 key.

Numpad4

The numpad 4 key.

Numpad5

The numpad 5 key.

Numpad6

The numpad 6 key.

Numpad7

The numpad 7 key.

Numpad8

The numpad 8 key.

Numpad9

The numpad 9 key.

F1

The F1 key.

F2

The F2 key.

F3

The F3 key.

F4

The F4 key.

F5

The F5 key.

F6

The F6 key.

F7

The F7 key.

F8

The F8 key.

F9

The F9 key.

F10

The F10 key.

F11

The F11 key.

F12

The F12 key.

F13

The F13 key.

F14

The F14 key.

F15

The F15 key.

Pause

The Pause key.

KeyCount

Keep last – the total number of keyboard keys.

Definition at line 48 of file Keyboard.hpp.

Member Function Documentation

static bool sf::Keyboard::isKeyPressed ( Key key )
static

Check if a key is pressed.

Parameters
key Key to check
Returns
True if the key is pressed, false otherwise
The documentation for this class was generated from the following file:
  • Keyboard.hpp


  • sf
  • Mouse
Public Types | Static Public Member Functions | List of all members
sf::Mouse Class Reference
Window module

Give access to the real-time state of the mouse. More...

#include <Mouse.hpp>

Public Types

enum Button {
Left,
Right,
Middle,
XButton1,
XButton2,
ButtonCount
}
Mouse buttons. More...

Static Public Member Functions

static bool | isButtonPressed (Button button)
Check if a mouse button is pressed.
static Vector2i | getPosition ()
Get the current position of the mouse in desktop coordinates.
static Vector2i | getPosition (const Window &relativeTo)
Get the current position of the mouse in window coordinates.
static void | setPosition (const Vector2i &position)
Set the current position of the mouse in desktop coordinates.
static void | setPosition (const Vector2i &position, const Window &relativeTo)
Set the current position of the mouse in window coordinates.

Detailed Description

Give access to the real-time state of the mouse.

sf::Mouse provides an interface to the state of the mouse.

It only contains static functions (a single mouse is assumed), so it's not meant to be instanciated.

This class allows users to query the mouse state at any time and directly, without having to deal with a window and its events. Compared to the MouseMoved, MouseButtonPressed and MouseButtonReleased events, sf::Mouse can retrieve the state of the cursor and the buttons at any time (you don't need to store and update a boolean on your side in order to know if a button is pressed or released), and you always get the real state of the mouse, even if it is moved, pressed or released when your window is out of focus and no event is triggered.

The setPosition and getPosition functions can be used to change or retrieve the current position of the mouse pointer. There are two versions: one that operates in global coordinates (relative to the desktop) and one that operates in window coordinates (relative to a specific window).

Usage example:

if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
// left click...
}
// get global mouse position
sf::Vector2i position = sf::Mouse::getPosition();
// set mouse position relative to a window
sf::Mouse::setPosition(sf::Vector2i(100, 200), window);
See Also
sf::Joystick, sf::Keyboard

Definition at line 43 of file Mouse.hpp.

Member Enumeration Documentation

enum sf::Mouse::Button

Mouse buttons.

Enumerator:
Left

The left mouse button.

Right

The right mouse button.

Middle

The middle (wheel) mouse button.

XButton1

The first extra mouse button.

XButton2

The second extra mouse button.

ButtonCount

Keep last – the total number of mouse buttons.

Definition at line 51 of file Mouse.hpp.

Member Function Documentation

static Vector2i sf::Mouse::getPosition ( )
static

Get the current position of the mouse in desktop coordinates.

This function returns the global position of the mouse cursor on the desktop.

Returns
Current position of the mouse
static Vector2i sf::Mouse::getPosition ( const Window & relativeTo )
static

Get the current position of the mouse in window coordinates.

This function returns the current position of the mouse cursor, relative to the given window.

Parameters
relativeTo Reference window
Returns
Current position of the mouse
static bool sf::Mouse::isButtonPressed ( Button button )
static

Check if a mouse button is pressed.

Parameters
button Button to check
Returns
True if the button is pressed, false otherwise
static void sf::Mouse::setPosition ( const Vector2i & position )
static

Set the current position of the mouse in desktop coordinates.

This function sets the global position of the mouse cursor on the desktop.

Parameters
position New position of the mouse
static void sf::Mouse::setPosition | ( | const Vector2i & | position,
 |  | const Window & | relativeTo
 | ) |  |
static

Set the current position of the mouse in window coordinates.

This function sets the current position of the mouse cursor, relative to the given window.

Parameters
position | New position of the mouse
relativeTo | Reference window
The documentation for this class was generated from the following file:
  • Mouse.hpp


  • sf
  • VideoMode
Public Member Functions | Static Public Member Functions | Public Attributes | Related Functions | List of all members
sf::VideoMode Class Reference
Window module

VideoMode defines a video mode (width, height, bpp) More...

#include <VideoMode.hpp>

Public Member Functions

VideoMode ()
Default constructor.
VideoMode (unsigned int modeWidth, unsigned int modeHeight, unsigned int modeBitsPerPixel=32)
Construct the video mode with its attributes.
bool isValid () const
Tell whether or not the video mode is valid.

Static Public Member Functions

static VideoMode getDesktopMode ()
Get the current desktop video mode.
static const std::vector
< VideoMode > & 		getFullscreenModes ()
Retrieve all the video modes supported in fullscreen mode.

Public Attributes

unsigned int | width
Video mode width, in pixels.
unsigned int | height
Video mode height, in pixels.
unsigned int | bitsPerPixel
Video mode pixel depth, in bits per pixels.

Related Functions

(Note that these are not member functions.)

bool | operator== (const VideoMode &left, const VideoMode &right)
Overload of == operator to compare two video modes.
bool | operator!= (const VideoMode &left, const VideoMode &right)
Overload of != operator to compare two video modes.
bool | operator< (const VideoMode &left, const VideoMode &right)
Overload of < operator to compare video modes.
bool | operator> (const VideoMode &left, const VideoMode &right)
Overload of > operator to compare video modes.
bool | operator<= (const VideoMode &left, const VideoMode &right)
Overload of <= operator to compare video modes.
bool | operator>= (const VideoMode &left, const VideoMode &right)
Overload of >= operator to compare video modes.

Detailed Description

VideoMode defines a video mode (width, height, bpp)

A video mode is defined by a width and a height (in pixels) and a depth (in bits per pixel).

Video modes are used to setup windows (sf::Window) at creation time.

The main usage of video modes is for fullscreen mode: indeed you must use one of the valid video modes allowed by the OS (which are defined by what the monitor and the graphics card support), otherwise your window creation will just fail.

sf::VideoMode provides a static function for retrieving the list of all the video modes supported by the system: getFullscreenModes().

A custom video mode can also be checked directly for fullscreen compatibility with its isValid() function.

Additionnally, sf::VideoMode provides a static function to get the mode currently used by the desktop: getDesktopMode(). This allows to build windows with the same size or pixel depth as the current resolution.

Usage example:

// Display the list of all the video modes available for fullscreen
std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes();
for (std::size_t i = 0; i < modes.size(); ++i)
{
sf::VideoMode mode = modes[i];
std::cout << "Mode #" << i << ": "
<< mode.width << "x" << mode.height << " - "
<< mode.bitsPerPixel << " bpp" << std::endl;
}
// Create a window with the same pixel depth as the desktop
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
window.create(sf::VideoMode(1024, 768, desktop.bitsPerPixel), "SFML window");

Definition at line 41 of file VideoMode.hpp.

Constructor & Destructor Documentation

sf::VideoMode::VideoMode ( )

Default constructor.

This constructors initializes all members to 0.

sf::VideoMode::VideoMode | ( | unsigned int | modeWidth,
 |  | unsigned int | modeHeight,
 |  | unsigned int | modeBitsPerPixel = 32
 | ) |  |

Construct the video mode with its attributes.

Parameters
modeWidth | Width in pixels
modeHeight | Height in pixels
modeBitsPerPixel | Pixel depths in bits per pixel

Member Function Documentation

static VideoMode sf::VideoMode::getDesktopMode ( )
static

Get the current desktop video mode.

Returns
Current desktop video mode
static const std::vector<VideoMode>& sf::VideoMode::getFullscreenModes ( )
static

Retrieve all the video modes supported in fullscreen mode.

When creating a fullscreen window, the video mode is restricted to be compatible with what the graphics driver and monitor support. This function returns the complete list of all video modes that can be used in fullscreen mode. The returned array is sorted from best to worst, so that the first element will always give the best mode (higher width, height and bits-per-pixel).

Returns
Array containing all the supported fullscreen modes
bool sf::VideoMode::isValid ( ) const

Tell whether or not the video mode is valid.

The validity of video modes is only relevant when using fullscreen windows; otherwise any video mode can be used with no restriction.

Returns
True if the video mode is valid for fullscreen mode

Friends And Related Function Documentation

bool operator!= | ( | const VideoMode & | left,
 |  | const VideoMode & | right
 | ) |  |
related

Overload of != operator to compare two video modes.

Parameters
left | Left operand (a video mode)
right | Right operand (a video mode)
Returns
True if modes are different
bool operator< | ( | const VideoMode & | left,
 |  | const VideoMode & | right
 | ) |  |
related

Overload of < operator to compare video modes.

Parameters
left | Left operand (a video mode)
right | Right operand (a video mode)
Returns
True if left is lesser than right
bool operator<= | ( | const VideoMode & | left,
 |  | const VideoMode & | right
 | ) |  |
related

Overload of <= operator to compare video modes.

Parameters
left | Left operand (a video mode)
right | Right operand (a video mode)
Returns
True if left is lesser or equal than right
bool operator== | ( | const VideoMode & | left,
 |  | const VideoMode & | right
 | ) |  |
related

Overload of == operator to compare two video modes.

Parameters
left | Left operand (a video mode)
right | Right operand (a video mode)
Returns
True if modes are equal
bool operator> | ( | const VideoMode & | left,
 |  | const VideoMode & | right
 | ) |  |
related

Overload of > operator to compare video modes.

Parameters
left | Left operand (a video mode)
right | Right operand (a video mode)
Returns
True if left is greater than right
bool operator>= | ( | const VideoMode & | left,
 |  | const VideoMode & | right
 | ) |  |
related

Overload of >= operator to compare video modes.

Parameters
left | Left operand (a video mode)
right | Right operand (a video mode)
Returns
True if left is greater or equal than right

Member Data Documentation

unsigned int sf::VideoMode::bitsPerPixel

Video mode pixel depth, in bits per pixels.

Definition at line 104 of file VideoMode.hpp.

unsigned int sf::VideoMode::height

Video mode height, in pixels.

Definition at line 103 of file VideoMode.hpp.

unsigned int sf::VideoMode::width

Video mode width, in pixels.

Definition at line 102 of file VideoMode.hpp.

The documentation for this class was generated from the following file:
  • VideoMode.hpp


  • sf
  • Window
Public Member Functions | Protected Member Functions | Static Private Member Functions | List of all members
sf::Window Class Reference
Window module

Window that serves as a target for OpenGL rendering. More...

#include <Window.hpp>

Inheritance diagram for sf::Window:
sf::GlResource sf::NonCopyable sf::RenderWindow

Public Member Functions

Window ()
Default constructor.
Window (VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings())
Construct a new window.
Window (WindowHandle handle, const ContextSettings &settings=ContextSettings())
Construct the window from an existing control.
virtual | ~Window ()
Destructor.
void | create (VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings())
Create (or recreate) the window.
void | create (WindowHandle handle, const ContextSettings &settings=ContextSettings())
Create (or recreate) the window from an existing control.
void | close ()
Close the window and destroy all the attached resources.
bool | isOpen () const
Tell whether or not the window is open.
const ContextSettings & | getSettings () const
Get the settings of the OpenGL context of the window.
bool | pollEvent (Event &event)
Pop the event on top of the event queue, if any, and return it.
bool | waitEvent (Event &event)
Wait for an event and return it.
Vector2i | getPosition () const
Get the position of the window.
void | setPosition (const Vector2i &position)
Change the position of the window on screen.
Vector2u | getSize () const
Get the size of the rendering region of the window.
void | setSize (const Vector2u size)
Change the size of the rendering region of the window.
void | setTitle (const String &title)
Change the title of the window.
void | setIcon (unsigned int width, unsigned int height, const Uint8 *pixels)
Change the window's icon.
void | setVisible (bool visible)
Show or hide the window.
void | setVerticalSyncEnabled (bool enabled)
Enable or disable vertical synchronization.
void | setMouseCursorVisible (bool visible)
Show or hide the mouse cursor.
void | setKeyRepeatEnabled (bool enabled)
Enable or disable automatic key-repeat.
void | setFramerateLimit (unsigned int limit)
Limit the framerate to a maximum fixed frequency.
void | setJoystickThreshold (float threshold)
Change the joystick threshold.
bool | setActive (bool active=true) const
Activate or deactivate the window as the current target for OpenGL rendering.
void | display ()
Display on screen what has been rendered to the window so far.
WindowHandle | getSystemHandle () const
Get the OS-specific handle of the window.

Protected Member Functions

virtual void | onCreate ()
Function called after the window has been created.
virtual void | onResize ()
Function called after the window has been resized.

Static Private Member Functions

static void ensureGlContext ()
Make sure that a valid OpenGL context exists in the current thread.

Detailed Description

Window that serves as a target for OpenGL rendering.

sf::Window is the main class of the Window module.

It defines an OS window that is able to receive an OpenGL rendering.

A sf::Window can create its own new window, or be embedded into an already existing control using the create(handle) function. This can be useful for embedding an OpenGL rendering area into a view which is part of a bigger GUI with existing windows, controls, etc. It can also serve as embedding an OpenGL rendering area into a window created by another (probably richer) GUI library like Qt or wxWidgets.

The sf::Window class provides a simple interface for manipulating the window: move, resize, show/hide, control mouse cursor, etc. It also provides event handling through its pollEvent() and waitEvent() functions.

Note that OpenGL experts can pass their own parameters (antialiasing level, bits for the depth and stencil buffers, etc.) to the OpenGL context attached to the window, with the sf::ContextSettings structure which is passed as an optional argument when creating the window.

Usage example:

// Declare and create a new window
sf::Window window(sf::VideoMode(800, 600), "SFML window");
// Limit the framerate to 60 frames per second (this step is optional)
window.setFramerateLimit(60);
// The main loop - ends as soon as the window is closed
while (window.isOpen())
{
// Event processing
sf::Event event;
while (window.pollEvent(event))
{
// Request for closing the window
if (event.type == sf::Event::Closed)
window.close();
}
// Activate the window for OpenGL rendering
window.setActive();
// OpenGL drawing commands go here...
// End the current frame and display its contents on screen
window.display();
}

Definition at line 57 of file Window/Window.hpp.

Constructor & Destructor Documentation

sf::Window::Window ( )

Default constructor.

This constructor doesn't actually create the window, use the other constructors or call "create" to do so.

sf::Window::Window | ( | VideoMode | mode,
 |  | const String & | title,
 |  | Uint32 | style = Style::Default,
 |  | const ContextSettings & | settings = ContextSettings()
 | ) |  |

Construct a new window.

This constructor creates the window with the size and pixel depth defined in mode. An optional style can be passed to customize the look and behaviour of the window (borders, title bar, resizable, closable, ...). If style contains Style::Fullscreen, then mode must be a valid video mode.

The fourth parameter is an optional structure specifying advanced OpenGL context settings such as antialiasing, depth-buffer bits, etc.

Parameters
mode | Video mode to use (defines the width, height and depth of the rendering area of the window)
title | Title of the window
style | Window style
settings | Additional settings for the underlying OpenGL context
sf::Window::Window | ( | WindowHandle | handle,
 |  | const ContextSettings & | settings = ContextSettings()
 | ) |  |
explicit

Construct the window from an existing control.

Use this constructor if you want to create an OpenGL rendering area into an already existing control.

The second parameter is an optional structure specifying advanced OpenGL context settings such as antialiasing, depth-buffer bits, etc.

Parameters
handle | Platform-specific handle of the control
settings | Additional settings for the underlying OpenGL context
virtual sf::Window::~Window ( )
virtual

Destructor.

Closes the window and free all the resources attached to it.

Member Function Documentation

void sf::Window::close ( )

Close the window and destroy all the attached resources.

After calling this function, the sf::Window instance remains valid and you can call create() to recreate the window. All other functions such as pollEvent() or display() will still work (i.e. you don't have to test isOpen() every time), and will have no effect on closed windows.

void sf::Window::create | ( | VideoMode | mode,
 |  | const String & | title,
 |  | Uint32 | style = Style::Default,
 |  | const ContextSettings & | settings = ContextSettings()
 | ) |  |

Create (or recreate) the window.

If the window was already created, it closes it first. If style contains Style::Fullscreen, then mode must be a valid video mode.

Parameters
mode | Video mode to use (defines the width, height and depth of the rendering area of the window)
title | Title of the window
style | Window style
settings | Additional settings for the underlying OpenGL context
void sf::Window::create | ( | WindowHandle | handle,
 |  | const ContextSettings & | settings = ContextSettings()
 | ) |  |

Create (or recreate) the window from an existing control.

Use this function if you want to create an OpenGL rendering area into an already existing control. If the window was already created, it closes it first.

Parameters
handle | Platform-specific handle of the control
settings | Additional settings for the underlying OpenGL context
void sf::Window::display ( )

Display on screen what has been rendered to the window so far.

This function is typically called after all OpenGL rendering has been done for the current frame, in order to show it on screen.

Vector2i sf::Window::getPosition ( ) const

Get the position of the window.

Returns
Position of the window, in pixels
See Also
setPosition
const ContextSettings& sf::Window::getSettings ( ) const

Get the settings of the OpenGL context of the window.

Note that these settings may be different from what was passed to the constructor or the create() function, if one or more settings were not supported. In this case, SFML chose the closest match.

Returns
Structure containing the OpenGL context settings
Vector2u sf::Window::getSize ( ) const

Get the size of the rendering region of the window.

The size doesn't include the titlebar and borders of the window.

Returns
Size in pixels
See Also
setSize
WindowHandle sf::Window::getSystemHandle ( ) const

Get the OS-specific handle of the window.

The type of the returned handle is sf::WindowHandle, which is a typedef to the handle type defined by the OS. You shouldn't need to use this function, unless you have very specific stuff to implement that SFML doesn't support, or implement a temporary workaround until a bug is fixed.

Returns
System handle of the window
bool sf::Window::isOpen ( ) const

Tell whether or not the window is open.

This function returns whether or not the window exists. Note that a hidden window (setVisible(false)) is open (therefore this function would return true).

Returns
True if the window is open, false if it has been closed
virtual void sf::Window::onCreate ( )
protectedvirtual

Function called after the window has been created.

This function is called so that derived classes can perform their own specific initialization as soon as the window is created.

Reimplemented in sf::RenderWindow.

virtual void sf::Window::onResize ( )
protectedvirtual

Function called after the window has been resized.

This function is called so that derived classes can perform custom actions when the size of the window changes.

Reimplemented in sf::RenderWindow.

bool sf::Window::pollEvent ( Event & event )

Pop the event on top of the event queue, if any, and return it.

This function is not blocking: if there's no pending event then it will return false and leave event unmodified. Note that more than one event may be present in the event queue, thus you should always call this function in a loop to make sure that you process every pending event.

sf::Event event;
while (window.pollEvent(event))
{
// process event...
}
Parameters
event Event to be returned
Returns
True if an event was returned, or false if the event queue was empty
See Also
waitEvent
bool sf::Window::setActive ( bool active = true ) const

Activate or deactivate the window as the current target for OpenGL rendering.

A window is active only on the current thread, if you want to make it active on another thread you have to deactivate it on the previous thread first if it was active. Only one window can be active on a thread at a time, thus the window previously active (if any) automatically gets deactivated.

Parameters
active True to activate, false to deactivate
Returns
True if operation was successful, false otherwise
void sf::Window::setFramerateLimit ( unsigned int limit )

Limit the framerate to a maximum fixed frequency.

If a limit is set, the window will use a small delay after each call to display() to ensure that the current frame lasted long enough to match the framerate limit. SFML will try to match the given limit as much as it can, but since it internally uses sf::sleep, whose precision depends on the underlying OS, the results may be a little unprecise as well (for example, you can get 65 FPS when requesting 60).

Parameters
limit Framerate limit, in frames per seconds (use 0 to disable limit)
void sf::Window::setIcon | ( | unsigned int | width,
 |  | unsigned int | height,
 |  | const Uint8 * | pixels
 | ) |  |

Change the window's icon.

pixels must be an array of width x height pixels in 32-bits RGBA format.

The OS default icon is used by default.

Parameters
width | Icon's width, in pixels
height | Icon's height, in pixels
pixels | Pointer to the array of pixels in memory
See Also
setTitle
void sf::Window::setJoystickThreshold ( float threshold )

Change the joystick threshold.

The joystick threshold is the value below which no JoystickMoved event will be generated.

The threshold value is 0.1 by default.

Parameters
threshold New threshold, in the range [0, 100]
void sf::Window::setKeyRepeatEnabled ( bool enabled )

Enable or disable automatic key-repeat.

If key repeat is enabled, you will receive repeated KeyPressed events while keeping a key pressed. If it is disabled, you will only get a single event when the key is pressed.

Key repeat is enabled by default.

Parameters
enabled True to enable, false to disable
void sf::Window::setMouseCursorVisible ( bool visible )

Show or hide the mouse cursor.

The mouse cursor is visible by default.

Parameters
visible True to show the mouse cursor, false to hide it
void sf::Window::setPosition ( const Vector2i & position )

Change the position of the window on screen.

This function only works for top-level windows (i.e. it will be ignored for windows created from the handle of a child window/control).

Parameters
position New position, in pixels
See Also
getPosition
void sf::Window::setSize ( const Vector2u size )

Change the size of the rendering region of the window.

Parameters
size New size, in pixels
See Also
getSize
void sf::Window::setTitle ( const String & title )

Change the title of the window.

Parameters
title New title
See Also
setIcon
void sf::Window::setVerticalSyncEnabled ( bool enabled )

Enable or disable vertical synchronization.

Activating vertical synchronization will limit the number of frames displayed to the refresh rate of the monitor. This can avoid some visual artifacts, and limit the framerate to a good value (but not constant across different computers).

Vertical synchronization is disabled by default.

Parameters
enabled True to enable v-sync, false to deactivate it
void sf::Window::setVisible ( bool visible )

Show or hide the window.

The window is shown by default.

Parameters
visible True to show the window, false to hide it
bool sf::Window::waitEvent ( Event & event )

Wait for an event and return it.

This function is blocking: if there's no pending event then it will wait until an event is received. After this function returns (and no error occured), the event object is always valid and filled properly. This function is typically used when you have a thread that is dedicated to events handling: you want to make this thread sleep as long as no new event is received.

sf::Event event;
if (window.waitEvent(event))
{
// process event...
}
Parameters
event Event to be returned
Returns
False if any error occured
See Also
pollEvent
The documentation for this class was generated from the following file:
  • Window/Window.hpp


  • sf
  • Event
  • JoystickButtonEvent
Public Attributes | List of all members
sf::Event::JoystickButtonEvent Struct Reference
Window module

Joystick buttons events parameters (JoystickButtonPressed, JoystickButtonReleased) More...

#include <Event.hpp>

Public Attributes

unsigned int | joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
unsigned int | button
Index of the button that has been pressed (in range [0 .. Joystick::ButtonCount - 1])

Detailed Description

Joystick buttons events parameters (JoystickButtonPressed, JoystickButtonReleased)

Definition at line 138 of file Event.hpp.

Member Data Documentation

unsigned int sf::Event::JoystickButtonEvent::button

Index of the button that has been pressed (in range [0 .. Joystick::ButtonCount - 1])

Definition at line 141 of file Event.hpp.

unsigned int sf::Event::JoystickButtonEvent::joystickId

Index of the joystick (in range [0 .. Joystick::Count - 1])

Definition at line 140 of file Event.hpp.

The documentation for this struct was generated from the following file:
  • Event.hpp


  • sf
  • Event
  • JoystickConnectEvent
Public Attributes | List of all members
sf::Event::JoystickConnectEvent Struct Reference
Window module

Joystick connection events parameters (JoystickConnected, JoystickDisconnected) More...

#include <Event.hpp>

Public Attributes

unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])

Detailed Description

Joystick connection events parameters (JoystickConnected, JoystickDisconnected)

Definition at line 117 of file Event.hpp.

Member Data Documentation

unsigned int sf::Event::JoystickConnectEvent::joystickId

Index of the joystick (in range [0 .. Joystick::Count - 1])

Definition at line 119 of file Event.hpp.

The documentation for this struct was generated from the following file:
  • Event.hpp


  • sf
  • Event
  • JoystickMoveEvent
Public Attributes | List of all members
sf::Event::JoystickMoveEvent Struct Reference
Window module

Joystick axis move event parameters (JoystickMoved) More...

#include <Event.hpp>

Public Attributes

unsigned int | joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
Joystick::Axis axis
Axis on which the joystick moved.
float | position
New position on the axis (in range [-100 .. 100])

Detailed Description

Joystick axis move event parameters (JoystickMoved)

Definition at line 126 of file Event.hpp.

Member Data Documentation

Joystick::Axis sf::Event::JoystickMoveEvent::axis

Axis on which the joystick moved.

Definition at line 129 of file Event.hpp.

unsigned int sf::Event::JoystickMoveEvent::joystickId

Index of the joystick (in range [0 .. Joystick::Count - 1])

Definition at line 128 of file Event.hpp.

float sf::Event::JoystickMoveEvent::position

New position on the axis (in range [-100 .. 100])

Definition at line 130 of file Event.hpp.

The documentation for this struct was generated from the following file:
  • Event.hpp


  • sf
  • Event
  • KeyEvent
Public Attributes | List of all members
sf::Event::KeyEvent Struct Reference
Window module

Keyboard event parameters (KeyPressed, KeyReleased) More...

#include <Event.hpp>

Public Attributes

Keyboard::Key code
Code of the key that has been pressed.
bool | alt
Is the Alt key pressed?
bool | control
Is the Control key pressed?
bool | shift
Is the Shift key pressed?
bool | system
Is the System key pressed?

Detailed Description

Keyboard event parameters (KeyPressed, KeyReleased)

Definition at line 61 of file Event.hpp.

Member Data Documentation

bool sf::Event::KeyEvent::alt

Is the Alt key pressed?

Definition at line 64 of file Event.hpp.

Keyboard::Key sf::Event::KeyEvent::code

Code of the key that has been pressed.

Definition at line 63 of file Event.hpp.

bool sf::Event::KeyEvent::control

Is the Control key pressed?

Definition at line 65 of file Event.hpp.

bool sf::Event::KeyEvent::shift

Is the Shift key pressed?

Definition at line 66 of file Event.hpp.

bool sf::Event::KeyEvent::system

Is the System key pressed?

Definition at line 67 of file Event.hpp.

The documentation for this struct was generated from the following file:
  • Event.hpp


  • sf
  • Event
  • MouseButtonEvent
Public Attributes | List of all members
sf::Event::MouseButtonEvent Struct Reference
Window module

Mouse buttons events parameters (MouseButtonPressed, MouseButtonReleased) More...

#include <Event.hpp>

Public Attributes

Mouse::Button button
Code of the button that has been pressed.
int | x
X position of the mouse pointer, relative to the left of the owner window.
int | y
Y position of the mouse pointer, relative to the top of the owner window.

Detailed Description

Mouse buttons events parameters (MouseButtonPressed, MouseButtonReleased)

Definition at line 94 of file Event.hpp.

Member Data Documentation

Mouse::Button sf::Event::MouseButtonEvent::button

Code of the button that has been pressed.

Definition at line 96 of file Event.hpp.

int sf::Event::MouseButtonEvent::x

X position of the mouse pointer, relative to the left of the owner window.

Definition at line 97 of file Event.hpp.

int sf::Event::MouseButtonEvent::y

Y position of the mouse pointer, relative to the top of the owner window.

Definition at line 98 of file Event.hpp.

The documentation for this struct was generated from the following file:
  • Event.hpp


  • sf
  • Event
  • MouseMoveEvent
Public Attributes | List of all members
sf::Event::MouseMoveEvent Struct Reference
Window module

Mouse move event parameters (MouseMoved) More...

#include <Event.hpp>

Public Attributes

int | x
X position of the mouse pointer, relative to the left of the owner window.
int | y
Y position of the mouse pointer, relative to the top of the owner window.

Detailed Description

Mouse move event parameters (MouseMoved)

Definition at line 83 of file Event.hpp.

Member Data Documentation

int sf::Event::MouseMoveEvent::x

X position of the mouse pointer, relative to the left of the owner window.

Definition at line 85 of file Event.hpp.

int sf::Event::MouseMoveEvent::y

Y position of the mouse pointer, relative to the top of the owner window.

Definition at line 86 of file Event.hpp.

The documentation for this struct was generated from the following file:
  • Event.hpp


  • sf
  • Event
  • MouseWheelEvent
Public Attributes | List of all members
sf::Event::MouseWheelEvent Struct Reference
Window module

Mouse wheel events parameters (MouseWheelMoved) More...

#include <Event.hpp>

Public Attributes

int | delta
Number of ticks the wheel has moved (positive is up, negative is down)
int | x
X position of the mouse pointer, relative to the left of the owner window.
int | y
Y position of the mouse pointer, relative to the top of the owner window.

Detailed Description

Mouse wheel events parameters (MouseWheelMoved)

Definition at line 105 of file Event.hpp.

Member Data Documentation

int sf::Event::MouseWheelEvent::delta

Number of ticks the wheel has moved (positive is up, negative is down)

Definition at line 107 of file Event.hpp.

int sf::Event::MouseWheelEvent::x

X position of the mouse pointer, relative to the left of the owner window.

Definition at line 108 of file Event.hpp.

int sf::Event::MouseWheelEvent::y

Y position of the mouse pointer, relative to the top of the owner window.

Definition at line 109 of file Event.hpp.

The documentation for this struct was generated from the following file:
  • Event.hpp


  • sf
  • Event
  • SizeEvent
Public Attributes | List of all members
sf::Event::SizeEvent Struct Reference
Window module

Size events parameters (Resized) More...

#include <Event.hpp>

Public Attributes

unsigned int | width
New width, in pixels.
unsigned int | height
New height, in pixels.

Detailed Description

Size events parameters (Resized)

Definition at line 51 of file Event.hpp.

Member Data Documentation

unsigned int sf::Event::SizeEvent::height

New height, in pixels.

Definition at line 54 of file Event.hpp.

unsigned int sf::Event::SizeEvent::width

New width, in pixels.

Definition at line 53 of file Event.hpp.

The documentation for this struct was generated from the following file:
  • Event.hpp


  • sf
  • Event
  • TextEvent
Public Attributes | List of all members
sf::Event::TextEvent Struct Reference
Window module

Text event parameters (TextEntered) More...

#include <Event.hpp>

Public Attributes

Uint32 unicode
UTF-32 unicode value of the character.

Detailed Description

Text event parameters (TextEntered)

Definition at line 74 of file Event.hpp.

Member Data Documentation

Uint32 sf::Event::TextEvent::unicode

UTF-32 unicode value of the character.

Definition at line 76 of file Event.hpp.

The documentation for this struct was generated from the following file:
  • Event.hpp


Class List
Here are the classes, structs, unions and interfaces with brief descriptions:
[detail level 123]
o N sf |
| o C Listener | The audio listener is the point in the scene from where all the sounds are heard
| o C Music | Streamed music played from an audio file
| o C Sound | Regular sound that can be played in the audio environment
| o C SoundBuffer | Storage for audio samples defining a sound
| o C SoundBufferRecorder | Specialized SoundRecorder which stores the captured audio data into a sound buffer
| o C SoundRecorder | Abstract base class for capturing sound data
| o C SoundSource | Base class defining a sound's properties
| o C SoundStream | Abstract base class for streamed audio sources
| | \ C Chunk | Structure defining a chunk of audio data to stream
| o C CircleShape | Specialized shape representing a circle
| o C Color | Utility class for manpulating RGBA colors
| o C ConvexShape | Specialized shape representing a convex polygon
| o C Drawable | Abstract base class for objects that can be drawn to a render target
| o C Font | Class for loading and manipulating character fonts
| o C Glyph | Structure describing a glyph
| o C Image | Class for loading, manipulating and saving images
| o C Rect | Utility class for manipulating 2D axis aligned rectangles
| o C RectangleShape | Specialized shape representing a rectangle
| o C RenderStates | Define the states used for drawing to a RenderTarget
| o C RenderTarget | Base class for all render targets (window, texture, ...)
| o C RenderTexture | Target for off-screen 2D rendering into a texture
| o C RenderWindow | Window that can serve as a target for 2D drawing
| o C Shader | Shader class (vertex and fragment)
| | \ C CurrentTextureType | Special type/value that can be passed to setParameter, and that represents the texture of the object being drawn
| o C Shape | Base class for textured shapes with outline
| o C Sprite | Drawable representation of a texture, with its own transformations, color, etc
| o C Text | Graphical text that can be drawn to a render target
| o C Texture | Image living on the graphics card that can be used for drawing
| o C Transform | Define a 3x3 transform matrix
| o C Transformable | Decomposed transform defined by a position, a rotation and a scale
| o C Vertex | Define a point with color and texture coordinates
| o C VertexArray | Define a set of one or more 2D primitives
| o C View | 2D camera that defines what region is shown on screen
| o C Ftp | A FTP client
| | o C DirectoryResponse | Specialization of FTP response returning a directory
| | o C ListingResponse | Specialization of FTP response returning a filename lisiting
| | \ C Response | Define a FTP response
| o C Http | A HTTP client
| | o C Request | Define a HTTP request
| | \ C Response | Define a HTTP response
| o C IpAddress | Encapsulate an IPv4 network address
| o C Packet | Utility class to build blocks of data to transfer over the network
| o C Socket | Base class for all the socket types
| o C SocketSelector | Multiplexer that allows to read from multiple sockets
| o C TcpListener | Socket that listens to new TCP connections
| o C TcpSocket | Specialized socket using the TCP protocol
| o C UdpSocket | Specialized socket using the UDP protocol
| o C Clock | Utility class that measures the elapsed time
| o C InputStream | Abstract class for custom file input streams
| o C Lock | Automatic wrapper for locking and unlocking mutexes
| o C Mutex | Blocks concurrent access to shared resources from multiple threads
| o C NonCopyable | Utility class that makes any derived class non-copyable
| o C String | Utility string class that automatically handles conversions between types and encodings
| o C Thread | Utility class to manipulate threads
| o C ThreadLocal | Defines variables with thread-local storage
| o C ThreadLocalPtr | Pointer to a thread-local variable
| o C Time | Represents a time value
| o C Utf< 8 > | Specialization of the Utf template for UTF-8
| o C Utf< 16 > | Specialization of the Utf template for UTF-16
| o C Utf< 32 > | Specialization of the Utf template for UTF-32
| o C Vector2 | Utility template class for manipulating 2-dimensional vectors
| o C Vector3 | Utility template class for manipulating 3-dimensional vectors
| o C Context | Class holding a valid drawing context
| o C ContextSettings | Structure defining the settings of the OpenGL context attached to a window
| o C Event | Defines a system event and its parameters
| | o C JoystickButtonEvent | Joystick buttons events parameters (JoystickButtonPressed, JoystickButtonReleased)
| | o C JoystickConnectEvent | Joystick connection events parameters (JoystickConnected, JoystickDisconnected)
| | o C JoystickMoveEvent | Joystick axis move event parameters (JoystickMoved)
| | o C KeyEvent | Keyboard event parameters (KeyPressed, KeyReleased)
| | o C MouseButtonEvent | Mouse buttons events parameters (MouseButtonPressed, MouseButtonReleased)
| | o C MouseMoveEvent | Mouse move event parameters (MouseMoved)
| | o C MouseWheelEvent | Mouse wheel events parameters (MouseWheelMoved)
| | o C SizeEvent | Size events parameters (Resized)
| | \ C TextEvent | Text event parameters (TextEntered)
| o C GlResource | Base class for classes that require an OpenGL context
| o C Joystick | Give access to the real-time state of the joysticks
| o C Keyboard | Give access to the real-time state of the keyboard
| o C Mouse | Give access to the real-time state of the mouse
| o C VideoMode | VideoMode defines a video mode (width, height, bpp)
| o C Window | Window that serves as a target for OpenGL rendering
| \ C Utf | Utility class providing generic functions for UTF conversions
\ C Utf |


  • sf
  • Utf< 8 >
Static Public Member Functions | List of all members
sf::Utf< 8 > Class Template Reference

Specialization of the Utf template for UTF-8. More...

#include <Utf.hpp>

Static Public Member Functions

template<typename In >
static In | decode (In begin, In end, Uint32 &output, Uint32 replacement=0)
Decode a single UTF-8 character.
template<typename Out >
static Out | encode (Uint32 input, Out output, Uint8 replacement=0)
Encode a single UTF-8 character.
template<typename In >
static In | next (In begin, In end)
Advance to the next UTF-8 character.
template<typename In >
static std::size_t | count (In begin, In end)
Count the number of characters of a UTF-8 sequence.
template<typename In , typename Out >
static Out | fromAnsi (In begin, In end, Out output, const std::locale &locale=std::locale())
Convert an ANSI characters range to UTF-8.
template<typename In , typename Out >
static Out | fromWide (In begin, In end, Out output)
Convert a wide characters range to UTF-8.
template<typename In , typename Out >
static Out | fromLatin1 (In begin, In end, Out output)
Convert a latin-1 (ISO-5589-1) characters range to UTF-8.
template<typename In , typename Out >
static Out | toAnsi (In begin, In end, Out output, char replacement=0, const std::locale &locale=std::locale())
Convert an UTF-8 characters range to ANSI characters.
template<typename In , typename Out >
static Out | toWide (In begin, In end, Out output, wchar_t replacement=0)
Convert an UTF-8 characters range to wide characters.
template<typename In , typename Out >
static Out | toLatin1 (In begin, In end, Out output, char replacement=0)
Convert an UTF-8 characters range to latin-1 (ISO-5589-1) characters.
template<typename In , typename Out >
static Out | toUtf8 (In begin, In end, Out output)
Convert a UTF-8 characters range to UTF-8.
template<typename In , typename Out >
static Out | toUtf16 (In begin, In end, Out output)
Convert a UTF-8 characters range to UTF-16.
template<typename In , typename Out >
static Out | toUtf32 (In begin, In end, Out output)
Convert a UTF-8 characters range to UTF-32.

Detailed Description

template<>
class sf::Utf< 8 >

Specialization of the Utf template for UTF-8.

Definition at line 48 of file Utf.hpp.

Member Function Documentation

template<typename In >
static std::size_t sf::Utf< 8 >::count | ( | In | begin,
 |  | In | end
 | ) |  |
static

Count the number of characters of a UTF-8 sequence.

This function is necessary for multi-elements encodings, as a single character may use more than 1 storage element, thus the total size can be different from (begin - end).

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
Returns
Iterator pointing to one past the last read element of the input sequence
template<typename In >
static In sf::Utf< 8 >::decode | ( | In | begin,
 |  | In | end,
 |  | Uint32 & | output,
 |  | Uint32 | replacement = 0
 | ) |  |
static

Decode a single UTF-8 character.

Decoding a character means finding its unique 32-bits code (called the codepoint) in the Unicode standard.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Codepoint of the decoded UTF-8 character
replacement | Replacement character to use in case the UTF-8 sequence is invalid
Returns
Iterator pointing to one past the last read element of the input sequence
template<typename Out >
static Out sf::Utf< 8 >::encode | ( | Uint32 | input,
 |  | Out | output,
 |  | Uint8 | replacement = 0
 | ) |  |
static

Encode a single UTF-8 character.

Encoding a character means converting a unique 32-bits code (called the codepoint) in the target encoding, UTF-8.

Parameters
input | Codepoint to encode as UTF-8
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement for characters not convertible to UTF-8 (use 0 to skip them)
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 8 >::fromAnsi | ( | In | begin,
 |  | In | end,
 |  | Out | output,
 |  | const std::locale & | locale = std::locale()
 | ) |  |
static

Convert an ANSI characters range to UTF-8.

The current global locale will be used by default, unless you pass a custom one in the locale parameter.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
locale | Locale to use for conversion
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 8 >::fromLatin1 | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a latin-1 (ISO-5589-1) characters range to UTF-8.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 8 >::fromWide | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a wide characters range to UTF-8.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In >
static In sf::Utf< 8 >::next | ( | In | begin,
 |  | In | end
 | ) |  |
static

Advance to the next UTF-8 character.

This function is necessary for multi-elements encodings, as a single character may use more than 1 storage element.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
Returns
Iterator pointing to one past the last read element of the input sequence
template<typename In , typename Out >
static Out sf::Utf< 8 >::toAnsi | ( | In | begin,
 |  | In | end,
 |  | Out | output,
 |  | char | replacement = 0,
 |  | const std::locale & | locale = std::locale()
 | ) |  |
static

Convert an UTF-8 characters range to ANSI characters.

The current global locale will be used by default, unless you pass a custom one in the locale parameter.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement for characters not convertible to ANSI (use 0 to skip them)
locale | Locale to use for conversion
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 8 >::toLatin1 | ( | In | begin,
 |  | In | end,
 |  | Out | output,
 |  | char | replacement = 0
 | ) |  |
static

Convert an UTF-8 characters range to latin-1 (ISO-5589-1) characters.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement for characters not convertible to wide (use 0 to skip them)
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 8 >::toUtf16 | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a UTF-8 characters range to UTF-16.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 8 >::toUtf32 | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a UTF-8 characters range to UTF-32.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 8 >::toUtf8 | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a UTF-8 characters range to UTF-8.

This functions does nothing more than a direct copy; it is defined only to provide the same interface as other specializations of the sf::Utf<> template, and allow generic code to be written on top of it.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 8 >::toWide | ( | In | begin,
 |  | In | end,
 |  | Out | output,
 |  | wchar_t | replacement = 0
 | ) |  |
static

Convert an UTF-8 characters range to wide characters.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement for characters not convertible to wide (use 0 to skip them)
Returns
Iterator to the end of the output sequence which has been written
The documentation for this class was generated from the following file:
  • Utf.hpp


  • sf
  • Utf< 16 >
Static Public Member Functions | List of all members
sf::Utf< 16 > Class Template Reference

Specialization of the Utf template for UTF-16. More...

#include <Utf.hpp>

Static Public Member Functions

template<typename In >
static In | decode (In begin, In end, Uint32 &output, Uint32 replacement=0)
Decode a single UTF-16 character.
template<typename Out >
static Out | encode (Uint32 input, Out output, Uint16 replacement=0)
Encode a single UTF-16 character.
template<typename In >
static In | next (In begin, In end)
Advance to the next UTF-16 character.
template<typename In >
static std::size_t | count (In begin, In end)
Count the number of characters of a UTF-16 sequence.
template<typename In , typename Out >
static Out | fromAnsi (In begin, In end, Out output, const std::locale &locale=std::locale())
Convert an ANSI characters range to UTF-16.
template<typename In , typename Out >
static Out | fromWide (In begin, In end, Out output)
Convert a wide characters range to UTF-16.
template<typename In , typename Out >
static Out | fromLatin1 (In begin, In end, Out output)
Convert a latin-1 (ISO-5589-1) characters range to UTF-16.
template<typename In , typename Out >
static Out | toAnsi (In begin, In end, Out output, char replacement=0, const std::locale &locale=std::locale())
Convert an UTF-16 characters range to ANSI characters.
template<typename In , typename Out >
static Out | toWide (In begin, In end, Out output, wchar_t replacement=0)
Convert an UTF-16 characters range to wide characters.
template<typename In , typename Out >
static Out | toLatin1 (In begin, In end, Out output, char replacement=0)
Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters.
template<typename In , typename Out >
static Out | toUtf8 (In begin, In end, Out output)
Convert a UTF-16 characters range to UTF-8.
template<typename In , typename Out >
static Out | toUtf16 (In begin, In end, Out output)
Convert a UTF-16 characters range to UTF-16.
template<typename In , typename Out >
static Out | toUtf32 (In begin, In end, Out output)
Convert a UTF-16 characters range to UTF-32.

Detailed Description

template<>
class sf::Utf< 16 >

Specialization of the Utf template for UTF-16.

Definition at line 255 of file Utf.hpp.

Member Function Documentation

template<typename In >
static std::size_t sf::Utf< 16 >::count | ( | In | begin,
 |  | In | end
 | ) |  |
static

Count the number of characters of a UTF-16 sequence.

This function is necessary for multi-elements encodings, as a single character may use more than 1 storage element, thus the total size can be different from (begin - end).

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
Returns
Iterator pointing to one past the last read element of the input sequence
template<typename In >
static In sf::Utf< 16 >::decode | ( | In | begin,
 |  | In | end,
 |  | Uint32 & | output,
 |  | Uint32 | replacement = 0
 | ) |  |
static

Decode a single UTF-16 character.

Decoding a character means finding its unique 32-bits code (called the codepoint) in the Unicode standard.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Codepoint of the decoded UTF-16 character
replacement | Replacement character to use in case the UTF-8 sequence is invalid
Returns
Iterator pointing to one past the last read element of the input sequence
template<typename Out >
static Out sf::Utf< 16 >::encode | ( | Uint32 | input,
 |  | Out | output,
 |  | Uint16 | replacement = 0
 | ) |  |
static

Encode a single UTF-16 character.

Encoding a character means converting a unique 32-bits code (called the codepoint) in the target encoding, UTF-16.

Parameters
input | Codepoint to encode as UTF-16
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement for characters not convertible to UTF-16 (use 0 to skip them)
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 16 >::fromAnsi | ( | In | begin,
 |  | In | end,
 |  | Out | output,
 |  | const std::locale & | locale = std::locale()
 | ) |  |
static

Convert an ANSI characters range to UTF-16.

The current global locale will be used by default, unless you pass a custom one in the locale parameter.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
locale | Locale to use for conversion
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 16 >::fromLatin1 | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a latin-1 (ISO-5589-1) characters range to UTF-16.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 16 >::fromWide | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a wide characters range to UTF-16.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In >
static In sf::Utf< 16 >::next | ( | In | begin,
 |  | In | end
 | ) |  |
static

Advance to the next UTF-16 character.

This function is necessary for multi-elements encodings, as a single character may use more than 1 storage element.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
Returns
Iterator pointing to one past the last read element of the input sequence
template<typename In , typename Out >
static Out sf::Utf< 16 >::toAnsi | ( | In | begin,
 |  | In | end,
 |  | Out | output,
 |  | char | replacement = 0,
 |  | const std::locale & | locale = std::locale()
 | ) |  |
static

Convert an UTF-16 characters range to ANSI characters.

The current global locale will be used by default, unless you pass a custom one in the locale parameter.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement for characters not convertible to ANSI (use 0 to skip them)
locale | Locale to use for conversion
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 16 >::toLatin1 | ( | In | begin,
 |  | In | end,
 |  | Out | output,
 |  | char | replacement = 0
 | ) |  |
static

Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement for characters not convertible to wide (use 0 to skip them)
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 16 >::toUtf16 | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a UTF-16 characters range to UTF-16.

This functions does nothing more than a direct copy; it is defined only to provide the same interface as other specializations of the sf::Utf<> template, and allow generic code to be written on top of it.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 16 >::toUtf32 | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a UTF-16 characters range to UTF-32.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 16 >::toUtf8 | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a UTF-16 characters range to UTF-8.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 16 >::toWide | ( | In | begin,
 |  | In | end,
 |  | Out | output,
 |  | wchar_t | replacement = 0
 | ) |  |
static

Convert an UTF-16 characters range to wide characters.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement for characters not convertible to wide (use 0 to skip them)
Returns
Iterator to the end of the output sequence which has been written
The documentation for this class was generated from the following file:
  • Utf.hpp


  • sf
  • Utf< 32 >
Static Public Member Functions | List of all members
sf::Utf< 32 > Class Template Reference

Specialization of the Utf template for UTF-32. More...

#include <Utf.hpp>

Static Public Member Functions

template<typename In >
static In | decode (In begin, In end, Uint32 &output, Uint32 replacement=0)
Decode a single UTF-32 character.
template<typename Out >
static Out | encode (Uint32 input, Out output, Uint32 replacement=0)
Encode a single UTF-32 character.
template<typename In >
static In | next (In begin, In end)
Advance to the next UTF-32 character.
template<typename In >
static std::size_t | count (In begin, In end)
Count the number of characters of a UTF-32 sequence.
template<typename In , typename Out >
static Out | fromAnsi (In begin, In end, Out output, const std::locale &locale=std::locale())
Convert an ANSI characters range to UTF-32.
template<typename In , typename Out >
static Out | fromWide (In begin, In end, Out output)
Convert a wide characters range to UTF-32.
template<typename In , typename Out >
static Out | fromLatin1 (In begin, In end, Out output)
Convert a latin-1 (ISO-5589-1) characters range to UTF-32.
template<typename In , typename Out >
static Out | toAnsi (In begin, In end, Out output, char replacement=0, const std::locale &locale=std::locale())
Convert an UTF-32 characters range to ANSI characters.
template<typename In , typename Out >
static Out | toWide (In begin, In end, Out output, wchar_t replacement=0)
Convert an UTF-32 characters range to wide characters.
template<typename In , typename Out >
static Out | toLatin1 (In begin, In end, Out output, char replacement=0)
Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters.
template<typename In , typename Out >
static Out | toUtf8 (In begin, In end, Out output)
Convert a UTF-32 characters range to UTF-8.
template<typename In , typename Out >
static Out | toUtf16 (In begin, In end, Out output)
Convert a UTF-32 characters range to UTF-16.
template<typename In , typename Out >
static Out | toUtf32 (In begin, In end, Out output)
Convert a UTF-32 characters range to UTF-32.
template<typename In >
static Uint32 | decodeAnsi (In input, const std::locale &locale=std::locale())
Decode a single ANSI character to UTF-32.
template<typename In >
static Uint32 | decodeWide (In input)
Decode a single wide character to UTF-32.
template<typename Out >
static Out | encodeAnsi (Uint32 codepoint, Out output, char replacement=0, const std::locale &locale=std::locale())
Encode a single UTF-32 character to ANSI.
template<typename Out >
static Out | encodeWide (Uint32 codepoint, Out output, wchar_t replacement=0)
Encode a single UTF-32 character to wide.

Detailed Description

template<>
class sf::Utf< 32 >

Specialization of the Utf template for UTF-32.

Definition at line 462 of file Utf.hpp.

Member Function Documentation

template<typename In >
static std::size_t sf::Utf< 32 >::count | ( | In | begin,
 |  | In | end
 | ) |  |
static

Count the number of characters of a UTF-32 sequence.

This function is trivial for UTF-32, which can store every character in a single storage element.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
Returns
Iterator pointing to one past the last read element of the input sequence
template<typename In >
static In sf::Utf< 32 >::decode | ( | In | begin,
 |  | In | end,
 |  | Uint32 & | output,
 |  | Uint32 | replacement = 0
 | ) |  |
static

Decode a single UTF-32 character.

Decoding a character means finding its unique 32-bits code (called the codepoint) in the Unicode standard. For UTF-32, the character value is the same as the codepoint.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Codepoint of the decoded UTF-32 character
replacement | Replacement character to use in case the UTF-8 sequence is invalid
Returns
Iterator pointing to one past the last read element of the input sequence
template<typename In >
static Uint32 sf::Utf< 32 >::decodeAnsi | ( | In | input,
 |  | const std::locale & | locale = std::locale()
 | ) |  |
static

Decode a single ANSI character to UTF-32.

This function does not exist in other specializations of sf::Utf<>, it is defined for convenience (it is used by several other conversion functions).

Parameters
input | Input ANSI character
locale | Locale to use for conversion
Returns
Converted character
template<typename In >
static Uint32 sf::Utf< 32 >::decodeWide ( In input )
static

Decode a single wide character to UTF-32.

This function does not exist in other specializations of sf::Utf<>, it is defined for convenience (it is used by several other conversion functions).

Parameters
input Input wide character
Returns
Converted character
template<typename Out >
static Out sf::Utf< 32 >::encode | ( | Uint32 | input,
 |  | Out | output,
 |  | Uint32 | replacement = 0
 | ) |  |
static

Encode a single UTF-32 character.

Encoding a character means converting a unique 32-bits code (called the codepoint) in the target encoding, UTF-32. For UTF-32, the codepoint is the same as the character value.

Parameters
input | Codepoint to encode as UTF-32
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement for characters not convertible to UTF-32 (use 0 to skip them)
Returns
Iterator to the end of the output sequence which has been written
template<typename Out >
static Out sf::Utf< 32 >::encodeAnsi | ( | Uint32 | codepoint,
 |  | Out | output,
 |  | char | replacement = 0,
 |  | const std::locale & | locale = std::locale()
 | ) |  |
static

Encode a single UTF-32 character to ANSI.

This function does not exist in other specializations of sf::Utf<>, it is defined for convenience (it is used by several other conversion functions).

Parameters
codepoint | Iterator pointing to the beginning of the input sequence
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement if the input character is not convertible to ANSI (use 0 to skip it)
locale | Locale to use for conversion
Returns
Iterator to the end of the output sequence which has been written
template<typename Out >
static Out sf::Utf< 32 >::encodeWide | ( | Uint32 | codepoint,
 |  | Out | output,
 |  | wchar_t | replacement = 0
 | ) |  |
static

Encode a single UTF-32 character to wide.

This function does not exist in other specializations of sf::Utf<>, it is defined for convenience (it is used by several other conversion functions).

Parameters
codepoint | Iterator pointing to the beginning of the input sequence
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement if the input character is not convertible to wide (use 0 to skip it)
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 32 >::fromAnsi | ( | In | begin,
 |  | In | end,
 |  | Out | output,
 |  | const std::locale & | locale = std::locale()
 | ) |  |
static

Convert an ANSI characters range to UTF-32.

The current global locale will be used by default, unless you pass a custom one in the locale parameter.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
locale | Locale to use for conversion
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 32 >::fromLatin1 | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a latin-1 (ISO-5589-1) characters range to UTF-32.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 32 >::fromWide | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a wide characters range to UTF-32.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In >
static In sf::Utf< 32 >::next | ( | In | begin,
 |  | In | end
 | ) |  |
static

Advance to the next UTF-32 character.

This function is trivial for UTF-32, which can store every character in a single storage element.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
Returns
Iterator pointing to one past the last read element of the input sequence
template<typename In , typename Out >
static Out sf::Utf< 32 >::toAnsi | ( | In | begin,
 |  | In | end,
 |  | Out | output,
 |  | char | replacement = 0,
 |  | const std::locale & | locale = std::locale()
 | ) |  |
static

Convert an UTF-32 characters range to ANSI characters.

The current global locale will be used by default, unless you pass a custom one in the locale parameter.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement for characters not convertible to ANSI (use 0 to skip them)
locale | Locale to use for conversion
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 32 >::toLatin1 | ( | In | begin,
 |  | In | end,
 |  | Out | output,
 |  | char | replacement = 0
 | ) |  |
static

Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement for characters not convertible to wide (use 0 to skip them)
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 32 >::toUtf16 | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a UTF-32 characters range to UTF-16.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 32 >::toUtf32 | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a UTF-32 characters range to UTF-32.

This functions does nothing more than a direct copy; it is defined only to provide the same interface as other specializations of the sf::Utf<> template, and allow generic code to be written on top of it.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 32 >::toUtf8 | ( | In | begin,
 |  | In | end,
 |  | Out | output
 | ) |  |
static

Convert a UTF-32 characters range to UTF-8.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
Returns
Iterator to the end of the output sequence which has been written
template<typename In , typename Out >
static Out sf::Utf< 32 >::toWide | ( | In | begin,
 |  | In | end,
 |  | Out | output,
 |  | wchar_t | replacement = 0
 | ) |  |
static

Convert an UTF-32 characters range to wide characters.

Parameters
begin | Iterator pointing to the beginning of the input sequence
end | Iterator pointing to the end of the input sequence
output | Iterator pointing to the beginning of the output sequence
replacement | Replacement for characters not convertible to wide (use 0 to skip them)
Returns
Iterator to the end of the output sequence which has been written
The documentation for this class was generated from the following file:
  • Utf.hpp


Utf< N > Class Template Reference

Detailed Description

template<unsigned int N>
class Utf< N >

Definition at line 41 of file Utf.hpp.

The documentation for this class was generated from the following file:
  • Utf.hpp


Class Index
C | D | E | F | G | H | I | J | K | L | M | N | P | R | S | T | U | V | W
C
Glyph (sf)
M
Ftp::Response (sf) ThreadLocal (sf)
H
S
ThreadLocalPtr (sf)
SoundStream::Chunk (sf) | Mouse (sf) | Time (sf)
CircleShape (sf) | Http (sf) | Event::MouseButtonEvent (sf) | Shader (sf) | Transform (sf)
Clock (sf)
I
Event::MouseMoveEvent (sf) Shape (sf) Transformable (sf)
Color (sf) Event::MouseWheelEvent (sf) Event::SizeEvent (sf)
U
Context (sf) | Image (sf) | Music (sf) | Socket (sf)
ContextSettings (sf) | InputStream (sf) | Mutex (sf) | SocketSelector (sf) | UdpSocket (sf)
ConvexShape (sf) IpAddress (sf)
N
Sound (sf) Utf (sf)
Shader::CurrentTextureType (sf)
J
SoundBuffer (sf) Utf
D
NonCopyable (sf) SoundBufferRecorder (sf) Utf< 16 > (sf)
Joystick (sf)
P
SoundRecorder (sf) Utf< 32 > (sf)
Ftp::DirectoryResponse (sf) | Event::JoystickButtonEvent (sf) | SoundSource (sf) | Utf< 8 > (sf)
Drawable (sf) Event::JoystickConnectEvent (sf) Packet (sf) SoundStream (sf)
V
E
Event::JoystickMoveEvent (sf)
R
Sprite (sf)
K
String (sf) Vector2 (sf)
Event (sf) Rect (sf)
T
Vector3 (sf)
F
Keyboard (sf) RectangleShape (sf) Vertex (sf)
Event::KeyEvent (sf) | RenderStates (sf) | TcpListener (sf) | VertexArray (sf)
Font (sf)
L
RenderTarget (sf) TcpSocket (sf) VideoMode (sf)
Ftp (sf) | RenderTexture (sf) | Text (sf) | View (sf)
G
Listener (sf) RenderWindow (sf) Event::TextEvent (sf)
W
Ftp::ListingResponse (sf) | Http::Request (sf) | Texture (sf)
GlResource (sf) | Lock (sf) | Http::Response (sf) | Thread (sf) | Window (sf)
C | D | E | F | G | H | I | J | K | L | M | N | P | R | S | T | U | V | W


Class Hierarchy
This inheritance list is sorted roughly, but not completely, alphabetically:
[detail level 123]
o C sf::SoundStream::Chunk | Structure defining a chunk of audio data to stream
o C sf::Clock | Utility class that measures the elapsed time
o C sf::Color | Utility class for manpulating RGBA colors
o C sf::ContextSettings | Structure defining the settings of the OpenGL context attached to a window
o C sf::Shader::CurrentTextureType | Special type/value that can be passed to setParameter, and that represents the texture of the object being drawn
o C sf::Drawable | Abstract base class for objects that can be drawn to a render target
| o C sf::Shape | Base class for textured shapes with outline
| | o C sf::CircleShape | Specialized shape representing a circle
| | o C sf::ConvexShape | Specialized shape representing a convex polygon
| | \ C sf::RectangleShape | Specialized shape representing a rectangle
| o C sf::Sprite | Drawable representation of a texture, with its own transformations, color, etc
| o C sf::Text | Graphical text that can be drawn to a render target
| \ C sf::VertexArray | Define a set of one or more 2D primitives
o C sf::Event | Defines a system event and its parameters
o C sf::Font | Class for loading and manipulating character fonts
o C sf::GlResource | Base class for classes that require an OpenGL context
| o C sf::Context | Class holding a valid drawing context
| o C sf::Shader | Shader class (vertex and fragment)
| o C sf::Texture | Image living on the graphics card that can be used for drawing
| \ C sf::Window | Window that serves as a target for OpenGL rendering
| \ C sf::RenderWindow | Window that can serve as a target for 2D drawing
o C sf::Glyph | Structure describing a glyph
o C sf::Image | Class for loading, manipulating and saving images
o C sf::InputStream | Abstract class for custom file input streams
o C sf::IpAddress | Encapsulate an IPv4 network address
o C sf::Joystick | Give access to the real-time state of the joysticks
o C sf::Event::JoystickButtonEvent | Joystick buttons events parameters (JoystickButtonPressed, JoystickButtonReleased)
o C sf::Event::JoystickConnectEvent | Joystick connection events parameters (JoystickConnected, JoystickDisconnected)
o C sf::Event::JoystickMoveEvent | Joystick axis move event parameters (JoystickMoved)
o C sf::Keyboard | Give access to the real-time state of the keyboard
o C sf::Event::KeyEvent | Keyboard event parameters (KeyPressed, KeyReleased)
o C sf::Listener | The audio listener is the point in the scene from where all the sounds are heard
o C sf::Mouse | Give access to the real-time state of the mouse
o C sf::Event::MouseButtonEvent | Mouse buttons events parameters (MouseButtonPressed, MouseButtonReleased)
o C sf::Event::MouseMoveEvent | Mouse move event parameters (MouseMoved)
o C sf::Event::MouseWheelEvent | Mouse wheel events parameters (MouseWheelMoved)
o C sf::NonCopyable | Utility class that makes any derived class non-copyable
| o C sf::Context | Class holding a valid drawing context
| o C sf::Ftp | A FTP client
| o C sf::Http | A HTTP client
| o C sf::Lock | Automatic wrapper for locking and unlocking mutexes
| o C sf::Mutex | Blocks concurrent access to shared resources from multiple threads
| o C sf::RenderTarget | Base class for all render targets (window, texture, ...)
| | o C sf::RenderTexture | Target for off-screen 2D rendering into a texture
| | \ C sf::RenderWindow | Window that can serve as a target for 2D drawing
| o C sf::Shader | Shader class (vertex and fragment)
| o C sf::Socket | Base class for all the socket types
| | o C sf::TcpListener | Socket that listens to new TCP connections
| | o C sf::TcpSocket | Specialized socket using the TCP protocol
| | \ C sf::UdpSocket | Specialized socket using the UDP protocol
| o C sf::Thread | Utility class to manipulate threads
| o C sf::ThreadLocal | Defines variables with thread-local storage
| | \ C sf::ThreadLocalPtr< T > | Pointer to a thread-local variable
| \ C sf::Window | Window that serves as a target for OpenGL rendering
o C sf::Packet | Utility class to build blocks of data to transfer over the network
o C sf::Rect< T > | Utility class for manipulating 2D axis aligned rectangles
o C sf::Rect< float > |
o C sf::Rect< int > |
o C sf::RenderStates | Define the states used for drawing to a RenderTarget
o C sf::Http::Request | Define a HTTP request
o C sf::Ftp::Response | Define a FTP response
| o C sf::Ftp::DirectoryResponse | Specialization of FTP response returning a directory
| \ C sf::Ftp::ListingResponse | Specialization of FTP response returning a filename lisiting
o C sf::Http::Response | Define a HTTP response
o C sf::Event::SizeEvent | Size events parameters (Resized)
o C sf::SocketSelector | Multiplexer that allows to read from multiple sockets
o C sf::SoundBuffer | Storage for audio samples defining a sound
o C sf::SoundRecorder | Abstract base class for capturing sound data
| \ C sf::SoundBufferRecorder | Specialized SoundRecorder which stores the captured audio data into a sound buffer
o C sf::SoundSource | Base class defining a sound's properties
| o C sf::Sound | Regular sound that can be played in the audio environment
| \ C sf::SoundStream | Abstract base class for streamed audio sources
| \ C sf::Music | Streamed music played from an audio file
o C sf::String | Utility string class that automatically handles conversions between types and encodings
o C sf::Event::TextEvent | Text event parameters (TextEntered)
o C sf::Time | Represents a time value
o C sf::Transform | Define a 3x3 transform matrix
o C sf::Transformable | Decomposed transform defined by a position, a rotation and a scale
| o C sf::Shape | Base class for textured shapes with outline
| o C sf::Sprite | Drawable representation of a texture, with its own transformations, color, etc
| \ C sf::Text | Graphical text that can be drawn to a render target
o C Utf< N > |
o C sf::Utf | Utility class providing generic functions for UTF conversions
o C sf::Utf< 16 > | Specialization of the Utf template for UTF-16
o C sf::Utf< 32 > | Specialization of the Utf template for UTF-32
o C sf::Utf< 8 > | Specialization of the Utf template for UTF-8
o C sf::Vector2< T > | Utility template class for manipulating 2-dimensional vectors
o C sf::Vector2< float > |
o C sf::Vector2< unsigned int > |
o C sf::Vector3< T > | Utility template class for manipulating 3-dimensional vectors
o C sf::Vertex | Define a point with color and texture coordinates
o C sf::VideoMode | VideoMode defines a video mode (width, height, bpp)
\ C sf::View | 2D camera that defines what region is shown on screen


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- a -

  • A : sf::Keyboard
  • a : sf::Color
  • accept() : sf::TcpListener
  • Accepted : sf::Http::Response
  • add() : sf::SocketSelector
  • Add : sf::Keyboard
  • advance : sf::Glyph
  • alt : sf::Event::KeyEvent
  • antialiasingLevel : sf::ContextSettings
  • AnyPort : sf::Socket
  • append()
: sf::VertexArray
, sf::Packet
  • Ascii : sf::Ftp
  • asMicroseconds() : sf::Time
  • asMilliseconds() : sf::Time
  • asSeconds() : sf::Time
  • Axis : sf::Joystick
  • axis : sf::Event::JoystickMoveEvent
  • AxisCount : sf::Joystick


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- b -

  • B : sf::Keyboard
  • b : sf::Color
  • BackSlash : sf::Keyboard
  • BackSpace : sf::Keyboard
  • BadCommandSequence : sf::Ftp::Response
  • BadGateway : sf::Http::Response
  • BadRequest : sf::Http::Response
  • begin() : sf::String
  • Binary : sf::Ftp
  • bind()
: sf::Shader
, sf::Texture
, sf::UdpSocket
  • bitsPerPixel : sf::VideoMode
  • Black : sf::Color
  • blendMode : sf::RenderStates
  • Blue : sf::Color
  • Bold : sf::Text
  • bounds : sf::Glyph
  • Broadcast : sf::IpAddress
  • button : sf::Event::MouseButtonEvent , sf::Event::JoystickButtonEvent
  • Button : sf::Mouse
  • ButtonCount : sf::Mouse , sf::Joystick


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- c -

  • C : sf::Keyboard
  • capture() : sf::RenderWindow
  • changeDirectory() : sf::Ftp
  • CircleShape() : sf::CircleShape
  • clear()
: sf::SocketSelector
, sf::String
, sf::RenderTarget
, sf::VertexArray
, sf::Packet
  • Clock() : sf::Clock
  • close()
: sf::Socket
, sf::TcpListener
, sf::Window
  • Closed : sf::Event
  • ClosingConnection : sf::Ftp::Response
  • ClosingDataConnection : sf::Ftp::Response
  • code : sf::Event::KeyEvent
  • Color() : sf::Color
  • color : sf::Vertex
  • combine() : sf::Transform
  • Comma : sf::Keyboard
  • CommandNotImplemented : sf::Ftp::Response
  • CommandUnknown : sf::Ftp::Response
  • connect()
: sf::Ftp
, sf::TcpSocket
  • ConnectionClosed : sf::Ftp::Response
  • ConnectionFailed : sf::Ftp::Response , sf::Http::Response
  • ConstIterator : sf::String
  • contains() : sf::Rect< T >
  • Context() : sf::Context
  • ContextSettings() : sf::ContextSettings
  • control : sf::Event::KeyEvent
  • ConvexShape() : sf::ConvexShape
  • CoordinateType : sf::Texture
  • copy() : sf::Image
  • copyToImage() : sf::Texture
  • Count : sf::Event
  • count() : sf::Utf< 8 >
  • Count : sf::Joystick
  • count()
: sf::Utf< 16 >
, sf::Utf< 32 >
  • create()
: sf::Socket
, sf::Image
, sf::Texture
, sf::Image
, sf::Window
, sf::Socket
, sf::RenderTexture
  • Created : sf::Http::Response
  • createDirectory() : sf::Ftp
  • createMaskFromColor() : sf::Image
  • Cyan : sf::Color


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- d -

  • D : sf::Keyboard
  • Dash : sf::Keyboard
  • DataConnectionAlreadyOpened : sf::Ftp::Response
  • DataConnectionOpened : sf::Ftp::Response
  • DataConnectionUnavailable : sf::Ftp::Response
  • decode()
: sf::Utf< 32 >
, sf::Utf< 8 >
, sf::Utf< 16 >
  • decodeAnsi() : sf::Utf< 32 >
  • decodeWide() : sf::Utf< 32 >
  • Default : sf::RenderStates
  • Delete : sf::Keyboard
  • deleteDirectory() : sf::Ftp
  • deleteFile() : sf::Ftp
  • delta : sf::Event::MouseWheelEvent
  • depthBits : sf::ContextSettings
  • DirectoryOk : sf::Ftp::Response
  • DirectoryResponse() : sf::Ftp::DirectoryResponse
  • DirectoryStatus : sf::Ftp::Response
  • disconnect()
: sf::Ftp
, sf::TcpSocket
  • Disconnected : sf::Socket
  • display()
: sf::RenderTexture
, sf::Window
  • Divide : sf::Keyboard
  • Done : sf::Socket
  • Down : sf::Keyboard
  • download() : sf::Ftp
  • draw()
: sf::RenderTarget
, sf::Drawable


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- e -

  • E : sf::Keyboard
  • Ebcdic : sf::Ftp
  • encode()
: sf::Utf< 16 >
, sf::Utf< 32 >
, sf::Utf< 8 >
  • encodeAnsi() : sf::Utf< 32 >
  • encodeWide() : sf::Utf< 32 >
  • end() : sf::String
  • End : sf::Keyboard
  • endOfPacket() : sf::Packet
  • ensureGlContext() : sf::GlResource
  • EnteringPassiveMode : sf::Ftp::Response
  • Equal : sf::Keyboard
  • erase() : sf::String
  • Error : sf::Socket
  • Escape : sf::Keyboard
  • EventType : sf::Event


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- f -

  • F : sf::Keyboard
  • F1 : sf::Keyboard
  • F10 : sf::Keyboard
  • F11 : sf::Keyboard
  • F12 : sf::Keyboard
  • F13 : sf::Keyboard
  • F14 : sf::Keyboard
  • F15 : sf::Keyboard
  • F2 : sf::Keyboard
  • F3 : sf::Keyboard
  • F4 : sf::Keyboard
  • F5 : sf::Keyboard
  • F6 : sf::Keyboard
  • F7 : sf::Keyboard
  • F8 : sf::Keyboard
  • F9 : sf::Keyboard
  • FileActionAborted : sf::Ftp::Response
  • FileActionOk : sf::Ftp::Response
  • FilenameNotAllowed : sf::Ftp::Response
  • FileStatus : sf::Ftp::Response
  • FileUnavailable : sf::Ftp::Response
  • find() : sf::String
  • findCharacterPos() : sf::Text
  • flipHorizontally() : sf::Image
  • flipVertically() : sf::Image
  • Font() : sf::Font
  • Forbidden : sf::Http::Response
  • Fragment : sf::Shader
  • fromAnsi()
: sf::Utf< 32 >
, sf::Utf< 16 >
, sf::Utf< 8 >
  • fromLatin1()
: sf::Utf< 32 >
, sf::Utf< 8 >
, sf::Utf< 16 >
  • fromWide()
: sf::Utf< 16 >
, sf::Utf< 8 >
, sf::Utf< 32 >


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- g -

  • G : sf::Keyboard
  • g : sf::Color
  • GainedFocus : sf::Event
  • GatewayTimeout : sf::Http::Response
  • Get : sf::Http::Request
  • getAttenuation() : sf::SoundSource
  • getAxisPosition() : sf::Joystick
  • getBody() : sf::Http::Response
  • getBounds() : sf::VertexArray
  • getBuffer()
: sf::Sound
, sf::SoundBufferRecorder
  • getButtonCount() : sf::Joystick
  • getCenter() : sf::View
  • getChannelCount()
: sf::SoundBuffer
, sf::SoundStream
  • getCharacterSize() : sf::Text
  • getColor()
: sf::Sprite
, sf::Text
  • getData()
: sf::Packet
, sf::String
  • getDataSize() : sf::Packet
  • getDefaultView() : sf::RenderTarget
  • getDesktopMode() : sf::VideoMode
  • getDirection() : sf::Listener
  • getDirectory() : sf::Ftp::DirectoryResponse
  • getDirectoryListing() : sf::Ftp
  • getDuration()
: sf::Music
, sf::SoundBuffer
  • getElapsedTime() : sf::Clock
  • getField() : sf::Http::Response
  • getFillColor() : sf::Shape
  • getFont() : sf::Text
  • getFullscreenModes() : sf::VideoMode
  • getGlobalBounds()
: sf::Shape
, sf::Sprite
, sf::Text
  • getGlobalVolume() : sf::Listener
  • getGlyph() : sf::Font
  • getHandle() : sf::Socket
  • getInverse() : sf::Transform
  • getInverseTransform()
: sf::Transformable
, sf::View
  • getKerning() : sf::Font
  • getLineSpacing() : sf::Font
  • getListing() : sf::Ftp::ListingResponse
  • getLocalAddress() : sf::IpAddress
  • getLocalBounds()
: sf::Shape
, sf::Sprite
, sf::Text
  • getLocalPort()
: sf::TcpListener
, sf::TcpSocket
, sf::UdpSocket
  • getLoop()
: sf::Sound
, sf::SoundStream
  • getMajorHttpVersion() : sf::Http::Response
  • getMatrix() : sf::Transform
  • getMaximumSize() : sf::Texture
  • getMessage() : sf::Ftp::Response
  • getMinDistance() : sf::SoundSource
  • getMinorHttpVersion() : sf::Http::Response
  • getOrigin() : sf::Transformable
  • getOutlineColor() : sf::Shape
  • getOutlineThickness() : sf::Shape
  • getPitch() : sf::SoundSource
  • getPixel() : sf::Image
  • getPixelsPtr() : sf::Image
  • getPlayingOffset()
: sf::Sound
, sf::SoundStream
  • getPoint()
: sf::CircleShape
, sf::ConvexShape
, sf::Shape
, sf::RectangleShape
  • getPointCount()
: sf::CircleShape
, sf::ConvexShape
, sf::Shape
, sf::RectangleShape
  • getPosition()
: sf::Listener
, sf::SoundSource
, sf::Mouse
, sf::Window
, sf::Transformable
  • getPrimitiveType() : sf::VertexArray
  • getPublicAddress() : sf::IpAddress
  • getRadius() : sf::CircleShape
  • getRemoteAddress() : sf::TcpSocket
  • getRemotePort() : sf::TcpSocket
  • getRotation()
: sf::Transformable
, sf::View
  • getSampleCount() : sf::SoundBuffer
  • getSampleRate()
: sf::SoundStream
, sf::SoundBuffer
, sf::SoundRecorder
  • getSamples() : sf::SoundBuffer
  • getScale() : sf::Transformable
  • getSettings() : sf::Window
  • getSize()
: sf::RenderWindow
, sf::Texture
, sf::View
, sf::RectangleShape
, sf::Image
, sf::RenderTexture
, sf::InputStream
, sf::Window
, sf::RenderTarget
, sf::String
  • getStatus()
: sf::Http::Response
, sf::SoundSource
, sf::SoundStream
, sf::Ftp::Response
, sf::Sound
  • getString() : sf::Text
  • getStyle() : sf::Text
  • getSystemHandle() : sf::Window
  • getTexture()
: sf::Shape
, sf::Font
, sf::RenderTexture
, sf::Sprite
  • getTextureRect()
: sf::Shape
, sf::Sprite
  • getTransform()
: sf::Transformable
, sf::View
  • getValue() : sf::ThreadLocal
  • getVertexCount() : sf::VertexArray
  • getView() : sf::RenderTarget
  • getViewport()
: sf::RenderTarget
, sf::View
  • getVolume() : sf::SoundSource
  • getWorkingDirectory() : sf::Ftp
  • GlResource() : sf::GlResource
  • Glyph() : sf::Glyph
  • Green : sf::Color


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- h -

  • H : sf::Keyboard
  • hasAxis() : sf::Joystick
  • Head : sf::Http::Request
  • height
: sf::Rect< T >
, sf::Event::SizeEvent
, sf::VideoMode
  • HelpMessage : sf::Ftp::Response
  • Home : sf::Keyboard
  • Http() : sf::Http


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- i -

  • I : sf::Keyboard
  • Identity : sf::Transform
  • Image() : sf::Image
  • initialize()
: sf::SoundStream
, sf::RenderTarget
  • insert() : sf::String
  • Insert : sf::Keyboard
  • InsufficientStorageSpace : sf::Ftp::Response
  • InternalServerError : sf::Http::Response
  • intersects() : sf::Rect< T >
  • InvalidFile : sf::Ftp::Response
  • InvalidPos : sf::String
  • InvalidResponse : sf::Ftp::Response , sf::Http::Response
  • IpAddress() : sf::IpAddress
  • isAvailable()
: sf::SoundRecorder
, sf::Shader
  • isBlocking() : sf::Socket
  • isButtonPressed()
: sf::Joystick
, sf::Mouse
  • isConnected() : sf::Joystick
  • isEmpty() : sf::String
  • isKeyPressed() : sf::Keyboard
  • isOk() : sf::Ftp::Response
  • isOpen() : sf::Window
  • isReady() : sf::SocketSelector
  • isRelativeToListener() : sf::SoundSource
  • isRepeated()
: sf::Texture
, sf::RenderTexture
  • isSmooth()
: sf::RenderTexture
, sf::Texture
  • isValid() : sf::VideoMode
  • Italic : sf::Text
  • Iterator : sf::String


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- j -

  • J : sf::Keyboard
  • joystickButton : sf::Event
  • JoystickButtonPressed : sf::Event
  • JoystickButtonReleased : sf::Event
  • joystickConnect : sf::Event
  • JoystickConnected : sf::Event
  • JoystickDisconnected : sf::Event
  • joystickId
: sf::Event::JoystickMoveEvent
, sf::Event::JoystickButtonEvent
, sf::Event::JoystickConnectEvent
  • joystickMove : sf::Event
  • JoystickMoved : sf::Event


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- k -

  • K : sf::Keyboard
  • keepAlive() : sf::Ftp
  • Key : sf::Keyboard
  • key : sf::Event
  • KeyCount : sf::Keyboard
  • KeyPressed : sf::Event
  • KeyReleased : sf::Event


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- l -

  • L : sf::Keyboard
  • LAlt : sf::Keyboard
  • launch() : sf::Thread
  • LBracket : sf::Keyboard
  • LControl : sf::Keyboard
  • left : sf::Rect< T >
  • Left : sf::Keyboard , sf::Mouse
  • listen() : sf::TcpListener
  • ListingResponse() : sf::Ftp::ListingResponse
  • loadFromFile()
: sf::Texture
, sf::SoundBuffer
, sf::Font
, sf::Image
, sf::Shader
  • loadFromImage() : sf::Texture
  • loadFromMemory()
: sf::SoundBuffer
, sf::Texture
, sf::Font
, sf::Image
, sf::Shader
  • loadFromSamples() : sf::SoundBuffer
  • loadFromStream()
: sf::Texture
, sf::Shader
, sf::SoundBuffer
, sf::Shader
, sf::Font
, sf::Image
  • LocalError : sf::Ftp::Response
  • LocalHost : sf::IpAddress
  • lock() : sf::Mutex
  • Lock() : sf::Lock
  • LoggedIn : sf::Ftp::Response
  • login() : sf::Ftp
  • LostFocus : sf::Event
  • LShift : sf::Keyboard
  • LSystem : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- m -

  • M : sf::Keyboard
  • m_source : sf::SoundSource
  • Magenta : sf::Color
  • majorVersion : sf::ContextSettings
  • mapCoordsToPixel() : sf::RenderTarget
  • mapPixelToCoords() : sf::RenderTarget
  • MaxDatagramSize : sf::UdpSocket
  • Menu : sf::Keyboard
  • Method : sf::Http::Request
  • microseconds() : sf::Time
  • Middle : sf::Mouse
  • milliseconds() : sf::Time
  • minorVersion : sf::ContextSettings
  • mouseButton : sf::Event
  • MouseButtonPressed : sf::Event
  • MouseButtonReleased : sf::Event
  • MouseEntered : sf::Event
  • MouseLeft : sf::Event
  • mouseMove : sf::Event
  • MouseMoved : sf::Event
  • mouseWheel : sf::Event
  • MouseWheelMoved : sf::Event
  • move()
: sf::Transformable
, sf::View
, sf::Transformable
, sf::View
  • MovedPermanently : sf::Http::Response
  • MovedTemporarily : sf::Http::Response
  • MultipleChoices : sf::Http::Response
  • Multiply : sf::Keyboard
  • Music() : sf::Music
  • Mutex() : sf::Mutex


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- n -

  • N : sf::Keyboard
  • NeedAccountToLogIn : sf::Ftp::Response
  • NeedAccountToStore : sf::Ftp::Response
  • NeedInformation : sf::Ftp::Response
  • NeedPassword : sf::Ftp::Response
  • next()
: sf::Utf< 32 >
, sf::Utf< 8 >
, sf::Utf< 16 >
  • NoContent : sf::Http::Response
  • NonCopyable() : sf::NonCopyable
  • None : sf::IpAddress
  • Normalized : sf::Texture
  • NotEnoughMemory : sf::Ftp::Response
  • NotFound : sf::Http::Response
  • NotImplemented : sf::Http::Response
  • NotLoggedIn : sf::Ftp::Response
  • NotModified : sf::Http::Response
  • NotReady : sf::Socket
  • Num0 : sf::Keyboard
  • Num1 : sf::Keyboard
  • Num2 : sf::Keyboard
  • Num3 : sf::Keyboard
  • Num4 : sf::Keyboard
  • Num5 : sf::Keyboard
  • Num6 : sf::Keyboard
  • Num7 : sf::Keyboard
  • Num8 : sf::Keyboard
  • Num9 : sf::Keyboard
  • Numpad0 : sf::Keyboard
  • Numpad1 : sf::Keyboard
  • Numpad2 : sf::Keyboard
  • Numpad3 : sf::Keyboard
  • Numpad4 : sf::Keyboard
  • Numpad5 : sf::Keyboard
  • Numpad6 : sf::Keyboard
  • Numpad7 : sf::Keyboard
  • Numpad8 : sf::Keyboard
  • Numpad9 : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- o -

  • O : sf::Keyboard
  • Ok : sf::Ftp::Response , sf::Http::Response
  • onCreate()
: sf::RenderWindow
, sf::Window
  • onGetData()
: sf::Music
, sf::SoundStream
  • onProcessSamples()
: sf::SoundBufferRecorder
, sf::SoundRecorder
  • onReceive() : sf::Packet
  • onResize()
: sf::RenderWindow
, sf::Window
  • onSeek()
: sf::Music
, sf::SoundStream
  • onSend() : sf::Packet
  • onStart()
: sf::SoundBufferRecorder
, sf::SoundRecorder
  • onStop()
: sf::SoundBufferRecorder
, sf::SoundRecorder
  • openFromFile() : sf::Music
  • openFromMemory() : sf::Music
  • openFromStream() : sf::Music
  • OpeningDataConnection : sf::Ftp::Response
  • operator BoolType() : sf::Packet
  • operator std::string() : sf::String
  • operator std::wstring() : sf::String
  • operator T *() : sf::ThreadLocalPtr< T >
  • operator!=()
: sf::Vector2< T >
, sf::Vector3< T >
, sf::VideoMode
, sf::Color
, sf::Rect< T >
, sf::String
, sf::Time
  • operator*()
: sf::ThreadLocalPtr< T >
, sf::Color
, sf::Transform
, sf::Time
, sf::Vector2< T >
, sf::Vector3< T >
  • operator*=()
: sf::Color
, sf::Transform
, sf::Time
, sf::Vector2< T >
, sf::Vector3< T >
  • operator+()
: sf::Color
, sf::String
, sf::Time
, sf::Vector2< T >
, sf::Vector3< T >
  • operator+=()
: sf::String
, sf::Color
, sf::Time
, sf::Vector2< T >
, sf::Vector3< T >
  • operator-()
: sf::Time
, sf::Vector2< T >
, sf::Vector3< T >
, sf::Time
  • operator-=()
: sf::Time
, sf::Vector2< T >
, sf::Vector3< T >
  • operator->() : sf::ThreadLocalPtr< T >
  • operator/()
: sf::Time
, sf::Vector3< T >
, sf::Vector2< T >
  • operator/=()
: sf::Time
, sf::Vector2< T >
, sf::Time
, sf::Vector3< T >
  • operator<()
: sf::Time
, sf::String
, sf::VideoMode
  • operator<<() : sf::Packet
  • operator<=()
: sf::Time
, sf::String
, sf::VideoMode
  • operator=()
: sf::Texture
, sf::ThreadLocalPtr< T >
, sf::Sound
, sf::SocketSelector
, sf::SoundBuffer
, sf::String
, sf::Font
  • operator==()
: sf::Vector2< T >
, sf::String
, sf::Time
, sf::Rect< T >
, sf::Color
, sf::Vector3< T >
, sf::VideoMode
  • operator>()
: sf::String
, sf::VideoMode
, sf::Time
  • operator>=()
: sf::String
, sf::VideoMode
, sf::Time
  • operator>>() : sf::Packet
  • operator[]()
: sf::VertexArray
, sf::String
, sf::VertexArray
, sf::String


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- p -

  • P : sf::Keyboard
  • Packet() : sf::Packet
  • PageDown : sf::Keyboard
  • PageTypeUnknown : sf::Ftp::Response
  • PageUp : sf::Keyboard
  • ParameterNotImplemented : sf::Ftp::Response
  • ParametersUnknown : sf::Ftp::Response
  • parentDirectory() : sf::Ftp
  • PartialContent : sf::Http::Response
  • Pause : sf::Keyboard
  • pause()
: sf::Sound
, sf::SoundStream
  • Paused : sf::SoundSource
  • Period : sf::Keyboard
  • Pixels : sf::Texture
  • play()
: sf::Sound
, sf::SoundStream
  • Playing : sf::SoundSource
  • PointlessCommand : sf::Ftp::Response
  • pollEvent() : sf::Window
  • popGLStates() : sf::RenderTarget
  • position : sf::Event::JoystickMoveEvent , sf::Vertex
  • Post : sf::Http::Request
  • PovX : sf::Joystick
  • PovY : sf::Joystick
  • pushGLStates() : sf::RenderTarget


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- q -

  • Q : sf::Keyboard
  • Quote : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- r -

  • R : sf::Joystick , sf::Keyboard
  • r : sf::Color
  • RAlt : sf::Keyboard
  • RangeNotSatisfiable : sf::Http::Response
  • RBracket : sf::Keyboard
  • RControl : sf::Keyboard
  • read() : sf::InputStream
  • receive()
: sf::TcpSocket
, sf::UdpSocket
  • Rect() : sf::Rect< T >
  • RectangleShape() : sf::RectangleShape
  • Red : sf::Color
  • Regular : sf::Text
  • remove() : sf::SocketSelector
  • renameFile() : sf::Ftp
  • RenderStates() : sf::RenderStates
  • RenderTarget() : sf::RenderTarget
  • RenderTexture() : sf::RenderTexture
  • RenderWindow() : sf::RenderWindow
  • Request() : sf::Http::Request
  • reset() : sf::View
  • resetBuffer() : sf::Sound
  • ResetContent : sf::Http::Response
  • resetGLStates() : sf::RenderTarget
  • resize() : sf::VertexArray
  • Resized : sf::Event
  • Response()
: sf::Ftp::Response
, sf::Http::Response
  • restart() : sf::Clock
  • RestartMarkerReply : sf::Ftp::Response
  • Return : sf::Keyboard
  • Right : sf::Keyboard , sf::Mouse
  • rotate()
: sf::View
, sf::Transform
, sf::Transformable
, sf::Transform
  • RShift : sf::Keyboard
  • RSystem : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- s -

  • S : sf::Keyboard
  • sampleCount : sf::SoundStream::Chunk
  • samples : sf::SoundStream::Chunk
  • saveToFile()
: sf::SoundBuffer
, sf::Image
  • scale()
: sf::Transform
, sf::Transformable
, sf::Transform
  • seconds() : sf::Time
  • seek() : sf::InputStream
  • SemiColon : sf::Keyboard
  • send()
: sf::TcpSocket
, sf::UdpSocket
, sf::TcpSocket
  • sendRequest() : sf::Http
  • ServiceNotAvailable : sf::Http::Response
  • ServiceReady : sf::Ftp::Response
  • ServiceReadySoon : sf::Ftp::Response
  • ServiceUnavailable : sf::Ftp::Response
  • setActive()
: sf::RenderTexture
, sf::Context
, sf::Window
  • setAttenuation() : sf::SoundSource
  • setBlocking() : sf::Socket
  • setBody() : sf::Http::Request
  • setBuffer() : sf::Sound
  • setCenter() : sf::View
  • setCharacterSize() : sf::Text
  • setColor()
: sf::Sprite
, sf::Text
  • setDirection() : sf::Listener
  • setField() : sf::Http::Request
  • setFillColor() : sf::Shape
  • setFont() : sf::Text
  • setFramerateLimit() : sf::Window
  • setGlobalVolume() : sf::Listener
  • setHost() : sf::Http
  • setHttpVersion() : sf::Http::Request
  • setIcon() : sf::Window
  • setJoystickThreshold() : sf::Window
  • setKeyRepeatEnabled() : sf::Window
  • setLoop()
: sf::Sound
, sf::SoundStream
  • setMethod() : sf::Http::Request
  • setMinDistance() : sf::SoundSource
  • setMouseCursorVisible() : sf::Window
  • setOrigin() : sf::Transformable
  • setOutlineColor() : sf::Shape
  • setOutlineThickness() : sf::Shape
  • setParameter() : sf::Shader
  • setPitch() : sf::SoundSource
  • setPixel() : sf::Image
  • setPlayingOffset()
: sf::Sound
, sf::SoundStream
  • setPoint() : sf::ConvexShape
  • setPointCount()
: sf::CircleShape
, sf::ConvexShape
  • setPosition()
: sf::Listener
, sf::SoundSource
, sf::Transformable
, sf::Mouse
, sf::Window
  • setPrimitiveType() : sf::VertexArray
  • setRadius() : sf::CircleShape
  • setRelativeToListener() : sf::SoundSource
  • setRepeated()
: sf::Texture
, sf::RenderTexture
  • setRotation()
: sf::Transformable
, sf::View
  • setScale() : sf::Transformable
  • setSize()
: sf::RectangleShape
, sf::View
, sf::Window
  • setSmooth()
: sf::RenderTexture
, sf::Texture
  • setString() : sf::Text
  • setStyle() : sf::Text
  • setTexture()
: sf::Shape
, sf::Sprite
  • setTextureRect()
: sf::Sprite
, sf::Shape
  • setTitle() : sf::Window
  • setUri() : sf::Http::Request
  • setValue() : sf::ThreadLocal
  • setVerticalSyncEnabled() : sf::Window
  • setView() : sf::RenderTarget
  • setViewport() : sf::View
  • setVisible() : sf::Window
  • setVolume() : sf::SoundSource
  • Shader() : sf::Shader
  • shader : sf::RenderStates
  • Shape() : sf::Shape
  • shift : sf::Event::KeyEvent
  • size : sf::Event
  • Slash : sf::Keyboard
  • Socket() : sf::Socket
  • SocketSelector() : sf::SocketSelector
  • Sound() : sf::Sound
  • SoundBuffer() : sf::SoundBuffer
  • SoundRecorder() : sf::SoundRecorder
  • SoundSource() : sf::SoundSource
  • SoundStream() : sf::SoundStream
  • Space : sf::Keyboard
  • Sprite() : sf::Sprite
  • start() : sf::SoundRecorder
  • Status
: sf::Ftp::Response
, sf::Socket
, sf::SoundSource
, sf::Http::Response
  • stencilBits : sf::ContextSettings
  • stop()
: sf::Sound
, sf::SoundStream
, sf::SoundRecorder
  • Stopped : sf::SoundSource
  • String() : sf::String
  • Style : sf::Text
  • Subtract : sf::Keyboard
  • system : sf::Event::KeyEvent
  • SystemStatus : sf::Ftp::Response
  • SystemType : sf::Ftp::Response


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- t -

  • T : sf::Keyboard
  • Tab : sf::Keyboard
  • Tcp : sf::Socket
  • TcpListener() : sf::TcpListener
  • TcpSocket() : sf::TcpSocket
  • tell() : sf::InputStream
  • terminate() : sf::Thread
  • texCoords : sf::Vertex
  • text : sf::Event
  • Text() : sf::Text
  • TextEntered : sf::Event
  • Texture() : sf::Texture
  • texture : sf::RenderStates
  • textureRect : sf::Glyph
  • Thread() : sf::Thread
  • ThreadLocal() : sf::ThreadLocal
  • ThreadLocalPtr() : sf::ThreadLocalPtr< T >
  • Tilde : sf::Keyboard
  • Time() : sf::Time
  • toAnsi()
: sf::Utf< 8 >
, sf::Utf< 16 >
, sf::Utf< 32 >
  • toAnsiString() : sf::String
  • toInteger() : sf::IpAddress
  • toLatin1()
: sf::Utf< 8 >
, sf::Utf< 16 >
, sf::Utf< 32 >
  • top : sf::Rect< T >
  • toString() : sf::IpAddress
  • toUtf16()
: sf::Utf< 8 >
, sf::Utf< 16 >
, sf::Utf< 32 >
  • toUtf32()
: sf::Utf< 8 >
, sf::Utf< 16 >
, sf::Utf< 32 >
  • toUtf8()
: sf::Utf< 8 >
, sf::Utf< 16 >
, sf::Utf< 32 >
  • toWide()
: sf::Utf< 32 >
, sf::Utf< 8 >
, sf::Utf< 16 >
  • toWideString() : sf::String
  • TransferAborted : sf::Ftp::Response
  • TransferMode : sf::Ftp
  • transform : sf::RenderStates
  • Transform() : sf::Transform
  • Transformable() : sf::Transformable
  • transformPoint() : sf::Transform
  • transformRect() : sf::Transform
  • translate() : sf::Transform
  • Transparent : sf::Color
  • Type : sf::Shader , sf::Socket
  • type : sf::Event


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- u -

  • U : sf::Joystick , sf::Keyboard
  • Udp : sf::Socket
  • UdpSocket() : sf::UdpSocket
  • Unauthorized : sf::Http::Response
  • unbind() : sf::UdpSocket
  • Underlined : sf::Text
  • unicode : sf::Event::TextEvent
  • Unknown : sf::Keyboard
  • unlock() : sf::Mutex
  • Up : sf::Keyboard
  • update()
: sf::Texture
, sf::Joystick
, sf::Shape
, sf::Texture
  • upload() : sf::Ftp


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- v -

  • V : sf::Joystick , sf::Keyboard
  • Vector2() : sf::Vector2< T >
  • Vector3() : sf::Vector3< T >
  • VersionNotSupported : sf::Http::Response
  • Vertex()
: sf::Vertex
, sf::Shader
, sf::Vertex
  • VertexArray() : sf::VertexArray
  • VideoMode() : sf::VideoMode
  • View() : sf::View


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- w -

  • W : sf::Keyboard
  • wait()
: sf::SocketSelector
, sf::Thread
  • waitEvent() : sf::Window
  • White : sf::Color
  • width
: sf::Event::SizeEvent
, sf::VideoMode
, sf::Rect< T >
  • Window() : sf::Window


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- x -

  • X : sf::Joystick , sf::Keyboard
  • x
: sf::Vector3< T >
, sf::Event::MouseWheelEvent
, sf::Event::MouseButtonEvent
, sf::Event::MouseMoveEvent
, sf::Vector2< T >
  • XButton1 : sf::Mouse
  • XButton2 : sf::Mouse


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- y -

  • y : sf::Vector2< T > , sf::Vector3< T >
  • Y : sf::Keyboard , sf::Joystick
  • y
: sf::Event::MouseWheelEvent
, sf::Event::MouseButtonEvent
, sf::Event::MouseMoveEvent
  • Yellow : sf::Color


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- z -

  • Z : sf::Joystick , sf::Keyboard
  • z : sf::Vector3< T >
  • Zero : sf::Time
  • zoom() : sf::View


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z
  • ~
Here is a list of all documented class members with links to the class documentation for each member:

- ~ -

  • ~Context() : sf::Context
  • ~Drawable() : sf::Drawable
  • ~Font() : sf::Font
  • ~Ftp() : sf::Ftp
  • ~GlResource() : sf::GlResource
  • ~InputStream() : sf::InputStream
  • ~Lock() : sf::Lock
  • ~Music() : sf::Music
  • ~Mutex() : sf::Mutex
  • ~Packet() : sf::Packet
  • ~RenderTarget() : sf::RenderTarget
  • ~RenderTexture() : sf::RenderTexture
  • ~RenderWindow() : sf::RenderWindow
  • ~Shader() : sf::Shader
  • ~Shape() : sf::Shape
  • ~Socket() : sf::Socket
  • ~SocketSelector() : sf::SocketSelector
  • ~Sound() : sf::Sound
  • ~SoundBuffer() : sf::SoundBuffer
  • ~SoundRecorder() : sf::SoundRecorder
  • ~SoundSource() : sf::SoundSource
  • ~SoundStream() : sf::SoundStream
  • ~Texture() : sf::Texture
  • ~Thread() : sf::Thread
  • ~ThreadLocal() : sf::ThreadLocal
  • ~Transformable() : sf::Transformable
  • ~Window() : sf::Window


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- a -

  • accept() : sf::TcpListener
  • add() : sf::SocketSelector
  • append()
: sf::Packet
, sf::VertexArray
  • asMicroseconds() : sf::Time
  • asMilliseconds() : sf::Time
  • asSeconds() : sf::Time


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- b -

  • begin() : sf::String
  • bind()
: sf::Texture
, sf::Shader
, sf::UdpSocket


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- c -

  • capture() : sf::RenderWindow
  • changeDirectory() : sf::Ftp
  • CircleShape() : sf::CircleShape
  • clear()
: sf::RenderTarget
, sf::String
, sf::VertexArray
, sf::Packet
, sf::SocketSelector
  • Clock() : sf::Clock
  • close()
: sf::Socket
, sf::TcpListener
, sf::Window
  • Color() : sf::Color
  • combine() : sf::Transform
  • connect()
: sf::Ftp
, sf::TcpSocket
  • contains() : sf::Rect< T >
  • Context() : sf::Context
  • ContextSettings() : sf::ContextSettings
  • ConvexShape() : sf::ConvexShape
  • copy() : sf::Image
  • copyToImage() : sf::Texture
  • count()
: sf::Utf< 16 >
, sf::Utf< 8 >
, sf::Utf< 32 >
  • create()
: sf::Window
, sf::Socket
, sf::RenderTexture
, sf::Window
, sf::Texture
, sf::Image
, sf::Socket
  • createDirectory() : sf::Ftp
  • createMaskFromColor() : sf::Image


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- d -

  • decode()
: sf::Utf< 8 >
, sf::Utf< 16 >
, sf::Utf< 32 >
  • decodeAnsi() : sf::Utf< 32 >
  • decodeWide() : sf::Utf< 32 >
  • deleteDirectory() : sf::Ftp
  • deleteFile() : sf::Ftp
  • DirectoryResponse() : sf::Ftp::DirectoryResponse
  • disconnect()
: sf::Ftp
, sf::TcpSocket
  • display()
: sf::RenderTexture
, sf::Window
  • download() : sf::Ftp
  • draw()
: sf::RenderTarget
, sf::Drawable


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- e -

  • encode()
: sf::Utf< 8 >
, sf::Utf< 16 >
, sf::Utf< 32 >
  • encodeAnsi() : sf::Utf< 32 >
  • encodeWide() : sf::Utf< 32 >
  • end() : sf::String
  • endOfPacket() : sf::Packet
  • ensureGlContext() : sf::GlResource
  • erase() : sf::String


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- f -

  • find() : sf::String
  • findCharacterPos() : sf::Text
  • flipHorizontally() : sf::Image
  • flipVertically() : sf::Image
  • Font() : sf::Font
  • fromAnsi()
: sf::Utf< 16 >
, sf::Utf< 32 >
, sf::Utf< 8 >
  • fromLatin1()
: sf::Utf< 16 >
, sf::Utf< 8 >
, sf::Utf< 32 >
  • fromWide()
: sf::Utf< 8 >
, sf::Utf< 16 >
, sf::Utf< 32 >


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- g -

  • getAttenuation() : sf::SoundSource
  • getAxisPosition() : sf::Joystick
  • getBody() : sf::Http::Response
  • getBounds() : sf::VertexArray
  • getBuffer()
: sf::Sound
, sf::SoundBufferRecorder
  • getButtonCount() : sf::Joystick
  • getCenter() : sf::View
  • getChannelCount()
: sf::SoundBuffer
, sf::SoundStream
  • getCharacterSize() : sf::Text
  • getColor()
: sf::Sprite
, sf::Text
  • getData()
: sf::Packet
, sf::String
  • getDataSize() : sf::Packet
  • getDefaultView() : sf::RenderTarget
  • getDesktopMode() : sf::VideoMode
  • getDirection() : sf::Listener
  • getDirectory() : sf::Ftp::DirectoryResponse
  • getDirectoryListing() : sf::Ftp
  • getDuration()
: sf::Music
, sf::SoundBuffer
  • getElapsedTime() : sf::Clock
  • getField() : sf::Http::Response
  • getFillColor() : sf::Shape
  • getFont() : sf::Text
  • getFullscreenModes() : sf::VideoMode
  • getGlobalBounds()
: sf::Shape
, sf::Sprite
, sf::Text
  • getGlobalVolume() : sf::Listener
  • getGlyph() : sf::Font
  • getHandle() : sf::Socket
  • getInverse() : sf::Transform
  • getInverseTransform()
: sf::Transformable
, sf::View
  • getKerning() : sf::Font
  • getLineSpacing() : sf::Font
  • getListing() : sf::Ftp::ListingResponse
  • getLocalAddress() : sf::IpAddress
  • getLocalBounds()
: sf::Shape
, sf::Sprite
, sf::Text
  • getLocalPort()
: sf::TcpListener
, sf::TcpSocket
, sf::UdpSocket
  • getLoop()
: sf::Sound
, sf::SoundStream
  • getMajorHttpVersion() : sf::Http::Response
  • getMatrix() : sf::Transform
  • getMaximumSize() : sf::Texture
  • getMessage() : sf::Ftp::Response
  • getMinDistance() : sf::SoundSource
  • getMinorHttpVersion() : sf::Http::Response
  • getOrigin() : sf::Transformable
  • getOutlineColor() : sf::Shape
  • getOutlineThickness() : sf::Shape
  • getPitch() : sf::SoundSource
  • getPixel() : sf::Image
  • getPixelsPtr() : sf::Image
  • getPlayingOffset()
: sf::Sound
, sf::SoundStream
  • getPoint()
: sf::CircleShape
, sf::ConvexShape
, sf::RectangleShape
, sf::Shape
  • getPointCount()
: sf::CircleShape
, sf::ConvexShape
, sf::RectangleShape
, sf::Shape
  • getPosition()
: sf::Listener
, sf::SoundSource
, sf::Transformable
, sf::Mouse
, sf::Window
, sf::Mouse
  • getPrimitiveType() : sf::VertexArray
  • getPublicAddress() : sf::IpAddress
  • getRadius() : sf::CircleShape
  • getRemoteAddress() : sf::TcpSocket
  • getRemotePort() : sf::TcpSocket
  • getRotation()
: sf::View
, sf::Transformable
  • getSampleCount() : sf::SoundBuffer
  • getSampleRate()
: sf::SoundRecorder
, sf::SoundBuffer
, sf::SoundStream
  • getSamples() : sf::SoundBuffer
  • getScale() : sf::Transformable
  • getSettings() : sf::Window
  • getSize()
: sf::RenderTexture
, sf::Image
, sf::RenderWindow
, sf::Texture
, sf::View
, sf::String
, sf::RectangleShape
, sf::Window
, sf::RenderTarget
, sf::InputStream
  • getStatus()
: sf::Http::Response
, sf::SoundSource
, sf::Sound
, sf::SoundStream
, sf::Ftp::Response
  • getString() : sf::Text
  • getStyle() : sf::Text
  • getSystemHandle() : sf::Window
  • getTexture()
: sf::RenderTexture
, sf::Sprite
, sf::Shape
, sf::Font
  • getTextureRect()
: sf::Sprite
, sf::Shape
  • getTransform()
: sf::View
, sf::Transformable
  • getValue() : sf::ThreadLocal
  • getVertexCount() : sf::VertexArray
  • getView() : sf::RenderTarget
  • getViewport()
: sf::RenderTarget
, sf::View
  • getVolume() : sf::SoundSource
  • getWorkingDirectory() : sf::Ftp
  • GlResource() : sf::GlResource
  • Glyph() : sf::Glyph


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- h -

  • hasAxis() : sf::Joystick
  • Http() : sf::Http


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- i -

  • Image() : sf::Image
  • initialize()
: sf::SoundStream
, sf::RenderTarget
  • insert() : sf::String
  • intersects() : sf::Rect< T >
  • IpAddress() : sf::IpAddress
  • isAvailable()
: sf::SoundRecorder
, sf::Shader
  • isBlocking() : sf::Socket
  • isButtonPressed()
: sf::Mouse
, sf::Joystick
  • isConnected() : sf::Joystick
  • isEmpty() : sf::String
  • isKeyPressed() : sf::Keyboard
  • isOk() : sf::Ftp::Response
  • isOpen() : sf::Window
  • isReady() : sf::SocketSelector
  • isRelativeToListener() : sf::SoundSource
  • isRepeated()
: sf::Texture
, sf::RenderTexture
  • isSmooth()
: sf::Texture
, sf::RenderTexture
  • isValid() : sf::VideoMode


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- k -

  • keepAlive() : sf::Ftp


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- l -

  • launch() : sf::Thread
  • listen() : sf::TcpListener
  • ListingResponse() : sf::Ftp::ListingResponse
  • loadFromFile()
: sf::SoundBuffer
, sf::Shader
, sf::Texture
, sf::Font
, sf::Image
, sf::Shader
  • loadFromImage() : sf::Texture
  • loadFromMemory()
: sf::Texture
, sf::SoundBuffer
, sf::Font
, sf::Shader
, sf::Image
, sf::Shader
  • loadFromSamples() : sf::SoundBuffer
  • loadFromStream()
: sf::Shader
, sf::Font
, sf::SoundBuffer
, sf::Texture
, sf::Shader
, sf::Image
  • lock() : sf::Mutex
  • Lock() : sf::Lock
  • login() : sf::Ftp


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- m -

  • mapCoordsToPixel() : sf::RenderTarget
  • mapPixelToCoords() : sf::RenderTarget
  • microseconds() : sf::Time
  • milliseconds() : sf::Time
  • move()
: sf::View
, sf::Transformable
, sf::View
, sf::Transformable
  • Music() : sf::Music
  • Mutex() : sf::Mutex


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- n -

  • next()
: sf::Utf< 8 >
, sf::Utf< 16 >
, sf::Utf< 32 >
  • NonCopyable() : sf::NonCopyable


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- o -

  • onCreate()
: sf::RenderWindow
, sf::Window
  • onGetData()
: sf::SoundStream
, sf::Music
  • onProcessSamples()
: sf::SoundBufferRecorder
, sf::SoundRecorder
  • onReceive() : sf::Packet
  • onResize()
: sf::RenderWindow
, sf::Window
  • onSeek()
: sf::Music
, sf::SoundStream
  • onSend() : sf::Packet
  • onStart()
: sf::SoundBufferRecorder
, sf::SoundRecorder
  • onStop()
: sf::SoundRecorder
, sf::SoundBufferRecorder
  • openFromFile() : sf::Music
  • openFromMemory() : sf::Music
  • openFromStream() : sf::Music
  • operator BoolType() : sf::Packet
  • operator std::string() : sf::String
  • operator std::wstring() : sf::String
  • operator T *() : sf::ThreadLocalPtr< T >
  • operator!=()
: sf::Color
, sf::Rect< T >
, sf::String
, sf::Time
, sf::Vector2< T >
, sf::Vector3< T >
, sf::VideoMode
  • operator*()
: sf::Color
, sf::Transform
, sf::Time
, sf::Vector2< T >
, sf::Vector3< T >
, sf::ThreadLocalPtr< T >
  • operator*=()
: sf::Color
, sf::Transform
, sf::Time
, sf::Vector2< T >
, sf::Vector3< T >
  • operator+()
: sf::Color
, sf::String
, sf::Time
, sf::Vector2< T >
, sf::Vector3< T >
  • operator+=()
: sf::String
, sf::Color
, sf::Time
, sf::Vector2< T >
, sf::Vector3< T >
  • operator-()
: sf::Vector3< T >
, sf::Time
, sf::Vector2< T >
  • operator-=()
: sf::Time
, sf::Vector2< T >
, sf::Vector3< T >
  • operator->() : sf::ThreadLocalPtr< T >
  • operator/()
: sf::Time
, sf::Vector3< T >
, sf::Vector2< T >
  • operator/=()
: sf::Vector2< T >
, sf::Time
, sf::Vector3< T >
  • operator<()
: sf::VideoMode
, sf::String
, sf::Time
  • operator<<() : sf::Packet
  • operator<=()
: sf::Time
, sf::String
, sf::VideoMode
  • operator=()
: sf::Sound
, sf::SocketSelector
, sf::ThreadLocalPtr< T >
, sf::SoundBuffer
, sf::Font
, sf::Texture
, sf::String
  • operator==()
: sf::Rect< T >
, sf::String
, sf::Vector3< T >
, sf::Color
, sf::Time
, sf::Vector2< T >
, sf::VideoMode
  • operator>()
: sf::String
, sf::Time
, sf::VideoMode
  • operator>=()
: sf::Time
, sf::VideoMode
, sf::String
  • operator>>() : sf::Packet
  • operator[]()
: sf::String
, sf::VertexArray
, sf::String
, sf::VertexArray


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- p -

  • Packet() : sf::Packet
  • parentDirectory() : sf::Ftp
  • pause()
: sf::SoundStream
, sf::Sound
  • play()
: sf::Sound
, sf::SoundStream
  • pollEvent() : sf::Window
  • popGLStates() : sf::RenderTarget
  • pushGLStates() : sf::RenderTarget


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- r -

  • read() : sf::InputStream
  • receive()
: sf::TcpSocket
, sf::UdpSocket
, sf::TcpSocket
  • Rect() : sf::Rect< T >
  • RectangleShape() : sf::RectangleShape
  • remove() : sf::SocketSelector
  • renameFile() : sf::Ftp
  • RenderStates() : sf::RenderStates
  • RenderTarget() : sf::RenderTarget
  • RenderTexture() : sf::RenderTexture
  • RenderWindow() : sf::RenderWindow
  • Request() : sf::Http::Request
  • reset() : sf::View
  • resetBuffer() : sf::Sound
  • resetGLStates() : sf::RenderTarget
  • resize() : sf::VertexArray
  • Response()
: sf::Ftp::Response
, sf::Http::Response
  • restart() : sf::Clock
  • rotate()
: sf::Transform
, sf::View
, sf::Transform
, sf::Transformable


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- s -

  • saveToFile()
: sf::SoundBuffer
, sf::Image
  • scale()
: sf::Transform
, sf::Transformable
, sf::Transform
, sf::Transformable
  • seconds() : sf::Time
  • seek() : sf::InputStream
  • send()
: sf::TcpSocket
, sf::UdpSocket
  • sendRequest() : sf::Http
  • setActive()
: sf::RenderTexture
, sf::Context
, sf::Window
  • setAttenuation() : sf::SoundSource
  • setBlocking() : sf::Socket
  • setBody() : sf::Http::Request
  • setBuffer() : sf::Sound
  • setCenter() : sf::View
  • setCharacterSize() : sf::Text
  • setColor()
: sf::Sprite
, sf::Text
  • setDirection() : sf::Listener
  • setField() : sf::Http::Request
  • setFillColor() : sf::Shape
  • setFont() : sf::Text
  • setFramerateLimit() : sf::Window
  • setGlobalVolume() : sf::Listener
  • setHost() : sf::Http
  • setHttpVersion() : sf::Http::Request
  • setIcon() : sf::Window
  • setJoystickThreshold() : sf::Window
  • setKeyRepeatEnabled() : sf::Window
  • setLoop()
: sf::Sound
, sf::SoundStream
  • setMethod() : sf::Http::Request
  • setMinDistance() : sf::SoundSource
  • setMouseCursorVisible() : sf::Window
  • setOrigin() : sf::Transformable
  • setOutlineColor() : sf::Shape
  • setOutlineThickness() : sf::Shape
  • setParameter() : sf::Shader
  • setPitch() : sf::SoundSource
  • setPixel() : sf::Image
  • setPlayingOffset()
: sf::Sound
, sf::SoundStream
  • setPoint() : sf::ConvexShape
  • setPointCount()
: sf::CircleShape
, sf::ConvexShape
  • setPosition()
: sf::Transformable
, sf::Listener
, sf::SoundSource
, sf::Transformable
, sf::Mouse
, sf::Window
  • setPrimitiveType() : sf::VertexArray
  • setRadius() : sf::CircleShape
  • setRelativeToListener() : sf::SoundSource
  • setRepeated()
: sf::RenderTexture
, sf::Texture
  • setRotation()
: sf::Transformable
, sf::View
  • setScale() : sf::Transformable
  • setSize()
: sf::RectangleShape
, sf::View
, sf::Window
  • setSmooth()
: sf::RenderTexture
, sf::Texture
  • setString() : sf::Text
  • setStyle() : sf::Text
  • setTexture()
: sf::Sprite
, sf::Shape
  • setTextureRect()
: sf::Sprite
, sf::Shape
  • setTitle() : sf::Window
  • setUri() : sf::Http::Request
  • setValue() : sf::ThreadLocal
  • setVerticalSyncEnabled() : sf::Window
  • setView() : sf::RenderTarget
  • setViewport() : sf::View
  • setVisible() : sf::Window
  • setVolume() : sf::SoundSource
  • Shader() : sf::Shader
  • Shape() : sf::Shape
  • Socket() : sf::Socket
  • SocketSelector() : sf::SocketSelector
  • Sound() : sf::Sound
  • SoundBuffer() : sf::SoundBuffer
  • SoundRecorder() : sf::SoundRecorder
  • SoundSource() : sf::SoundSource
  • SoundStream() : sf::SoundStream
  • Sprite() : sf::Sprite
  • start() : sf::SoundRecorder
  • stop()
: sf::SoundRecorder
, sf::SoundStream
, sf::Sound
  • String() : sf::String


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- t -

  • TcpListener() : sf::TcpListener
  • TcpSocket() : sf::TcpSocket
  • tell() : sf::InputStream
  • terminate() : sf::Thread
  • Text() : sf::Text
  • Texture() : sf::Texture
  • Thread() : sf::Thread
  • ThreadLocal() : sf::ThreadLocal
  • ThreadLocalPtr() : sf::ThreadLocalPtr< T >
  • Time() : sf::Time
  • toAnsi()
: sf::Utf< 16 >
, sf::Utf< 32 >
, sf::Utf< 8 >
  • toAnsiString() : sf::String
  • toInteger() : sf::IpAddress
  • toLatin1()
: sf::Utf< 8 >
, sf::Utf< 16 >
, sf::Utf< 32 >
  • toString() : sf::IpAddress
  • toUtf16()
: sf::Utf< 8 >
, sf::Utf< 16 >
, sf::Utf< 32 >
  • toUtf32()
: sf::Utf< 8 >
, sf::Utf< 16 >
, sf::Utf< 32 >
  • toUtf8()
: sf::Utf< 32 >
, sf::Utf< 16 >
, sf::Utf< 8 >
  • toWide()
: sf::Utf< 32 >
, sf::Utf< 8 >
, sf::Utf< 16 >
  • toWideString() : sf::String
  • Transform() : sf::Transform
  • Transformable() : sf::Transformable
  • transformPoint() : sf::Transform
  • transformRect() : sf::Transform
  • translate() : sf::Transform


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- u -

  • UdpSocket() : sf::UdpSocket
  • unbind() : sf::UdpSocket
  • unlock() : sf::Mutex
  • update()
: sf::Texture
, sf::Shape
, sf::Texture
, sf::Joystick
  • upload() : sf::Ftp


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- v -

  • Vector2() : sf::Vector2< T >
  • Vector3() : sf::Vector3< T >
  • Vertex() : sf::Vertex
  • VertexArray() : sf::VertexArray
  • VideoMode() : sf::VideoMode
  • View() : sf::View


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- w -

  • wait()
: sf::SocketSelector
, sf::Thread
  • waitEvent() : sf::Window
  • Window() : sf::Window


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- z -

  • zoom() : sf::View


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • k
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • z
  • ~

- ~ -

  • ~Context() : sf::Context
  • ~Drawable() : sf::Drawable
  • ~Font() : sf::Font
  • ~Ftp() : sf::Ftp
  • ~GlResource() : sf::GlResource
  • ~InputStream() : sf::InputStream
  • ~Lock() : sf::Lock
  • ~Music() : sf::Music
  • ~Mutex() : sf::Mutex
  • ~Packet() : sf::Packet
  • ~RenderTarget() : sf::RenderTarget
  • ~RenderTexture() : sf::RenderTexture
  • ~RenderWindow() : sf::RenderWindow
  • ~Shader() : sf::Shader
  • ~Shape() : sf::Shape
  • ~Socket() : sf::Socket
  • ~SocketSelector() : sf::SocketSelector
  • ~Sound() : sf::Sound
  • ~SoundBuffer() : sf::SoundBuffer
  • ~SoundRecorder() : sf::SoundRecorder
  • ~SoundSource() : sf::SoundSource
  • ~SoundStream() : sf::SoundStream
  • ~Texture() : sf::Texture
  • ~Thread() : sf::Thread
  • ~ThreadLocal() : sf::ThreadLocal
  • ~Transformable() : sf::Transformable
  • ~Window() : sf::Window


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • p
  • r
  • s
  • t
  • u
  • w
  • x
  • y
  • z

- a -

  • a : sf::Color
  • advance : sf::Glyph
  • alt : sf::Event::KeyEvent
  • antialiasingLevel : sf::ContextSettings
  • axis : sf::Event::JoystickMoveEvent

- b -

  • b : sf::Color
  • bitsPerPixel : sf::VideoMode
  • Black : sf::Color
  • blendMode : sf::RenderStates
  • Blue : sf::Color
  • bounds : sf::Glyph
  • Broadcast : sf::IpAddress
  • button : sf::Event::MouseButtonEvent , sf::Event::JoystickButtonEvent

- c -

  • code : sf::Event::KeyEvent
  • color : sf::Vertex
  • control : sf::Event::KeyEvent
  • Cyan : sf::Color

- d -

  • Default : sf::RenderStates
  • delta : sf::Event::MouseWheelEvent
  • depthBits : sf::ContextSettings

- g -

  • g : sf::Color
  • Green : sf::Color

- h -

  • height
: sf::Rect< T >
, sf::VideoMode
, sf::Event::SizeEvent

- i -

  • Identity : sf::Transform
  • InvalidPos : sf::String

- j -

  • joystickButton : sf::Event
  • joystickConnect : sf::Event
  • joystickId
: sf::Event::JoystickButtonEvent
, sf::Event::JoystickMoveEvent
, sf::Event::JoystickConnectEvent
  • joystickMove : sf::Event

- k -

  • key : sf::Event

- l -

  • left : sf::Rect< T >
  • LocalHost : sf::IpAddress

- m -

  • m_source : sf::SoundSource
  • Magenta : sf::Color
  • majorVersion : sf::ContextSettings
  • minorVersion : sf::ContextSettings
  • mouseButton : sf::Event
  • mouseMove : sf::Event
  • mouseWheel : sf::Event

- n -

  • None : sf::IpAddress

- p -

  • position : sf::Vertex , sf::Event::JoystickMoveEvent

- r -

  • r : sf::Color
  • Red : sf::Color

- s -

  • sampleCount : sf::SoundStream::Chunk
  • samples : sf::SoundStream::Chunk
  • shader : sf::RenderStates
  • shift : sf::Event::KeyEvent
  • size : sf::Event
  • stencilBits : sf::ContextSettings
  • system : sf::Event::KeyEvent

- t -

  • texCoords : sf::Vertex
  • text : sf::Event
  • texture : sf::RenderStates
  • textureRect : sf::Glyph
  • top : sf::Rect< T >
  • transform : sf::RenderStates
  • Transparent : sf::Color
  • type : sf::Event

- u -

  • unicode : sf::Event::TextEvent

- w -

  • White : sf::Color
  • width
: sf::VideoMode
, sf::Event::SizeEvent
, sf::Rect< T >

- x -

  • x
: sf::Vector2< T >
, sf::Event::MouseWheelEvent
, sf::Event::MouseButtonEvent
, sf::Event::MouseMoveEvent
, sf::Vector3< T >

- y -

  • y
: sf::Vector2< T >
, sf::Vector3< T >
, sf::Event::MouseWheelEvent
, sf::Event::MouseButtonEvent
, sf::Event::MouseMoveEvent
  • Yellow : sf::Color

- z -

  • z : sf::Vector3< T >
  • Zero : sf::Time


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • ConstIterator : sf::String
  • Iterator : sf::String


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • Axis : sf::Joystick
  • Button : sf::Mouse
  • CoordinateType : sf::Texture
  • EventType : sf::Event
  • Key : sf::Keyboard
  • Method : sf::Http::Request
  • Status
: sf::SoundSource
, sf::Ftp::Response
, sf::Socket
, sf::Http::Response
  • Style : sf::Text
  • TransferMode : sf::Ftp
  • Type : sf::Socket , sf::Shader


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- a -

  • A : sf::Keyboard
  • Accepted : sf::Http::Response
  • Add : sf::Keyboard
  • AnyPort : sf::Socket
  • Ascii : sf::Ftp
  • AxisCount : sf::Joystick


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- b -

  • B : sf::Keyboard
  • BackSlash : sf::Keyboard
  • BackSpace : sf::Keyboard
  • BadCommandSequence : sf::Ftp::Response
  • BadGateway : sf::Http::Response
  • BadRequest : sf::Http::Response
  • Binary : sf::Ftp
  • Bold : sf::Text
  • ButtonCount : sf::Joystick , sf::Mouse


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- c -

  • C : sf::Keyboard
  • Closed : sf::Event
  • ClosingConnection : sf::Ftp::Response
  • ClosingDataConnection : sf::Ftp::Response
  • Comma : sf::Keyboard
  • CommandNotImplemented : sf::Ftp::Response
  • CommandUnknown : sf::Ftp::Response
  • ConnectionClosed : sf::Ftp::Response
  • ConnectionFailed : sf::Ftp::Response , sf::Http::Response
  • Count : sf::Event , sf::Joystick
  • Created : sf::Http::Response


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- d -

  • D : sf::Keyboard
  • Dash : sf::Keyboard
  • DataConnectionAlreadyOpened : sf::Ftp::Response
  • DataConnectionOpened : sf::Ftp::Response
  • DataConnectionUnavailable : sf::Ftp::Response
  • Delete : sf::Keyboard
  • DirectoryOk : sf::Ftp::Response
  • DirectoryStatus : sf::Ftp::Response
  • Disconnected : sf::Socket
  • Divide : sf::Keyboard
  • Done : sf::Socket
  • Down : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- e -

  • E : sf::Keyboard
  • Ebcdic : sf::Ftp
  • End : sf::Keyboard
  • EnteringPassiveMode : sf::Ftp::Response
  • Equal : sf::Keyboard
  • Error : sf::Socket
  • Escape : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- f -

  • F : sf::Keyboard
  • F1 : sf::Keyboard
  • F10 : sf::Keyboard
  • F11 : sf::Keyboard
  • F12 : sf::Keyboard
  • F13 : sf::Keyboard
  • F14 : sf::Keyboard
  • F15 : sf::Keyboard
  • F2 : sf::Keyboard
  • F3 : sf::Keyboard
  • F4 : sf::Keyboard
  • F5 : sf::Keyboard
  • F6 : sf::Keyboard
  • F7 : sf::Keyboard
  • F8 : sf::Keyboard
  • F9 : sf::Keyboard
  • FileActionAborted : sf::Ftp::Response
  • FileActionOk : sf::Ftp::Response
  • FilenameNotAllowed : sf::Ftp::Response
  • FileStatus : sf::Ftp::Response
  • FileUnavailable : sf::Ftp::Response
  • Forbidden : sf::Http::Response
  • Fragment : sf::Shader


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- g -

  • G : sf::Keyboard
  • GainedFocus : sf::Event
  • GatewayTimeout : sf::Http::Response
  • Get : sf::Http::Request


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- h -

  • H : sf::Keyboard
  • Head : sf::Http::Request
  • HelpMessage : sf::Ftp::Response
  • Home : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- i -

  • I : sf::Keyboard
  • Insert : sf::Keyboard
  • InsufficientStorageSpace : sf::Ftp::Response
  • InternalServerError : sf::Http::Response
  • InvalidFile : sf::Ftp::Response
  • InvalidResponse : sf::Ftp::Response , sf::Http::Response
  • Italic : sf::Text


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- j -

  • J : sf::Keyboard
  • JoystickButtonPressed : sf::Event
  • JoystickButtonReleased : sf::Event
  • JoystickConnected : sf::Event
  • JoystickDisconnected : sf::Event
  • JoystickMoved : sf::Event


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- k -

  • K : sf::Keyboard
  • KeyCount : sf::Keyboard
  • KeyPressed : sf::Event
  • KeyReleased : sf::Event


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- l -

  • L : sf::Keyboard
  • LAlt : sf::Keyboard
  • LBracket : sf::Keyboard
  • LControl : sf::Keyboard
  • Left : sf::Keyboard , sf::Mouse
  • LocalError : sf::Ftp::Response
  • LoggedIn : sf::Ftp::Response
  • LostFocus : sf::Event
  • LShift : sf::Keyboard
  • LSystem : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- m -

  • M : sf::Keyboard
  • MaxDatagramSize : sf::UdpSocket
  • Menu : sf::Keyboard
  • Middle : sf::Mouse
  • MouseButtonPressed : sf::Event
  • MouseButtonReleased : sf::Event
  • MouseEntered : sf::Event
  • MouseLeft : sf::Event
  • MouseMoved : sf::Event
  • MouseWheelMoved : sf::Event
  • MovedPermanently : sf::Http::Response
  • MovedTemporarily : sf::Http::Response
  • MultipleChoices : sf::Http::Response
  • Multiply : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- n -

  • N : sf::Keyboard
  • NeedAccountToLogIn : sf::Ftp::Response
  • NeedAccountToStore : sf::Ftp::Response
  • NeedInformation : sf::Ftp::Response
  • NeedPassword : sf::Ftp::Response
  • NoContent : sf::Http::Response
  • Normalized : sf::Texture
  • NotEnoughMemory : sf::Ftp::Response
  • NotFound : sf::Http::Response
  • NotImplemented : sf::Http::Response
  • NotLoggedIn : sf::Ftp::Response
  • NotModified : sf::Http::Response
  • NotReady : sf::Socket
  • Num0 : sf::Keyboard
  • Num1 : sf::Keyboard
  • Num2 : sf::Keyboard
  • Num3 : sf::Keyboard
  • Num4 : sf::Keyboard
  • Num5 : sf::Keyboard
  • Num6 : sf::Keyboard
  • Num7 : sf::Keyboard
  • Num8 : sf::Keyboard
  • Num9 : sf::Keyboard
  • Numpad0 : sf::Keyboard
  • Numpad1 : sf::Keyboard
  • Numpad2 : sf::Keyboard
  • Numpad3 : sf::Keyboard
  • Numpad4 : sf::Keyboard
  • Numpad5 : sf::Keyboard
  • Numpad6 : sf::Keyboard
  • Numpad7 : sf::Keyboard
  • Numpad8 : sf::Keyboard
  • Numpad9 : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- o -

  • O : sf::Keyboard
  • Ok : sf::Ftp::Response , sf::Http::Response
  • OpeningDataConnection : sf::Ftp::Response


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- p -

  • P : sf::Keyboard
  • PageDown : sf::Keyboard
  • PageTypeUnknown : sf::Ftp::Response
  • PageUp : sf::Keyboard
  • ParameterNotImplemented : sf::Ftp::Response
  • ParametersUnknown : sf::Ftp::Response
  • PartialContent : sf::Http::Response
  • Pause : sf::Keyboard
  • Paused : sf::SoundSource
  • Period : sf::Keyboard
  • Pixels : sf::Texture
  • Playing : sf::SoundSource
  • PointlessCommand : sf::Ftp::Response
  • Post : sf::Http::Request
  • PovX : sf::Joystick
  • PovY : sf::Joystick


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- q -

  • Q : sf::Keyboard
  • Quote : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- r -

  • R : sf::Joystick , sf::Keyboard
  • RAlt : sf::Keyboard
  • RangeNotSatisfiable : sf::Http::Response
  • RBracket : sf::Keyboard
  • RControl : sf::Keyboard
  • Regular : sf::Text
  • ResetContent : sf::Http::Response
  • Resized : sf::Event
  • RestartMarkerReply : sf::Ftp::Response
  • Return : sf::Keyboard
  • Right : sf::Mouse , sf::Keyboard
  • RShift : sf::Keyboard
  • RSystem : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- s -

  • S : sf::Keyboard
  • SemiColon : sf::Keyboard
  • ServiceNotAvailable : sf::Http::Response
  • ServiceReady : sf::Ftp::Response
  • ServiceReadySoon : sf::Ftp::Response
  • ServiceUnavailable : sf::Ftp::Response
  • Slash : sf::Keyboard
  • Space : sf::Keyboard
  • Stopped : sf::SoundSource
  • Subtract : sf::Keyboard
  • SystemStatus : sf::Ftp::Response
  • SystemType : sf::Ftp::Response


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- t -

  • T : sf::Keyboard
  • Tab : sf::Keyboard
  • Tcp : sf::Socket
  • TextEntered : sf::Event
  • Tilde : sf::Keyboard
  • TransferAborted : sf::Ftp::Response


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- u -

  • U : sf::Joystick , sf::Keyboard
  • Udp : sf::Socket
  • Unauthorized : sf::Http::Response
  • Underlined : sf::Text
  • Unknown : sf::Keyboard
  • Up : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- v -

  • V : sf::Joystick , sf::Keyboard
  • VersionNotSupported : sf::Http::Response
  • Vertex : sf::Shader


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- w -

  • W : sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- x -

  • X : sf::Joystick , sf::Keyboard
  • XButton1 : sf::Mouse
  • XButton2 : sf::Mouse


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- y -

  • Y : sf::Joystick , sf::Keyboard


  • All
  • Functions
  • Variables
  • Typedefs
  • Enumerations
  • Enumerator
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • l
  • m
  • n
  • o
  • p
  • q
  • r
  • s
  • t
  • u
  • v
  • w
  • x
  • y
  • z

- z -

  • Z : sf::Joystick , sf::Keyboard


  • File List
File List
Here is a list of all documented files with brief descriptions:
o * Audio.hpp
o * BlendMode.hpp
o * CircleShape.hpp
o * Clock.hpp
o * Color.hpp
o * Config.hpp
o * Context.hpp
o * ContextSettings.hpp
o * ConvexShape.hpp
o * Drawable.hpp
o * Err.hpp
o * Event.hpp
o * Audio/Export.hpp
o * Graphics/Export.hpp
o * Network/Export.hpp
o * System/Export.hpp
o * Window/Export.hpp
o * Font.hpp
o * Ftp.hpp
o * GlResource.hpp
o * Glyph.hpp
o * Graphics.hpp
o * Http.hpp
o * Image.hpp
o * InputStream.hpp
o * IpAddress.hpp
o * Joystick.hpp
o * Keyboard.hpp
o * Listener.hpp
o * Lock.hpp
o * mainpage.hpp
o * Mouse.hpp
o * Music.hpp
o * Mutex.hpp
o * Network.hpp
o * NonCopyable.hpp
o * OpenGL.hpp
o * Packet.hpp
o * PrimitiveType.hpp
o * Rect.hpp
o * Rect.inl
o * RectangleShape.hpp
o * RenderStates.hpp
o * RenderTarget.hpp
o * RenderTexture.hpp
o * RenderWindow.hpp
o * Shader.hpp
o * Shape.hpp
o * Sleep.hpp
o * Socket.hpp
o * SocketHandle.hpp
o * SocketSelector.hpp
o * Sound.hpp
o * SoundBuffer.hpp
o * SoundBufferRecorder.hpp
o * SoundRecorder.hpp
o * SoundSource.hpp
o * SoundStream.hpp
o * Sprite.hpp
o * String.hpp
o * System.hpp
o * TcpListener.hpp
o * TcpSocket.hpp
o * Text.hpp
o * Texture.hpp
o * Thread.hpp
o * Thread.inl
o * ThreadLocal.hpp
o * ThreadLocalPtr.hpp
o * ThreadLocalPtr.inl
o * Time.hpp
o * Transform.hpp
o * Transformable.hpp
o * UdpSocket.hpp
o * Utf.hpp
o * Utf.inl
o * Vector2.hpp
o * Vector2.inl
o * Vector3.hpp
o * Vector3.inl
o * Vertex.hpp
o * VertexArray.hpp
o * VideoMode.hpp
o * View.hpp
o * Window/Window.hpp
o * Window.hpp
o * WindowHandle.hpp
\ * WindowStyle.hpp


  • File List
  • include
  • SFML
Audio.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_AUDIO_HPP
26 #define SFML_AUDIO_HPP
27
29 // Headers
31
32 #include <SFML/System.hpp>
33 #include <SFML/Audio/Listener.hpp>
34 #include <SFML/Audio/Music.hpp>
35 #include <SFML/Audio/Sound.hpp>
36 #include <SFML/Audio/SoundBuffer.hpp>
37 #include <SFML/Audio/SoundBufferRecorder.hpp>
38 #include <SFML/Audio/SoundRecorder.hpp>
39 #include <SFML/Audio/SoundStream.hpp>
40
41
42 #endif // SFML_AUDIO_HPP
43


  • File List
  • include
  • SFML
  • Graphics
BlendMode.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_BLENDMODE_HPP
26 #define SFML_BLENDMODE_HPP
27
28 namespace sf
29 {
35 enum BlendMode
36 {
37 BlendAlpha,
38 BlendAdd,
39 BlendMultiply,
40 BlendNone
41 };
42
43 } // namespace sf
44
45
46 #endif // SFML_BLENDMODE_HPP


  • File List
  • include
  • SFML
  • Graphics
CircleShape.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_CIRCLESHAPE_HPP
26 #define SFML_CIRCLESHAPE_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Shape.hpp>
33
34
35 namespace sf
36 {
41 class SFML_GRAPHICS_API CircleShape : public Shape
42 {
43 public :
44
52 explicit CircleShape(float radius = 0, unsigned int pointCount = 30);
53
62 void setRadius(float radius);
63
72 float getRadius() const;
73
82 void setPointCount(unsigned int count);
83
92 virtual unsigned int getPointCount() const;
93
104 virtual Vector2f getPoint(unsigned int index) const;
105
106 private :
107
109 // Member data
111 float m_radius;
112 unsigned int m_pointCount;
113 };
114
115 } // namespace sf
116
117
118 #endif // SFML_CIRCLESHAPE_HPP
119
120


  • File List
  • include
  • SFML
  • System
Clock.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_CLOCK_HPP
26 #define SFML_CLOCK_HPP
27
29 // Headers
31 #include <SFML/System/Export.hpp>
32 #include <SFML/System/Time.hpp>
33
34
35 namespace sf
36 {
41 class SFML_SYSTEM_API Clock
42 {
43 public :
44
51 Clock();
52
63 Time getElapsedTime() const;
64
74 Time restart();
75
76 private :
77
79 // Member data
81 Time m_startTime;
82 };
83
84 } // namespace sf
85
86
87 #endif // SFML_CLOCK_HPP
88
89


  • File List
  • include
  • SFML
  • Graphics
Color.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_COLOR_HPP
26 #define SFML_COLOR_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32
33
34 namespace sf
35 {
40 class SFML_GRAPHICS_API Color
41 {
42 public :
43
51 Color();
52
62 Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = 255);
63
65 // Static member data
67 static const Color Black;
68 static const Color White;
69 static const Color Red;
70 static const Color Green;
71 static const Color Blue;
72 static const Color Yellow;
73 static const Color Magenta;
74 static const Color Cyan;
75 static const Color Transparent;
76
78 // Member data
80 Uint8 r;
81 Uint8 g;
82 Uint8 b;
83 Uint8 a;
84 };
85
98 SFML_GRAPHICS_API bool operator ==(const Color& left, const Color& right);
99
112 SFML_GRAPHICS_API bool operator !=(const Color& left, const Color& right);
113
127 SFML_GRAPHICS_API Color operator +(const Color& left, const Color& right);
128
144 SFML_GRAPHICS_API Color operator *(const Color& left, const Color& right);
145
160 SFML_GRAPHICS_API Color& operator +=(Color& left, const Color& right);
161
178 SFML_GRAPHICS_API Color& operator *=(Color& left, const Color& right);
179
180 } // namespace sf
181
182
183 #endif // SFML_COLOR_HPP
184
185


  • File List
  • include
  • SFML
Config.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_CONFIG_HPP
26 #define SFML_CONFIG_HPP
27
28
30 // Define the SFML version
32 #define SFML_VERSION_MAJOR 2
33 #define SFML_VERSION_MINOR 1
34
35
37 // Identify the operating system
39 #if defined(_WIN32) || defined(__WIN32__)
40
41 // Windows
42 #define SFML_SYSTEM_WINDOWS
43 #ifndef NOMINMAX
44 #define NOMINMAX
45 #endif
46
47 #elif defined(linux) || defined(__linux)
48
49 // Linux
50 #define SFML_SYSTEM_LINUX
51
52 #elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)
53
54 // MacOS
55 #define SFML_SYSTEM_MACOS
56
57 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
58
59 // FreeBSD
60 #define SFML_SYSTEM_FREEBSD
61
62 #else
63
64 // Unsupported system
65 #error This operating system is not supported by SFML library
66
67 #endif
68
69
71 // Define a portable debug macro
73 #if !defined(NDEBUG)
74
75 #define SFML_DEBUG
76
77 #endif
78
79
81 // Define helpers to create portable import / export macros for each module
83 #if !defined(SFML_STATIC)
84
85 #if defined(SFML_SYSTEM_WINDOWS)
86
87 // Windows compilers need specific (and different) keywords for export and import
88 #define SFML_API_EXPORT __declspec(dllexport)
89 #define SFML_API_IMPORT __declspec(dllimport)
90
91 // For Visual C++ compilers, we also need to turn off this annoying C4251 warning
92 #ifdef _MSC_VER
93
94 #pragma warning(disable : 4251)
95
96 #endif
97
98 #else // Linux, FreeBSD, Mac OS X
99
100 #if __GNUC__ >= 4
101
102 // GCC 4 has special keywords for showing/hidding symbols,
103 // the same keyword is used for both importing and exporting
104 #define SFML_API_EXPORT __attribute__ ((__visibility__ ("default")))
105 #define SFML_API_IMPORT __attribute__ ((__visibility__ ("default")))
106
107 #else
108
109 // GCC < 4 has no mechanism to explicitely hide symbols, everything's exported
110 #define SFML_API_EXPORT
111 #define SFML_API_IMPORT
112
113 #endif
114
115 #endif
116
117 #else
118
119 // Static build doesn't need import/export macros
120 #define SFML_API_EXPORT
121 #define SFML_API_IMPORT
122
123 #endif
124
125
127 // Define portable fixed-size types
129 namespace sf
130 {
131 // All "common" platforms use the same size for char, short and int
132 // (basically there are 3 types for 3 sizes, so no other match is possible),
133 // we can use them without doing any kind of check
134
135 // 8 bits integer types
136 typedef signed char Int8;
137 typedef unsigned char Uint8;
138
139 // 16 bits integer types
140 typedef signed short Int16;
141 typedef unsigned short Uint16;
142
143 // 32 bits integer types
144 typedef signed int Int32;
145 typedef unsigned int Uint32;
146
147 // 64 bits integer types
148 #if defined(_MSC_VER)
149 typedef signed __int64 Int64;
150 typedef unsigned __int64 Uint64;
151 #else
152 typedef signed long long Int64;
153 typedef unsigned long long Uint64;
154 #endif
155
156 } // namespace sf
157
158
159 #endif // SFML_CONFIG_HPP


  • File List
  • include
  • SFML
  • Window
Context.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_CONTEXT_HPP
26 #define SFML_CONTEXT_HPP
27
29 // Headers
31 #include <SFML/Window/Export.hpp>
32 #include <SFML/Window/GlResource.hpp>
33 #include <SFML/Window/ContextSettings.hpp>
34 #include <SFML/System/NonCopyable.hpp>
35
36
37 namespace sf
38 {
39 namespace priv
40 {
41 class GlContext;
42 }
43
48 class SFML_WINDOW_API Context : GlResource, NonCopyable
49 {
50 public :
51
58 Context();
59
66 ~Context();
67
76 bool setActive(bool active);
77
78 public :
79
91 Context(const ContextSettings& settings, unsigned int width, unsigned int height);
92
93 private :
94
96 // Member data
98 priv::GlContext* m_context;
99 };
100
101 } // namespace sf
102
103
104 #endif // SFML_CONTEXT_HPP
105


  • File List
  • include
  • SFML
  • Window
ContextSettings.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_CONTEXTSETTINGS_HPP
26 #define SFML_CONTEXTSETTINGS_HPP
27
28
29 namespace sf
30 {
36 struct ContextSettings
37 {
48 explicit ContextSettings(unsigned int depth = 0, unsigned int stencil = 0, unsigned int antialiasing = 0, unsigned int major = 2, unsigned int minor = 0) :
49 depthBits (depth),
50 stencilBits (stencil),
51 antialiasingLevel(antialiasing),
52 majorVersion (major),
53 minorVersion (minor)
54 {
55 }
56
58 // Member data
60 unsigned int depthBits;
61 unsigned int stencilBits;
62 unsigned int antialiasingLevel;
63 unsigned int majorVersion;
64 unsigned int minorVersion;
65 };
66
67 } // namespace sf
68
69
70 #endif // SFML_CONTEXTSETTINGS_HPP
71
72


  • File List
  • include
  • SFML
  • Graphics
ConvexShape.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_CONVEXSHAPE_HPP
26 #define SFML_CONVEXSHAPE_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Shape.hpp>
33 #include <vector>
34
35
36 namespace sf
37 {
42 class SFML_GRAPHICS_API ConvexShape : public Shape
43 {
44 public :
45
52 explicit ConvexShape(unsigned int pointCount = 0);
53
64 void setPointCount(unsigned int count);
65
74 virtual unsigned int getPointCount() const;
75
91 void setPoint(unsigned int index, const Vector2f& point);
92
105 virtual Vector2f getPoint(unsigned int index) const;
106
107 private :
108
110 // Member data
112 std::vector<Vector2f> m_points;
113 };
114
115 } // namespace sf
116
117
118 #endif // SFML_CONVEXSHAPE_HPP
119
120


  • File List
  • include
  • SFML
  • Graphics
Drawable.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_DRAWABLE_HPP
26 #define SFML_DRAWABLE_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/RenderStates.hpp>
33
34
35 namespace sf
36 {
37 class RenderTarget;
38
44 class SFML_GRAPHICS_API Drawable
45 {
46 public :
47
52 virtual ~Drawable() {}
53
54 protected :
55
56 friend class RenderTarget;
57
69 virtual void draw(RenderTarget& target, RenderStates states) const = 0;
70 };
71
72 } // namespace sf
73
74
75 #endif // SFML_DRAWABLE_HPP
76
77


  • File List
  • include
  • SFML
  • System
Err.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_ERR_HPP
26 #define SFML_ERR_HPP
27
29 // Headers
31 #include <SFML/System/Export.hpp>
32 #include <ostream>
33
34
35 namespace sf
36 {
41 SFML_SYSTEM_API std::ostream& err();
42
43 } // namespace sf
44
45
46 #endif // SFML_ERR_HPP
47
48


  • File List
  • include
  • SFML
  • Window
Event.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_EVENT_HPP
26 #define SFML_EVENT_HPP
27
29 // Headers
31 #include <SFML/Config.hpp>
32 #include <SFML/Window/Joystick.hpp>
33 #include <SFML/Window/Keyboard.hpp>
34 #include <SFML/Window/Mouse.hpp>
35
36
37 namespace sf
38 {
43 class Event
44 {
45 public :
46
51 struct SizeEvent
52 {
53 unsigned int width;
54 unsigned int height;
55 };
56
61 struct KeyEvent
62 {
63 Keyboard::Key code;
64 bool alt;
65 bool control;
66 bool shift;
67 bool system;
68 };
69
74 struct TextEvent
75 {
76 Uint32 unicode;
77 };
78
83 struct MouseMoveEvent
84 {
85 int x;
86 int y;
87 };
88
94 struct MouseButtonEvent
95 {
96 Mouse::Button button;
97 int x;
98 int y;
99 };
100
105 struct MouseWheelEvent
106 {
107 int delta;
108 int x;
109 int y;
110 };
111
117 struct JoystickConnectEvent
118 {
119 unsigned int joystickId;
120 };
121
126 struct JoystickMoveEvent
127 {
128 unsigned int joystickId;
129 Joystick::Axis axis;
130 float position;
131 };
132
138 struct JoystickButtonEvent
139 {
140 unsigned int joystickId;
141 unsigned int button;
142 };
143
148 enum EventType
149 {
150 Closed,
151 Resized,
152 LostFocus,
153 GainedFocus,
154 TextEntered,
155 KeyPressed,
156 KeyReleased,
157 MouseWheelMoved,
158 MouseButtonPressed,
159 MouseButtonReleased,
160 MouseMoved,
161 MouseEntered,
162 MouseLeft,
163 JoystickButtonPressed,
164 JoystickButtonReleased,
165 JoystickMoved,
166 JoystickConnected,
167 JoystickDisconnected,
168
169 Count
170 };
171
173 // Member data
175 EventType type;
176
177 union
178 {
179 SizeEvent size;
180 KeyEvent key;
181 TextEvent text;
182 MouseMoveEvent mouseMove;
183 MouseButtonEvent mouseButton;
184 MouseWheelEvent mouseWheel;
185 JoystickMoveEvent joystickMove;
186 JoystickButtonEvent joystickButton;
187 JoystickConnectEvent joystickConnect;
188 };
189 };
190
191 } // namespace sf
192
193
194 #endif // SFML_EVENT_HPP
195
196


  • File List
  • include
  • SFML
  • Audio
Audio/Export.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_AUDIO_EXPORT_HPP
26 #define SFML_AUDIO_EXPORT_HPP
27
29 // Headers
31 #include <SFML/Config.hpp>
32
33
35 // Define portable import / export macros
37 #if defined(SFML_AUDIO_EXPORTS)
38
39 #define SFML_AUDIO_API SFML_API_EXPORT
40
41 #else
42
43 #define SFML_AUDIO_API SFML_API_IMPORT
44
45 #endif
46
47
48 #endif // SFML_AUDIO_EXPORT_HPP


  • File List
  • include
  • SFML
  • Graphics
Graphics/Export.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_GRAPHICS_EXPORT_HPP
26 #define SFML_GRAPHICS_EXPORT_HPP
27
29 // Headers
31 #include <SFML/Config.hpp>
32
33
35 // Define portable import / export macros
37 #if defined(SFML_GRAPHICS_EXPORTS)
38
39 #define SFML_GRAPHICS_API SFML_API_EXPORT
40
41 #else
42
43 #define SFML_GRAPHICS_API SFML_API_IMPORT
44
45 #endif
46
47
48 #endif // SFML_GRAPHICS_EXPORT_HPP


  • File List
  • include
  • SFML
  • Network
Network/Export.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_NETWORK_EXPORT_HPP
26 #define SFML_NETWORK_EXPORT_HPP
27
29 // Headers
31 #include <SFML/Config.hpp>
32
33
35 // Define portable import / export macros
37 #if defined(SFML_NETWORK_EXPORTS)
38
39 #define SFML_NETWORK_API SFML_API_EXPORT
40
41 #else
42
43 #define SFML_NETWORK_API SFML_API_IMPORT
44
45 #endif
46
47
48 #endif // SFML_NETWORK_EXPORT_HPP


  • File List
  • include
  • SFML
  • System
System/Export.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SYSTEM_EXPORT_HPP
26 #define SFML_SYSTEM_EXPORT_HPP
27
29 // Headers
31 #include <SFML/Config.hpp>
32
33
35 // Define portable import / export macros
37 #if defined(SFML_SYSTEM_EXPORTS)
38
39 #define SFML_SYSTEM_API SFML_API_EXPORT
40
41 #else
42
43 #define SFML_SYSTEM_API SFML_API_IMPORT
44
45 #endif
46
47
48 #endif // SFML_SYSTEM_EXPORT_HPP


  • File List
  • include
  • SFML
  • Window
Window/Export.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_WINDOW_EXPORT_HPP
26 #define SFML_WINDOW_EXPORT_HPP
27
29 // Headers
31 #include <SFML/Config.hpp>
32
33
35 // Define portable import / export macros
37 #if defined(SFML_WINDOW_EXPORTS)
38
39 #define SFML_WINDOW_API SFML_API_EXPORT
40
41 #else
42
43 #define SFML_WINDOW_API SFML_API_IMPORT
44
45 #endif
46
47
48 #endif // SFML_WINDOW_EXPORT_HPP


  • File List
  • include
  • SFML
  • Graphics
Font.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_FONT_HPP
26 #define SFML_FONT_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Glyph.hpp>
33 #include <SFML/Graphics/Texture.hpp>
34 #include <SFML/Graphics/Rect.hpp>
35 #include <SFML/System/Vector2.hpp>
36 #include <SFML/System/String.hpp>
37 #include <map>
38 #include <string>
39 #include <vector>
40
41
42 namespace sf
43 {
44 class InputStream;
45
50 class SFML_GRAPHICS_API Font
51 {
52 public :
53
60 Font();
61
68 Font(const Font& copy);
69
76 ~Font();
77
94 bool loadFromFile(const std::string& filename);
95
113 bool loadFromMemory(const void* data, std::size_t sizeInBytes);
114
131 bool loadFromStream(InputStream& stream);
132
143 const Glyph& getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const;
144
161 int getKerning(Uint32 first, Uint32 second, unsigned int characterSize) const;
162
174 int getLineSpacing(unsigned int characterSize) const;
175
188 const Texture& getTexture(unsigned int characterSize) const;
189
198 Font& operator =(const Font& right);
199
200 private :
201
206 struct Row
207 {
208 Row(unsigned int rowTop, unsigned int rowHeight) : width(0), top(rowTop), height(rowHeight) {}
209
210 unsigned int width;
211 unsigned int top;
212 unsigned int height;
213 };
214
216 // Types
218 typedef std::map<Uint32, Glyph> GlyphTable;
219
224 struct Page
225 {
226 Page();
227
228 GlyphTable glyphs;
229 sf::Texture texture;
230 unsigned int nextRow;
231 std::vector<Row> rows;
232 };
233
238 void cleanup();
239
250 Glyph loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const;
251
262 IntRect findGlyphRect(Page& page, unsigned int width, unsigned int height) const;
263
272 bool setCurrentSize(unsigned int characterSize) const;
273
275 // Types
277 typedef std::map<unsigned int, Page> PageTable;
278
280 // Member data
282 void* m_library;
283 void* m_face;
284 void* m_streamRec;
285 int* m_refCount;
286 mutable PageTable m_pages;
287 mutable std::vector<Uint8> m_pixelBuffer;
288 };
289
290 } // namespace sf
291
292
293 #endif // SFML_FONT_HPP
294
295


  • File List
  • include
  • SFML
  • Network
Ftp.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_FTP_HPP
26 #define SFML_FTP_HPP
27
29 // Headers
31 #include <SFML/Network/Export.hpp>
32 #include <SFML/Network/TcpSocket.hpp>
33 #include <SFML/System/NonCopyable.hpp>
34 #include <SFML/System/Time.hpp>
35 #include <string>
36 #include <vector>
37
38
39 namespace sf
40 {
41 class IpAddress;
42
47 class SFML_NETWORK_API Ftp : NonCopyable
48 {
49 public :
50
55 enum TransferMode
56 {
57 Binary,
58 Ascii,
59 Ebcdic
60 };
61
66 class SFML_NETWORK_API Response
67 {
68 public :
69
74 enum Status
75 {
76 // 1xx: the requested action is being initiated,
77 // expect another reply before proceeding with a new command
78 RestartMarkerReply = 110,
79 ServiceReadySoon = 120,
80 DataConnectionAlreadyOpened = 125,
81 OpeningDataConnection = 150,
82
83 // 2xx: the requested action has been successfully completed
84 Ok = 200,
85 PointlessCommand = 202,
86 SystemStatus = 211,
87 DirectoryStatus = 212,
88 FileStatus = 213,
89 HelpMessage = 214,
90 SystemType = 215,
91 ServiceReady = 220,
92 ClosingConnection = 221,
93 DataConnectionOpened = 225,
94 ClosingDataConnection = 226,
95 EnteringPassiveMode = 227,
96 LoggedIn = 230,
97 FileActionOk = 250,
98 DirectoryOk = 257,
99
100 // 3xx: the command has been accepted, but the requested action
101 // is dormant, pending receipt of further information
102 NeedPassword = 331,
103 NeedAccountToLogIn = 332,
104 NeedInformation = 350,
105
106 // 4xx: the command was not accepted and the requested action did not take place,
107 // but the error condition is temporary and the action may be requested again
108 ServiceUnavailable = 421,
109 DataConnectionUnavailable = 425,
110 TransferAborted = 426,
111 FileActionAborted = 450,
112 LocalError = 451,
113 InsufficientStorageSpace = 452,
114
115 // 5xx: the command was not accepted and
116 // the requested action did not take place
117 CommandUnknown = 500,
118 ParametersUnknown = 501,
119 CommandNotImplemented = 502,
120 BadCommandSequence = 503,
121 ParameterNotImplemented = 504,
122 NotLoggedIn = 530,
123 NeedAccountToStore = 532,
124 FileUnavailable = 550,
125 PageTypeUnknown = 551,
126 NotEnoughMemory = 552,
127 FilenameNotAllowed = 553,
128
129 // 10xx: SFML custom codes
130 InvalidResponse = 1000,
131 ConnectionFailed = 1001,
132 ConnectionClosed = 1002,
133 InvalidFile = 1003
134 };
135
146 explicit Response(Status code = InvalidResponse, const std::string& message = "");
147
157 bool isOk() const;
158
165 Status getStatus() const;
166
173 const std::string& getMessage() const;
174
175 private :
176
178 // Member data
180 Status m_status;
181 std::string m_message;
182 };
183
188 class SFML_NETWORK_API DirectoryResponse : public Response
189 {
190 public :
191
198 DirectoryResponse(const Response& response);
199
206 const std::string& getDirectory() const;
207
208 private :
209
211 // Member data
213 std::string m_directory;
214 };
215
216
221 class SFML_NETWORK_API ListingResponse : public Response
222 {
223 public :
224
232 ListingResponse(const Response& response, const std::vector<char>& data);
233
240 const std::vector<std::string>& getListing() const;
241
242 private :
243
245 // Member data
247 std::vector<std::string> m_listing;
248 };
249
250
258 ~Ftp();
259
281 Response connect(const IpAddress& server, unsigned short port = 21, Time timeout = Time::Zero);
282
291 Response disconnect();
292
302 Response login();
303
316 Response login(const std::string& name, const std::string& password);
317
327 Response keepAlive();
328
340 DirectoryResponse getWorkingDirectory();
341
357 ListingResponse getDirectoryListing(const std::string& directory = "");
358
371 Response changeDirectory(const std::string& directory);
372
381 Response parentDirectory();
382
396 Response createDirectory(const std::string& name);
397
413 Response deleteDirectory(const std::string& name);
414
429 Response renameFile(const std::string& file, const std::string& newName);
430
446 Response deleteFile(const std::string& name);
447
465 Response download(const std::string& remoteFile, const std::string& localPath, TransferMode mode = Binary);
466
484 Response upload(const std::string& localFile, const std::string& remotePath, TransferMode mode = Binary);
485
486 private :
487
497 Response sendCommand(const std::string& command, const std::string& parameter = "");
498
508 Response getResponse();
509
515 class DataChannel;
516
517 friend class DataChannel;
518
520 // Member data
522 TcpSocket m_commandSocket;
523 };
524
525 } // namespace sf
526
527
528 #endif // SFML_FTP_HPP
529
530


  • File List
  • include
  • SFML
  • Window
GlResource.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_GLRESOURCE_HPP
26 #define SFML_GLRESOURCE_HPP
27
29 // Headers
31 #include <SFML/Window/Export.hpp>
32
33
34 namespace sf
35 {
40 class SFML_WINDOW_API GlResource
41 {
42 protected :
43
48 GlResource();
49
54 ~GlResource();
55
60 static void ensureGlContext();
61 };
62
63 } // namespace sf
64
65
66 #endif // SFML_GLRESOURCE_HPP
67


  • File List
  • include
  • SFML
  • Graphics
Glyph.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_GLYPH_HPP
26 #define SFML_GLYPH_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Rect.hpp>
33
34
35 namespace sf
36 {
41 class SFML_GRAPHICS_API Glyph
42 {
43 public :
44
49 Glyph() : advance(0) {}
50
52 // Member data
54 int advance;
55 IntRect bounds;
56 IntRect textureRect;
57 };
58
59 } // namespace sf
60
61
62 #endif // SFML_GLYPH_HPP
63
64


  • File List
  • include
  • SFML
Graphics.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_GRAPHICS_HPP
26 #define SFML_GRAPHICS_HPP
27
29 // Headers
31
32 #include <SFML/Window.hpp>
33 #include <SFML/Graphics/BlendMode.hpp>
34 #include <SFML/Graphics/Color.hpp>
35 #include <SFML/Graphics/Font.hpp>
36 #include <SFML/Graphics/Glyph.hpp>
37 #include <SFML/Graphics/Image.hpp>
38 #include <SFML/Graphics/RenderStates.hpp>
39 #include <SFML/Graphics/RenderTexture.hpp>
40 #include <SFML/Graphics/RenderWindow.hpp>
41 #include <SFML/Graphics/Shader.hpp>
42 #include <SFML/Graphics/Shape.hpp>
43 #include <SFML/Graphics/CircleShape.hpp>
44 #include <SFML/Graphics/RectangleShape.hpp>
45 #include <SFML/Graphics/ConvexShape.hpp>
46 #include <SFML/Graphics/Sprite.hpp>
47 #include <SFML/Graphics/Text.hpp>
48 #include <SFML/Graphics/Texture.hpp>
49 #include <SFML/Graphics/Transform.hpp>
50 #include <SFML/Graphics/Vertex.hpp>
51 #include <SFML/Graphics/VertexArray.hpp>
52 #include <SFML/Graphics/View.hpp>
53
54
55 #endif // SFML_GRAPHICS_HPP
56


  • File List
  • include
  • SFML
  • Network
Http.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_HTTP_HPP
26 #define SFML_HTTP_HPP
27
29 // Headers
31 #include <SFML/Network/Export.hpp>
32 #include <SFML/Network/IpAddress.hpp>
33 #include <SFML/Network/TcpSocket.hpp>
34 #include <SFML/System/NonCopyable.hpp>
35 #include <SFML/System/Time.hpp>
36 #include <map>
37 #include <string>
38
39
40 namespace sf
41 {
46 class SFML_NETWORK_API Http : NonCopyable
47 {
48 public :
49
54 class SFML_NETWORK_API Request
55 {
56 public :
57
62 enum Method
63 {
64 Get,
65 Post,
66 Head
67 };
68
80 Request(const std::string& uri = "/", Method method = Get, const std::string& body = "");
81
95 void setField(const std::string& field, const std::string& value);
96
107 void setMethod(Method method);
108
119 void setUri(const std::string& uri);
120
130 void setHttpVersion(unsigned int major, unsigned int minor);
131
142 void setBody(const std::string& body);
143
144 private :
145
146 friend class Http;
147
157 std::string prepare() const;
158
169 bool hasField(const std::string& field) const;
170
172 // Types
174 typedef std::map<std::string, std::string> FieldTable;
175
177 // Member data
179 FieldTable m_fields;
180 Method m_method;
181 std::string m_uri;
182 unsigned int m_majorVersion;
183 unsigned int m_minorVersion;
184 std::string m_body;
185 };
186
191 class SFML_NETWORK_API Response
192 {
193 public :
194
199 enum Status
200 {
201 // 2xx: success
202 Ok = 200,
203 Created = 201,
204 Accepted = 202,
205 NoContent = 204,
206 ResetContent = 205,
207 PartialContent = 206,
208
209 // 3xx: redirection
210 MultipleChoices = 300,
211 MovedPermanently = 301,
212 MovedTemporarily = 302,
213 NotModified = 304,
214
215 // 4xx: client error
216 BadRequest = 400,
217 Unauthorized = 401,
218 Forbidden = 403,
219 NotFound = 404,
220 RangeNotSatisfiable = 407,
221
222 // 5xx: server error
223 InternalServerError = 500,
224 NotImplemented = 501,
225 BadGateway = 502,
226 ServiceNotAvailable = 503,
227 GatewayTimeout = 504,
228 VersionNotSupported = 505,
229
230 // 10xx: SFML custom codes
231 InvalidResponse = 1000,
232 ConnectionFailed = 1001
233 };
234
241 Response();
242
255 const std::string& getField(const std::string& field) const;
256
268 Status getStatus() const;
269
278 unsigned int getMajorHttpVersion() const;
279
288 unsigned int getMinorHttpVersion() const;
289
302 const std::string& getBody() const;
303
304 private :
305
306 friend class Http;
307
317 void parse(const std::string& data);
318
320 // Types
322 typedef std::map<std::string, std::string> FieldTable;
323
325 // Member data
327 FieldTable m_fields;
328 Status m_status;
329 unsigned int m_majorVersion;
330 unsigned int m_minorVersion;
331 std::string m_body;
332 };
333
338 Http();
339
354 Http(const std::string& host, unsigned short port = 0);
355
371 void setHost(const std::string& host, unsigned short port = 0);
372
391 Response sendRequest(const Request& request, Time timeout = Time::Zero);
392
393 private :
394
396 // Member data
398 TcpSocket m_connection;
399 IpAddress m_host;
400 std::string m_hostName;
401 unsigned short m_port;
402 };
403
404 } // namespace sf
405
406
407 #endif // SFML_HTTP_HPP
408
409


  • File List
  • include
  • SFML
  • Graphics
Image.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_IMAGE_HPP
26 #define SFML_IMAGE_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Color.hpp>
33 #include <SFML/Graphics/Rect.hpp>
34 #include <string>
35 #include <vector>
36
37
38 namespace sf
39 {
40 class InputStream;
41
46 class SFML_GRAPHICS_API Image
47 {
48 public :
49
56 Image();
57
66 void create(unsigned int width, unsigned int height, const Color& color = Color(0, 0, 0));
67
81 void create(unsigned int width, unsigned int height, const Uint8* pixels);
82
98 bool loadFromFile(const std::string& filename);
99
116 bool loadFromMemory(const void* data, std::size_t size);
117
133 bool loadFromStream(InputStream& stream);
134
150 bool saveToFile(const std::string& filename) const;
151
158 Vector2u getSize() const;
159
171 void createMaskFromColor(const Color& color, Uint8 alpha = 0);
172
193 void copy(const Image& source, unsigned int destX, unsigned int destY, const IntRect& sourceRect = IntRect(0, 0, 0, 0), bool applyAlpha = false);
194
209 void setPixel(unsigned int x, unsigned int y, const Color& color);
210
226 Color getPixel(unsigned int x, unsigned int y) const;
227
241 const Uint8* getPixelsPtr() const;
242
247 void flipHorizontally();
248
253 void flipVertically();
254
255 private :
256
258 // Member data
260 Vector2u m_size;
261 std::vector<Uint8> m_pixels;
262 };
263
264 } // namespace sf
265
266
267 #endif // SFML_IMAGE_HPP
268
269


  • File List
  • include
  • SFML
  • System
InputStream.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_INPUTSTREAM_HPP
26 #define SFML_INPUTSTREAM_HPP
27
29 // Headers
31 #include <SFML/Config.hpp>
32
33
34 namespace sf
35 {
40 class InputStream
41 {
42 public :
43
48 virtual ~InputStream() {}
49
62 virtual Int64 read(void* data, Int64 size) = 0;
63
72 virtual Int64 seek(Int64 position) = 0;
73
80 virtual Int64 tell() = 0;
81
88 virtual Int64 getSize() = 0;
89 };
90
91 } // namespace sf
92
93
94 #endif // SFML_INPUTSTREAM_HPP
95
96


  • File List
  • include
  • SFML
  • Network
IpAddress.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_IPADDRESS_HPP
26 #define SFML_IPADDRESS_HPP
27
29 // Headers
31 #include <SFML/Network/Export.hpp>
32 #include <SFML/System/Time.hpp>
33 #include <istream>
34 #include <ostream>
35 #include <string>
36
37
38 namespace sf
39 {
44 class SFML_NETWORK_API IpAddress
45 {
46 public :
47
54 IpAddress();
55
65 IpAddress(const std::string& address);
66
79 IpAddress(const char* address);
80
94 IpAddress(Uint8 byte0, Uint8 byte1, Uint8 byte2, Uint8 byte3);
95
109 explicit IpAddress(Uint32 address);
110
123 std::string toString() const;
124
139 Uint32 toInteger() const;
140
155 static IpAddress getLocalAddress();
156
179 static IpAddress getPublicAddress(Time timeout = Time::Zero);
180
182 // Static member data
184 static const IpAddress None;
185 static const IpAddress LocalHost;
186 static const IpAddress Broadcast;
187
188 private :
189
191 // Member data
193 Uint32 m_address;
194 };
195
205 SFML_NETWORK_API bool operator ==(const IpAddress& left, const IpAddress& right);
206
216 SFML_NETWORK_API bool operator !=(const IpAddress& left, const IpAddress& right);
217
227 SFML_NETWORK_API bool operator <(const IpAddress& left, const IpAddress& right);
228
238 SFML_NETWORK_API bool operator >(const IpAddress& left, const IpAddress& right);
239
249 SFML_NETWORK_API bool operator <=(const IpAddress& left, const IpAddress& right);
250
260 SFML_NETWORK_API bool operator >=(const IpAddress& left, const IpAddress& right);
261
271 SFML_NETWORK_API std::istream& operator >>(std::istream& stream, IpAddress& address);
272
282 SFML_NETWORK_API std::ostream& operator <<(std::ostream& stream, const IpAddress& address);
283
284 } // namespace sf
285
286
287 #endif // SFML_IPADDRESS_HPP
288
289


  • File List
  • include
  • SFML
  • Window
Joystick.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_JOYSTICK_HPP
26 #define SFML_JOYSTICK_HPP
27
29 // Headers
31 #include <SFML/Window/Export.hpp>
32
33
34 namespace sf
35 {
40 class SFML_WINDOW_API Joystick
41 {
42 public :
43
48 enum
49 {
50 Count = 8,
51 ButtonCount = 32,
52 AxisCount = 8
53 };
54
59 enum Axis
60 {
61 X,
62 Y,
63 Z,
64 R,
65 U,
66 V,
67 PovX,
68 PovY
69 };
70
79 static bool isConnected(unsigned int joystick);
80
91 static unsigned int getButtonCount(unsigned int joystick);
92
104 static bool hasAxis(unsigned int joystick, Axis axis);
105
117 static bool isButtonPressed(unsigned int joystick, unsigned int button);
118
130 static float getAxisPosition(unsigned int joystick, Axis axis);
131
141 static void update();
142 };
143
144 } // namespace sf
145
146
147 #endif // SFML_JOYSTICK_HPP
148
149


  • File List
  • include
  • SFML
  • Window
Keyboard.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_KEYBOARD_HPP
26 #define SFML_KEYBOARD_HPP
27
29 // Headers
31 #include <SFML/Window/Export.hpp>
32
33
34 namespace sf
35 {
40 class SFML_WINDOW_API Keyboard
41 {
42 public :
43
48 enum Key
49 {
50 Unknown = -1,
51 A = 0,
52 B,
53 C,
54 D,
55 E,
56 F,
57 G,
58 H,
59 I,
60 J,
61 K,
62 L,
63 M,
64 N,
65 O,
66 P,
67 Q,
68 R,
69 S,
70 T,
71 U,
72 V,
73 W,
74 X,
75 Y,
76 Z,
77 Num0,
78 Num1,
79 Num2,
80 Num3,
81 Num4,
82 Num5,
83 Num6,
84 Num7,
85 Num8,
86 Num9,
87 Escape,
88 LControl,
89 LShift,
90 LAlt,
91 LSystem,
92 RControl,
93 RShift,
94 RAlt,
95 RSystem,
96 Menu,
97 LBracket,
98 RBracket,
99 SemiColon,
100 Comma,
101 Period,
102 Quote,
103 Slash,
104 BackSlash,
105 Tilde,
106 Equal,
107 Dash,
108 Space,
109 Return,
110 BackSpace,
111 Tab,
112 PageUp,
113 PageDown,
114 End,
115 Home,
116 Insert,
117 Delete,
118 Add,
119 Subtract,
120 Multiply,
121 Divide,
122 Left,
123 Right,
124 Up,
125 Down,
126 Numpad0,
127 Numpad1,
128 Numpad2,
129 Numpad3,
130 Numpad4,
131 Numpad5,
132 Numpad6,
133 Numpad7,
134 Numpad8,
135 Numpad9,
136 F1,
137 F2,
138 F3,
139 F4,
140 F5,
141 F6,
142 F7,
143 F8,
144 F9,
145 F10,
146 F11,
147 F12,
148 F13,
149 F14,
150 F15,
151 Pause,
152
153 KeyCount
154 };
155
164 static bool isKeyPressed(Key key);
165 };
166
167 } // namespace sf
168
169
170 #endif // SFML_KEYBOARD_HPP
171
172


  • File List
  • include
  • SFML
  • Audio
Listener.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_LISTENER_HPP
26 #define SFML_LISTENER_HPP
27
29 // Headers
31 #include <SFML/Audio/Export.hpp>
32 #include <SFML/System/Vector3.hpp>
33
34
35 namespace sf
36 {
42 class SFML_AUDIO_API Listener
43 {
44 public :
45
58 static void setGlobalVolume(float volume);
59
68 static float getGlobalVolume();
69
82 static void setPosition(float x, float y, float z);
83
94 static void setPosition(const Vector3f& position);
95
104 static Vector3f getPosition();
105
121 static void setDirection(float x, float y, float z);
122
136 static void setDirection(const Vector3f& direction);
137
146 static Vector3f getDirection();
147 };
148
149 } // namespace sf
150
151
152 #endif // SFML_LISTENER_HPP
153
154


  • File List
  • include
  • SFML
  • System
Lock.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_LOCK_HPP
26 #define SFML_LOCK_HPP
27
29 // Headers
31 #include <SFML/System/Export.hpp>
32 #include <SFML/System/NonCopyable.hpp>
33
34
35 namespace sf
36 {
37 class Mutex;
38
43 class SFML_SYSTEM_API Lock : NonCopyable
44 {
45 public :
46
55 explicit Lock(Mutex& mutex);
56
63 ~Lock();
64
65 private :
66
68 // Member data
70 Mutex& m_mutex;
71 };
72
73 } // namespace sf
74
75
76 #endif // SFML_LOCK_HPP
77
78


  • File List
  • doc
mainpage.hpp
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71


  • File List
  • include
  • SFML
  • Window
Mouse.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_MOUSE_HPP
26 #define SFML_MOUSE_HPP
27
29 // Headers
31 #include <SFML/Window/Export.hpp>
32 #include <SFML/System/Vector2.hpp>
33
34
35 namespace sf
36 {
37 class Window;
38
43 class SFML_WINDOW_API Mouse
44 {
45 public :
46
51 enum Button
52 {
53 Left,
54 Right,
55 Middle,
56 XButton1,
57 XButton2,
58
59 ButtonCount
60 };
61
70 static bool isButtonPressed(Button button);
71
81 static Vector2i getPosition();
82
94 static Vector2i getPosition(const Window& relativeTo);
95
105 static void setPosition(const Vector2i& position);
106
117 static void setPosition(const Vector2i& position, const Window& relativeTo);
118 };
119
120 } // namespace sf
121
122
123 #endif // SFML_MOUSE_HPP
124
125


  • File List
  • include
  • SFML
  • Audio
Music.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_MUSIC_HPP
26 #define SFML_MUSIC_HPP
27
29 // Headers
31 #include <SFML/Audio/Export.hpp>
32 #include <SFML/Audio/SoundStream.hpp>
33 #include <SFML/System/Mutex.hpp>
34 #include <SFML/System/Time.hpp>
35 #include <string>
36 #include <vector>
37
38
39 namespace sf
40 {
41 namespace priv
42 {
43 class SoundFile;
44 }
45
46 class InputStream;
47
52 class SFML_AUDIO_API Music : public SoundStream
53 {
54 public :
55
60 Music();
61
66 ~Music();
67
84 bool openFromFile(const std::string& filename);
85
107 bool openFromMemory(const void* data, std::size_t sizeInBytes);
108
129 bool openFromStream(InputStream& stream);
130
137 Time getDuration() const;
138
139 protected :
140
152 virtual bool onGetData(Chunk& data);
153
160 virtual void onSeek(Time timeOffset);
161
162 private :
163
168 void initialize();
169
171 // Member data
173 priv::SoundFile* m_file;
174 Time m_duration;
175 std::vector<Int16> m_samples;
176 Mutex m_mutex;
177 };
178
179 } // namespace sf
180
181
182 #endif // SFML_MUSIC_HPP
183
184


  • File List
  • include
  • SFML
  • System
Mutex.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_MUTEX_HPP
26 #define SFML_MUTEX_HPP
27
29 // Headers
31 #include <SFML/System/Export.hpp>
32 #include <SFML/System/NonCopyable.hpp>
33
34
35 namespace sf
36 {
37 namespace priv
38 {
39 class MutexImpl;
40 }
41
47 class SFML_SYSTEM_API Mutex : NonCopyable
48 {
49 public :
50
55 Mutex();
56
61 ~Mutex();
62
73 void lock();
74
81 void unlock();
82
83 private :
84
86 // Member data
88 priv::MutexImpl* m_mutexImpl;
89 };
90
91 } // namespace sf
92
93
94 #endif // SFML_MUTEX_HPP
95
96


  • File List
  • include
  • SFML
Network.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_NETWORK_HPP
26 #define SFML_NETWORK_HPP
27
29 // Headers
31
32 #include <SFML/System.hpp>
33 #include <SFML/Network/Ftp.hpp>
34 #include <SFML/Network/Http.hpp>
35 #include <SFML/Network/IpAddress.hpp>
36 #include <SFML/Network/Packet.hpp>
37 #include <SFML/Network/SocketSelector.hpp>
38 #include <SFML/Network/TcpListener.hpp>
39 #include <SFML/Network/TcpSocket.hpp>
40 #include <SFML/Network/UdpSocket.hpp>
41
42
43 #endif // SFML_NETWORK_HPP
44


  • File List
  • include
  • SFML
  • System
NonCopyable.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_NONCOPYABLE_HPP
26 #define SFML_NONCOPYABLE_HPP
27
29 // Headers
31 #include <SFML/System/Export.hpp>
32
33
34 namespace sf
35 {
41 class SFML_SYSTEM_API NonCopyable
42 {
43 protected :
44
53 NonCopyable() {}
54
55 private :
56
67 NonCopyable(const NonCopyable&);
68
79 NonCopyable& operator =(const NonCopyable&);
80 };
81
82 } // namespace sf
83
84
85 #endif // SFML_NONCOPYABLE_HPP
86
87


  • File List
  • include
  • SFML
OpenGL.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_OPENGL_HPP
26 #define SFML_OPENGL_HPP
27
28
32 #include <SFML/Config.hpp>
33
34
39 #if defined(SFML_SYSTEM_WINDOWS)
40
41 // The Visual C++ version of gl.h uses WINGDIAPI and APIENTRY but doesn't define them
42 #ifdef _MSC_VER
43 #include <windows.h>
44 #endif
45
46 #include <GL/gl.h>
47 #include <GL/glu.h>
48
49 #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD)
50
51 #include <GL/gl.h>
52 #include <GL/glu.h>
53
54 #elif defined(SFML_SYSTEM_MACOS)
55
56 #include <OpenGL/gl.h>
57 #include <OpenGL/glu.h>
58
59 #endif
60
61
62 #endif // SFML_OPENGL_HPP


  • File List
  • include
  • SFML
  • Network
Packet.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_PACKET_HPP
26 #define SFML_PACKET_HPP
27
29 // Headers
31 #include <SFML/Network/Export.hpp>
32 #include <string>
33 #include <vector>
34
35
36 namespace sf
37 {
38 class String;
39 class TcpSocket;
40 class UdpSocket;
41
47 class SFML_NETWORK_API Packet
48 {
49 // A bool-like type that cannot be converted to integer or pointer types
50 typedef bool (Packet::*BoolType)(std::size_t);
51
52 public :
53
60 Packet();
61
66 virtual ~Packet();
67
77 void append(const void* data, std::size_t sizeInBytes);
78
87 void clear();
88
102 const void* getData() const;
103
115 std::size_t getDataSize() const;
116
129 bool endOfPacket() const;
130
131 public:
132
171 operator BoolType() const;
172
177 Packet& operator >>(bool& data);
178 Packet& operator >>(Int8& data);
179 Packet& operator >>(Uint8& data);
180 Packet& operator >>(Int16& data);
181 Packet& operator >>(Uint16& data);
182 Packet& operator >>(Int32& data);
183 Packet& operator >>(Uint32& data);
184 Packet& operator >>(float& data);
185 Packet& operator >>(double& data);
186 Packet& operator >>(char* data);
187 Packet& operator >>(std::string& data);
188 Packet& operator >>(wchar_t* data);
189 Packet& operator >>(std::wstring& data);
190 Packet& operator >>(String& data);
191
196 Packet& operator <<(bool data);
197 Packet& operator <<(Int8 data);
198 Packet& operator <<(Uint8 data);
199 Packet& operator <<(Int16 data);
200 Packet& operator <<(Uint16 data);
201 Packet& operator <<(Int32 data);
202 Packet& operator <<(Uint32 data);
203 Packet& operator <<(float data);
204 Packet& operator <<(double data);
205 Packet& operator <<(const char* data);
206 Packet& operator <<(const std::string& data);
207 Packet& operator <<(const wchar_t* data);
208 Packet& operator <<(const std::wstring& data);
209 Packet& operator <<(const String& data);
210
211 protected:
212
213 friend class TcpSocket;
214 friend class UdpSocket;
215
234 virtual const void* onSend(std::size_t& size);
235
253 virtual void onReceive(const void* data, std::size_t size);
254
255 private :
256
261 bool operator ==(const Packet& right) const;
262 bool operator !=(const Packet& right) const;
263
274 bool checkSize(std::size_t size);
275
277 // Member data
279 std::vector<char> m_data;
280 std::size_t m_readPos;
281 bool m_isValid;
282 };
283
284 } // namespace sf
285
286
287 #endif // SFML_PACKET_HPP
288
289


  • File List
  • include
  • SFML
  • Graphics
PrimitiveType.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_PRIMITIVETYPE_HPP
26 #define SFML_PRIMITIVETYPE_HPP
27
28 namespace sf
29 {
39 enum PrimitiveType
40 {
41 Points,
42 Lines,
43 LinesStrip,
44 Triangles,
45 TrianglesStrip,
46 TrianglesFan,
47 Quads
48 };
49
50 } // namespace sf
51
52
53 #endif // SFML_PRIMITIVETYPE_HPP


  • File List
  • include
  • SFML
  • Graphics
Rect.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_RECT_HPP
26 #define SFML_RECT_HPP
27
29 // Headers
31 #include <SFML/System/Vector2.hpp>
32 #include <algorithm>
33
34
35 namespace sf
36 {
41 template <typename T>
42 class Rect
43 {
44 public :
45
53 Rect();
54
67 Rect(T rectLeft, T rectTop, T rectWidth, T rectHeight);
68
79 Rect(const Vector2<T>& position, const Vector2<T>& size);
80
92 template <typename U>
93 explicit Rect(const Rect<U>& rectangle);
94
106 bool contains(T x, T y) const;
107
118 bool contains(const Vector2<T>& point) const;
119
130 bool intersects(const Rect<T>& rectangle) const;
131
146 bool intersects(const Rect<T>& rectangle, Rect<T>& intersection) const;
147
149 // Member data
151 T left;
152 T top;
153 T width;
154 T height;
155 };
156
169 template <typename T>
170 bool operator ==(const Rect<T>& left, const Rect<T>& right);
171
184 template <typename T>
185 bool operator !=(const Rect<T>& left, const Rect<T>& right);
186
187 #include <SFML/Graphics/Rect.inl>
188
189 // Create typedefs for the most common types
190 typedef Rect<int> IntRect;
191 typedef Rect<float> FloatRect;
192
193 } // namespace sf
194
195
196 #endif // SFML_RECT_HPP
197
198


  • File List
  • include
  • SFML
  • Graphics
Rect.inl
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2012 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25
27 template <typename T>
28 Rect<T>::Rect() :
29 left (0),
30 top (0),
31 width (0),
32 height(0)
33 {
34
35 }
36
37
39 template <typename T>
40 Rect<T>::Rect(T rectLeft, T rectTop, T rectWidth, T rectHeight) :
41 left (rectLeft),
42 top (rectTop),
43 width (rectWidth),
44 height(rectHeight)
45 {
46
47 }
48
49
51 template <typename T>
52 Rect<T>::Rect(const Vector2<T>& position, const Vector2<T>& size) :
53 left (position.x),
54 top (position.y),
55 width (size.x),
56 height(size.y)
57 {
58
59 }
60
61
63 template <typename T>
64 template <typename U>
65 Rect<T>::Rect(const Rect<U>& rectangle) :
66 left (static_cast<T>(rectangle.left)),
67 top (static_cast<T>(rectangle.top)),
68 width (static_cast<T>(rectangle.width)),
69 height(static_cast<T>(rectangle.height))
70 {
71 }
72
73
75 template <typename T>
76 bool Rect<T>::contains(T x, T y) const
77 {
78 // Rectangles with negative dimensions are allowed, so we must handle them correctly
79
80 // Compute the real min and max of the rectangle on both axes
81 T minX = std::min(left, left + width);
82 T maxX = std::max(left, left + width);
83 T minY = std::min(top, top + height);
84 T maxY = std::max(top, top + height);
85
86 return (x >= minX) && (x < maxX) && (y >= minY) && (y < maxY);
87 }
88
89
91 template <typename T>
92 bool Rect<T>::contains(const Vector2<T>& point) const
93 {
94 return contains(point.x, point.y);
95 }
96
97
99 template <typename T>
100 bool Rect<T>::intersects(const Rect<T>& rectangle) const
101 {
102 Rect<T> intersection;
103 return intersects(rectangle, intersection);
104 }
105
106
108 template <typename T>
109 bool Rect<T>::intersects(const Rect<T>& rectangle, Rect<T>& intersection) const
110 {
111 // Rectangles with negative dimensions are allowed, so we must handle them correctly
112
113 // Compute the min and max of the first rectangle on both axes
114 T r1MinX = std::min(left, left + width);
115 T r1MaxX = std::max(left, left + width);
116 T r1MinY = std::min(top, top + height);
117 T r1MaxY = std::max(top, top + height);
118
119 // Compute the min and max of the second rectangle on both axes
120 T r2MinX = std::min(rectangle.left, rectangle.left + rectangle.width);
121 T r2MaxX = std::max(rectangle.left, rectangle.left + rectangle.width);
122 T r2MinY = std::min(rectangle.top, rectangle.top + rectangle.height);
123 T r2MaxY = std::max(rectangle.top, rectangle.top + rectangle.height);
124
125 // Compute the intersection boundaries
126 T interLeft = std::max(r1MinX, r2MinX);
127 T interTop = std::max(r1MinY, r2MinY);
128 T interRight = std::min(r1MaxX, r2MaxX);
129 T interBottom = std::min(r1MaxY, r2MaxY);
130
131 // If the intersection is valid (positive non zero area), then there is an intersection
132 if ((interLeft < interRight) && (interTop < interBottom))
133 {
134 intersection = Rect<T>(interLeft, interTop, interRight - interLeft, interBottom - interTop);
135 return true;
136 }
137 else
138 {
139 intersection = Rect<T>(0, 0, 0, 0);
140 return false;
141 }
142 }
143
144
146 template <typename T>
147 inline bool operator ==(const Rect<T>& left, const Rect<T>& right)
148 {
149 return (left.left == right.left) && (left.width == right.width) &&
150 (left.top == right.top) && (left.height == right.height);
151 }
152
153
155 template <typename T>
156 inline bool operator !=(const Rect<T>& left, const Rect<T>& right)
157 {
158 return !(left == right);
159 }


  • File List
  • include
  • SFML
  • Graphics
RectangleShape.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_RECTANGLESHAPE_HPP
26 #define SFML_RECTANGLESHAPE_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Shape.hpp>
33
34
35 namespace sf
36 {
41 class SFML_GRAPHICS_API RectangleShape : public Shape
42 {
43 public :
44
51 explicit RectangleShape(const Vector2f& size = Vector2f(0, 0));
52
61 void setSize(const Vector2f& size);
62
71 const Vector2f& getSize() const;
72
79 virtual unsigned int getPointCount() const;
80
91 virtual Vector2f getPoint(unsigned int index) const;
92
93 private :
94
96 // Member data
98 Vector2f m_size;
99 };
100
101 } // namespace sf
102
103
104 #endif // SFML_RECTANGLESHAPE_HPP
105
106


  • File List
  • include
  • SFML
  • Graphics
RenderStates.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_RENDERSTATES_HPP
26 #define SFML_RENDERSTATES_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/BlendMode.hpp>
33 #include <SFML/Graphics/Transform.hpp>
34
35
36 namespace sf
37 {
38 class Shader;
39 class Texture;
40
45 class SFML_GRAPHICS_API RenderStates
46 {
47 public :
48
61 RenderStates();
62
69 RenderStates(BlendMode theBlendMode);
70
77 RenderStates(const Transform& theTransform);
78
85 RenderStates(const Texture* theTexture);
86
93 RenderStates(const Shader* theShader);
94
104 RenderStates(BlendMode theBlendMode, const Transform& theTransform,
105 const Texture* theTexture, const Shader* theShader);
106
108 // Static member data
110 static const RenderStates Default;
111
113 // Member data
115 BlendMode blendMode;
116 Transform transform;
117 const Texture* texture;
118 const Shader* shader;
119 };
120
121 } // namespace sf
122
123
124 #endif // SFML_RENDERSTATES_HPP
125
126


  • File List
  • include
  • SFML
  • Graphics
RenderTarget.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_RENDERTARGET_HPP
26 #define SFML_RENDERTARGET_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Color.hpp>
33 #include <SFML/Graphics/Rect.hpp>
34 #include <SFML/Graphics/View.hpp>
35 #include <SFML/Graphics/Transform.hpp>
36 #include <SFML/Graphics/BlendMode.hpp>
37 #include <SFML/Graphics/RenderStates.hpp>
38 #include <SFML/Graphics/PrimitiveType.hpp>
39 #include <SFML/Graphics/Vertex.hpp>
40 #include <SFML/System/NonCopyable.hpp>
41
42
43 namespace sf
44 {
45 class Drawable;
46
51 class SFML_GRAPHICS_API RenderTarget : NonCopyable
52 {
53 public :
54
59 virtual ~RenderTarget();
60
70 void clear(const Color& color = Color(0, 0, 0, 255));
71
91 void setView(const View& view);
92
101 const View& getView() const;
102
114 const View& getDefaultView() const;
115
129 IntRect getViewport(const View& view) const;
130
149 Vector2f mapPixelToCoords(const Vector2i& point) const;
150
180 Vector2f mapPixelToCoords(const Vector2i& point, const View& view) const;
181
200 Vector2i mapCoordsToPixel(const Vector2f& point) const;
201
227 Vector2i mapCoordsToPixel(const Vector2f& point, const View& view) const;
228
236 void draw(const Drawable& drawable, const RenderStates& states = RenderStates::Default);
237
247 void draw(const Vertex* vertices, unsigned int vertexCount,
248 PrimitiveType type, const RenderStates& states = RenderStates::Default);
249
256 virtual Vector2u getSize() const = 0;
257
290 void pushGLStates();
291
301 void popGLStates();
302
324 void resetGLStates();
325
326 protected :
327
332 RenderTarget();
333
341 void initialize();
342
343 private:
344
349 void applyCurrentView();
350
357 void applyBlendMode(BlendMode mode);
358
365 void applyTransform(const Transform& transform);
366
373 void applyTexture(const Texture* texture);
374
381 void applyShader(const Shader* shader);
382
395 virtual bool activate(bool active) = 0;
396
401 struct StatesCache
402 {
403 enum {VertexCacheSize = 4};
404
405 bool glStatesSet;
406 bool viewChanged;
407 BlendMode lastBlendMode;
408 Uint64 lastTextureId;
409 bool useVertexCache;
410 Vertex vertexCache[VertexCacheSize];
411 };
412
414 // Member data
416 View m_defaultView;
417 View m_view;
418 StatesCache m_cache;
419 };
420
421 } // namespace sf
422
423
424 #endif // SFML_RENDERTARGET_HPP
425
426


  • File List
  • include
  • SFML
  • Graphics
RenderTexture.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_RENDERTEXTURE_HPP
26 #define SFML_RENDERTEXTURE_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Texture.hpp>
33 #include <SFML/Graphics/RenderTarget.hpp>
34
35
36 namespace sf
37 {
38 namespace priv
39 {
40 class RenderTextureImpl;
41 }
42
47 class SFML_GRAPHICS_API RenderTexture : public RenderTarget
48 {
49 public :
50
60 RenderTexture();
61
66 virtual ~RenderTexture();
67
86 bool create(unsigned int width, unsigned int height, bool depthBuffer = false);
87
99 void setSmooth(bool smooth);
100
109 bool isSmooth() const;
110
122 void setRepeated(bool repeated);
123
132 bool isRepeated() const;
133
149 bool setActive(bool active = true);
150
160 void display();
161
171 virtual Vector2u getSize() const;
172
187 const Texture& getTexture() const;
188
189 private :
190
202 virtual bool activate(bool active);
203
205 // Member data
207 priv::RenderTextureImpl* m_impl;
208 Texture m_texture;
209 };
210
211 } // namespace sf
212
213
214 #endif // SFML_RENDERTEXTURE_HPP
215
216


  • File List
  • include
  • SFML
  • Graphics
RenderWindow.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_RENDERWINDOW_HPP
26 #define SFML_RENDERWINDOW_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/RenderTarget.hpp>
33 #include <SFML/Graphics/Image.hpp>
34 #include <SFML/Window/Window.hpp>
35 #include <string>
36
37
38 namespace sf
39 {
44 class SFML_GRAPHICS_API RenderWindow : public Window, public RenderTarget
45 {
46 public :
47
55 RenderWindow();
56
76 RenderWindow(VideoMode mode, const String& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());
77
93 explicit RenderWindow(WindowHandle handle, const ContextSettings& settings = ContextSettings());
94
101 virtual ~RenderWindow();
102
112 virtual Vector2u getSize() const;
113
128 Image capture() const;
129
130 protected:
131
140 virtual void onCreate();
141
149 virtual void onResize();
150
151 private :
152
161 virtual bool activate(bool active);
162 };
163
164 } // namespace sf
165
166
167 #endif // SFML_RENDERWINDOW_HPP
168
169


  • File List
  • include
  • SFML
  • Graphics
Shader.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SHADER_HPP
26 #define SFML_SHADER_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Transform.hpp>
33 #include <SFML/Graphics/Color.hpp>
34 #include <SFML/Window/GlResource.hpp>
35 #include <SFML/System/NonCopyable.hpp>
36 #include <SFML/System/Vector2.hpp>
37 #include <SFML/System/Vector3.hpp>
38 #include <map>
39 #include <string>
40
41
42 namespace sf
43 {
44 class InputStream;
45 class Texture;
46
51 class SFML_GRAPHICS_API Shader : GlResource, NonCopyable
52 {
53 public :
54
59 enum Type
60 {
61 Vertex,
62 Fragment
63 };
64
70 struct CurrentTextureType {};
71 static CurrentTextureType CurrentTexture;
72
73 public :
74
81 Shader();
82
87 ~Shader();
88
108 bool loadFromFile(const std::string& filename, Type type);
109
129 bool loadFromFile(const std::string& vertexShaderFilename, const std::string& fragmentShaderFilename);
130
149 bool loadFromMemory(const std::string& shader, Type type);
150
170 bool loadFromMemory(const std::string& vertexShader, const std::string& fragmentShader);
171
190 bool loadFromStream(InputStream& stream, Type type);
191
211 bool loadFromStream(InputStream& vertexShaderStream, InputStream& fragmentShaderStream);
212
232 void setParameter(const std::string& name, float x);
233
254 void setParameter(const std::string& name, float x, float y);
255
277 void setParameter(const std::string& name, float x, float y, float z);
278
301 void setParameter(const std::string& name, float x, float y, float z, float w);
302
322 void setParameter(const std::string& name, const Vector2f& vector);
323
343 void setParameter(const std::string& name, const Vector3f& vector);
344
370 void setParameter(const std::string& name, const Color& color);
371
393 void setParameter(const std::string& name, const sf::Transform& transform);
394
425 void setParameter(const std::string& name, const Texture& texture);
426
448 void setParameter(const std::string& name, CurrentTextureType);
449
471 static void bind(const Shader* shader);
472
483 static bool isAvailable();
484
485 private :
486
499 bool compile(const char* vertexShaderCode, const char* fragmentShaderCode);
500
508 void bindTextures() const;
509
518 int getParamLocation(const std::string& name);
519
521 // Types
523 typedef std::map<int, const Texture*> TextureTable;
524 typedef std::map<std::string, int> ParamTable;
525
527 // Member data
529 unsigned int m_shaderProgram;
530 int m_currentTexture;
531 TextureTable m_textures;
532 ParamTable m_params;
533 };
534
535 } // namespace sf
536
537
538 #endif // SFML_SHADER_HPP
539
540


  • File List
  • include
  • SFML
  • Graphics
Shape.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SHAPE_HPP
26 #define SFML_SHAPE_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Drawable.hpp>
33 #include <SFML/Graphics/Transformable.hpp>
34 #include <SFML/Graphics/VertexArray.hpp>
35 #include <SFML/System/Vector2.hpp>
36
37
38 namespace sf
39 {
44 class SFML_GRAPHICS_API Shape : public Drawable, public Transformable
45 {
46 public :
47
52 virtual ~Shape();
53
74 void setTexture(const Texture* texture, bool resetRect = false);
75
88 void setTextureRect(const IntRect& rect);
89
105 void setFillColor(const Color& color);
106
117 void setOutlineColor(const Color& color);
118
132 void setOutlineThickness(float thickness);
133
146 const Texture* getTexture() const;
147
156 const IntRect& getTextureRect() const;
157
166 const Color& getFillColor() const;
167
176 const Color& getOutlineColor() const;
177
186 float getOutlineThickness() const;
187
196 virtual unsigned int getPointCount() const = 0;
197
210 virtual Vector2f getPoint(unsigned int index) const = 0;
211
224 FloatRect getLocalBounds() const;
225
238 FloatRect getGlobalBounds() const;
239
240 protected :
241
246 Shape();
247
256 void update();
257
258 private :
259
267 virtual void draw(RenderTarget& target, RenderStates states) const;
268
273 void updateFillColors();
274
279 void updateTexCoords();
280
285 void updateOutline();
286
291 void updateOutlineColors();
292
293 private :
294
296 // Member data
298 const Texture* m_texture;
299 IntRect m_textureRect;
300 Color m_fillColor;
301 Color m_outlineColor;
302 float m_outlineThickness;
303 VertexArray m_vertices;
304 VertexArray m_outlineVertices;
305 FloatRect m_insideBounds;
306 FloatRect m_bounds;
307 };
308
309 } // namespace sf
310
311
312 #endif // SFML_SHAPE_HPP
313
314


  • File List
  • include
  • SFML
  • System
Sleep.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SLEEP_HPP
26 #define SFML_SLEEP_HPP
27
29 // Headers
31 #include <SFML/System/Export.hpp>
32 #include <SFML/System/Time.hpp>
33
34
35 namespace sf
36 {
47 void SFML_SYSTEM_API sleep(Time duration);
48
49 } // namespace sf
50
51
52 #endif // SFML_SLEEP_HPP


  • File List
  • include
  • SFML
  • Network
Socket.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SOCKET_HPP
26 #define SFML_SOCKET_HPP
27
29 // Headers
31 #include <SFML/Network/Export.hpp>
32 #include <SFML/Network/SocketHandle.hpp>
33 #include <SFML/System/NonCopyable.hpp>
34 #include <vector>
35
36
37 namespace sf
38 {
39 class SocketSelector;
40
45 class SFML_NETWORK_API Socket : NonCopyable
46 {
47 public :
48
53 enum Status
54 {
55 Done,
56 NotReady,
57 Disconnected,
58 Error
59 };
60
65 enum
66 {
67 AnyPort = 0
68 };
69
70 public :
71
76 virtual ~Socket();
77
95 void setBlocking(bool blocking);
96
105 bool isBlocking() const;
106
107 protected :
108
113 enum Type
114 {
115 Tcp,
116 Udp
117 };
118
127 Socket(Type type);
128
139 SocketHandle getHandle() const;
140
147 void create();
148
158 void create(SocketHandle handle);
159
166 void close();
167
168 private :
169
170 friend class SocketSelector;
171
173 // Member data
175 Type m_type;
176 SocketHandle m_socket;
177 bool m_isBlocking;
178 };
179
180 } // namespace sf
181
182
183 #endif // SFML_SOCKET_HPP
184
185


  • File List
  • include
  • SFML
  • Network
SocketHandle.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SOCKETHANDLE_HPP
26 #define SFML_SOCKETHANDLE_HPP
27
29 // Headers
31 #include <SFML/Config.hpp>
32
33 #if defined(SFML_SYSTEM_WINDOWS)
34 #include <basetsd.h>
35 #endif
36
37
38 namespace sf
39 {
41 // Define the low-level socket handle type, specific to
42 // each platform
44 #if defined(SFML_SYSTEM_WINDOWS)
45
46 typedef UINT_PTR SocketHandle;
47
48 #else
49
50 typedef int SocketHandle;
51
52 #endif
53
54 } // namespace sf
55
56
57 #endif // SFML_SOCKETHANDLE_HPP


  • File List
  • include
  • SFML
  • Network
SocketSelector.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SOCKETSELECTOR_HPP
26 #define SFML_SOCKETSELECTOR_HPP
27
29 // Headers
31 #include <SFML/Network/Export.hpp>
32 #include <SFML/System/Time.hpp>
33
34
35 namespace sf
36 {
37 class Socket;
38
43 class SFML_NETWORK_API SocketSelector
44 {
45 public :
46
51 SocketSelector();
52
59 SocketSelector(const SocketSelector& copy);
60
65 ~SocketSelector();
66
80 void add(Socket& socket);
81
93 void remove(Socket& socket);
94
105 void clear();
106
123 bool wait(Time timeout = Time::Zero);
124
142 bool isReady(Socket& socket) const;
143
152 SocketSelector& operator =(const SocketSelector& right);
153
154 private :
155
156 struct SocketSelectorImpl;
157
159 // Member data
161 SocketSelectorImpl* m_impl;
162 };
163
164 } // namespace sf
165
166
167 #endif // SFML_SOCKETSELECTOR_HPP
168
169


  • File List
  • include
  • SFML
  • Audio
Sound.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SOUND_HPP
26 #define SFML_SOUND_HPP
27
29 // Headers
31 #include <SFML/Audio/Export.hpp>
32 #include <SFML/Audio/SoundSource.hpp>
33 #include <SFML/System/Time.hpp>
34 #include <cstdlib>
35
36
37 namespace sf
38 {
39 class SoundBuffer;
40
45 class SFML_AUDIO_API Sound : public SoundSource
46 {
47 public :
48
53 Sound();
54
61 explicit Sound(const SoundBuffer& buffer);
62
69 Sound(const Sound& copy);
70
75 ~Sound();
76
89 void play();
90
100 void pause();
101
112 void stop();
113
126 void setBuffer(const SoundBuffer& buffer);
127
141 void setLoop(bool loop);
142
154 void setPlayingOffset(Time timeOffset);
155
162 const SoundBuffer* getBuffer() const;
163
172 bool getLoop() const;
173
182 Time getPlayingOffset() const;
183
190 Status getStatus() const;
191
200 Sound& operator =(const Sound& right);
201
211 void resetBuffer();
212
213 private :
214
216 // Member data
218 const SoundBuffer* m_buffer;
219 };
220
221 } // namespace sf
222
223
224 #endif // SFML_SOUND_HPP
225
226


  • File List
  • include
  • SFML
  • Audio
SoundBuffer.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SOUNDBUFFER_HPP
26 #define SFML_SOUNDBUFFER_HPP
27
29 // Headers
31 #include <SFML/Audio/Export.hpp>
32 #include <SFML/System/Time.hpp>
33 #include <string>
34 #include <vector>
35 #include <set>
36
37
38 namespace sf
39 {
40 namespace priv
41 {
42 class SoundFile;
43 }
44
45 class Sound;
46 class InputStream;
47
52 class SFML_AUDIO_API SoundBuffer
53 {
54 public :
55
60 SoundBuffer();
61
68 SoundBuffer(const SoundBuffer& copy);
69
74 ~SoundBuffer();
75
90 bool loadFromFile(const std::string& filename);
91
107 bool loadFromMemory(const void* data, std::size_t sizeInBytes);
108
123 bool loadFromStream(InputStream& stream);
124
141 bool loadFromSamples(const Int16* samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate);
142
157 bool saveToFile(const std::string& filename) const;
158
171 const Int16* getSamples() const;
172
184 std::size_t getSampleCount() const;
185
198 unsigned int getSampleRate() const;
199
211 unsigned int getChannelCount() const;
212
221 Time getDuration() const;
222
231 SoundBuffer& operator =(const SoundBuffer& right);
232
233 private :
234
235 friend class Sound;
236
245 bool initialize(priv::SoundFile& file);
246
256 bool update(unsigned int channelCount, unsigned int sampleRate);
257
264 void attachSound(Sound* sound) const;
265
272 void detachSound(Sound* sound) const;
273
275 // Types
277 typedef std::set<Sound*> SoundList;
278
280 // Member data
282 unsigned int m_buffer;
283 std::vector<Int16> m_samples;
284 Time m_duration;
285 mutable SoundList m_sounds;
286 };
287
288 } // namespace sf
289
290
291 #endif // SFML_SOUNDBUFFER_HPP
292
293


  • File List
  • include
  • SFML
  • Audio
SoundBufferRecorder.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SOUNDBUFFERRECORDER_HPP
26 #define SFML_SOUNDBUFFERRECORDER_HPP
27
29 // Headers
31 #include <SFML/Audio/Export.hpp>
32 #include <SFML/Audio/SoundBuffer.hpp>
33 #include <SFML/Audio/SoundRecorder.hpp>
34 #include <vector>
35
36
37 namespace sf
38 {
44 class SFML_AUDIO_API SoundBufferRecorder : public SoundRecorder
45 {
46 public :
47
59 const SoundBuffer& getBuffer() const;
60
61 protected:
62
69 virtual bool onStart();
70
80 virtual bool onProcessSamples(const Int16* samples, std::size_t sampleCount);
81
86 virtual void onStop();
87
88 private :
89
91 // Member data
93 std::vector<Int16> m_samples;
94 SoundBuffer m_buffer;
95 };
96
97 } // namespace sf
98
99 #endif // SFML_SOUNDBUFFERRECORDER_HPP
100
101


  • File List
  • include
  • SFML
  • Audio
SoundRecorder.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SOUNDRECORDER_HPP
26 #define SFML_SOUNDRECORDER_HPP
27
29 // Headers
31 #include <SFML/Audio/Export.hpp>
32 #include <SFML/System/Thread.hpp>
33 #include <vector>
34
35
36 namespace sf
37 {
42 class SFML_AUDIO_API SoundRecorder
43 {
44 public :
45
50 virtual ~SoundRecorder();
51
67 void start(unsigned int sampleRate = 44100);
68
75 void stop();
76
87 unsigned int getSampleRate() const;
88
100 static bool isAvailable();
101
102 protected :
103
110 SoundRecorder();
111
123 virtual bool onStart();
124
139 virtual bool onProcessSamples(const Int16* samples, std::size_t sampleCount) = 0;
140
150 virtual void onStop();
151
152 private :
153
161 void record();
162
171 void processCapturedSamples();
172
179 void cleanup();
180
182 // Member data
184 Thread m_thread;
185 std::vector<Int16> m_samples;
186 unsigned int m_sampleRate;
187 bool m_isCapturing;
188 };
189
190 } // namespace sf
191
192
193 #endif // SFML_SOUNDRECORDER_HPP
194
195


  • File List
  • include
  • SFML
  • Audio
SoundSource.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SOUNDSOURCE_HPP
26 #define SFML_SOUNDSOURCE_HPP
27
29 // Headers
31 #include <SFML/Audio/Export.hpp>
32 #include <SFML/System/Vector3.hpp>
33
34
35 namespace sf
36 {
41 class SFML_AUDIO_API SoundSource
42 {
43 public :
44
49 enum Status
50 {
51 Stopped,
52 Paused,
53 Playing
54 };
55
62 SoundSource(const SoundSource& copy);
63
68 virtual ~SoundSource();
69
84 void setPitch(float pitch);
85
97 void setVolume(float volume);
98
113 void setPosition(float x, float y, float z);
114
127 void setPosition(const Vector3f& position);
128
143 void setRelativeToListener(bool relative);
144
160 void setMinDistance(float distance);
161
179 void setAttenuation(float attenuation);
180
189 float getPitch() const;
190
199 float getVolume() const;
200
209 Vector3f getPosition() const;
210
220 bool isRelativeToListener() const;
221
230 float getMinDistance() const;
231
240 float getAttenuation() const;
241
242 protected :
243
250 SoundSource();
251
258 Status getStatus() const;
259
261 // Member data
263 unsigned int m_source;
264 };
265
266 } // namespace sf
267
268
269 #endif // SFML_SOUNDSOURCE_HPP
270
271


  • File List
  • include
  • SFML
  • Audio
SoundStream.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SOUNDSTREAM_HPP
26 #define SFML_SOUNDSTREAM_HPP
27
29 // Headers
31 #include <SFML/Audio/Export.hpp>
32 #include <SFML/Audio/SoundSource.hpp>
33 #include <SFML/System/Thread.hpp>
34 #include <SFML/System/Time.hpp>
35 #include <cstdlib>
36
37
38 namespace sf
39 {
44 class SFML_AUDIO_API SoundStream : public SoundSource
45 {
46 public :
47
52 struct Chunk
53 {
54 const Int16* samples;
55 std::size_t sampleCount;
56 };
57
62 virtual ~SoundStream();
63
76 void play();
77
87 void pause();
88
99 void stop();
100
109 unsigned int getChannelCount() const;
110
120 unsigned int getSampleRate() const;
121
128 Status getStatus() const;
129
141 void setPlayingOffset(Time timeOffset);
142
151 Time getPlayingOffset() const;
152
166 void setLoop(bool loop);
167
176 bool getLoop() const;
177
178 protected :
179
186 SoundStream();
187
202 void initialize(unsigned int channelCount, unsigned int sampleRate);
203
218 virtual bool onGetData(Chunk& data) = 0;
219
229 virtual void onSeek(Time timeOffset) = 0;
230
231 private :
232
240 void streamData();
241
255 bool fillAndPushBuffer(unsigned int bufferNum);
256
266 bool fillQueue();
267
274 void clearQueue();
275
276 enum
277 {
278 BufferCount = 3
279 };
280
282 // Member data
284 Thread m_thread;
285 bool m_isStreaming;
286 unsigned int m_buffers[BufferCount];
287 unsigned int m_channelCount;
288 unsigned int m_sampleRate;
289 Uint32 m_format;
290 bool m_loop;
291 Uint64 m_samplesProcessed;
292 bool m_endBuffers[BufferCount];
293 };
294
295 } // namespace sf
296
297
298 #endif // SFML_SOUNDSTREAM_HPP
299
300


  • File List
  • include
  • SFML
  • Graphics
Sprite.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SPRITE_HPP
26 #define SFML_SPRITE_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Drawable.hpp>
33 #include <SFML/Graphics/Transformable.hpp>
34 #include <SFML/Graphics/Vertex.hpp>
35 #include <SFML/Graphics/Rect.hpp>
36
37
38 namespace sf
39 {
40 class Texture;
41
47 class SFML_GRAPHICS_API Sprite : public Drawable, public Transformable
48 {
49 public :
50
57 Sprite();
58
67 explicit Sprite(const Texture& texture);
68
78 Sprite(const Texture& texture, const IntRect& rectangle);
79
99 void setTexture(const Texture& texture, bool resetRect = false);
100
113 void setTextureRect(const IntRect& rectangle);
114
128 void setColor(const Color& color);
129
142 const Texture* getTexture() const;
143
152 const IntRect& getTextureRect() const;
153
162 const Color& getColor() const;
163
176 FloatRect getLocalBounds() const;
177
190 FloatRect getGlobalBounds() const;
191
192 private :
193
201 virtual void draw(RenderTarget& target, RenderStates states) const;
202
207 void updatePositions();
208
213 void updateTexCoords();
214
216 // Member data
218 Vertex m_vertices[4];
219 const Texture* m_texture;
220 IntRect m_textureRect;
221 };
222
223 } // namespace sf
224
225
226 #endif // SFML_SPRITE_HPP
227
228


  • File List
  • include
  • SFML
  • System
String.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_STRING_HPP
26 #define SFML_STRING_HPP
27
29 // Headers
31 #include <SFML/System/Export.hpp>
32 #include <locale>
33 #include <string>
34
35
36 namespace sf
37 {
43 class SFML_SYSTEM_API String
44 {
45 public :
46
48 // Types
50 typedef std::basic_string<Uint32>::iterator Iterator;
51 typedef std::basic_string<Uint32>::const_iterator ConstIterator;
52
54 // Static member data
56 static const std::size_t InvalidPos;
57
64 String();
65
76 String(char ansiChar, const std::locale& locale = std::locale());
77
84 String(wchar_t wideChar);
85
92 String(Uint32 utf32Char);
93
104 String(const char* ansiString, const std::locale& locale = std::locale());
105
116 String(const std::string& ansiString, const std::locale& locale = std::locale());
117
124 String(const wchar_t* wideString);
125
132 String(const std::wstring& wideString);
133
140 String(const Uint32* utf32String);
141
148 String(const std::basic_string<Uint32>& utf32String);
149
156 String(const String& copy);
157
173 operator std::string() const;
174
188 operator std::wstring() const;
189
205 std::string toAnsiString(const std::locale& locale = std::locale()) const;
206
218 std::wstring toWideString() const;
219
228 String& operator =(const String& right);
229
238 String& operator +=(const String& right);
239
251 Uint32 operator [](std::size_t index) const;
252
264 Uint32& operator [](std::size_t index);
265
274 void clear();
275
284 std::size_t getSize() const;
285
294 bool isEmpty() const;
295
306 void erase(std::size_t position, std::size_t count = 1);
307
318 void insert(std::size_t position, const String& str);
319
332 std::size_t find(const String& str, std::size_t start = 0) const;
333
345 const Uint32* getData() const;
346
355 Iterator begin();
356
365 ConstIterator begin() const;
366
379 Iterator end();
380
393 ConstIterator end() const;
394
395 private :
396
397 friend SFML_SYSTEM_API bool operator ==(const String& left, const String& right);
398 friend SFML_SYSTEM_API bool operator <(const String& left, const String& right);
399
401 // Member data
403 std::basic_string<Uint32> m_string;
404 };
405
416 SFML_SYSTEM_API bool operator ==(const String& left, const String& right);
417
428 SFML_SYSTEM_API bool operator !=(const String& left, const String& right);
429
440 SFML_SYSTEM_API bool operator <(const String& left, const String& right);
441
452 SFML_SYSTEM_API bool operator >(const String& left, const String& right);
453
464 SFML_SYSTEM_API bool operator <=(const String& left, const String& right);
465
476 SFML_SYSTEM_API bool operator >=(const String& left, const String& right);
477
488 SFML_SYSTEM_API String operator +(const String& left, const String& right);
489
490 } // namespace sf
491
492
493 #endif // SFML_STRING_HPP
494
495


  • File List
  • include
  • SFML
System.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SYSTEM_HPP
26 #define SFML_SYSTEM_HPP
27
29 // Headers
31
32 #include <SFML/Config.hpp>
33 #include <SFML/System/Clock.hpp>
34 #include <SFML/System/Err.hpp>
35 #include <SFML/System/InputStream.hpp>
36 #include <SFML/System/Lock.hpp>
37 #include <SFML/System/Mutex.hpp>
38 #include <SFML/System/Sleep.hpp>
39 #include <SFML/System/String.hpp>
40 #include <SFML/System/Thread.hpp>
41 #include <SFML/System/ThreadLocal.hpp>
42 #include <SFML/System/ThreadLocalPtr.hpp>
43 #include <SFML/System/Utf.hpp>
44 #include <SFML/System/Vector2.hpp>
45 #include <SFML/System/Vector3.hpp>
46
47 #endif // SFML_SYSTEM_HPP
48


  • File List
  • include
  • SFML
  • Network
TcpListener.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_TCPLISTENER_HPP
26 #define SFML_TCPLISTENER_HPP
27
29 // Headers
31 #include <SFML/Network/Export.hpp>
32 #include <SFML/Network/Socket.hpp>
33
34
35 namespace sf
36 {
37 class TcpSocket;
38
43 class SFML_NETWORK_API TcpListener : public Socket
44 {
45 public :
46
51 TcpListener();
52
64 unsigned short getLocalPort() const;
65
81 Status listen(unsigned short port);
82
92 void close();
93
107 Status accept(TcpSocket& socket);
108 };
109
110
111 } // namespace sf
112
113
114 #endif // SFML_TCPLISTENER_HPP
115
116


  • File List
  • include
  • SFML
  • Network
TcpSocket.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_TCPSOCKET_HPP
26 #define SFML_TCPSOCKET_HPP
27
29 // Headers
31 #include <SFML/Network/Export.hpp>
32 #include <SFML/Network/Socket.hpp>
33 #include <SFML/System/Time.hpp>
34
35
36 namespace sf
37 {
38 class TcpListener;
39 class IpAddress;
40 class Packet;
41
46 class SFML_NETWORK_API TcpSocket : public Socket
47 {
48 public :
49
54 TcpSocket();
55
66 unsigned short getLocalPort() const;
67
79 IpAddress getRemoteAddress() const;
80
92 unsigned short getRemotePort() const;
93
111 Status connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout = Time::Zero);
112
122 void disconnect();
123
137 Status send(const void* data, std::size_t size);
138
155 Status receive(void* data, std::size_t size, std::size_t& received);
156
169 Status send(Packet& packet);
170
185 Status receive(Packet& packet);
186
187 private:
188
189 friend class TcpListener;
190
195 struct PendingPacket
196 {
197 PendingPacket();
198
199 Uint32 Size;
200 std::size_t SizeReceived;
201 std::vector<char> Data;
202 };
203
205 // Member data
207 PendingPacket m_pendingPacket;
208 };
209
210 } // namespace sf
211
212
213 #endif // SFML_TCPSOCKET_HPP
214
215


  • File List
  • include
  • SFML
  • Graphics
Text.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_TEXT_HPP
26 #define SFML_TEXT_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Drawable.hpp>
33 #include <SFML/Graphics/Transformable.hpp>
34 #include <SFML/Graphics/Font.hpp>
35 #include <SFML/Graphics/Rect.hpp>
36 #include <SFML/Graphics/VertexArray.hpp>
37 #include <SFML/System/String.hpp>
38 #include <string>
39 #include <vector>
40
41
42 namespace sf
43 {
48 class SFML_GRAPHICS_API Text : public Drawable, public Transformable
49 {
50 public :
51
56 enum Style
57 {
58 Regular = 0,
59 Bold = 1 << 0,
60 Italic = 1 << 1,
61 Underlined = 1 << 2
62 };
63
70 Text();
71
80 Text(const String& string, const Font& font, unsigned int characterSize = 30);
81
101 void setString(const String& string);
102
118 void setFont(const Font& font);
119
130 void setCharacterSize(unsigned int size);
131
144 void setStyle(Uint32 style);
145
156 void setColor(const Color& color);
157
175 const String& getString() const;
176
189 const Font* getFont() const;
190
199 unsigned int getCharacterSize() const;
200
209 Uint32 getStyle() const;
210
219 const Color& getColor() const;
220
236 Vector2f findCharacterPos(std::size_t index) const;
237
250 FloatRect getLocalBounds() const;
251
264 FloatRect getGlobalBounds() const;
265
266 private :
267
275 virtual void draw(RenderTarget& target, RenderStates states) const;
276
281 void updateGeometry();
282
284 // Member data
286 String m_string;
287 const Font* m_font;
288 unsigned int m_characterSize;
289 Uint32 m_style;
290 Color m_color;
291 VertexArray m_vertices;
292 FloatRect m_bounds;
293 };
294
295 } // namespace sf
296
297
298 #endif // SFML_TEXT_HPP
299
300


  • File List
  • include
  • SFML
  • Graphics
Texture.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_TEXTURE_HPP
26 #define SFML_TEXTURE_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Image.hpp>
33 #include <SFML/Window/GlResource.hpp>
34
35
36 namespace sf
37 {
38 class Window;
39 class RenderTarget;
40 class RenderTexture;
41 class InputStream;
42
47 class SFML_GRAPHICS_API Texture : GlResource
48 {
49 public :
50
55 enum CoordinateType
56 {
57 Normalized,
58 Pixels
59 };
60
61 public :
62
69 Texture();
70
77 Texture(const Texture& copy);
78
83 ~Texture();
84
96 bool create(unsigned int width, unsigned int height);
97
127 bool loadFromFile(const std::string& filename, const IntRect& area = IntRect());
128
159 bool loadFromMemory(const void* data, std::size_t size, const IntRect& area = IntRect());
160
190 bool loadFromStream(sf::InputStream& stream, const IntRect& area = IntRect());
191
214 bool loadFromImage(const Image& image, const IntRect& area = IntRect());
215
222 Vector2u getSize() const;
223
237 Image copyToImage() const;
238
255 void update(const Uint8* pixels);
256
277 void update(const Uint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y);
278
297 void update(const Image& image);
298
314 void update(const Image& image, unsigned int x, unsigned int y);
315
334 void update(const Window& window);
335
351 void update(const Window& window, unsigned int x, unsigned int y);
352
367 void setSmooth(bool smooth);
368
377 bool isSmooth() const;
378
401 void setRepeated(bool repeated);
402
411 bool isRepeated() const;
412
421 Texture& operator =(const Texture& right);
422
454 static void bind(const Texture* texture, CoordinateType coordinateType = Normalized);
455
466 static unsigned int getMaximumSize();
467
468 private :
469
470 friend class RenderTexture;
471 friend class RenderTarget;
472
486 static unsigned int getValidSize(unsigned int size);
487
489 // Member data
491 Vector2u m_size;
492 Vector2u m_actualSize;
493 unsigned int m_texture;
494 bool m_isSmooth;
495 bool m_isRepeated;
496 mutable bool m_pixelsFlipped;
497 Uint64 m_cacheId;
498 };
499
500 } // namespace sf
501
502
503 #endif // SFML_TEXTURE_HPP
504


  • File List
  • include
  • SFML
  • System
Thread.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_THREAD_HPP
26 #define SFML_THREAD_HPP
27
29 // Headers
31 #include <SFML/System/Export.hpp>
32 #include <SFML/System/NonCopyable.hpp>
33 #include <cstdlib>
34
35
36 namespace sf
37 {
38 namespace priv
39 {
40 class ThreadImpl;
41 struct ThreadFunc;
42 }
43
48 class SFML_SYSTEM_API Thread : NonCopyable
49 {
50 public :
51
74 template <typename F>
75 Thread(F function);
76
102 template <typename F, typename A>
103 Thread(F function, A argument);
104
125 template <typename C>
126 Thread(void(C::*function)(), C* object);
127
135 ~Thread();
136
146 void launch();
147
159 void wait();
160
172 void terminate();
173
174 private :
175
176 friend class priv::ThreadImpl;
177
184 void run();
185
187 // Member data
189 priv::ThreadImpl* m_impl;
190 priv::ThreadFunc* m_entryPoint;
191 };
192
193 #include <SFML/System/Thread.inl>
194
195 } // namespace sf
196
197 #endif // SFML_THREAD_HPP
198
199


  • File List
  • include
  • SFML
  • System
Thread.inl
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2012 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 namespace priv
26 {
27 // Base class for abstract thread functions
28 struct ThreadFunc
29 {
30 virtual ~ThreadFunc() {}
31 virtual void run() = 0;
32 };
33
34 // Specialization using a functor (including free functions) with no argument
35 template <typename T>
36 struct ThreadFunctor : ThreadFunc
37 {
38 ThreadFunctor(T functor) : m_functor(functor) {}
39 virtual void run() {m_functor();}
40 T m_functor;
41 };
42
43 // Specialization using a functor (including free functions) with one argument
44 template <typename F, typename A>
45 struct ThreadFunctorWithArg : ThreadFunc
46 {
47 ThreadFunctorWithArg(F function, A arg) : m_function(function), m_arg(arg) {}
48 virtual void run() {m_function(m_arg);}
49 F m_function;
50 A m_arg;
51 };
52
53 // Specialization using a member function
54 template <typename C>
55 struct ThreadMemberFunc : ThreadFunc
56 {
57 ThreadMemberFunc(void(C::*function)(), C* object) : m_function(function), m_object(object) {}
58 virtual void run() {(m_object->*m_function)();}
59 void(C::*m_function)();
60 C* m_object;
61 };
62
63 } // namespace priv
64
65
67 template <typename F>
68 Thread::Thread(F functor) :
69 m_impl (NULL),
70 m_entryPoint(new priv::ThreadFunctor<F>(functor))
71 {
72 }
73
74
76 template <typename F, typename A>
77 Thread::Thread(F function, A argument) :
78 m_impl (NULL),
79 m_entryPoint(new priv::ThreadFunctorWithArg<F, A>(function, argument))
80 {
81 }
82
83
85 template <typename C>
86 Thread::Thread(void(C::*function)(), C* object) :
87 m_impl (NULL),
88 m_entryPoint(new priv::ThreadMemberFunc<C>(function, object))
89 {
90 }


  • File List
  • include
  • SFML
  • System
ThreadLocal.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_THREADLOCAL_HPP
26 #define SFML_THREADLOCAL_HPP
27
29 // Headers
31 #include <SFML/System/Export.hpp>
32 #include <SFML/System/NonCopyable.hpp>
33 #include <cstdlib>
34
35
36 namespace sf
37 {
38 namespace priv
39 {
40 class ThreadLocalImpl;
41 }
42
47 class SFML_SYSTEM_API ThreadLocal : NonCopyable
48 {
49 public :
50
57 ThreadLocal(void* value = NULL);
58
63 ~ThreadLocal();
64
71 void setValue(void* value);
72
79 void* getValue() const;
80
81 private :
82
84 // Member data
86 priv::ThreadLocalImpl* m_impl;
87 };
88
89 } // namespace sf
90
91
92 #endif // SFML_THREADLOCAL_HPP
93
94


  • File List
  • include
  • SFML
  • System
ThreadLocalPtr.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_THREADLOCALPTR_HPP
26 #define SFML_THREADLOCALPTR_HPP
27
29 // Headers
31 #include <SFML/System/ThreadLocal.hpp>
32
33
34 namespace sf
35 {
40 template <typename T>
41 class ThreadLocalPtr : private ThreadLocal
42 {
43 public :
44
51 ThreadLocalPtr(T* value = NULL);
52
62 T& operator *() const;
63
73 T* operator ->() const;
74
82 operator T*() const;
83
92 ThreadLocalPtr<T>& operator =(T* value);
93
102 ThreadLocalPtr<T>& operator =(const ThreadLocalPtr<T>& right);
103 };
104
105 } // namespace sf
106
107 #include <SFML/System/ThreadLocalPtr.inl>
108
109
110 #endif // SFML_THREADLOCALPTR_HPP
111
112


  • File List
  • include
  • SFML
  • System
ThreadLocalPtr.inl
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2012 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25
26 namespace sf
27 {
29 template <typename T>
30 ThreadLocalPtr<T>::ThreadLocalPtr(T* value) :
31 ThreadLocal(value)
32 {
33 }
34
35
37 template <typename T>
38 T& ThreadLocalPtr<T>::operator *() const
39 {
40 return *static_cast<T*>(getValue());
41 }
42
43
45 template <typename T>
46 T* ThreadLocalPtr<T>::operator ->() const
47 {
48 return static_cast<T*>(getValue());
49 }
50
51
53 template <typename T>
54 ThreadLocalPtr<T>::operator T*() const
55 {
56 return static_cast<T*>(getValue());
57 }
58
59
61 template <typename T>
62 ThreadLocalPtr<T>& ThreadLocalPtr<T>::operator =(T* value)
63 {
64 setValue(value);
65 return *this;
66 }
67
68
70 template <typename T>
71 ThreadLocalPtr<T>& ThreadLocalPtr<T>::operator =(const ThreadLocalPtr<T>& right)
72 {
73 setValue(right.getValue());
74 return *this;
75 }
76
77 } // namespace sf


  • File List
  • include
  • SFML
  • System
Time.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_TIME_HPP
26 #define SFML_TIME_HPP
27
29 // Headers
31 #include <SFML/System/Export.hpp>
32
33
34 namespace sf
35 {
40 class SFML_SYSTEM_API Time
41 {
42 public :
43
50 Time();
51
60 float asSeconds() const;
61
70 Int32 asMilliseconds() const;
71
80 Int64 asMicroseconds() const;
81
83 // Static member data
85 static const Time Zero;
86
87 private :
88
89 friend SFML_SYSTEM_API Time seconds(float);
90 friend SFML_SYSTEM_API Time milliseconds(Int32);
91 friend SFML_SYSTEM_API Time microseconds(Int64);
92
102 explicit Time(Int64 microseconds);
103
104 private :
105
107 // Member data
109 Int64 m_microseconds;
110 };
111
123 SFML_SYSTEM_API Time seconds(float amount);
124
136 SFML_SYSTEM_API Time milliseconds(Int32 amount);
137
149 SFML_SYSTEM_API Time microseconds(Int64 amount);
150
161 SFML_SYSTEM_API bool operator ==(Time left, Time right);
162
173 SFML_SYSTEM_API bool operator !=(Time left, Time right);
174
185 SFML_SYSTEM_API bool operator <(Time left, Time right);
186
197 SFML_SYSTEM_API bool operator >(Time left, Time right);
198
209 SFML_SYSTEM_API bool operator <=(Time left, Time right);
210
221 SFML_SYSTEM_API bool operator >=(Time left, Time right);
222
232 SFML_SYSTEM_API Time operator -(Time right);
233
244 SFML_SYSTEM_API Time operator +(Time left, Time right);
245
256 SFML_SYSTEM_API Time& operator +=(Time& left, Time right);
257
268 SFML_SYSTEM_API Time operator -(Time left, Time right);
269
280 SFML_SYSTEM_API Time& operator -=(Time& left, Time right);
281
292 SFML_SYSTEM_API Time operator *(Time left, float right);
293
304 SFML_SYSTEM_API Time operator *(Time left, Int64 right);
305
316 SFML_SYSTEM_API Time operator *(float left, Time right);
317
328 SFML_SYSTEM_API Time operator *(Int64 left, Time right);
329
340 SFML_SYSTEM_API Time& operator *=(Time& left, float right);
341
352 SFML_SYSTEM_API Time& operator *=(Time& left, Int64 right);
353
364 SFML_SYSTEM_API Time operator /(Time left, float right);
365
376 SFML_SYSTEM_API Time operator /(Time left, Int64 right);
377
388 SFML_SYSTEM_API Time& operator /=(Time& left, float right);
389
400 SFML_SYSTEM_API Time& operator /=(Time& left, Int64 right);
401
402 } // namespace sf
403
404
405 #endif // SFML_TIME_HPP
406
407


  • File List
  • include
  • SFML
  • Graphics
Transform.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_TRANSFORM_HPP
26 #define SFML_TRANSFORM_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Rect.hpp>
33 #include <SFML/System/Vector2.hpp>
34
35
36 namespace sf
37 {
42 class SFML_GRAPHICS_API Transform
43 {
44 public :
45
52 Transform();
53
68 Transform(float a00, float a01, float a02,
69 float a10, float a11, float a12,
70 float a20, float a21, float a22);
71
87 const float* getMatrix() const;
88
98 Transform getInverse() const;
99
109 Vector2f transformPoint(float x, float y) const;
110
119 Vector2f transformPoint(const Vector2f& point) const;
120
135 FloatRect transformRect(const FloatRect& rectangle) const;
136
149 Transform& combine(const Transform& transform);
150
169 Transform& translate(float x, float y);
170
188 Transform& translate(const Vector2f& offset);
189
207 Transform& rotate(float angle);
208
233 Transform& rotate(float angle, float centerX, float centerY);
234
258 Transform& rotate(float angle, const Vector2f& center);
259
278 Transform& scale(float scaleX, float scaleY);
279
305 Transform& scale(float scaleX, float scaleY, float centerX, float centerY);
306
324 Transform& scale(const Vector2f& factors);
325
349 Transform& scale(const Vector2f& factors, const Vector2f& center);
350
352 // Static member data
354 static const Transform Identity;
355
356 private:
357
359 // Member data
361 float m_matrix[16];
362 };
363
376 SFML_GRAPHICS_API Transform operator *(const Transform& left, const Transform& right);
377
390 SFML_GRAPHICS_API Transform& operator *=(Transform& left, const Transform& right);
391
404 SFML_GRAPHICS_API Vector2f operator *(const Transform& left, const Vector2f& right);
405
406 } // namespace sf
407
408
409 #endif // SFML_TRANSFORM_HPP
410
411


  • File List
  • include
  • SFML
  • Graphics
Transformable.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_TRANSFORMABLE_HPP
26 #define SFML_TRANSFORMABLE_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Transform.hpp>
33
34
35 namespace sf
36 {
41 class SFML_GRAPHICS_API Transformable
42 {
43 public :
44
49 Transformable();
50
55 virtual ~Transformable();
56
70 void setPosition(float x, float y);
71
84 void setPosition(const Vector2f& position);
85
98 void setRotation(float angle);
99
113 void setScale(float factorX, float factorY);
114
127 void setScale(const Vector2f& factors);
128
145 void setOrigin(float x, float y);
146
162 void setOrigin(const Vector2f& origin);
163
172 const Vector2f& getPosition() const;
173
184 float getRotation() const;
185
194 const Vector2f& getScale() const;
195
204 const Vector2f& getOrigin() const;
205
223 void move(float offsetX, float offsetY);
224
240 void move(const Vector2f& offset);
241
255 void rotate(float angle);
256
274 void scale(float factorX, float factorY);
275
292 void scale(const Vector2f& factor);
293
302 const Transform& getTransform() const;
303
312 const Transform& getInverseTransform() const;
313
314 private :
315
317 // Member data
319 Vector2f m_origin;
320 Vector2f m_position;
321 float m_rotation;
322 Vector2f m_scale;
323 mutable Transform m_transform;
324 mutable bool m_transformNeedUpdate;
325 mutable Transform m_inverseTransform;
326 mutable bool m_inverseTransformNeedUpdate;
327 };
328
329 } // namespace sf
330
331
332 #endif // SFML_TRANSFORMABLE_HPP
333
334


  • File List
  • include
  • SFML
  • Network
UdpSocket.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_UDPSOCKET_HPP
26 #define SFML_UDPSOCKET_HPP
27
29 // Headers
31 #include <SFML/Network/Export.hpp>
32 #include <SFML/Network/Socket.hpp>
33 #include <vector>
34
35
36 namespace sf
37 {
38 class IpAddress;
39 class Packet;
40
45 class SFML_NETWORK_API UdpSocket : public Socket
46 {
47 public :
48
50 // Constants
52 enum
53 {
54 MaxDatagramSize = 65507
55 };
56
61 UdpSocket();
62
74 unsigned short getLocalPort() const;
75
92 Status bind(unsigned short port);
93
104 void unbind();
105
123 Status send(const void* data, std::size_t size, const IpAddress& remoteAddress, unsigned short remotePort);
124
146 Status receive(void* data, std::size_t size, std::size_t& received, IpAddress& remoteAddress, unsigned short& remotePort);
147
164 Status send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort);
165
181 Status receive(Packet& packet, IpAddress& remoteAddress, unsigned short& remotePort);
182
183 private:
184
186 // Member data
188 std::vector<char> m_buffer;
189 };
190
191 } // namespace sf
192
193
194 #endif // SFML_UDPSOCKET_HPP
195
196


  • File List
  • include
  • SFML
  • System
Utf.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_UTF_HPP
26 #define SFML_UTF_HPP
27
29 // Headers
31 #include <SFML/Config.hpp>
32 #include <algorithm>
33 #include <locale>
34 #include <string>
35 #include <cstdlib>
36
37
38 namespace sf
39 {
40 template <unsigned int N>
41 class Utf;
42
47 template <>
48 class Utf<8>
49 {
50 public :
51
66 template <typename In>
67 static In decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
68
82 template <typename Out>
83 static Out encode(Uint32 input, Out output, Uint8 replacement = 0);
84
97 template <typename In>
98 static In next(In begin, In end);
99
113 template <typename In>
114 static std::size_t count(In begin, In end);
115
130 template <typename In, typename Out>
131 static Out fromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
132
143 template <typename In, typename Out>
144 static Out fromWide(In begin, In end, Out output);
145
156 template <typename In, typename Out>
157 static Out fromLatin1(In begin, In end, Out output);
158
174 template <typename In, typename Out>
175 static Out toAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
176
188 template <typename In, typename Out>
189 static Out toWide(In begin, In end, Out output, wchar_t replacement = 0);
190
202 template <typename In, typename Out>
203 static Out toLatin1(In begin, In end, Out output, char replacement = 0);
204
220 template <typename In, typename Out>
221 static Out toUtf8(In begin, In end, Out output);
222
233 template <typename In, typename Out>
234 static Out toUtf16(In begin, In end, Out output);
235
246 template <typename In, typename Out>
247 static Out toUtf32(In begin, In end, Out output);
248 };
249
254 template <>
255 class Utf<16>
256 {
257 public :
258
273 template <typename In>
274 static In decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
275
289 template <typename Out>
290 static Out encode(Uint32 input, Out output, Uint16 replacement = 0);
291
304 template <typename In>
305 static In next(In begin, In end);
306
320 template <typename In>
321 static std::size_t count(In begin, In end);
322
337 template <typename In, typename Out>
338 static Out fromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
339
350 template <typename In, typename Out>
351 static Out fromWide(In begin, In end, Out output);
352
363 template <typename In, typename Out>
364 static Out fromLatin1(In begin, In end, Out output);
365
381 template <typename In, typename Out>
382 static Out toAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
383
395 template <typename In, typename Out>
396 static Out toWide(In begin, In end, Out output, wchar_t replacement = 0);
397
409 template <typename In, typename Out>
410 static Out toLatin1(In begin, In end, Out output, char replacement = 0);
411
422 template <typename In, typename Out>
423 static Out toUtf8(In begin, In end, Out output);
424
440 template <typename In, typename Out>
441 static Out toUtf16(In begin, In end, Out output);
442
453 template <typename In, typename Out>
454 static Out toUtf32(In begin, In end, Out output);
455 };
456
461 template <>
462 class Utf<32>
463 {
464 public :
465
481 template <typename In>
482 static In decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
483
498 template <typename Out>
499 static Out encode(Uint32 input, Out output, Uint32 replacement = 0);
500
513 template <typename In>
514 static In next(In begin, In end);
515
528 template <typename In>
529 static std::size_t count(In begin, In end);
530
545 template <typename In, typename Out>
546 static Out fromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
547
558 template <typename In, typename Out>
559 static Out fromWide(In begin, In end, Out output);
560
571 template <typename In, typename Out>
572 static Out fromLatin1(In begin, In end, Out output);
573
589 template <typename In, typename Out>
590 static Out toAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
591
603 template <typename In, typename Out>
604 static Out toWide(In begin, In end, Out output, wchar_t replacement = 0);
605
617 template <typename In, typename Out>
618 static Out toLatin1(In begin, In end, Out output, char replacement = 0);
619
630 template <typename In, typename Out>
631 static Out toUtf8(In begin, In end, Out output);
632
643 template <typename In, typename Out>
644 static Out toUtf16(In begin, In end, Out output);
645
661 template <typename In, typename Out>
662 static Out toUtf32(In begin, In end, Out output);
663
677 template <typename In>
678 static Uint32 decodeAnsi(In input, const std::locale& locale = std::locale());
679
692 template <typename In>
693 static Uint32 decodeWide(In input);
694
710 template <typename Out>
711 static Out encodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale());
712
727 template <typename Out>
728 static Out encodeWide(Uint32 codepoint, Out output, wchar_t replacement = 0);
729 };
730
731 #include <SFML/System/Utf.inl>
732
733 // Make typedefs to get rid of the template syntax
734 typedef Utf<8> Utf8;
735 typedef Utf<16> Utf16;
736 typedef Utf<32> Utf32;
737
738 } // namespace sf
739
740
741 #endif // SFML_UTF_HPP
742
743


  • File List
  • include
  • SFML
  • System
Utf.inl
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2012 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25
27 // References :
28 //
29 // http://www.unicode.org/
30 // http://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c
31 // http://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.h
32 // http://people.w3.org/rishida/scripts/uniview/conversion
33 //
35
36
38 template <typename In>
39 In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement)
40 {
41 // Some useful precomputed data
42 static const int trailing[256] =
43 {
44 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
45 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
48 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
49 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
50 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
51 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5
52 };
53 static const Uint32 offsets[6] =
54 {
55 0x00000000, 0x00003080, 0x000E2080, 0x03C82080, 0xFA082080, 0x82082080
56 };
57
58 // decode the character
59 int trailingBytes = trailing[static_cast<Uint8>(*begin)];
60 if (begin + trailingBytes < end)
61 {
62 output = 0;
63 switch (trailingBytes)
64 {
65 case 5 : output += static_cast<Uint8>(*begin++); output <<= 6;
66 case 4 : output += static_cast<Uint8>(*begin++); output <<= 6;
67 case 3 : output += static_cast<Uint8>(*begin++); output <<= 6;
68 case 2 : output += static_cast<Uint8>(*begin++); output <<= 6;
69 case 1 : output += static_cast<Uint8>(*begin++); output <<= 6;
70 case 0 : output += static_cast<Uint8>(*begin++);
71 }
72 output -= offsets[trailingBytes];
73 }
74 else
75 {
76 // Incomplete character
77 begin = end;
78 output = replacement;
79 }
80
81 return begin;
82 }
83
84
86 template <typename Out>
87 Out Utf<8>::encode(Uint32 input, Out output, Uint8 replacement)
88 {
89 // Some useful precomputed data
90 static const Uint8 firstBytes[7] =
91 {
92 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
93 };
94
95 // encode the character
96 if ((input > 0x0010FFFF) || ((input >= 0xD800) && (input <= 0xDBFF)))
97 {
98 // Invalid character
99 if (replacement)
100 *output++ = replacement;
101 }
102 else
103 {
104 // Valid character
105
106 // Get the number of bytes to write
107 std::size_t bytestoWrite = 1;
108 if (input < 0x80) bytestoWrite = 1;
109 else if (input < 0x800) bytestoWrite = 2;
110 else if (input < 0x10000) bytestoWrite = 3;
111 else if (input <= 0x0010FFFF) bytestoWrite = 4;
112
113 // Extract the bytes to write
114 Uint8 bytes[4];
115 switch (bytestoWrite)
116 {
117 case 4 : bytes[3] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
118 case 3 : bytes[2] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
119 case 2 : bytes[1] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
120 case 1 : bytes[0] = static_cast<Uint8> (input | firstBytes[bytestoWrite]);
121 }
122
123 // Add them to the output
124 output = std::copy(bytes, bytes + bytestoWrite, output);
125 }
126
127 return output;
128 }
129
130
132 template <typename In>
133 In Utf<8>::next(In begin, In end)
134 {
135 Uint32 codepoint;
136 return decode(begin, end, codepoint);
137 }
138
139
141 template <typename In>
142 std::size_t Utf<8>::count(In begin, In end)
143 {
144 std::size_t length = 0;
145 while (begin < end)
146 {
147 begin = next(begin, end);
148 ++length;
149 }
150
151 return length;
152 }
153
154
156 template <typename In, typename Out>
157 Out Utf<8>::fromAnsi(In begin, In end, Out output, const std::locale& locale)
158 {
159 while (begin < end)
160 {
161 Uint32 codepoint = Utf<32>::decodeAnsi(*begin++, locale);
162 output = encode(codepoint, output);
163 }
164
165 return output;
166 }
167
168
170 template <typename In, typename Out>
171 Out Utf<8>::fromWide(In begin, In end, Out output)
172 {
173 while (begin < end)
174 {
175 Uint32 codepoint = Utf<32>::decodeWide(*begin++);
176 output = encode(codepoint, output);
177 }
178
179 return output;
180 }
181
182
184 template <typename In, typename Out>
185 Out Utf<8>::fromLatin1(In begin, In end, Out output)
186 {
187 // Latin-1 is directly compatible with Unicode encodings,
188 // and can thus be treated as (a sub-range of) UTF-32
189 while (begin < end)
190 output = encode(*begin++, output);
191
192 return output;
193 }
194
195
197 template <typename In, typename Out>
198 Out Utf<8>::toAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)
199 {
200 while (begin < end)
201 {
202 Uint32 codepoint;
203 begin = decode(begin, end, codepoint);
204 output = Utf<32>::encodeAnsi(codepoint, output, replacement, locale);
205 }
206
207 return output;
208 }
209
210
212 template <typename In, typename Out>
213 Out Utf<8>::toWide(In begin, In end, Out output, wchar_t replacement)
214 {
215 while (begin < end)
216 {
217 Uint32 codepoint;
218 begin = decode(begin, end, codepoint);
219 output = Utf<32>::encodeWide(codepoint, output, replacement);
220 }
221
222 return output;
223 }
224
225
227 template <typename In, typename Out>
228 Out Utf<8>::toLatin1(In begin, In end, Out output, char replacement)
229 {
230 // Latin-1 is directly compatible with Unicode encodings,
231 // and can thus be treated as (a sub-range of) UTF-32
232 while (begin < end)
233 {
234 Uint32 codepoint;
235 begin = decode(begin, end, codepoint);
236 *output++ = codepoint < 256 ? static_cast<char>(codepoint) : replacement;
237 }
238
239 return output;
240 }
241
242
244 template <typename In, typename Out>
245 Out Utf<8>::toUtf8(In begin, In end, Out output)
246 {
247 return std::copy(begin, end, output);
248 }
249
250
252 template <typename In, typename Out>
253 Out Utf<8>::toUtf16(In begin, In end, Out output)
254 {
255 while (begin < end)
256 {
257 Uint32 codepoint;
258 begin = decode(begin, end, codepoint);
259 output = Utf<16>::encode(codepoint, output);
260 }
261
262 return output;
263 }
264
265
267 template <typename In, typename Out>
268 Out Utf<8>::toUtf32(In begin, In end, Out output)
269 {
270 while (begin < end)
271 {
272 Uint32 codepoint;
273 begin = decode(begin, end, codepoint);
274 *output++ = codepoint;
275 }
276
277 return output;
278 }
279
280
282 template <typename In>
283 In Utf<16>::decode(In begin, In end, Uint32& output, Uint32 replacement)
284 {
285 Uint16 first = *begin++;
286
287 // If it's a surrogate pair, first convert to a single UTF-32 character
288 if ((first >= 0xD800) && (first <= 0xDBFF))
289 {
290 if (begin < end)
291 {
292 Uint32 second = *begin++;
293 if ((second >= 0xDC00) && (second <= 0xDFFF))
294 {
295 // The second element is valid: convert the two elements to a UTF-32 character
296 output = static_cast<Uint32>(((first - 0xD800) << 10) + (second - 0xDC00) + 0x0010000);
297 }
298 else
299 {
300 // Invalid character
301 output = replacement;
302 }
303 }
304 else
305 {
306 // Invalid character
307 begin = end;
308 output = replacement;
309 }
310 }
311 else
312 {
313 // We can make a direct copy
314 output = first;
315 }
316
317 return begin;
318 }
319
320
322 template <typename Out>
323 Out Utf<16>::encode(Uint32 input, Out output, Uint16 replacement)
324 {
325 if (input < 0xFFFF)
326 {
327 // The character can be copied directly, we just need to check if it's in the valid range
328 if ((input >= 0xD800) && (input <= 0xDFFF))
329 {
330 // Invalid character (this range is reserved)
331 if (replacement)
332 *output++ = replacement;
333 }
334 else
335 {
336 // Valid character directly convertible to a single UTF-16 character
337 *output++ = static_cast<Uint16>(input);
338 }
339 }
340 else if (input > 0x0010FFFF)
341 {
342 // Invalid character (greater than the maximum unicode value)
343 if (replacement)
344 *output++ = replacement;
345 }
346 else
347 {
348 // The input character will be converted to two UTF-16 elements
349 input -= 0x0010000;
350 *output++ = static_cast<Uint16>((input >> 10) + 0xD800);
351 *output++ = static_cast<Uint16>((input & 0x3FFUL) + 0xDC00);
352 }
353
354 return output;
355 }
356
357
359 template <typename In>
360 In Utf<16>::next(In begin, In end)
361 {
362 Uint32 codepoint;
363 return decode(begin, end, codepoint);
364 }
365
366
368 template <typename In>
369 std::size_t Utf<16>::count(In begin, In end)
370 {
371 std::size_t length = 0;
372 while (begin < end)
373 {
374 begin = next(begin, end);
375 ++length;
376 }
377
378 return length;
379 }
380
381
383 template <typename In, typename Out>
384 Out Utf<16>::fromAnsi(In begin, In end, Out output, const std::locale& locale)
385 {
386 while (begin < end)
387 {
388 Uint32 codepoint = Utf<32>::decodeAnsi(*begin++, locale);
389 output = encode(codepoint, output);
390 }
391
392 return output;
393 }
394
395
397 template <typename In, typename Out>
398 Out Utf<16>::fromWide(In begin, In end, Out output)
399 {
400 while (begin < end)
401 {
402 Uint32 codepoint = Utf<32>::decodeWide(*begin++);
403 output = encode(codepoint, output);
404 }
405
406 return output;
407 }
408
409
411 template <typename In, typename Out>
412 Out Utf<16>::fromLatin1(In begin, In end, Out output)
413 {
414 // Latin-1 is directly compatible with Unicode encodings,
415 // and can thus be treated as (a sub-range of) UTF-32
416 return std::copy(begin, end, output);
417 }
418
419
421 template <typename In, typename Out>
422 Out Utf<16>::toAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)
423 {
424 while (begin < end)
425 {
426 Uint32 codepoint;
427 begin = decode(begin, end, codepoint);
428 output = Utf<32>::encodeAnsi(codepoint, output, replacement, locale);
429 }
430
431 return output;
432 }
433
434
436 template <typename In, typename Out>
437 Out Utf<16>::toWide(In begin, In end, Out output, wchar_t replacement)
438 {
439 while (begin < end)
440 {
441 Uint32 codepoint;
442 begin = decode(begin, end, codepoint);
443 output = Utf<32>::encodeWide(codepoint, output, replacement);
444 }
445
446 return output;
447 }
448
449
451 template <typename In, typename Out>
452 Out Utf<16>::toLatin1(In begin, In end, Out output, char replacement)
453 {
454 // Latin-1 is directly compatible with Unicode encodings,
455 // and can thus be treated as (a sub-range of) UTF-32
456 while (begin < end)
457 {
458 *output++ = *begin < 256 ? static_cast<char>(*begin) : replacement;
459 begin++;
460 }
461
462 return output;
463 }
464
465
467 template <typename In, typename Out>
468 Out Utf<16>::toUtf8(In begin, In end, Out output)
469 {
470 while (begin < end)
471 {
472 Uint32 codepoint;
473 begin = decode(begin, end, codepoint);
474 output = Utf<8>::encode(codepoint, output);
475 }
476
477 return output;
478 }
479
480
482 template <typename In, typename Out>
483 Out Utf<16>::toUtf16(In begin, In end, Out output)
484 {
485 return std::copy(begin, end, output);
486 }
487
488
490 template <typename In, typename Out>
491 Out Utf<16>::toUtf32(In begin, In end, Out output)
492 {
493 while (begin < end)
494 {
495 Uint32 codepoint;
496 begin = decode(begin, end, codepoint);
497 *output++ = codepoint;
498 }
499
500 return output;
501 }
502
503
505 template <typename In>
506 In Utf<32>::decode(In begin, In /*end*/, Uint32& output, Uint32 /*replacement*/)
507 {
508 output = *begin++;
509 return begin;
510 }
511
512
514 template <typename Out>
515 Out Utf<32>::encode(Uint32 input, Out output, Uint32 /*replacement*/)
516 {
517 *output++ = input;
518 return output;
519 }
520
521
523 template <typename In>
524 In Utf<32>::next(In begin, In /*end*/)
525 {
526 return ++begin;
527 }
528
529
531 template <typename In>
532 std::size_t Utf<32>::count(In begin, In end)
533 {
534 return begin - end;
535 }
536
537
539 template <typename In, typename Out>
540 Out Utf<32>::fromAnsi(In begin, In end, Out output, const std::locale& locale)
541 {
542 while (begin < end)
543 *output++ = decodeAnsi(*begin++, locale);
544
545 return output;
546 }
547
548
550 template <typename In, typename Out>
551 Out Utf<32>::fromWide(In begin, In end, Out output)
552 {
553 while (begin < end)
554 *output++ = decodeWide(*begin++);
555
556 return output;
557 }
558
559
561 template <typename In, typename Out>
562 Out Utf<32>::fromLatin1(In begin, In end, Out output)
563 {
564 // Latin-1 is directly compatible with Unicode encodings,
565 // and can thus be treated as (a sub-range of) UTF-32
566 return std::copy(begin, end, output);
567 }
568
569
571 template <typename In, typename Out>
572 Out Utf<32>::toAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)
573 {
574 while (begin < end)
575 output = encodeAnsi(*begin++, output, replacement, locale);
576
577 return output;
578 }
579
580
582 template <typename In, typename Out>
583 Out Utf<32>::toWide(In begin, In end, Out output, wchar_t replacement)
584 {
585 while (begin < end)
586 output = encodeWide(*begin++, output, replacement);
587
588 return output;
589 }
590
591
593 template <typename In, typename Out>
594 Out Utf<32>::toLatin1(In begin, In end, Out output, char replacement)
595 {
596 // Latin-1 is directly compatible with Unicode encodings,
597 // and can thus be treated as (a sub-range of) UTF-32
598 while (begin < end)
599 {
600 *output++ = *begin < 256 ? static_cast<char>(*begin) : replacement;
601 begin++;
602 }
603
604 return output;
605 }
606
607
609 template <typename In, typename Out>
610 Out Utf<32>::toUtf8(In begin, In end, Out output)
611 {
612 while (begin < end)
613 output = Utf<8>::encode(*begin++, output);
614
615 return output;
616 }
617
619 template <typename In, typename Out>
620 Out Utf<32>::toUtf16(In begin, In end, Out output)
621 {
622 while (begin < end)
623 output = Utf<16>::encode(*begin++, output);
624
625 return output;
626 }
627
628
630 template <typename In, typename Out>
631 Out Utf<32>::toUtf32(In begin, In end, Out output)
632 {
633 return std::copy(begin, end, output);
634 }
635
636
638 template <typename In>
639 Uint32 Utf<32>::decodeAnsi(In input, const std::locale& locale)
640 {
641 // On Windows, gcc's standard library (glibc++) has almost
642 // no support for Unicode stuff. As a consequence, in this
643 // context we can only use the default locale and ignore
644 // the one passed as parameter.
645
646 #if defined(SFML_SYSTEM_WINDOWS) && /* if Windows ... */ \
647 (defined(__GLIBCPP__) || defined (__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \
648 !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */
649
650 (void)locale; // to avoid warnings
651
652 wchar_t character = 0;
653 mbtowc(&character, &input, 1);
654 return static_cast<Uint32>(character);
655
656 #else
657
658 // Get the facet of the locale which deals with character conversion
659 const std::ctype<wchar_t>& facet = std::use_facet< std::ctype<wchar_t> >(locale);
660
661 // Use the facet to convert each character of the input string
662 return static_cast<Uint32>(facet.widen(input));
663
664 #endif
665 }
666
667
669 template <typename In>
670 Uint32 Utf<32>::decodeWide(In input)
671 {
672 // The encoding of wide characters is not well defined and is left to the system;
673 // however we can safely assume that it is UCS-2 on Windows and
674 // UCS-4 on Unix systems.
675 // In both cases, a simple copy is enough (UCS-2 is a subset of UCS-4,
676 // and UCS-4 *is* UTF-32).
677
678 return input;
679 }
680
681
683 template <typename Out>
684 Out Utf<32>::encodeAnsi(Uint32 codepoint, Out output, char replacement, const std::locale& locale)
685 {
686 // On Windows, gcc's standard library (glibc++) has almost
687 // no support for Unicode stuff. As a consequence, in this
688 // context we can only use the default locale and ignore
689 // the one passed as parameter.
690
691 #if defined(SFML_SYSTEM_WINDOWS) && /* if Windows ... */ \
692 (defined(__GLIBCPP__) || defined (__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \
693 !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */
694
695 (void)locale; // to avoid warnings
696
697 char character = 0;
698 if (wctomb(&character, static_cast<wchar_t>(codepoint)) >= 0)
699 *output++ = character;
700 else if (replacement)
701 *output++ = replacement;
702
703 return output;
704
705 #else
706
707 // Get the facet of the locale which deals with character conversion
708 const std::ctype<wchar_t>& facet = std::use_facet< std::ctype<wchar_t> >(locale);
709
710 // Use the facet to convert each character of the input string
711 *output++ = facet.narrow(static_cast<wchar_t>(codepoint), replacement);
712
713 return output;
714
715 #endif
716 }
717
718
720 template <typename Out>
721 Out Utf<32>::encodeWide(Uint32 codepoint, Out output, wchar_t replacement)
722 {
723 // The encoding of wide characters is not well defined and is left to the system;
724 // however we can safely assume that it is UCS-2 on Windows and
725 // UCS-4 on Unix systems.
726 // For UCS-2 we need to check if the source characters fits in (UCS-2 is a subset of UCS-4).
727 // For UCS-4 we can do a direct copy (UCS-4 *is* UTF-32).
728
729 switch (sizeof(wchar_t))
730 {
731 case 4:
732 {
733 *output++ = static_cast<wchar_t>(codepoint);
734 break;
735 }
736
737 default:
738 {
739 if ((codepoint <= 0xFFFF) && ((codepoint < 0xD800) || (codepoint > 0xDFFF)))
740 {
741 *output++ = static_cast<wchar_t>(codepoint);
742 }
743 else if (replacement)
744 {
745 *output++ = replacement;
746 }
747 break;
748 }
749 }
750
751 return output;
752 }


  • File List
  • include
  • SFML
  • System
Vector2.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_VECTOR2_HPP
26 #define SFML_VECTOR2_HPP
27
28
29 namespace sf
30 {
36 template <typename T>
37 class Vector2
38 {
39 public :
40
47 Vector2();
48
56 Vector2(T X, T Y);
57
69 template <typename U>
70 explicit Vector2(const Vector2<U>& vector);
71
73 // Member data
75 T x;
76 T y;
77 };
78
88 template <typename T>
89 Vector2<T> operator -(const Vector2<T>& right);
90
104 template <typename T>
105 Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right);
106
120 template <typename T>
121 Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right);
122
133 template <typename T>
134 Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right);
135
146 template <typename T>
147 Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right);
148
159 template <typename T>
160 Vector2<T> operator *(const Vector2<T>& left, T right);
161
172 template <typename T>
173 Vector2<T> operator *(T left, const Vector2<T>& right);
174
188 template <typename T>
189 Vector2<T>& operator *=(Vector2<T>& left, T right);
190
201 template <typename T>
202 Vector2<T> operator /(const Vector2<T>& left, T right);
203
217 template <typename T>
218 Vector2<T>& operator /=(Vector2<T>& left, T right);
219
232 template <typename T>
233 bool operator ==(const Vector2<T>& left, const Vector2<T>& right);
234
247 template <typename T>
248 bool operator !=(const Vector2<T>& left, const Vector2<T>& right);
249
250 #include <SFML/System/Vector2.inl>
251
252 // Define the most common types
253 typedef Vector2<int> Vector2i;
254 typedef Vector2<unsigned int> Vector2u;
255 typedef Vector2<float> Vector2f;
256
257 } // namespace sf
258
259
260 #endif // SFML_VECTOR2_HPP
261
262


  • File List
  • include
  • SFML
  • System
Vector2.inl
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2012 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25
27 template <typename T>
28 inline Vector2<T>::Vector2() :
29 x(0),
30 y(0)
31 {
32
33 }
34
35
37 template <typename T>
38 inline Vector2<T>::Vector2(T X, T Y) :
39 x(X),
40 y(Y)
41 {
42
43 }
44
45
47 template <typename T>
48 template <typename U>
49 inline Vector2<T>::Vector2(const Vector2<U>& vector) :
50 x(static_cast<T>(vector.x)),
51 y(static_cast<T>(vector.y))
52 {
53 }
54
55
57 template <typename T>
58 inline Vector2<T> operator -(const Vector2<T>& right)
59 {
60 return Vector2<T>(-right.x, -right.y);
61 }
62
63
65 template <typename T>
66 inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right)
67 {
68 left.x += right.x;
69 left.y += right.y;
70
71 return left;
72 }
73
74
76 template <typename T>
77 inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right)
78 {
79 left.x -= right.x;
80 left.y -= right.y;
81
82 return left;
83 }
84
85
87 template <typename T>
88 inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right)
89 {
90 return Vector2<T>(left.x + right.x, left.y + right.y);
91 }
92
93
95 template <typename T>
96 inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right)
97 {
98 return Vector2<T>(left.x - right.x, left.y - right.y);
99 }
100
101
103 template <typename T>
104 inline Vector2<T> operator *(const Vector2<T>& left, T right)
105 {
106 return Vector2<T>(left.x * right, left.y * right);
107 }
108
109
111 template <typename T>
112 inline Vector2<T> operator *(T left, const Vector2<T>& right)
113 {
114 return Vector2<T>(right.x * left, right.y * left);
115 }
116
117
119 template <typename T>
120 inline Vector2<T>& operator *=(Vector2<T>& left, T right)
121 {
122 left.x *= right;
123 left.y *= right;
124
125 return left;
126 }
127
128
130 template <typename T>
131 inline Vector2<T> operator /(const Vector2<T>& left, T right)
132 {
133 return Vector2<T>(left.x / right, left.y / right);
134 }
135
136
138 template <typename T>
139 inline Vector2<T>& operator /=(Vector2<T>& left, T right)
140 {
141 left.x /= right;
142 left.y /= right;
143
144 return left;
145 }
146
147
149 template <typename T>
150 inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right)
151 {
152 return (left.x == right.x) && (left.y == right.y);
153 }
154
155
157 template <typename T>
158 inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right)
159 {
160 return (left.x != right.x) || (left.y != right.y);
161 }


  • File List
  • include
  • SFML
  • System
Vector3.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_VECTOR3_HPP
26 #define SFML_VECTOR3_HPP
27
28
29 namespace sf
30 {
36 template <typename T>
37 class Vector3
38 {
39 public :
40
47 Vector3();
48
57 Vector3(T X, T Y, T Z);
58
70 template <typename U>
71 explicit Vector3(const Vector3<U>& vector);
72
74 // Member data
76 T x;
77 T y;
78 T z;
79 };
80
90 template <typename T>
91 Vector3<T> operator -(const Vector3<T>& left);
92
106 template <typename T>
107 Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right);
108
122 template <typename T>
123 Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right);
124
135 template <typename T>
136 Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right);
137
148 template <typename T>
149 Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right);
150
161 template <typename T>
162 Vector3<T> operator *(const Vector3<T>& left, T right);
163
174 template <typename T>
175 Vector3<T> operator *(T left, const Vector3<T>& right);
176
190 template <typename T>
191 Vector3<T>& operator *=(Vector3<T>& left, T right);
192
203 template <typename T>
204 Vector3<T> operator /(const Vector3<T>& left, T right);
205
219 template <typename T>
220 Vector3<T>& operator /=(Vector3<T>& left, T right);
221
234 template <typename T>
235 bool operator ==(const Vector3<T>& left, const Vector3<T>& right);
236
249 template <typename T>
250 bool operator !=(const Vector3<T>& left, const Vector3<T>& right);
251
252 #include <SFML/System/Vector3.inl>
253
254 // Define the most common types
255 typedef Vector3<int> Vector3i;
256 typedef Vector3<float> Vector3f;
257
258 } // namespace sf
259
260
261 #endif // SFML_VECTOR3_HPP
262
263


  • File List
  • include
  • SFML
  • System
Vector3.inl
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2012 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25
27 template <typename T>
28 inline Vector3<T>::Vector3() :
29 x(0),
30 y(0),
31 z(0)
32 {
33
34 }
35
36
38 template <typename T>
39 inline Vector3<T>::Vector3(T X, T Y, T Z) :
40 x(X),
41 y(Y),
42 z(Z)
43 {
44
45 }
46
47
49 template <typename T>
50 template <typename U>
51 inline Vector3<T>::Vector3(const Vector3<U>& vector) :
52 x(static_cast<T>(vector.x)),
53 y(static_cast<T>(vector.y)),
54 z(static_cast<T>(vector.z))
55 {
56 }
57
58
60 template <typename T>
61 inline Vector3<T> operator -(const Vector3<T>& left)
62 {
63 return Vector3<T>(-left.x, -left.y, -left.z);
64 }
65
66
68 template <typename T>
69 inline Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right)
70 {
71 left.x += right.x;
72 left.y += right.y;
73 left.z += right.z;
74
75 return left;
76 }
77
78
80 template <typename T>
81 inline Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right)
82 {
83 left.x -= right.x;
84 left.y -= right.y;
85 left.z -= right.z;
86
87 return left;
88 }
89
90
92 template <typename T>
93 inline Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right)
94 {
95 return Vector3<T>(left.x + right.x, left.y + right.y, left.z + right.z);
96 }
97
98
100 template <typename T>
101 inline Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right)
102 {
103 return Vector3<T>(left.x - right.x, left.y - right.y, left.z - right.z);
104 }
105
106
108 template <typename T>
109 inline Vector3<T> operator *(const Vector3<T>& left, T right)
110 {
111 return Vector3<T>(left.x * right, left.y * right, left.z * right);
112 }
113
114
116 template <typename T>
117 inline Vector3<T> operator *(T left, const Vector3<T>& right)
118 {
119 return Vector3<T>(right.x * left, right.y * left, right.z * left);
120 }
121
122
124 template <typename T>
125 inline Vector3<T>& operator *=(Vector3<T>& left, T right)
126 {
127 left.x *= right;
128 left.y *= right;
129 left.z *= right;
130
131 return left;
132 }
133
134
136 template <typename T>
137 inline Vector3<T> operator /(const Vector3<T>& left, T right)
138 {
139 return Vector3<T>(left.x / right, left.y / right, left.z / right);
140 }
141
142
144 template <typename T>
145 inline Vector3<T>& operator /=(Vector3<T>& left, T right)
146 {
147 left.x /= right;
148 left.y /= right;
149 left.z /= right;
150
151 return left;
152 }
153
154
156 template <typename T>
157 inline bool operator ==(const Vector3<T>& left, const Vector3<T>& right)
158 {
159 return (left.x == right.x) && (left.y == right.y) && (left.z == right.z);
160 }
161
162
164 template <typename T>
165 inline bool operator !=(const Vector3<T>& left, const Vector3<T>& right)
166 {
167 return (left.x != right.x) || (left.y != right.y) || (left.z != right.z);
168 }


  • File List
  • include
  • SFML
  • Graphics
Vertex.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_VERTEX_HPP
26 #define SFML_VERTEX_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Color.hpp>
33 #include <SFML/System/Vector2.hpp>
34
35
36 namespace sf
37 {
42 class SFML_GRAPHICS_API Vertex
43 {
44 public :
45
50 Vertex();
51
60 Vertex(const Vector2f& thePosition);
61
71 Vertex(const Vector2f& thePosition, const Color& theColor);
72
82 Vertex(const Vector2f& thePosition, const Vector2f& theTexCoords);
83
92 Vertex(const Vector2f& thePosition, const Color& theColor, const Vector2f& theTexCoords);
93
95 // Member data
97 Vector2f position;
98 Color color;
99 Vector2f texCoords;
100 };
101
102 } // namespace sf
103
104
105 #endif // SFML_VERTEX_HPP
106
107


  • File List
  • include
  • SFML
  • Graphics
VertexArray.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_VERTEXARRAY_HPP
26 #define SFML_VERTEXARRAY_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Vertex.hpp>
33 #include <SFML/Graphics/PrimitiveType.hpp>
34 #include <SFML/Graphics/Rect.hpp>
35 #include <SFML/Graphics/Drawable.hpp>
36 #include <vector>
37
38
39 namespace sf
40 {
45 class SFML_GRAPHICS_API VertexArray : public Drawable
46 {
47 public :
48
55 VertexArray();
56
64 explicit VertexArray(PrimitiveType type, unsigned int vertexCount = 0);
65
72 unsigned int getVertexCount() const;
73
88 Vertex& operator [](unsigned int index);
89
104 const Vertex& operator [](unsigned int index) const;
105
115 void clear();
116
129 void resize(unsigned int vertexCount);
130
137 void append(const Vertex& vertex);
138
153 void setPrimitiveType(PrimitiveType type);
154
161 PrimitiveType getPrimitiveType() const;
162
172 FloatRect getBounds() const;
173
174 private :
175
183 virtual void draw(RenderTarget& target, RenderStates states) const;
184
185 private:
186
188 // Member data
190 std::vector<Vertex> m_vertices;
191 PrimitiveType m_primitiveType;
192 };
193
194 } // namespace sf
195
196
197 #endif // SFML_VERTEXARRAY_HPP
198
199


  • File List
  • include
  • SFML
  • Window
VideoMode.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_VIDEOMODE_HPP
26 #define SFML_VIDEOMODE_HPP
27
29 // Headers
31 #include <SFML/Window/Export.hpp>
32 #include <vector>
33
34
35 namespace sf
36 {
41 class SFML_WINDOW_API VideoMode
42 {
43 public :
44
51 VideoMode();
52
61 VideoMode(unsigned int modeWidth, unsigned int modeHeight, unsigned int modeBitsPerPixel = 32);
62
69 static VideoMode getDesktopMode();
70
85 static const std::vector<VideoMode>& getFullscreenModes();
86
97 bool isValid() const;
98
100 // Member data
102 unsigned int width;
103 unsigned int height;
104 unsigned int bitsPerPixel;
105 };
106
117 SFML_WINDOW_API bool operator ==(const VideoMode& left, const VideoMode& right);
118
129 SFML_WINDOW_API bool operator !=(const VideoMode& left, const VideoMode& right);
130
141 SFML_WINDOW_API bool operator <(const VideoMode& left, const VideoMode& right);
142
153 SFML_WINDOW_API bool operator >(const VideoMode& left, const VideoMode& right);
154
165 SFML_WINDOW_API bool operator <=(const VideoMode& left, const VideoMode& right);
166
177 SFML_WINDOW_API bool operator >=(const VideoMode& left, const VideoMode& right);
178
179 } // namespace sf
180
181
182 #endif // SFML_VIDEOMODE_HPP
183
184


  • File List
  • include
  • SFML
  • Graphics
View.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_VIEW_HPP
26 #define SFML_VIEW_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/Rect.hpp>
33 #include <SFML/Graphics/Transform.hpp>
34 #include <SFML/System/Vector2.hpp>
35
36
37 namespace sf
38 {
43 class SFML_GRAPHICS_API View
44 {
45 public :
46
53 View();
54
61 explicit View(const FloatRect& rectangle);
62
70 View(const Vector2f& center, const Vector2f& size);
71
81 void setCenter(float x, float y);
82
91 void setCenter(const Vector2f& center);
92
102 void setSize(float width, float height);
103
112 void setSize(const Vector2f& size);
113
124 void setRotation(float angle);
125
141 void setViewport(const FloatRect& viewport);
142
153 void reset(const FloatRect& rectangle);
154
163 const Vector2f& getCenter() const;
164
173 const Vector2f& getSize() const;
174
183 float getRotation() const;
184
193 const FloatRect& getViewport() const;
194
204 void move(float offsetX, float offsetY);
205
214 void move(const Vector2f& offset);
215
224 void rotate(float angle);
225
241 void zoom(float factor);
242
253 const Transform& getTransform() const;
254
265 const Transform& getInverseTransform() const;
266
267 private :
268
270 // Member data
272 Vector2f m_center;
273 Vector2f m_size;
274 float m_rotation;
275 FloatRect m_viewport;
276 mutable Transform m_transform;
277 mutable Transform m_inverseTransform;
278 mutable bool m_transformUpdated;
279 mutable bool m_invTransformUpdated;
280 };
281
282 } // namespace sf
283
284
285 #endif // SFML_VIEW_HPP
286
287


  • File List
  • include
  • SFML
  • Window
Window/Window.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_WINDOW_HPP
26 #define SFML_WINDOW_HPP
27
29 // Headers
31 #include <SFML/Window/Export.hpp>
32 #include <SFML/Window/ContextSettings.hpp>
33 #include <SFML/Window/VideoMode.hpp>
34 #include <SFML/Window/WindowHandle.hpp>
35 #include <SFML/Window/WindowStyle.hpp>
36 #include <SFML/Window/GlResource.hpp>
37 #include <SFML/System/Clock.hpp>
38 #include <SFML/System/Vector2.hpp>
39 #include <SFML/System/NonCopyable.hpp>
40 #include <SFML/System/String.hpp>
41
42
43 namespace sf
44 {
45 namespace priv
46 {
47 class GlContext;
48 class WindowImpl;
49 }
50
51 class Event;
52
57 class SFML_WINDOW_API Window : GlResource, NonCopyable
58 {
59 public :
60
68 Window();
69
89 Window(VideoMode mode, const String& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());
90
105 explicit Window(WindowHandle handle, const ContextSettings& settings = ContextSettings());
106
113 virtual ~Window();
114
128 void create(VideoMode mode, const String& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());
129
141 void create(WindowHandle handle, const ContextSettings& settings = ContextSettings());
142
153 void close();
154
165 bool isOpen() const;
166
178 const ContextSettings& getSettings() const;
179
203 bool pollEvent(Event& event);
204
230 bool waitEvent(Event& event);
231
240 Vector2i getPosition() const;
241
254 void setPosition(const Vector2i& position);
255
267 Vector2u getSize() const;
268
277 void setSize(const Vector2u size);
278
287 void setTitle(const String& title);
288
304 void setIcon(unsigned int width, unsigned int height, const Uint8* pixels);
305
314 void setVisible(bool visible);
315
329 void setVerticalSyncEnabled(bool enabled);
330
339 void setMouseCursorVisible(bool visible);
340
353 void setKeyRepeatEnabled(bool enabled);
354
370 void setFramerateLimit(unsigned int limit);
371
383 void setJoystickThreshold(float threshold);
384
400 bool setActive(bool active = true) const;
401
410 void display();
411
424 WindowHandle getSystemHandle() const;
425
426 protected :
427
436 virtual void onCreate();
437
445 virtual void onResize();
446
447 private:
448
461 bool filterEvent(const Event& event);
462
467 void initialize();
468
470 // Member data
472 priv::WindowImpl* m_impl;
473 priv::GlContext* m_context;
474 Clock m_clock;
475 Time m_frameTimeLimit;
476 Vector2u m_size;
477 };
478
479 } // namespace sf
480
481
482 #endif // SFML_WINDOW_HPP
483
484


  • File List
  • include
  • SFML
Window.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_SFML_WINDOW_HPP
26 #define SFML_SFML_WINDOW_HPP
27
29 // Headers
31
32 #include <SFML/System.hpp>
33 #include <SFML/Window/Context.hpp>
34 #include <SFML/Window/ContextSettings.hpp>
35 #include <SFML/Window/Event.hpp>
36 #include <SFML/Window/Joystick.hpp>
37 #include <SFML/Window/Keyboard.hpp>
38 #include <SFML/Window/Mouse.hpp>
39 #include <SFML/Window/VideoMode.hpp>
40 #include <SFML/Window/Window.hpp>
41 #include <SFML/Window/WindowStyle.hpp>
42
43
44 #endif // SFML_SFML_WINDOW_HPP
45


  • File List
  • include
  • SFML
  • Window
WindowHandle.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_WINDOWHANDLE_HPP
26 #define SFML_WINDOWHANDLE_HPP
27
29 // Headers
31 #include <SFML/Config.hpp>
32
33 // Windows' HWND is a typedef on struct HWND__*
34 #if defined(SFML_SYSTEM_WINDOWS)
35 struct HWND__;
36 #endif
37
38 namespace sf
39 {
44 #if defined(SFML_SYSTEM_WINDOWS)
45
46 // Window handle is HWND (HWND__*) on Windows
47 typedef HWND__* WindowHandle;
48
49 #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD)
50
51 // Window handle is Window (unsigned long) on Unix - X11
52 typedef unsigned long WindowHandle;
53
54 #elif defined(SFML_SYSTEM_MACOS)
55
56 // Window handle is NSWindow (void*) on Mac OS X - Cocoa
57 typedef void* WindowHandle;
58
59 #endif
60
61 } // namespace sf
62
63
64 #endif // SFML_WINDOWHANDLE_HPP


  • File List
  • include
  • SFML
  • Window
WindowStyle.hpp
1
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24
25 #ifndef SFML_WINDOWSTYLE_HPP
26 #define SFML_WINDOWSTYLE_HPP
27
28
29 namespace sf
30 {
31 namespace Style
32 {
38 enum
39 {
40 None = 0,
41 Titlebar = 1 << 0,
42 Resize = 1 << 1,
43 Close = 1 << 2,
44 Fullscreen = 1 << 3,
45
46 Default = Titlebar | Resize | Close
47 };
48 }
49
50 } // namespace sf
51
52
53 #endif // SFML_WINDOWSTYLE_HPP


  • sf
  • CircleShape
sf::CircleShape Member List

This is the complete list of members for sf::CircleShape, including all inherited members.

CircleShape(float radius=0, unsigned int pointCount=30) | sf::CircleShape | explicit
getFillColor() const | sf::Shape |
getGlobalBounds() const | sf::Shape |
getInverseTransform() const | sf::Transformable |
getLocalBounds() const | sf::Shape |
getOrigin() const | sf::Transformable |
getOutlineColor() const | sf::Shape |
getOutlineThickness() const | sf::Shape |
getPoint(unsigned int index) const | sf::CircleShape | virtual
getPointCount() const | sf::CircleShape | virtual
getPosition() const | sf::Transformable |
getRadius() const | sf::CircleShape |
getRotation() const | sf::Transformable |
getScale() const | sf::Transformable |
getTexture() const | sf::Shape |
getTextureRect() const | sf::Shape |
getTransform() const | sf::Transformable |
move(float offsetX, float offsetY) | sf::Transformable |
move(const Vector2f &offset) | sf::Transformable |
rotate(float angle) | sf::Transformable |
scale(float factorX, float factorY) | sf::Transformable |
scale(const Vector2f &factor) | sf::Transformable |
setFillColor(const Color &color) | sf::Shape |
setOrigin(float x, float y) | sf::Transformable |
setOrigin(const Vector2f &origin) | sf::Transformable |
setOutlineColor(const Color &color) | sf::Shape |
setOutlineThickness(float thickness) | sf::Shape |
setPointCount(unsigned int count) | sf::CircleShape |
setPosition(float x, float y) | sf::Transformable |
setPosition(const Vector2f &position) | sf::Transformable |
setRadius(float radius) | sf::CircleShape |
setRotation(float angle) | sf::Transformable |
setScale(float factorX, float factorY) | sf::Transformable |
setScale(const Vector2f &factors) | sf::Transformable |
setTexture(const Texture *texture, bool resetRect=false) | sf::Shape |
setTextureRect(const IntRect &rect) | sf::Shape |
Shape() | sf::Shape | protected
Transformable() | sf::Transformable |
update() | sf::Shape | protected
~Drawable() | sf::Drawable | inlinevirtual
~Shape() | sf::Shape | virtual
~Transformable() | sf::Transformable | virtual


  • sf
  • Clock
sf::Clock Member List

This is the complete list of members for sf::Clock, including all inherited members.

Clock() | sf::Clock
getElapsedTime() const | sf::Clock
restart() | sf::Clock


  • sf
  • Color
sf::Color Member List

This is the complete list of members for sf::Color, including all inherited members.

a | sf::Color |
b | sf::Color |
Black | sf::Color | static
Blue | sf::Color | static
Color() | sf::Color |
Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha=255) | sf::Color |
Cyan | sf::Color | static
g | sf::Color |
Green | sf::Color | static
Magenta | sf::Color | static
operator!=(const Color &left, const Color &right) | sf::Color | related
operator*(const Color &left, const Color &right) | sf::Color | related
operator*=(Color &left, const Color &right) | sf::Color | related
operator+(const Color &left, const Color &right) | sf::Color | related
operator+=(Color &left, const Color &right) | sf::Color | related
operator==(const Color &left, const Color &right) | sf::Color | related
r | sf::Color |
Red | sf::Color | static
Transparent | sf::Color | static
White | sf::Color | static
Yellow | sf::Color | static


  • sf
  • Context
sf::Context Member List

This is the complete list of members for sf::Context, including all inherited members.

Context() | sf::Context |
Context(const ContextSettings &settings, unsigned int width, unsigned int height) | sf::Context |
ensureGlContext() | sf::GlResource | privatestatic
GlResource() | sf::GlResource | private
NonCopyable() | sf::NonCopyable | inlineprivate
setActive(bool active) | sf::Context |
~Context() | sf::Context |
~GlResource() | sf::GlResource | private


  • sf
  • ContextSettings
sf::ContextSettings Member List

This is the complete list of members for sf::ContextSettings, including all inherited members.

antialiasingLevel | sf::ContextSettings |
ContextSettings(unsigned int depth=0, unsigned int stencil=0, unsigned int antialiasing=0, unsigned int major=2, unsigned int minor=0) | sf::ContextSettings | inlineexplicit
depthBits | sf::ContextSettings |
majorVersion | sf::ContextSettings |
minorVersion | sf::ContextSettings |
stencilBits | sf::ContextSettings |


  • sf
  • ConvexShape
sf::ConvexShape Member List

This is the complete list of members for sf::ConvexShape, including all inherited members.

ConvexShape(unsigned int pointCount=0) | sf::ConvexShape | explicit
getFillColor() const | sf::Shape |
getGlobalBounds() const | sf::Shape |
getInverseTransform() const | sf::Transformable |
getLocalBounds() const | sf::Shape |
getOrigin() const | sf::Transformable |
getOutlineColor() const | sf::Shape |
getOutlineThickness() const | sf::Shape |
getPoint(unsigned int index) const | sf::ConvexShape | virtual
getPointCount() const | sf::ConvexShape | virtual
getPosition() const | sf::Transformable |
getRotation() const | sf::Transformable |
getScale() const | sf::Transformable |
getTexture() const | sf::Shape |
getTextureRect() const | sf::Shape |
getTransform() const | sf::Transformable |
move(float offsetX, float offsetY) | sf::Transformable |
move(const Vector2f &offset) | sf::Transformable |
rotate(float angle) | sf::Transformable |
scale(float factorX, float factorY) | sf::Transformable |
scale(const Vector2f &factor) | sf::Transformable |
setFillColor(const Color &color) | sf::Shape |
setOrigin(float x, float y) | sf::Transformable |
setOrigin(const Vector2f &origin) | sf::Transformable |
setOutlineColor(const Color &color) | sf::Shape |
setOutlineThickness(float thickness) | sf::Shape |
setPoint(unsigned int index, const Vector2f &point) | sf::ConvexShape |
setPointCount(unsigned int count) | sf::ConvexShape |
setPosition(float x, float y) | sf::Transformable |
setPosition(const Vector2f &position) | sf::Transformable |
setRotation(float angle) | sf::Transformable |
setScale(float factorX, float factorY) | sf::Transformable |
setScale(const Vector2f &factors) | sf::Transformable |
setTexture(const Texture *texture, bool resetRect=false) | sf::Shape |
setTextureRect(const IntRect &rect) | sf::Shape |
Shape() | sf::Shape | protected
Transformable() | sf::Transformable |
update() | sf::Shape | protected
~Drawable() | sf::Drawable | inlinevirtual
~Shape() | sf::Shape | virtual
~Transformable() | sf::Transformable | virtual


  • sf
  • Drawable
sf::Drawable Member List

This is the complete list of members for sf::Drawable, including all inherited members.

draw(RenderTarget &target, RenderStates states) const =0 | sf::Drawable | protectedpure virtual
RenderTarget (defined in sf::Drawable) | sf::Drawable | friend
~Drawable() | sf::Drawable | inlinevirtual


  • sf
  • Event
sf::Event Member List

This is the complete list of members for sf::Event, including all inherited members.

Closed enum value | sf::Event
Count enum value | sf::Event
EventType enum name | sf::Event
GainedFocus enum value | sf::Event
joystickButton | sf::Event
JoystickButtonPressed enum value | sf::Event
JoystickButtonReleased enum value | sf::Event
joystickConnect | sf::Event
JoystickConnected enum value | sf::Event
JoystickDisconnected enum value | sf::Event
joystickMove | sf::Event
JoystickMoved enum value | sf::Event
key | sf::Event
KeyPressed enum value | sf::Event
KeyReleased enum value | sf::Event
LostFocus enum value | sf::Event
mouseButton | sf::Event
MouseButtonPressed enum value | sf::Event
MouseButtonReleased enum value | sf::Event
MouseEntered enum value | sf::Event
MouseLeft enum value | sf::Event
mouseMove | sf::Event
MouseMoved enum value | sf::Event
mouseWheel | sf::Event
MouseWheelMoved enum value | sf::Event
Resized enum value | sf::Event
size | sf::Event
text | sf::Event
TextEntered enum value | sf::Event
type | sf::Event


  • sf
  • Font
sf::Font Member List

This is the complete list of members for sf::Font, including all inherited members.

Font() | sf::Font
Font(const Font &copy) | sf::Font
getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const | sf::Font
getKerning(Uint32 first, Uint32 second, unsigned int characterSize) const | sf::Font
getLineSpacing(unsigned int characterSize) const | sf::Font
getTexture(unsigned int characterSize) const | sf::Font
loadFromFile(const std::string &filename) | sf::Font
loadFromMemory(const void *data, std::size_t sizeInBytes) | sf::Font
loadFromStream(InputStream &stream) | sf::Font
operator=(const Font &right) | sf::Font
~Font() | sf::Font


  • sf
  • Ftp
sf::Ftp Member List

This is the complete list of members for sf::Ftp, including all inherited members.

Ascii enum value | sf::Ftp |
Binary enum value | sf::Ftp |
changeDirectory(const std::string &directory) | sf::Ftp |
connect(const IpAddress &server, unsigned short port=21, Time timeout=Time::Zero) | sf::Ftp |
createDirectory(const std::string &name) | sf::Ftp |
DataChannel (defined in sf::Ftp) | sf::Ftp | friend
deleteDirectory(const std::string &name) | sf::Ftp |
deleteFile(const std::string &name) | sf::Ftp |
disconnect() | sf::Ftp |
download(const std::string &remoteFile, const std::string &localPath, TransferMode mode=Binary) | sf::Ftp |
Ebcdic enum value | sf::Ftp |
getDirectoryListing(const std::string &directory="") | sf::Ftp |
getWorkingDirectory() | sf::Ftp |
keepAlive() | sf::Ftp |
login() | sf::Ftp |
login(const std::string &name, const std::string &password) | sf::Ftp |
NonCopyable() | sf::NonCopyable | inlineprivate
parentDirectory() | sf::Ftp |
renameFile(const std::string &file, const std::string &newName) | sf::Ftp |
TransferMode enum name | sf::Ftp |
upload(const std::string &localFile, const std::string &remotePath, TransferMode mode=Binary) | sf::Ftp |
~Ftp() | sf::Ftp |


  • sf
  • Ftp
  • DirectoryResponse
sf::Ftp::DirectoryResponse Member List

This is the complete list of members for sf::Ftp::DirectoryResponse, including all inherited members.

BadCommandSequence enum value | sf::Ftp::Response |
ClosingConnection enum value | sf::Ftp::Response |
ClosingDataConnection enum value | sf::Ftp::Response |
CommandNotImplemented enum value | sf::Ftp::Response |
CommandUnknown enum value | sf::Ftp::Response |
ConnectionClosed enum value | sf::Ftp::Response |
ConnectionFailed enum value | sf::Ftp::Response |
DataConnectionAlreadyOpened enum value | sf::Ftp::Response |
DataConnectionOpened enum value | sf::Ftp::Response |
DataConnectionUnavailable enum value | sf::Ftp::Response |
DirectoryOk enum value | sf::Ftp::Response |
DirectoryResponse(const Response &response) | sf::Ftp::DirectoryResponse |
DirectoryStatus enum value | sf::Ftp::Response |
EnteringPassiveMode enum value | sf::Ftp::Response |
FileActionAborted enum value | sf::Ftp::Response |
FileActionOk enum value | sf::Ftp::Response |
FilenameNotAllowed enum value | sf::Ftp::Response |
FileStatus enum value | sf::Ftp::Response |
FileUnavailable enum value | sf::Ftp::Response |
getDirectory() const | sf::Ftp::DirectoryResponse |
getMessage() const | sf::Ftp::Response |
getStatus() const | sf::Ftp::Response |
HelpMessage enum value | sf::Ftp::Response |
InsufficientStorageSpace enum value | sf::Ftp::Response |
InvalidFile enum value | sf::Ftp::Response |
InvalidResponse enum value | sf::Ftp::Response |
isOk() const | sf::Ftp::Response |
LocalError enum value | sf::Ftp::Response |
LoggedIn enum value | sf::Ftp::Response |
NeedAccountToLogIn enum value | sf::Ftp::Response |
NeedAccountToStore enum value | sf::Ftp::Response |
NeedInformation enum value | sf::Ftp::Response |
NeedPassword enum value | sf::Ftp::Response |
NotEnoughMemory enum value | sf::Ftp::Response |
NotLoggedIn enum value | sf::Ftp::Response |
Ok enum value | sf::Ftp::Response |
OpeningDataConnection enum value | sf::Ftp::Response |
PageTypeUnknown enum value | sf::Ftp::Response |
ParameterNotImplemented enum value | sf::Ftp::Response |
ParametersUnknown enum value | sf::Ftp::Response |
PointlessCommand enum value | sf::Ftp::Response |
Response(Status code=InvalidResponse, const std::string &message="") | sf::Ftp::Response | explicit
RestartMarkerReply enum value | sf::Ftp::Response |
ServiceReady enum value | sf::Ftp::Response |
ServiceReadySoon enum value | sf::Ftp::Response |
ServiceUnavailable enum value | sf::Ftp::Response |
Status enum name | sf::Ftp::Response |
SystemStatus enum value | sf::Ftp::Response |
SystemType enum value | sf::Ftp::Response |
TransferAborted enum value | sf::Ftp::Response |


  • sf
  • Ftp
  • ListingResponse
sf::Ftp::ListingResponse Member List

This is the complete list of members for sf::Ftp::ListingResponse, including all inherited members.

BadCommandSequence enum value | sf::Ftp::Response |
ClosingConnection enum value | sf::Ftp::Response |
ClosingDataConnection enum value | sf::Ftp::Response |
CommandNotImplemented enum value | sf::Ftp::Response |
CommandUnknown enum value | sf::Ftp::Response |
ConnectionClosed enum value | sf::Ftp::Response |
ConnectionFailed enum value | sf::Ftp::Response |
DataConnectionAlreadyOpened enum value | sf::Ftp::Response |
DataConnectionOpened enum value | sf::Ftp::Response |
DataConnectionUnavailable enum value | sf::Ftp::Response |
DirectoryOk enum value | sf::Ftp::Response |
DirectoryStatus enum value | sf::Ftp::Response |
EnteringPassiveMode enum value | sf::Ftp::Response |
FileActionAborted enum value | sf::Ftp::Response |
FileActionOk enum value | sf::Ftp::Response |
FilenameNotAllowed enum value | sf::Ftp::Response |
FileStatus enum value | sf::Ftp::Response |
FileUnavailable enum value | sf::Ftp::Response |
getListing() const | sf::Ftp::ListingResponse |
getMessage() const | sf::Ftp::Response |
getStatus() const | sf::Ftp::Response |
HelpMessage enum value | sf::Ftp::Response |
InsufficientStorageSpace enum value | sf::Ftp::Response |
InvalidFile enum value | sf::Ftp::Response |
InvalidResponse enum value | sf::Ftp::Response |
isOk() const | sf::Ftp::Response |
ListingResponse(const Response &response, const std::vector< char > &data) | sf::Ftp::ListingResponse |
LocalError enum value | sf::Ftp::Response |
LoggedIn enum value | sf::Ftp::Response |
NeedAccountToLogIn enum value | sf::Ftp::Response |
NeedAccountToStore enum value | sf::Ftp::Response |
NeedInformation enum value | sf::Ftp::Response |
NeedPassword enum value | sf::Ftp::Response |
NotEnoughMemory enum value | sf::Ftp::Response |
NotLoggedIn enum value | sf::Ftp::Response |
Ok enum value | sf::Ftp::Response |
OpeningDataConnection enum value | sf::Ftp::Response |
PageTypeUnknown enum value | sf::Ftp::Response |
ParameterNotImplemented enum value | sf::Ftp::Response |
ParametersUnknown enum value | sf::Ftp::Response |
PointlessCommand enum value | sf::Ftp::Response |
Response(Status code=InvalidResponse, const std::string &message="") | sf::Ftp::Response | explicit
RestartMarkerReply enum value | sf::Ftp::Response |
ServiceReady enum value | sf::Ftp::Response |
ServiceReadySoon enum value | sf::Ftp::Response |
ServiceUnavailable enum value | sf::Ftp::Response |
Status enum name | sf::Ftp::Response |
SystemStatus enum value | sf::Ftp::Response |
SystemType enum value | sf::Ftp::Response |
TransferAborted enum value | sf::Ftp::Response |


  • sf
  • Ftp
  • Response
sf::Ftp::Response Member List

This is the complete list of members for sf::Ftp::Response, including all inherited members.

BadCommandSequence enum value | sf::Ftp::Response |
ClosingConnection enum value | sf::Ftp::Response |
ClosingDataConnection enum value | sf::Ftp::Response |
CommandNotImplemented enum value | sf::Ftp::Response |
CommandUnknown enum value | sf::Ftp::Response |
ConnectionClosed enum value | sf::Ftp::Response |
ConnectionFailed enum value | sf::Ftp::Response |
DataConnectionAlreadyOpened enum value | sf::Ftp::Response |
DataConnectionOpened enum value | sf::Ftp::Response |
DataConnectionUnavailable enum value | sf::Ftp::Response |
DirectoryOk enum value | sf::Ftp::Response |
DirectoryStatus enum value | sf::Ftp::Response |
EnteringPassiveMode enum value | sf::Ftp::Response |
FileActionAborted enum value | sf::Ftp::Response |
FileActionOk enum value | sf::Ftp::Response |
FilenameNotAllowed enum value | sf::Ftp::Response |
FileStatus enum value | sf::Ftp::Response |
FileUnavailable enum value | sf::Ftp::Response |
getMessage() const | sf::Ftp::Response |
getStatus() const | sf::Ftp::Response |
HelpMessage enum value | sf::Ftp::Response |
InsufficientStorageSpace enum value | sf::Ftp::Response |
InvalidFile enum value | sf::Ftp::Response |
InvalidResponse enum value | sf::Ftp::Response |
isOk() const | sf::Ftp::Response |
LocalError enum value | sf::Ftp::Response |
LoggedIn enum value | sf::Ftp::Response |
NeedAccountToLogIn enum value | sf::Ftp::Response |
NeedAccountToStore enum value | sf::Ftp::Response |
NeedInformation enum value | sf::Ftp::Response |
NeedPassword enum value | sf::Ftp::Response |
NotEnoughMemory enum value | sf::Ftp::Response |
NotLoggedIn enum value | sf::Ftp::Response |
Ok enum value | sf::Ftp::Response |
OpeningDataConnection enum value | sf::Ftp::Response |
PageTypeUnknown enum value | sf::Ftp::Response |
ParameterNotImplemented enum value | sf::Ftp::Response |
ParametersUnknown enum value | sf::Ftp::Response |
PointlessCommand enum value | sf::Ftp::Response |
Response(Status code=InvalidResponse, const std::string &message="") | sf::Ftp::Response | explicit
RestartMarkerReply enum value | sf::Ftp::Response |
ServiceReady enum value | sf::Ftp::Response |
ServiceReadySoon enum value | sf::Ftp::Response |
ServiceUnavailable enum value | sf::Ftp::Response |
Status enum name | sf::Ftp::Response |
SystemStatus enum value | sf::Ftp::Response |
SystemType enum value | sf::Ftp::Response |
TransferAborted enum value | sf::Ftp::Response |


  • sf
  • GlResource
sf::GlResource Member List

This is the complete list of members for sf::GlResource, including all inherited members.

ensureGlContext() | sf::GlResource | protectedstatic
GlResource() | sf::GlResource | protected
~GlResource() | sf::GlResource | protected


  • sf
  • Glyph
sf::Glyph Member List

This is the complete list of members for sf::Glyph, including all inherited members.

advance | sf::Glyph |
bounds | sf::Glyph |
Glyph() | sf::Glyph | inline
textureRect | sf::Glyph |


  • sf
  • Http
sf::Http Member List

This is the complete list of members for sf::Http, including all inherited members.

Http() | sf::Http |
Http(const std::string &host, unsigned short port=0) | sf::Http |
NonCopyable() | sf::NonCopyable | inlineprivate
sendRequest(const Request &request, Time timeout=Time::Zero) | sf::Http |
setHost(const std::string &host, unsigned short port=0) | sf::Http |


  • sf
  • Http
  • Request
sf::Http::Request Member List

This is the complete list of members for sf::Http::Request, including all inherited members.

Get enum value | sf::Http::Request |
Head enum value | sf::Http::Request |
Http (defined in sf::Http::Request) | sf::Http::Request | friend
Method enum name | sf::Http::Request |
Post enum value | sf::Http::Request |
Request(const std::string &uri="/", Method method=Get, const std::string &body="") | sf::Http::Request |
setBody(const std::string &body) | sf::Http::Request |
setField(const std::string &field, const std::string &value) | sf::Http::Request |
setHttpVersion(unsigned int major, unsigned int minor) | sf::Http::Request |
setMethod(Method method) | sf::Http::Request |
setUri(const std::string &uri) | sf::Http::Request |


  • sf
  • Http
  • Response
sf::Http::Response Member List

This is the complete list of members for sf::Http::Response, including all inherited members.

Accepted enum value | sf::Http::Response |
BadGateway enum value | sf::Http::Response |
BadRequest enum value | sf::Http::Response |
ConnectionFailed enum value | sf::Http::Response |
Created enum value | sf::Http::Response |
Forbidden enum value | sf::Http::Response |
GatewayTimeout enum value | sf::Http::Response |
getBody() const | sf::Http::Response |
getField(const std::string &field) const | sf::Http::Response |
getMajorHttpVersion() const | sf::Http::Response |
getMinorHttpVersion() const | sf::Http::Response |
getStatus() const | sf::Http::Response |
Http (defined in sf::Http::Response) | sf::Http::Response | friend
InternalServerError enum value | sf::Http::Response |
InvalidResponse enum value | sf::Http::Response |
MovedPermanently enum value | sf::Http::Response |
MovedTemporarily enum value | sf::Http::Response |
MultipleChoices enum value | sf::Http::Response |
NoContent enum value | sf::Http::Response |
NotFound enum value | sf::Http::Response |
NotImplemented enum value | sf::Http::Response |
NotModified enum value | sf::Http::Response |
Ok enum value | sf::Http::Response |
PartialContent enum value | sf::Http::Response |
RangeNotSatisfiable enum value | sf::Http::Response |
ResetContent enum value | sf::Http::Response |
Response() | sf::Http::Response |
ServiceNotAvailable enum value | sf::Http::Response |
Status enum name | sf::Http::Response |
Unauthorized enum value | sf::Http::Response |
VersionNotSupported enum value | sf::Http::Response |


  • sf
  • Image
sf::Image Member List

This is the complete list of members for sf::Image, including all inherited members.

copy(const Image &source, unsigned int destX, unsigned int destY, const IntRect &sourceRect=IntRect(0, 0, 0, 0), bool applyAlpha=false) | sf::Image
create(unsigned int width, unsigned int height, const Color &color=Color(0, 0, 0)) | sf::Image
create(unsigned int width, unsigned int height, const Uint8 *pixels) | sf::Image
createMaskFromColor(const Color &color, Uint8 alpha=0) | sf::Image
flipHorizontally() | sf::Image
flipVertically() | sf::Image
getPixel(unsigned int x, unsigned int y) const | sf::Image
getPixelsPtr() const | sf::Image
getSize() const | sf::Image
Image() | sf::Image
loadFromFile(const std::string &filename) | sf::Image
loadFromMemory(const void *data, std::size_t size) | sf::Image
loadFromStream(InputStream &stream) | sf::Image
saveToFile(const std::string &filename) const | sf::Image
setPixel(unsigned int x, unsigned int y, const Color &color) | sf::Image


  • sf
  • InputStream
sf::InputStream Member List

This is the complete list of members for sf::InputStream, including all inherited members.

getSize()=0 | sf::InputStream | pure virtual
read(void *data, Int64 size)=0 | sf::InputStream | pure virtual
seek(Int64 position)=0 | sf::InputStream | pure virtual
tell()=0 | sf::InputStream | pure virtual
~InputStream() | sf::InputStream | inlinevirtual


  • sf
  • IpAddress
sf::IpAddress Member List

This is the complete list of members for sf::IpAddress, including all inherited members.

Broadcast | sf::IpAddress | static
getLocalAddress() | sf::IpAddress | static
getPublicAddress(Time timeout=Time::Zero) | sf::IpAddress | static
IpAddress() | sf::IpAddress |
IpAddress(const std::string &address) | sf::IpAddress |
IpAddress(const char *address) | sf::IpAddress |
IpAddress(Uint8 byte0, Uint8 byte1, Uint8 byte2, Uint8 byte3) | sf::IpAddress |
IpAddress(Uint32 address) | sf::IpAddress | explicit
LocalHost | sf::IpAddress | static
None | sf::IpAddress | static
toInteger() const | sf::IpAddress |
toString() const | sf::IpAddress |


  • sf
  • Joystick
sf::Joystick Member List

This is the complete list of members for sf::Joystick, including all inherited members.

Axis enum name | sf::Joystick |
AxisCount enum value | sf::Joystick |
ButtonCount enum value | sf::Joystick |
Count enum value | sf::Joystick |
getAxisPosition(unsigned int joystick, Axis axis) | sf::Joystick | static
getButtonCount(unsigned int joystick) | sf::Joystick | static
hasAxis(unsigned int joystick, Axis axis) | sf::Joystick | static
isButtonPressed(unsigned int joystick, unsigned int button) | sf::Joystick | static
isConnected(unsigned int joystick) | sf::Joystick | static
PovX enum value | sf::Joystick |
PovY enum value | sf::Joystick |
R enum value | sf::Joystick |
U enum value | sf::Joystick |
update() | sf::Joystick | static
V enum value | sf::Joystick |
X enum value | sf::Joystick |
Y enum value | sf::Joystick |
Z enum value | sf::Joystick |


  • sf
  • Keyboard
sf::Keyboard Member List

This is the complete list of members for sf::Keyboard, including all inherited members.

A enum value | sf::Keyboard |
Add enum value | sf::Keyboard |
B enum value | sf::Keyboard |
BackSlash enum value | sf::Keyboard |
BackSpace enum value | sf::Keyboard |
C enum value | sf::Keyboard |
Comma enum value | sf::Keyboard |
D enum value | sf::Keyboard |
Dash enum value | sf::Keyboard |
Delete enum value | sf::Keyboard |
Divide enum value | sf::Keyboard |
Down enum value | sf::Keyboard |
E enum value | sf::Keyboard |
End enum value | sf::Keyboard |
Equal enum value | sf::Keyboard |
Escape enum value | sf::Keyboard |
F enum value | sf::Keyboard |
F1 enum value | sf::Keyboard |
F10 enum value | sf::Keyboard |
F11 enum value | sf::Keyboard |
F12 enum value | sf::Keyboard |
F13 enum value | sf::Keyboard |
F14 enum value | sf::Keyboard |
F15 enum value | sf::Keyboard |
F2 enum value | sf::Keyboard |
F3 enum value | sf::Keyboard |
F4 enum value | sf::Keyboard |
F5 enum value | sf::Keyboard |
F6 enum value | sf::Keyboard |
F7 enum value | sf::Keyboard |
F8 enum value | sf::Keyboard |
F9 enum value | sf::Keyboard |
G enum value | sf::Keyboard |
H enum value | sf::Keyboard |
Home enum value | sf::Keyboard |
I enum value | sf::Keyboard |
Insert enum value | sf::Keyboard |
isKeyPressed(Key key) | sf::Keyboard | static
J enum value | sf::Keyboard |
K enum value | sf::Keyboard |
Key enum name | sf::Keyboard |
KeyCount enum value | sf::Keyboard |
L enum value | sf::Keyboard |
LAlt enum value | sf::Keyboard |
LBracket enum value | sf::Keyboard |
LControl enum value | sf::Keyboard |
Left enum value | sf::Keyboard |
LShift enum value | sf::Keyboard |
LSystem enum value | sf::Keyboard |
M enum value | sf::Keyboard |
Menu enum value | sf::Keyboard |
Multiply enum value | sf::Keyboard |
N enum value | sf::Keyboard |
Num0 enum value | sf::Keyboard |
Num1 enum value | sf::Keyboard |
Num2 enum value | sf::Keyboard |
Num3 enum value | sf::Keyboard |
Num4 enum value | sf::Keyboard |
Num5 enum value | sf::Keyboard |
Num6 enum value | sf::Keyboard |
Num7 enum value | sf::Keyboard |
Num8 enum value | sf::Keyboard |
Num9 enum value | sf::Keyboard |
Numpad0 enum value | sf::Keyboard |
Numpad1 enum value | sf::Keyboard |
Numpad2 enum value | sf::Keyboard |
Numpad3 enum value | sf::Keyboard |
Numpad4 enum value | sf::Keyboard |
Numpad5 enum value | sf::Keyboard |
Numpad6 enum value | sf::Keyboard |
Numpad7 enum value | sf::Keyboard |
Numpad8 enum value | sf::Keyboard |
Numpad9 enum value | sf::Keyboard |
O enum value | sf::Keyboard |
P enum value | sf::Keyboard |
PageDown enum value | sf::Keyboard |
PageUp enum value | sf::Keyboard |
Pause enum value | sf::Keyboard |
Period enum value | sf::Keyboard |
Q enum value | sf::Keyboard |
Quote enum value | sf::Keyboard |
R enum value | sf::Keyboard |
RAlt enum value | sf::Keyboard |
RBracket enum value | sf::Keyboard |
RControl enum value | sf::Keyboard |
Return enum value | sf::Keyboard |
Right enum value | sf::Keyboard |
RShift enum value | sf::Keyboard |
RSystem enum value | sf::Keyboard |
S enum value | sf::Keyboard |
SemiColon enum value | sf::Keyboard |
Slash enum value | sf::Keyboard |
Space enum value | sf::Keyboard |
Subtract enum value | sf::Keyboard |
T enum value | sf::Keyboard |
Tab enum value | sf::Keyboard |
Tilde enum value | sf::Keyboard |
U enum value | sf::Keyboard |
Unknown enum value | sf::Keyboard |
Up enum value | sf::Keyboard |
V enum value | sf::Keyboard |
W enum value | sf::Keyboard |
X enum value | sf::Keyboard |
Y enum value | sf::Keyboard |
Z enum value | sf::Keyboard |


  • sf
  • Listener
sf::Listener Member List

This is the complete list of members for sf::Listener, including all inherited members.

getDirection() | sf::Listener | static
getGlobalVolume() | sf::Listener | static
getPosition() | sf::Listener | static
setDirection(float x, float y, float z) | sf::Listener | static
setDirection(const Vector3f &direction) | sf::Listener | static
setGlobalVolume(float volume) | sf::Listener | static
setPosition(float x, float y, float z) | sf::Listener | static
setPosition(const Vector3f &position) | sf::Listener | static


  • sf
  • Lock
sf::Lock Member List

This is the complete list of members for sf::Lock, including all inherited members.

Lock(Mutex &mutex) | sf::Lock | explicit
NonCopyable() | sf::NonCopyable | inlineprivate
~Lock() | sf::Lock |


  • sf
  • Mouse
sf::Mouse Member List

This is the complete list of members for sf::Mouse, including all inherited members.

Button enum name | sf::Mouse |
ButtonCount enum value | sf::Mouse |
getPosition() | sf::Mouse | static
getPosition(const Window &relativeTo) | sf::Mouse | static
isButtonPressed(Button button) | sf::Mouse | static
Left enum value | sf::Mouse |
Middle enum value | sf::Mouse |
Right enum value | sf::Mouse |
setPosition(const Vector2i &position) | sf::Mouse | static
setPosition(const Vector2i &position, const Window &relativeTo) | sf::Mouse | static
XButton1 enum value | sf::Mouse |
XButton2 enum value | sf::Mouse |


  • sf
  • Music
sf::Music Member List

This is the complete list of members for sf::Music, including all inherited members.

getAttenuation() const | sf::SoundSource |
getChannelCount() const | sf::SoundStream |
getDuration() const | sf::Music |
getLoop() const | sf::SoundStream |
getMinDistance() const | sf::SoundSource |
getPitch() const | sf::SoundSource |
getPlayingOffset() const | sf::SoundStream |
getPosition() const | sf::SoundSource |
getSampleRate() const | sf::SoundStream |
getStatus() const | sf::SoundStream |
getVolume() const | sf::SoundSource |
sf::SoundStream::initialize(unsigned int channelCount, unsigned int sampleRate) | sf::SoundStream | protected
isRelativeToListener() const | sf::SoundSource |
m_source | sf::SoundSource | protected
Music() | sf::Music |
onGetData(Chunk &data) | sf::Music | protectedvirtual
onSeek(Time timeOffset) | sf::Music | protectedvirtual
openFromFile(const std::string &filename) | sf::Music |
openFromMemory(const void *data, std::size_t sizeInBytes) | sf::Music |
openFromStream(InputStream &stream) | sf::Music |
pause() | sf::SoundStream |
Paused enum value | sf::SoundSource |
play() | sf::SoundStream |
Playing enum value | sf::SoundSource |
setAttenuation(float attenuation) | sf::SoundSource |
setLoop(bool loop) | sf::SoundStream |
setMinDistance(float distance) | sf::SoundSource |
setPitch(float pitch) | sf::SoundSource |
setPlayingOffset(Time timeOffset) | sf::SoundStream |
setPosition(float x, float y, float z) | sf::SoundSource |
setPosition(const Vector3f &position) | sf::SoundSource |
setRelativeToListener(bool relative) | sf::SoundSource |
setVolume(float volume) | sf::SoundSource |
SoundSource(const SoundSource &copy) | sf::SoundSource |
SoundSource() | sf::SoundSource | protected
SoundStream() | sf::SoundStream | protected
Status enum name | sf::SoundSource |
stop() | sf::SoundStream |
Stopped enum value | sf::SoundSource |
~Music() | sf::Music |
~SoundSource() | sf::SoundSource | virtual
~SoundStream() | sf::SoundStream | virtual


  • sf
  • Mutex
sf::Mutex Member List

This is the complete list of members for sf::Mutex, including all inherited members.

lock() | sf::Mutex |
Mutex() | sf::Mutex |
NonCopyable() | sf::NonCopyable | inlineprivate
unlock() | sf::Mutex |
~Mutex() | sf::Mutex |


  • sf
  • NonCopyable
sf::NonCopyable Member List

This is the complete list of members for sf::NonCopyable, including all inherited members.

NonCopyable() sf::NonCopyable inlineprotected


  • sf
  • Packet
sf::Packet Member List

This is the complete list of members for sf::Packet, including all inherited members.

append(const void *data, std::size_t sizeInBytes) | sf::Packet |
clear() | sf::Packet |
endOfPacket() const | sf::Packet |
getData() const | sf::Packet |
getDataSize() const | sf::Packet |
onReceive(const void *data, std::size_t size) | sf::Packet | protectedvirtual
onSend(std::size_t &size) | sf::Packet | protectedvirtual
operator BoolType() const | sf::Packet |
operator<<(bool data) | sf::Packet |
operator<<(Int8 data) (defined in sf::Packet) | sf::Packet |
operator<<(Uint8 data) (defined in sf::Packet) | sf::Packet |
operator<<(Int16 data) (defined in sf::Packet) | sf::Packet |
operator<<(Uint16 data) (defined in sf::Packet) | sf::Packet |
operator<<(Int32 data) (defined in sf::Packet) | sf::Packet |
operator<<(Uint32 data) (defined in sf::Packet) | sf::Packet |
operator<<(float data) (defined in sf::Packet) | sf::Packet |
operator<<(double data) (defined in sf::Packet) | sf::Packet |
operator<<(const char *data) (defined in sf::Packet) | sf::Packet |
operator<<(const std::string &data) (defined in sf::Packet) | sf::Packet |
operator<<(const wchar_t *data) (defined in sf::Packet) | sf::Packet |
operator<<(const std::wstring &data) (defined in sf::Packet) | sf::Packet |
operator<<(const String &data) (defined in sf::Packet) | sf::Packet |
operator>>(bool &data) | sf::Packet |
operator>>(Int8 &data) (defined in sf::Packet) | sf::Packet |
operator>>(Uint8 &data) (defined in sf::Packet) | sf::Packet |
operator>>(Int16 &data) (defined in sf::Packet) | sf::Packet |
operator>>(Uint16 &data) (defined in sf::Packet) | sf::Packet |
operator>>(Int32 &data) (defined in sf::Packet) | sf::Packet |
operator>>(Uint32 &data) (defined in sf::Packet) | sf::Packet |
operator>>(float &data) (defined in sf::Packet) | sf::Packet |
operator>>(double &data) (defined in sf::Packet) | sf::Packet |
operator>>(char *data) (defined in sf::Packet) | sf::Packet |
operator>>(std::string &data) (defined in sf::Packet) | sf::Packet |
operator>>(wchar_t *data) (defined in sf::Packet) | sf::Packet |
operator>>(std::wstring &data) (defined in sf::Packet) | sf::Packet |
operator>>(String &data) (defined in sf::Packet) | sf::Packet |
Packet() | sf::Packet |
TcpSocket (defined in sf::Packet) | sf::Packet | friend
UdpSocket (defined in sf::Packet) | sf::Packet | friend
~Packet() | sf::Packet | virtual


  • sf
  • Rect
sf::Rect< T > Member List

This is the complete list of members for sf::Rect< T >, including all inherited members.

contains(T x, T y) const | sf::Rect< T > |
contains(const Vector2< T > &point) const | sf::Rect< T > |
height | sf::Rect< T > |
intersects(const Rect< T > &rectangle) const | sf::Rect< T > |
intersects(const Rect< T > &rectangle, Rect< T > &intersection) const | sf::Rect< T > |
left | sf::Rect< T > |
operator!=(const Rect< T > &left, const Rect< T > &right) | sf::Rect< T > | related
operator==(const Rect< T > &left, const Rect< T > &right) | sf::Rect< T > | related
Rect() | sf::Rect< T > |
Rect(T rectLeft, T rectTop, T rectWidth, T rectHeight) | sf::Rect< T > |
Rect(const Vector2< T > &position, const Vector2< T > &size) | sf::Rect< T > |
Rect(const Rect< U > &rectangle) | sf::Rect< T > | explicit
Rect() (defined in sf::Rect< T >) | sf::Rect< T > |
Rect(T rectLeft, T rectTop, T rectWidth, T rectHeight) (defined in sf::Rect< T >) | sf::Rect< T > |
Rect(const Vector2< T > &position, const Vector2< T > &size) (defined in sf::Rect< T >) | sf::Rect< T > |
Rect(const Rect< U > &rectangle) (defined in sf::Rect< T >) | sf::Rect< T > |
top | sf::Rect< T > |
width | sf::Rect< T > |


  • sf
  • RectangleShape
sf::RectangleShape Member List

This is the complete list of members for sf::RectangleShape, including all inherited members.

getFillColor() const | sf::Shape |
getGlobalBounds() const | sf::Shape |
getInverseTransform() const | sf::Transformable |
getLocalBounds() const | sf::Shape |
getOrigin() const | sf::Transformable |
getOutlineColor() const | sf::Shape |
getOutlineThickness() const | sf::Shape |
getPoint(unsigned int index) const | sf::RectangleShape | virtual
getPointCount() const | sf::RectangleShape | virtual
getPosition() const | sf::Transformable |
getRotation() const | sf::Transformable |
getScale() const | sf::Transformable |
getSize() const | sf::RectangleShape |
getTexture() const | sf::Shape |
getTextureRect() const | sf::Shape |
getTransform() const | sf::Transformable |
move(float offsetX, float offsetY) | sf::Transformable |
move(const Vector2f &offset) | sf::Transformable |
RectangleShape(const Vector2f &size=Vector2f(0, 0)) | sf::RectangleShape | explicit
rotate(float angle) | sf::Transformable |
scale(float factorX, float factorY) | sf::Transformable |
scale(const Vector2f &factor) | sf::Transformable |
setFillColor(const Color &color) | sf::Shape |
setOrigin(float x, float y) | sf::Transformable |
setOrigin(const Vector2f &origin) | sf::Transformable |
setOutlineColor(const Color &color) | sf::Shape |
setOutlineThickness(float thickness) | sf::Shape |
setPosition(float x, float y) | sf::Transformable |
setPosition(const Vector2f &position) | sf::Transformable |
setRotation(float angle) | sf::Transformable |
setScale(float factorX, float factorY) | sf::Transformable |
setScale(const Vector2f &factors) | sf::Transformable |
setSize(const Vector2f &size) | sf::RectangleShape |
setTexture(const Texture *texture, bool resetRect=false) | sf::Shape |
setTextureRect(const IntRect &rect) | sf::Shape |
Shape() | sf::Shape | protected
Transformable() | sf::Transformable |
update() | sf::Shape | protected
~Drawable() | sf::Drawable | inlinevirtual
~Shape() | sf::Shape | virtual
~Transformable() | sf::Transformable | virtual


  • sf
  • RenderStates
sf::RenderStates Member List

This is the complete list of members for sf::RenderStates, including all inherited members.

blendMode | sf::RenderStates |
Default | sf::RenderStates | static
RenderStates() | sf::RenderStates |
RenderStates(BlendMode theBlendMode) | sf::RenderStates |
RenderStates(const Transform &theTransform) | sf::RenderStates |
RenderStates(const Texture *theTexture) | sf::RenderStates |
RenderStates(const Shader *theShader) | sf::RenderStates |
RenderStates(BlendMode theBlendMode, const Transform &theTransform, const Texture *theTexture, const Shader *theShader) | sf::RenderStates |
shader | sf::RenderStates |
texture | sf::RenderStates |
transform | sf::RenderStates |


  • sf
  • RenderTarget
sf::RenderTarget Member List

This is the complete list of members for sf::RenderTarget, including all inherited members.

clear(const Color &color=Color(0, 0, 0, 255)) | sf::RenderTarget |
draw(const Drawable &drawable, const RenderStates &states=RenderStates::Default) | sf::RenderTarget |
draw(const Vertex *vertices, unsigned int vertexCount, PrimitiveType type, const RenderStates &states=RenderStates::Default) | sf::RenderTarget |
getDefaultView() const | sf::RenderTarget |
getSize() const =0 | sf::RenderTarget | pure virtual
getView() const | sf::RenderTarget |
getViewport(const View &view) const | sf::RenderTarget |
initialize() | sf::RenderTarget | protected
mapCoordsToPixel(const Vector2f &point) const | sf::RenderTarget |
mapCoordsToPixel(const Vector2f &point, const View &view) const | sf::RenderTarget |
mapPixelToCoords(const Vector2i &point) const | sf::RenderTarget |
mapPixelToCoords(const Vector2i &point, const View &view) const | sf::RenderTarget |
NonCopyable() | sf::NonCopyable | inlineprivate
popGLStates() | sf::RenderTarget |
pushGLStates() | sf::RenderTarget |
RenderTarget() | sf::RenderTarget | protected
resetGLStates() | sf::RenderTarget |
setView(const View &view) | sf::RenderTarget |
~RenderTarget() | sf::RenderTarget | virtual


  • sf
  • RenderTexture
sf::RenderTexture Member List

This is the complete list of members for sf::RenderTexture, including all inherited members.

clear(const Color &color=Color(0, 0, 0, 255)) | sf::RenderTarget |
create(unsigned int width, unsigned int height, bool depthBuffer=false) | sf::RenderTexture |
display() | sf::RenderTexture |
draw(const Drawable &drawable, const RenderStates &states=RenderStates::Default) | sf::RenderTarget |
draw(const Vertex *vertices, unsigned int vertexCount, PrimitiveType type, const RenderStates &states=RenderStates::Default) | sf::RenderTarget |
getDefaultView() const | sf::RenderTarget |
getSize() const | sf::RenderTexture | virtual
getTexture() const | sf::RenderTexture |
getView() const | sf::RenderTarget |
getViewport(const View &view) const | sf::RenderTarget |
initialize() | sf::RenderTarget | protected
isRepeated() const | sf::RenderTexture |
isSmooth() const | sf::RenderTexture |
mapCoordsToPixel(const Vector2f &point) const | sf::RenderTarget |
mapCoordsToPixel(const Vector2f &point, const View &view) const | sf::RenderTarget |
mapPixelToCoords(const Vector2i &point) const | sf::RenderTarget |
mapPixelToCoords(const Vector2i &point, const View &view) const | sf::RenderTarget |
popGLStates() | sf::RenderTarget |
pushGLStates() | sf::RenderTarget |
RenderTarget() | sf::RenderTarget | protected
RenderTexture() | sf::RenderTexture |
resetGLStates() | sf::RenderTarget |
setActive(bool active=true) | sf::RenderTexture |
setRepeated(bool repeated) | sf::RenderTexture |
setSmooth(bool smooth) | sf::RenderTexture |
setView(const View &view) | sf::RenderTarget |
~RenderTarget() | sf::RenderTarget | virtual
~RenderTexture() | sf::RenderTexture | virtual


  • sf
  • RenderWindow
sf::RenderWindow Member List

This is the complete list of members for sf::RenderWindow, including all inherited members.

capture() const | sf::RenderWindow |
clear(const Color &color=Color(0, 0, 0, 255)) | sf::RenderTarget |
close() | sf::Window |
create(VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings()) | sf::Window |
create(WindowHandle handle, const ContextSettings &settings=ContextSettings()) | sf::Window |
display() | sf::Window |
draw(const Drawable &drawable, const RenderStates &states=RenderStates::Default) | sf::RenderTarget |
draw(const Vertex *vertices, unsigned int vertexCount, PrimitiveType type, const RenderStates &states=RenderStates::Default) | sf::RenderTarget |
getDefaultView() const | sf::RenderTarget |
getPosition() const | sf::Window |
getSettings() const | sf::Window |
getSize() const | sf::RenderWindow | virtual
getSystemHandle() const | sf::Window |
getView() const | sf::RenderTarget |
getViewport(const View &view) const | sf::RenderTarget |
initialize() | sf::RenderTarget | protected
isOpen() const | sf::Window |
mapCoordsToPixel(const Vector2f &point) const | sf::RenderTarget |
mapCoordsToPixel(const Vector2f &point, const View &view) const | sf::RenderTarget |
mapPixelToCoords(const Vector2i &point) const | sf::RenderTarget |
mapPixelToCoords(const Vector2i &point, const View &view) const | sf::RenderTarget |
NonCopyable() | sf::NonCopyable | inlineprotected
onCreate() | sf::RenderWindow | protectedvirtual
onResize() | sf::RenderWindow | protectedvirtual
pollEvent(Event &event) | sf::Window |
popGLStates() | sf::RenderTarget |
pushGLStates() | sf::RenderTarget |
RenderTarget() | sf::RenderTarget | protected
RenderWindow() | sf::RenderWindow |
RenderWindow(VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings()) | sf::RenderWindow |
RenderWindow(WindowHandle handle, const ContextSettings &settings=ContextSettings()) | sf::RenderWindow | explicit
resetGLStates() | sf::RenderTarget |
setActive(bool active=true) const | sf::Window |
setFramerateLimit(unsigned int limit) | sf::Window |
setIcon(unsigned int width, unsigned int height, const Uint8 *pixels) | sf::Window |
setJoystickThreshold(float threshold) | sf::Window |
setKeyRepeatEnabled(bool enabled) | sf::Window |
setMouseCursorVisible(bool visible) | sf::Window |
setPosition(const Vector2i &position) | sf::Window |
setSize(const Vector2u size) | sf::Window |
setTitle(const String &title) | sf::Window |
setVerticalSyncEnabled(bool enabled) | sf::Window |
setView(const View &view) | sf::RenderTarget |
setVisible(bool visible) | sf::Window |
waitEvent(Event &event) | sf::Window |
Window() | sf::Window |
Window(VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings()) | sf::Window |
Window(WindowHandle handle, const ContextSettings &settings=ContextSettings()) | sf::Window | explicit
~RenderTarget() | sf::RenderTarget | virtual
~RenderWindow() | sf::RenderWindow | virtual
~Window() | sf::Window | virtual


  • sf
  • Shader
sf::Shader Member List

This is the complete list of members for sf::Shader, including all inherited members.

bind(const Shader *shader) | sf::Shader | static
CurrentTexture (defined in sf::Shader) | sf::Shader | static
ensureGlContext() | sf::GlResource | privatestatic
Fragment enum value | sf::Shader |
GlResource() | sf::GlResource | private
isAvailable() | sf::Shader | static
loadFromFile(const std::string &filename, Type type) | sf::Shader |
loadFromFile(const std::string &vertexShaderFilename, const std::string &fragmentShaderFilename) | sf::Shader |
loadFromMemory(const std::string &shader, Type type) | sf::Shader |
loadFromMemory(const std::string &vertexShader, const std::string &fragmentShader) | sf::Shader |
loadFromStream(InputStream &stream, Type type) | sf::Shader |
loadFromStream(InputStream &vertexShaderStream, InputStream &fragmentShaderStream) | sf::Shader |
NonCopyable() | sf::NonCopyable | inlineprivate
setParameter(const std::string &name, float x) | sf::Shader |
setParameter(const std::string &name, float x, float y) | sf::Shader |
setParameter(const std::string &name, float x, float y, float z) | sf::Shader |
setParameter(const std::string &name, float x, float y, float z, float w) | sf::Shader |
setParameter(const std::string &name, const Vector2f &vector) | sf::Shader |
setParameter(const std::string &name, const Vector3f &vector) | sf::Shader |
setParameter(const std::string &name, const Color &color) | sf::Shader |
setParameter(const std::string &name, const sf::Transform &transform) | sf::Shader |
setParameter(const std::string &name, const Texture &texture) | sf::Shader |
setParameter(const std::string &name, CurrentTextureType) | sf::Shader |
Shader() | sf::Shader |
Type enum name | sf::Shader |
Vertex enum value | sf::Shader |
~GlResource() | sf::GlResource | private
~Shader() | sf::Shader |


  • sf
  • Shape
sf::Shape Member List

This is the complete list of members for sf::Shape, including all inherited members.

getFillColor() const | sf::Shape |
getGlobalBounds() const | sf::Shape |
getInverseTransform() const | sf::Transformable |
getLocalBounds() const | sf::Shape |
getOrigin() const | sf::Transformable |
getOutlineColor() const | sf::Shape |
getOutlineThickness() const | sf::Shape |
getPoint(unsigned int index) const =0 | sf::Shape | pure virtual
getPointCount() const =0 | sf::Shape | pure virtual
getPosition() const | sf::Transformable |
getRotation() const | sf::Transformable |
getScale() const | sf::Transformable |
getTexture() const | sf::Shape |
getTextureRect() const | sf::Shape |
getTransform() const | sf::Transformable |
move(float offsetX, float offsetY) | sf::Transformable |
move(const Vector2f &offset) | sf::Transformable |
rotate(float angle) | sf::Transformable |
scale(float factorX, float factorY) | sf::Transformable |
scale(const Vector2f &factor) | sf::Transformable |
setFillColor(const Color &color) | sf::Shape |
setOrigin(float x, float y) | sf::Transformable |
setOrigin(const Vector2f &origin) | sf::Transformable |
setOutlineColor(const Color &color) | sf::Shape |
setOutlineThickness(float thickness) | sf::Shape |
setPosition(float x, float y) | sf::Transformable |
setPosition(const Vector2f &position) | sf::Transformable |
setRotation(float angle) | sf::Transformable |
setScale(float factorX, float factorY) | sf::Transformable |
setScale(const Vector2f &factors) | sf::Transformable |
setTexture(const Texture *texture, bool resetRect=false) | sf::Shape |
setTextureRect(const IntRect &rect) | sf::Shape |
Shape() | sf::Shape | protected
Transformable() | sf::Transformable |
update() | sf::Shape | protected
~Drawable() | sf::Drawable | inlinevirtual
~Shape() | sf::Shape | virtual
~Transformable() | sf::Transformable | virtual


  • sf
  • Socket
sf::Socket Member List

This is the complete list of members for sf::Socket, including all inherited members.

AnyPort enum value | sf::Socket |
close() | sf::Socket | protected
create() | sf::Socket | protected
create(SocketHandle handle) | sf::Socket | protected
Disconnected enum value | sf::Socket |
Done enum value | sf::Socket |
Error enum value | sf::Socket |
getHandle() const | sf::Socket | protected
isBlocking() const | sf::Socket |
NonCopyable() | sf::NonCopyable | inlineprivate
NotReady enum value | sf::Socket |
setBlocking(bool blocking) | sf::Socket |
Socket(Type type) | sf::Socket | protected
SocketSelector (defined in sf::Socket) | sf::Socket | friend
Status enum name | sf::Socket |
Tcp enum value | sf::Socket | protected
Type enum name | sf::Socket | protected
Udp enum value | sf::Socket | protected
~Socket() | sf::Socket | virtual


  • sf
  • SocketSelector
sf::SocketSelector Member List

This is the complete list of members for sf::SocketSelector, including all inherited members.

add(Socket &socket) | sf::SocketSelector
clear() | sf::SocketSelector
isReady(Socket &socket) const | sf::SocketSelector
operator=(const SocketSelector &right) | sf::SocketSelector
remove(Socket &socket) | sf::SocketSelector
SocketSelector() | sf::SocketSelector
SocketSelector(const SocketSelector &copy) | sf::SocketSelector
wait(Time timeout=Time::Zero) | sf::SocketSelector
~SocketSelector() | sf::SocketSelector


  • sf
  • Sound
sf::Sound Member List

This is the complete list of members for sf::Sound, including all inherited members.

getAttenuation() const | sf::SoundSource |
getBuffer() const | sf::Sound |
getLoop() const | sf::Sound |
getMinDistance() const | sf::SoundSource |
getPitch() const | sf::SoundSource |
getPlayingOffset() const | sf::Sound |
getPosition() const | sf::SoundSource |
getStatus() const | sf::Sound |
getVolume() const | sf::SoundSource |
isRelativeToListener() const | sf::SoundSource |
m_source | sf::SoundSource | protected
operator=(const Sound &right) | sf::Sound |
pause() | sf::Sound |
Paused enum value | sf::SoundSource |
play() | sf::Sound |
Playing enum value | sf::SoundSource |
resetBuffer() | sf::Sound |
setAttenuation(float attenuation) | sf::SoundSource |
setBuffer(const SoundBuffer &buffer) | sf::Sound |
setLoop(bool loop) | sf::Sound |
setMinDistance(float distance) | sf::SoundSource |
setPitch(float pitch) | sf::SoundSource |
setPlayingOffset(Time timeOffset) | sf::Sound |
setPosition(float x, float y, float z) | sf::SoundSource |
setPosition(const Vector3f &position) | sf::SoundSource |
setRelativeToListener(bool relative) | sf::SoundSource |
setVolume(float volume) | sf::SoundSource |
Sound() | sf::Sound |
Sound(const SoundBuffer &buffer) | sf::Sound | explicit
Sound(const Sound &copy) | sf::Sound |
SoundSource(const SoundSource &copy) | sf::SoundSource |
SoundSource() | sf::SoundSource | protected
Status enum name | sf::SoundSource |
stop() | sf::Sound |
Stopped enum value | sf::SoundSource |
~Sound() | sf::Sound |
~SoundSource() | sf::SoundSource | virtual


  • sf
  • SoundBuffer
sf::SoundBuffer Member List

This is the complete list of members for sf::SoundBuffer, including all inherited members.

getChannelCount() const | sf::SoundBuffer |
getDuration() const | sf::SoundBuffer |
getSampleCount() const | sf::SoundBuffer |
getSampleRate() const | sf::SoundBuffer |
getSamples() const | sf::SoundBuffer |
loadFromFile(const std::string &filename) | sf::SoundBuffer |
loadFromMemory(const void *data, std::size_t sizeInBytes) | sf::SoundBuffer |
loadFromSamples(const Int16 *samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate) | sf::SoundBuffer |
loadFromStream(InputStream &stream) | sf::SoundBuffer |
operator=(const SoundBuffer &right) | sf::SoundBuffer |
saveToFile(const std::string &filename) const | sf::SoundBuffer |
Sound (defined in sf::SoundBuffer) | sf::SoundBuffer | friend
SoundBuffer() | sf::SoundBuffer |
SoundBuffer(const SoundBuffer &copy) | sf::SoundBuffer |
~SoundBuffer() | sf::SoundBuffer |


  • sf
  • SoundBufferRecorder
sf::SoundBufferRecorder Member List

This is the complete list of members for sf::SoundBufferRecorder, including all inherited members.

getBuffer() const | sf::SoundBufferRecorder |
getSampleRate() const | sf::SoundRecorder |
isAvailable() | sf::SoundRecorder | static
onProcessSamples(const Int16 *samples, std::size_t sampleCount) | sf::SoundBufferRecorder | protectedvirtual
onStart() | sf::SoundBufferRecorder | protectedvirtual
onStop() | sf::SoundBufferRecorder | protectedvirtual
SoundRecorder() | sf::SoundRecorder | protected
start(unsigned int sampleRate=44100) | sf::SoundRecorder |
stop() | sf::SoundRecorder |
~SoundRecorder() | sf::SoundRecorder | virtual


  • sf
  • SoundRecorder
sf::SoundRecorder Member List

This is the complete list of members for sf::SoundRecorder, including all inherited members.

getSampleRate() const | sf::SoundRecorder |
isAvailable() | sf::SoundRecorder | static
onProcessSamples(const Int16 *samples, std::size_t sampleCount)=0 | sf::SoundRecorder | protectedpure virtual
onStart() | sf::SoundRecorder | protectedvirtual
onStop() | sf::SoundRecorder | protectedvirtual
SoundRecorder() | sf::SoundRecorder | protected
start(unsigned int sampleRate=44100) | sf::SoundRecorder |
stop() | sf::SoundRecorder |
~SoundRecorder() | sf::SoundRecorder | virtual


  • sf
  • SoundSource
sf::SoundSource Member List

This is the complete list of members for sf::SoundSource, including all inherited members.

getAttenuation() const | sf::SoundSource |
getMinDistance() const | sf::SoundSource |
getPitch() const | sf::SoundSource |
getPosition() const | sf::SoundSource |
getStatus() const | sf::SoundSource | protected
getVolume() const | sf::SoundSource |
isRelativeToListener() const | sf::SoundSource |
m_source | sf::SoundSource | protected
Paused enum value | sf::SoundSource |
Playing enum value | sf::SoundSource |
setAttenuation(float attenuation) | sf::SoundSource |
setMinDistance(float distance) | sf::SoundSource |
setPitch(float pitch) | sf::SoundSource |
setPosition(float x, float y, float z) | sf::SoundSource |
setPosition(const Vector3f &position) | sf::SoundSource |
setRelativeToListener(bool relative) | sf::SoundSource |
setVolume(float volume) | sf::SoundSource |
SoundSource(const SoundSource &copy) | sf::SoundSource |
SoundSource() | sf::SoundSource | protected
Status enum name | sf::SoundSource |
Stopped enum value | sf::SoundSource |
~SoundSource() | sf::SoundSource | virtual


  • sf
  • SoundStream
sf::SoundStream Member List

This is the complete list of members for sf::SoundStream, including all inherited members.

getAttenuation() const | sf::SoundSource |
getChannelCount() const | sf::SoundStream |
getLoop() const | sf::SoundStream |
getMinDistance() const | sf::SoundSource |
getPitch() const | sf::SoundSource |
getPlayingOffset() const | sf::SoundStream |
getPosition() const | sf::SoundSource |
getSampleRate() const | sf::SoundStream |
getStatus() const | sf::SoundStream |
getVolume() const | sf::SoundSource |
initialize(unsigned int channelCount, unsigned int sampleRate) | sf::SoundStream | protected
isRelativeToListener() const | sf::SoundSource |
m_source | sf::SoundSource | protected
onGetData(Chunk &data)=0 | sf::SoundStream | protectedpure virtual
onSeek(Time timeOffset)=0 | sf::SoundStream | protectedpure virtual
pause() | sf::SoundStream |
Paused enum value | sf::SoundSource |
play() | sf::SoundStream |
Playing enum value | sf::SoundSource |
setAttenuation(float attenuation) | sf::SoundSource |
setLoop(bool loop) | sf::SoundStream |
setMinDistance(float distance) | sf::SoundSource |
setPitch(float pitch) | sf::SoundSource |
setPlayingOffset(Time timeOffset) | sf::SoundStream |
setPosition(float x, float y, float z) | sf::SoundSource |
setPosition(const Vector3f &position) | sf::SoundSource |
setRelativeToListener(bool relative) | sf::SoundSource |
setVolume(float volume) | sf::SoundSource |
SoundSource(const SoundSource &copy) | sf::SoundSource |
SoundSource() | sf::SoundSource | protected
SoundStream() | sf::SoundStream | protected
Status enum name | sf::SoundSource |
stop() | sf::SoundStream |
Stopped enum value | sf::SoundSource |
~SoundSource() | sf::SoundSource | virtual
~SoundStream() | sf::SoundStream | virtual


  • sf
  • Sprite
sf::Sprite Member List

This is the complete list of members for sf::Sprite, including all inherited members.

getColor() const | sf::Sprite |
getGlobalBounds() const | sf::Sprite |
getInverseTransform() const | sf::Transformable |
getLocalBounds() const | sf::Sprite |
getOrigin() const | sf::Transformable |
getPosition() const | sf::Transformable |
getRotation() const | sf::Transformable |
getScale() const | sf::Transformable |
getTexture() const | sf::Sprite |
getTextureRect() const | sf::Sprite |
getTransform() const | sf::Transformable |
move(float offsetX, float offsetY) | sf::Transformable |
move(const Vector2f &offset) | sf::Transformable |
rotate(float angle) | sf::Transformable |
scale(float factorX, float factorY) | sf::Transformable |
scale(const Vector2f &factor) | sf::Transformable |
setColor(const Color &color) | sf::Sprite |
setOrigin(float x, float y) | sf::Transformable |
setOrigin(const Vector2f &origin) | sf::Transformable |
setPosition(float x, float y) | sf::Transformable |
setPosition(const Vector2f &position) | sf::Transformable |
setRotation(float angle) | sf::Transformable |
setScale(float factorX, float factorY) | sf::Transformable |
setScale(const Vector2f &factors) | sf::Transformable |
setTexture(const Texture &texture, bool resetRect=false) | sf::Sprite |
setTextureRect(const IntRect &rectangle) | sf::Sprite |
Sprite() | sf::Sprite |
Sprite(const Texture &texture) | sf::Sprite | explicit
Sprite(const Texture &texture, const IntRect &rectangle) | sf::Sprite |
Transformable() | sf::Transformable |
~Drawable() | sf::Drawable | inlinevirtual
~Transformable() | sf::Transformable | virtual


  • sf
  • String
sf::String Member List

This is the complete list of members for sf::String, including all inherited members.

begin() | sf::String |
begin() const | sf::String |
clear() | sf::String |
ConstIterator typedef | sf::String |
end() | sf::String |
end() const | sf::String |
erase(std::size_t position, std::size_t count=1) | sf::String |
find(const String &str, std::size_t start=0) const | sf::String |
getData() const | sf::String |
getSize() const | sf::String |
insert(std::size_t position, const String &str) | sf::String |
InvalidPos | sf::String | static
isEmpty() const | sf::String |
Iterator typedef | sf::String |
operator std::string() const | sf::String |
operator std::wstring() const | sf::String |
operator!=(const String &left, const String &right) | sf::String | related
operator+(const String &left, const String &right) | sf::String | related
operator+=(const String &right) | sf::String |
operator< (defined in sf::String) | sf::String | friend
operator<(const String &left, const String &right) | sf::String | related
operator<=(const String &left, const String &right) | sf::String | related
operator=(const String &right) | sf::String |
operator== (defined in sf::String) | sf::String | friend
operator==(const String &left, const String &right) | sf::String | related
operator>(const String &left, const String &right) | sf::String | related
operator>=(const String &left, const String &right) | sf::String | related
operator[](std::size_t index) const | sf::String |
operator[](std::size_t index) | sf::String |
String() | sf::String |
String(char ansiChar, const std::locale &locale=std::locale()) | sf::String |
String(wchar_t wideChar) | sf::String |
String(Uint32 utf32Char) | sf::String |
String(const char *ansiString, const std::locale &locale=std::locale()) | sf::String |
String(const std::string &ansiString, const std::locale &locale=std::locale()) | sf::String |
String(const wchar_t *wideString) | sf::String |
String(const std::wstring &wideString) | sf::String |
String(const Uint32 *utf32String) | sf::String |
String(const std::basic_string< Uint32 > &utf32String) | sf::String |
String(const String &copy) | sf::String |
toAnsiString(const std::locale &locale=std::locale()) const | sf::String |
toWideString() const | sf::String |


  • sf
  • TcpListener
sf::TcpListener Member List

This is the complete list of members for sf::TcpListener, including all inherited members.

accept(TcpSocket &socket) | sf::TcpListener |
AnyPort enum value | sf::Socket |
close() | sf::TcpListener |
create() | sf::Socket | protected
create(SocketHandle handle) | sf::Socket | protected
Disconnected enum value | sf::Socket |
Done enum value | sf::Socket |
Error enum value | sf::Socket |
getHandle() const | sf::Socket | protected
getLocalPort() const | sf::TcpListener |
isBlocking() const | sf::Socket |
listen(unsigned short port) | sf::TcpListener |
NotReady enum value | sf::Socket |
setBlocking(bool blocking) | sf::Socket |
Socket(Type type) | sf::Socket | protected
Status enum name | sf::Socket |
Tcp enum value | sf::Socket | protected
TcpListener() | sf::TcpListener |
Type enum name | sf::Socket | protected
Udp enum value | sf::Socket | protected
~Socket() | sf::Socket | virtual


  • sf
  • TcpSocket
sf::TcpSocket Member List

This is the complete list of members for sf::TcpSocket, including all inherited members.

AnyPort enum value | sf::Socket |
close() | sf::Socket | protected
connect(const IpAddress &remoteAddress, unsigned short remotePort, Time timeout=Time::Zero) | sf::TcpSocket |
create() | sf::Socket | protected
create(SocketHandle handle) | sf::Socket | protected
disconnect() | sf::TcpSocket |
Disconnected enum value | sf::Socket |
Done enum value | sf::Socket |
Error enum value | sf::Socket |
getHandle() const | sf::Socket | protected
getLocalPort() const | sf::TcpSocket |
getRemoteAddress() const | sf::TcpSocket |
getRemotePort() const | sf::TcpSocket |
isBlocking() const | sf::Socket |
NotReady enum value | sf::Socket |
receive(void *data, std::size_t size, std::size_t &received) | sf::TcpSocket |
receive(Packet &packet) | sf::TcpSocket |
send(const void *data, std::size_t size) | sf::TcpSocket |
send(Packet &packet) | sf::TcpSocket |
setBlocking(bool blocking) | sf::Socket |
Socket(Type type) | sf::Socket | protected
Status enum name | sf::Socket |
Tcp enum value | sf::Socket | protected
TcpListener (defined in sf::TcpSocket) | sf::TcpSocket | friend
TcpSocket() | sf::TcpSocket |
Type enum name | sf::Socket | protected
Udp enum value | sf::Socket | protected
~Socket() | sf::Socket | virtual


  • sf
  • Text
sf::Text Member List

This is the complete list of members for sf::Text, including all inherited members.

Bold enum value | sf::Text |
findCharacterPos(std::size_t index) const | sf::Text |
getCharacterSize() const | sf::Text |
getColor() const | sf::Text |
getFont() const | sf::Text |
getGlobalBounds() const | sf::Text |
getInverseTransform() const | sf::Transformable |
getLocalBounds() const | sf::Text |
getOrigin() const | sf::Transformable |
getPosition() const | sf::Transformable |
getRotation() const | sf::Transformable |
getScale() const | sf::Transformable |
getString() const | sf::Text |
getStyle() const | sf::Text |
getTransform() const | sf::Transformable |
Italic enum value | sf::Text |
move(float offsetX, float offsetY) | sf::Transformable |
move(const Vector2f &offset) | sf::Transformable |
Regular enum value | sf::Text |
rotate(float angle) | sf::Transformable |
scale(float factorX, float factorY) | sf::Transformable |
scale(const Vector2f &factor) | sf::Transformable |
setCharacterSize(unsigned int size) | sf::Text |
setColor(const Color &color) | sf::Text |
setFont(const Font &font) | sf::Text |
setOrigin(float x, float y) | sf::Transformable |
setOrigin(const Vector2f &origin) | sf::Transformable |
setPosition(float x, float y) | sf::Transformable |
setPosition(const Vector2f &position) | sf::Transformable |
setRotation(float angle) | sf::Transformable |
setScale(float factorX, float factorY) | sf::Transformable |
setScale(const Vector2f &factors) | sf::Transformable |
setString(const String &string) | sf::Text |
setStyle(Uint32 style) | sf::Text |
Style enum name | sf::Text |
Text() | sf::Text |
Text(const String &string, const Font &font, unsigned int characterSize=30) | sf::Text |
Transformable() | sf::Transformable |
Underlined enum value | sf::Text |
~Drawable() | sf::Drawable | inlinevirtual
~Transformable() | sf::Transformable | virtual


  • sf
  • Texture
sf::Texture Member List

This is the complete list of members for sf::Texture, including all inherited members.

bind(const Texture *texture, CoordinateType coordinateType=Normalized) | sf::Texture | static
CoordinateType enum name | sf::Texture |
copyToImage() const | sf::Texture |
create(unsigned int width, unsigned int height) | sf::Texture |
ensureGlContext() | sf::GlResource | privatestatic
getMaximumSize() | sf::Texture | static
getSize() const | sf::Texture |
GlResource() | sf::GlResource | private
isRepeated() const | sf::Texture |
isSmooth() const | sf::Texture |
loadFromFile(const std::string &filename, const IntRect &area=IntRect()) | sf::Texture |
loadFromImage(const Image &image, const IntRect &area=IntRect()) | sf::Texture |
loadFromMemory(const void *data, std::size_t size, const IntRect &area=IntRect()) | sf::Texture |
loadFromStream(sf::InputStream &stream, const IntRect &area=IntRect()) | sf::Texture |
Normalized enum value | sf::Texture |
operator=(const Texture &right) | sf::Texture |
Pixels enum value | sf::Texture |
RenderTarget (defined in sf::Texture) | sf::Texture | friend
RenderTexture (defined in sf::Texture) | sf::Texture | friend
setRepeated(bool repeated) | sf::Texture |
setSmooth(bool smooth) | sf::Texture |
Texture() | sf::Texture |
Texture(const Texture &copy) | sf::Texture |
update(const Uint8 *pixels) | sf::Texture |
update(const Uint8 *pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y) | sf::Texture |
update(const Image &image) | sf::Texture |
update(const Image &image, unsigned int x, unsigned int y) | sf::Texture |
update(const Window &window) | sf::Texture |
update(const Window &window, unsigned int x, unsigned int y) | sf::Texture |
~GlResource() | sf::GlResource | private
~Texture() | sf::Texture |


  • sf
  • Thread
sf::Thread Member List

This is the complete list of members for sf::Thread, including all inherited members.

launch() | sf::Thread |
NonCopyable() | sf::NonCopyable | inlineprivate
terminate() | sf::Thread |
Thread(F function) | sf::Thread |
Thread(F function, A argument) | sf::Thread |
Thread(void(C::*function)(), C *object) | sf::Thread |
Thread(F functor) (defined in sf::Thread) | sf::Thread |
Thread(F function, A argument) (defined in sf::Thread) | sf::Thread |
Thread(void(C::*function)(), C *object) (defined in sf::Thread) | sf::Thread |
wait() | sf::Thread |
~Thread() | sf::Thread |


  • sf
  • ThreadLocal
sf::ThreadLocal Member List

This is the complete list of members for sf::ThreadLocal, including all inherited members.

getValue() const | sf::ThreadLocal |
NonCopyable() | sf::NonCopyable | inlineprivate
setValue(void *value) | sf::ThreadLocal |
ThreadLocal(void *value=NULL) | sf::ThreadLocal |
~ThreadLocal() | sf::ThreadLocal |


  • sf
  • ThreadLocalPtr
sf::ThreadLocalPtr< T > Member List

This is the complete list of members for sf::ThreadLocalPtr< T >, including all inherited members.

getValue() const | sf::ThreadLocal | private
operator T *() const | sf::ThreadLocalPtr< T > |
operator*() const | sf::ThreadLocalPtr< T > |
operator->() const | sf::ThreadLocalPtr< T > |
operator=(T *value) | sf::ThreadLocalPtr< T > |
operator=(const ThreadLocalPtr< T > &right) | sf::ThreadLocalPtr< T > |
setValue(void *value) | sf::ThreadLocal | private
ThreadLocal(void *value=NULL) | sf::ThreadLocal | private
ThreadLocalPtr(T *value=NULL) | sf::ThreadLocalPtr< T > |
~ThreadLocal() | sf::ThreadLocal | private


  • sf
  • Time
sf::Time Member List

This is the complete list of members for sf::Time, including all inherited members.

asMicroseconds() const | sf::Time |
asMilliseconds() const | sf::Time |
asSeconds() const | sf::Time |
microseconds (defined in sf::Time) | sf::Time | friend
microseconds(Int64 amount) | sf::Time | related
milliseconds (defined in sf::Time) | sf::Time | friend
milliseconds(Int32 amount) | sf::Time | related
operator!=(Time left, Time right) | sf::Time | related
operator*(Time left, float right) | sf::Time | related
operator*(Time left, Int64 right) | sf::Time | related
operator*(float left, Time right) | sf::Time | related
operator*(Int64 left, Time right) | sf::Time | related
operator*=(Time &left, float right) | sf::Time | related
operator*=(Time &left, Int64 right) | sf::Time | related
operator+(Time left, Time right) | sf::Time | related
operator+=(Time &left, Time right) | sf::Time | related
operator-(Time right) | sf::Time | related
operator-(Time left, Time right) | sf::Time | related
operator-=(Time &left, Time right) | sf::Time | related
operator/(Time left, float right) | sf::Time | related
operator/(Time left, Int64 right) | sf::Time | related
operator/=(Time &left, float right) | sf::Time | related
operator/=(Time &left, Int64 right) | sf::Time | related
operator<(Time left, Time right) | sf::Time | related
operator<=(Time left, Time right) | sf::Time | related
operator==(Time left, Time right) | sf::Time | related
operator>(Time left, Time right) | sf::Time | related
operator>=(Time left, Time right) | sf::Time | related
seconds (defined in sf::Time) | sf::Time | friend
seconds(float amount) | sf::Time | related
Time() | sf::Time |
Zero | sf::Time | static


  • sf
  • Transform
sf::Transform Member List

This is the complete list of members for sf::Transform, including all inherited members.

combine(const Transform &transform) | sf::Transform |
getInverse() const | sf::Transform |
getMatrix() const | sf::Transform |
Identity | sf::Transform | static
operator*(const Transform &left, const Transform &right) | sf::Transform | related
operator*(const Transform &left, const Vector2f &right) | sf::Transform | related
operator*=(Transform &left, const Transform &right) | sf::Transform | related
rotate(float angle) | sf::Transform |
rotate(float angle, float centerX, float centerY) | sf::Transform |
rotate(float angle, const Vector2f &center) | sf::Transform |
scale(float scaleX, float scaleY) | sf::Transform |
scale(float scaleX, float scaleY, float centerX, float centerY) | sf::Transform |
scale(const Vector2f &factors) | sf::Transform |
scale(const Vector2f &factors, const Vector2f &center) | sf::Transform |
Transform() | sf::Transform |
Transform(float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22) | sf::Transform |
transformPoint(float x, float y) const | sf::Transform |
transformPoint(const Vector2f &point) const | sf::Transform |
transformRect(const FloatRect &rectangle) const | sf::Transform |
translate(float x, float y) | sf::Transform |
translate(const Vector2f &offset) | sf::Transform |


  • sf
  • Transformable
sf::Transformable Member List

This is the complete list of members for sf::Transformable, including all inherited members.

getInverseTransform() const | sf::Transformable |
getOrigin() const | sf::Transformable |
getPosition() const | sf::Transformable |
getRotation() const | sf::Transformable |
getScale() const | sf::Transformable |
getTransform() const | sf::Transformable |
move(float offsetX, float offsetY) | sf::Transformable |
move(const Vector2f &offset) | sf::Transformable |
rotate(float angle) | sf::Transformable |
scale(float factorX, float factorY) | sf::Transformable |
scale(const Vector2f &factor) | sf::Transformable |
setOrigin(float x, float y) | sf::Transformable |
setOrigin(const Vector2f &origin) | sf::Transformable |
setPosition(float x, float y) | sf::Transformable |
setPosition(const Vector2f &position) | sf::Transformable |
setRotation(float angle) | sf::Transformable |
setScale(float factorX, float factorY) | sf::Transformable |
setScale(const Vector2f &factors) | sf::Transformable |
Transformable() | sf::Transformable |
~Transformable() | sf::Transformable | virtual


  • sf
  • UdpSocket
sf::UdpSocket Member List

This is the complete list of members for sf::UdpSocket, including all inherited members.

AnyPort enum value | sf::Socket |
bind(unsigned short port) | sf::UdpSocket |
close() | sf::Socket | protected
create() | sf::Socket | protected
create(SocketHandle handle) | sf::Socket | protected
Disconnected enum value | sf::Socket |
Done enum value | sf::Socket |
Error enum value | sf::Socket |
getHandle() const | sf::Socket | protected
getLocalPort() const | sf::UdpSocket |
isBlocking() const | sf::Socket |
MaxDatagramSize enum value | sf::UdpSocket |
NotReady enum value | sf::Socket |
receive(void *data, std::size_t size, std::size_t &received, IpAddress &remoteAddress, unsigned short &remotePort) | sf::UdpSocket |
receive(Packet &packet, IpAddress &remoteAddress, unsigned short &remotePort) | sf::UdpSocket |
send(const void *data, std::size_t size, const IpAddress &remoteAddress, unsigned short remotePort) | sf::UdpSocket |
send(Packet &packet, const IpAddress &remoteAddress, unsigned short remotePort) | sf::UdpSocket |
setBlocking(bool blocking) | sf::Socket |
Socket(Type type) | sf::Socket | protected
Status enum name | sf::Socket |
Tcp enum value | sf::Socket | protected
Type enum name | sf::Socket | protected
Udp enum value | sf::Socket | protected
UdpSocket() | sf::UdpSocket |
unbind() | sf::UdpSocket |
~Socket() | sf::Socket | virtual


  • sf
  • Utf< 8 >
sf::Utf< 8 > Member List

This is the complete list of members for sf::Utf< 8 >, including all inherited members.

count(In begin, In end) | sf::Utf< 8 > | static
decode(In begin, In end, Uint32 &output, Uint32 replacement=0) | sf::Utf< 8 > | static
encode(Uint32 input, Out output, Uint8 replacement=0) | sf::Utf< 8 > | static
fromAnsi(In begin, In end, Out output, const std::locale &locale=std::locale()) | sf::Utf< 8 > | static
fromLatin1(In begin, In end, Out output) | sf::Utf< 8 > | static
fromWide(In begin, In end, Out output) | sf::Utf< 8 > | static
next(In begin, In end) | sf::Utf< 8 > | static
toAnsi(In begin, In end, Out output, char replacement=0, const std::locale &locale=std::locale()) | sf::Utf< 8 > | static
toLatin1(In begin, In end, Out output, char replacement=0) | sf::Utf< 8 > | static
toUtf16(In begin, In end, Out output) | sf::Utf< 8 > | static
toUtf32(In begin, In end, Out output) | sf::Utf< 8 > | static
toUtf8(In begin, In end, Out output) | sf::Utf< 8 > | static
toWide(In begin, In end, Out output, wchar_t replacement=0) | sf::Utf< 8 > | static


  • sf
  • Utf< 16 >
sf::Utf< 16 > Member List

This is the complete list of members for sf::Utf< 16 >, including all inherited members.

count(In begin, In end) | sf::Utf< 16 > | static
decode(In begin, In end, Uint32 &output, Uint32 replacement=0) | sf::Utf< 16 > | static
encode(Uint32 input, Out output, Uint16 replacement=0) | sf::Utf< 16 > | static
fromAnsi(In begin, In end, Out output, const std::locale &locale=std::locale()) | sf::Utf< 16 > | static
fromLatin1(In begin, In end, Out output) | sf::Utf< 16 > | static
fromWide(In begin, In end, Out output) | sf::Utf< 16 > | static
next(In begin, In end) | sf::Utf< 16 > | static
toAnsi(In begin, In end, Out output, char replacement=0, const std::locale &locale=std::locale()) | sf::Utf< 16 > | static
toLatin1(In begin, In end, Out output, char replacement=0) | sf::Utf< 16 > | static
toUtf16(In begin, In end, Out output) | sf::Utf< 16 > | static
toUtf32(In begin, In end, Out output) | sf::Utf< 16 > | static
toUtf8(In begin, In end, Out output) | sf::Utf< 16 > | static
toWide(In begin, In end, Out output, wchar_t replacement=0) | sf::Utf< 16 > | static


  • sf
  • Utf< 32 >
sf::Utf< 32 > Member List

This is the complete list of members for sf::Utf< 32 >, including all inherited members.

count(In begin, In end) | sf::Utf< 32 > | static
decode(In begin, In end, Uint32 &output, Uint32 replacement=0) | sf::Utf< 32 > | static
decodeAnsi(In input, const std::locale &locale=std::locale()) | sf::Utf< 32 > | static
decodeWide(In input) | sf::Utf< 32 > | static
encode(Uint32 input, Out output, Uint32 replacement=0) | sf::Utf< 32 > | static
encodeAnsi(Uint32 codepoint, Out output, char replacement=0, const std::locale &locale=std::locale()) | sf::Utf< 32 > | static
encodeWide(Uint32 codepoint, Out output, wchar_t replacement=0) | sf::Utf< 32 > | static
fromAnsi(In begin, In end, Out output, const std::locale &locale=std::locale()) | sf::Utf< 32 > | static
fromLatin1(In begin, In end, Out output) | sf::Utf< 32 > | static
fromWide(In begin, In end, Out output) | sf::Utf< 32 > | static
next(In begin, In end) | sf::Utf< 32 > | static
toAnsi(In begin, In end, Out output, char replacement=0, const std::locale &locale=std::locale()) | sf::Utf< 32 > | static
toLatin1(In begin, In end, Out output, char replacement=0) | sf::Utf< 32 > | static
toUtf16(In begin, In end, Out output) | sf::Utf< 32 > | static
toUtf32(In begin, In end, Out output) | sf::Utf< 32 > | static
toUtf8(In begin, In end, Out output) | sf::Utf< 32 > | static
toWide(In begin, In end, Out output, wchar_t replacement=0) | sf::Utf< 32 > | static


  • sf
  • Vector2
sf::Vector2< T > Member List

This is the complete list of members for sf::Vector2< T >, including all inherited members.

operator!=(const Vector2< T > &left, const Vector2< T > &right) | sf::Vector2< T > | related
operator*(const Vector2< T > &left, T right) | sf::Vector2< T > | related
operator*(T left, const Vector2< T > &right) | sf::Vector2< T > | related
operator*=(Vector2< T > &left, T right) | sf::Vector2< T > | related
operator+(const Vector2< T > &left, const Vector2< T > &right) | sf::Vector2< T > | related
operator+=(Vector2< T > &left, const Vector2< T > &right) | sf::Vector2< T > | related
operator-(const Vector2< T > &right) | sf::Vector2< T > | related
operator-(const Vector2< T > &left, const Vector2< T > &right) | sf::Vector2< T > | related
operator-=(Vector2< T > &left, const Vector2< T > &right) | sf::Vector2< T > | related
operator/(const Vector2< T > &left, T right) | sf::Vector2< T > | related
operator/=(Vector2< T > &left, T right) | sf::Vector2< T > | related
operator==(const Vector2< T > &left, const Vector2< T > &right) | sf::Vector2< T > | related
Vector2() | sf::Vector2< T > |
Vector2(T X, T Y) | sf::Vector2< T > |
Vector2(const Vector2< U > &vector) | sf::Vector2< T > | explicit
Vector2() (defined in sf::Vector2< T >) | sf::Vector2< T > | inline
Vector2(T X, T Y) (defined in sf::Vector2< T >) | sf::Vector2< T > | inline
Vector2(const Vector2< U > &vector) (defined in sf::Vector2< T >) | sf::Vector2< T > | inline
x | sf::Vector2< T > |
y | sf::Vector2< T > |


  • sf
  • Vector3
sf::Vector3< T > Member List

This is the complete list of members for sf::Vector3< T >, including all inherited members.

operator!=(const Vector3< T > &left, const Vector3< T > &right) | sf::Vector3< T > | related
operator*(const Vector3< T > &left, T right) | sf::Vector3< T > | related
operator*(T left, const Vector3< T > &right) | sf::Vector3< T > | related
operator*=(Vector3< T > &left, T right) | sf::Vector3< T > | related
operator+(const Vector3< T > &left, const Vector3< T > &right) | sf::Vector3< T > | related
operator+=(Vector3< T > &left, const Vector3< T > &right) | sf::Vector3< T > | related
operator-(const Vector3< T > &left) | sf::Vector3< T > | related
operator-(const Vector3< T > &left, const Vector3< T > &right) | sf::Vector3< T > | related
operator-=(Vector3< T > &left, const Vector3< T > &right) | sf::Vector3< T > | related
operator/(const Vector3< T > &left, T right) | sf::Vector3< T > | related
operator/=(Vector3< T > &left, T right) | sf::Vector3< T > | related
operator==(const Vector3< T > &left, const Vector3< T > &right) | sf::Vector3< T > | related
Vector3() | sf::Vector3< T > |
Vector3(T X, T Y, T Z) | sf::Vector3< T > |
Vector3(const Vector3< U > &vector) | sf::Vector3< T > | explicit
Vector3() (defined in sf::Vector3< T >) | sf::Vector3< T > | inline
Vector3(T X, T Y, T Z) (defined in sf::Vector3< T >) | sf::Vector3< T > | inline
Vector3(const Vector3< U > &vector) (defined in sf::Vector3< T >) | sf::Vector3< T > | inline
x | sf::Vector3< T > |
y | sf::Vector3< T > |
z | sf::Vector3< T > |


  • sf
  • Vertex
sf::Vertex Member List

This is the complete list of members for sf::Vertex, including all inherited members.

color | sf::Vertex
position | sf::Vertex
texCoords | sf::Vertex
Vertex() | sf::Vertex
Vertex(const Vector2f &thePosition) | sf::Vertex
Vertex(const Vector2f &thePosition, const Color &theColor) | sf::Vertex
Vertex(const Vector2f &thePosition, const Vector2f &theTexCoords) | sf::Vertex
Vertex(const Vector2f &thePosition, const Color &theColor, const Vector2f &theTexCoords) | sf::Vertex


  • sf
  • VertexArray
sf::VertexArray Member List

This is the complete list of members for sf::VertexArray, including all inherited members.

append(const Vertex &vertex) | sf::VertexArray |
clear() | sf::VertexArray |
getBounds() const | sf::VertexArray |
getPrimitiveType() const | sf::VertexArray |
getVertexCount() const | sf::VertexArray |
operator[](unsigned int index) | sf::VertexArray |
operator[](unsigned int index) const | sf::VertexArray |
resize(unsigned int vertexCount) | sf::VertexArray |
setPrimitiveType(PrimitiveType type) | sf::VertexArray |
VertexArray() | sf::VertexArray |
VertexArray(PrimitiveType type, unsigned int vertexCount=0) | sf::VertexArray | explicit
~Drawable() | sf::Drawable | inlinevirtual


  • sf
  • VideoMode
sf::VideoMode Member List

This is the complete list of members for sf::VideoMode, including all inherited members.

bitsPerPixel | sf::VideoMode |
getDesktopMode() | sf::VideoMode | static
getFullscreenModes() | sf::VideoMode | static
height | sf::VideoMode |
isValid() const | sf::VideoMode |
operator!=(const VideoMode &left, const VideoMode &right) | sf::VideoMode | related
operator<(const VideoMode &left, const VideoMode &right) | sf::VideoMode | related
operator<=(const VideoMode &left, const VideoMode &right) | sf::VideoMode | related
operator==(const VideoMode &left, const VideoMode &right) | sf::VideoMode | related
operator>(const VideoMode &left, const VideoMode &right) | sf::VideoMode | related
operator>=(const VideoMode &left, const VideoMode &right) | sf::VideoMode | related
VideoMode() | sf::VideoMode |
VideoMode(unsigned int modeWidth, unsigned int modeHeight, unsigned int modeBitsPerPixel=32) | sf::VideoMode |
width | sf::VideoMode |


  • sf
  • View
sf::View Member List

This is the complete list of members for sf::View, including all inherited members.

getCenter() const | sf::View |
getInverseTransform() const | sf::View |
getRotation() const | sf::View |
getSize() const | sf::View |
getTransform() const | sf::View |
getViewport() const | sf::View |
move(float offsetX, float offsetY) | sf::View |
move(const Vector2f &offset) | sf::View |
reset(const FloatRect &rectangle) | sf::View |
rotate(float angle) | sf::View |
setCenter(float x, float y) | sf::View |
setCenter(const Vector2f &center) | sf::View |
setRotation(float angle) | sf::View |
setSize(float width, float height) | sf::View |
setSize(const Vector2f &size) | sf::View |
setViewport(const FloatRect &viewport) | sf::View |
View() | sf::View |
View(const FloatRect &rectangle) | sf::View | explicit
View(const Vector2f &center, const Vector2f &size) | sf::View |
zoom(float factor) | sf::View |


  • sf
  • Window
sf::Window Member List

This is the complete list of members for sf::Window, including all inherited members.

close() | sf::Window |
create(VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings()) | sf::Window |
create(WindowHandle handle, const ContextSettings &settings=ContextSettings()) | sf::Window |
display() | sf::Window |
ensureGlContext() | sf::GlResource | privatestatic
getPosition() const | sf::Window |
getSettings() const | sf::Window |
getSize() const | sf::Window |
getSystemHandle() const | sf::Window |
GlResource() | sf::GlResource | private
isOpen() const | sf::Window |
NonCopyable() | sf::NonCopyable | inlineprivate
onCreate() | sf::Window | protectedvirtual
onResize() | sf::Window | protectedvirtual
pollEvent(Event &event) | sf::Window |
setActive(bool active=true) const | sf::Window |
setFramerateLimit(unsigned int limit) | sf::Window |
setIcon(unsigned int width, unsigned int height, const Uint8 *pixels) | sf::Window |
setJoystickThreshold(float threshold) | sf::Window |
setKeyRepeatEnabled(bool enabled) | sf::Window |
setMouseCursorVisible(bool visible) | sf::Window |
setPosition(const Vector2i &position) | sf::Window |
setSize(const Vector2u size) | sf::Window |
setTitle(const String &title) | sf::Window |
setVerticalSyncEnabled(bool enabled) | sf::Window |
setVisible(bool visible) | sf::Window |
waitEvent(Event &event) | sf::Window |
Window() | sf::Window |
Window(VideoMode mode, const String &title, Uint32 style=Style::Default, const ContextSettings &settings=ContextSettings()) | sf::Window |
Window(WindowHandle handle, const ContextSettings &settings=ContextSettings()) | sf::Window | explicit
~GlResource() | sf::GlResource | private
~Window() | sf::Window | virtual


  • include
  • SFML
  • Audio
Audio Directory Reference

Files

file | Audio/Export.hpp [code]
file | Listener.hpp [code]
file | Music.hpp [code]
file | Sound.hpp [code]
file | SoundBuffer.hpp [code]
file | SoundBufferRecorder.hpp [code]
file | SoundRecorder.hpp [code]
file | SoundSource.hpp [code]
file | SoundStream.hpp [code]


  • include
  • SFML
  • System
System Directory Reference

Files

file | Clock.hpp [code]
file | Err.hpp [code]
file | System/Export.hpp [code]
file | InputStream.hpp [code]
file | Lock.hpp [code]
file | Mutex.hpp [code]
file | NonCopyable.hpp [code]
file | Sleep.hpp [code]
file | String.hpp [code]
file | Thread.hpp [code]
file | Thread.inl [code]
file | ThreadLocal.hpp [code]
file | ThreadLocalPtr.hpp [code]
file | ThreadLocalPtr.inl [code]
file | Time.hpp [code]
file | Utf.hpp [code]
file | Utf.inl [code]
file | Vector2.hpp [code]
file | Vector2.inl [code]
file | Vector3.hpp [code]
file | Vector3.inl [code]


  • include
  • SFML
  • Window
Window Directory Reference

Files

file | Context.hpp [code]
file | ContextSettings.hpp [code]
file | Event.hpp [code]
file | Window/Export.hpp [code]
file | GlResource.hpp [code]
file | Joystick.hpp [code]
file | Keyboard.hpp [code]
file | Mouse.hpp [code]
file | VideoMode.hpp [code]
file | Window/Window.hpp [code]
file | WindowHandle.hpp [code]
file | WindowStyle.hpp [code]


  • include
  • SFML
SFML Directory Reference

Directories

directory | Audio
directory | Graphics
directory | Network
directory | System
directory | Window

Files

file | Audio.hpp [code]
file | Config.hpp [code]
file | Graphics.hpp [code]
file | Network.hpp [code]
file | OpenGL.hpp [code]
file | System.hpp [code]
file | Window.hpp [code]


  • doc
doc Directory Reference

Files

file mainpage.hpp [code]


  • include
  • SFML
  • Graphics
Graphics Directory Reference

Files

file | BlendMode.hpp [code]
file | CircleShape.hpp [code]
file | Color.hpp [code]
file | ConvexShape.hpp [code]
file | Drawable.hpp [code]
file | Graphics/Export.hpp [code]
file | Font.hpp [code]
file | Glyph.hpp [code]
file | Image.hpp [code]
file | PrimitiveType.hpp [code]
file | Rect.hpp [code]
file | Rect.inl [code]
file | RectangleShape.hpp [code]
file | RenderStates.hpp [code]
file | RenderTarget.hpp [code]
file | RenderTexture.hpp [code]
file | RenderWindow.hpp [code]
file | Shader.hpp [code]
file | Shape.hpp [code]
file | Sprite.hpp [code]
file | Text.hpp [code]
file | Texture.hpp [code]
file | Transform.hpp [code]
file | Transformable.hpp [code]
file | Vertex.hpp [code]
file | VertexArray.hpp [code]
file | View.hpp [code]


  • include
  • SFML
  • Network
Network Directory Reference

Files

file | Network/Export.hpp [code]
file | Ftp.hpp [code]
file | Http.hpp [code]
file | IpAddress.hpp [code]
file | Packet.hpp [code]
file | Socket.hpp [code]
file | SocketHandle.hpp [code]
file | SocketSelector.hpp [code]
file | TcpListener.hpp [code]
file | TcpSocket.hpp [code]
file | UdpSocket.hpp [code]


  • include
include Directory Reference

Directories

directory SFML


SFML Documentation

Welcome

Welcome to the official SFML documentation. Here you will find a detailed view of all the SFML classes and functions.
If you are looking for tutorials, you can visit the official website at www.sfml-dev.org.

Short example

Here is a short example, to show you how simple it is to use SFML :

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
// Load a sprite to display
sf::Texture texture;
if (!texture.loadFromFile("cute_image.jpg"))
return EXIT_FAILURE;
sf::Sprite sprite(texture);
// Create a graphical text to display
sf::Font font;
if (!font.loadFromFile("arial.ttf"))
return EXIT_FAILURE;
sf::Text text("Hello SFML", font, 50);
// Load a music to play
sf::Music music;
if (!music.openFromFile("nice_music.ogg"))
return EXIT_FAILURE;
// Play the music
music.play();
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window : exit
if (event.type == sf::Event::Closed)
window.close();
}
// Clear screen
window.clear();
// Draw the sprite
window.draw(sprite);
// Draw the string
window.draw(text);
// Update the window
window.display();
}
return EXIT_SUCCESS;
}


  • sf
  • Event
  • JoystickButtonEvent
sf::Event::JoystickButtonEvent Member List

This is the complete list of members for sf::Event::JoystickButtonEvent, including all inherited members.

button | sf::Event::JoystickButtonEvent
joystickId | sf::Event::JoystickButtonEvent


  • sf
  • Event
  • JoystickConnectEvent
sf::Event::JoystickConnectEvent Member List

This is the complete list of members for sf::Event::JoystickConnectEvent, including all inherited members.

joystickId sf::Event::JoystickConnectEvent


  • sf
  • Event
  • JoystickMoveEvent
sf::Event::JoystickMoveEvent Member List

This is the complete list of members for sf::Event::JoystickMoveEvent, including all inherited members.

axis | sf::Event::JoystickMoveEvent
joystickId | sf::Event::JoystickMoveEvent
position | sf::Event::JoystickMoveEvent


  • sf
  • Event
  • KeyEvent
sf::Event::KeyEvent Member List

This is the complete list of members for sf::Event::KeyEvent, including all inherited members.

alt | sf::Event::KeyEvent
code | sf::Event::KeyEvent
control | sf::Event::KeyEvent
shift | sf::Event::KeyEvent
system | sf::Event::KeyEvent


  • sf
  • Event
  • MouseButtonEvent
sf::Event::MouseButtonEvent Member List

This is the complete list of members for sf::Event::MouseButtonEvent, including all inherited members.

button | sf::Event::MouseButtonEvent
x | sf::Event::MouseButtonEvent
y | sf::Event::MouseButtonEvent


  • sf
  • Event
  • MouseMoveEvent
sf::Event::MouseMoveEvent Member List

This is the complete list of members for sf::Event::MouseMoveEvent, including all inherited members.

x | sf::Event::MouseMoveEvent
y | sf::Event::MouseMoveEvent


  • sf
  • Event
  • MouseWheelEvent
sf::Event::MouseWheelEvent Member List

This is the complete list of members for sf::Event::MouseWheelEvent, including all inherited members.

delta | sf::Event::MouseWheelEvent
x | sf::Event::MouseWheelEvent
y | sf::Event::MouseWheelEvent


  • sf
  • Event
  • SizeEvent
sf::Event::SizeEvent Member List

This is the complete list of members for sf::Event::SizeEvent, including all inherited members.

height | sf::Event::SizeEvent
width | sf::Event::SizeEvent


  • sf
  • Event
  • TextEvent
sf::Event::TextEvent Member List

This is the complete list of members for sf::Event::TextEvent, including all inherited members.

unicode sf::Event::TextEvent


  • sf
  • SoundStream
  • Chunk
sf::SoundStream::Chunk Member List

This is the complete list of members for sf::SoundStream::Chunk, including all inherited members.

sampleCount | sf::SoundStream::Chunk
samples | sf::SoundStream::Chunk