Updated documentation
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1239 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
49ebb40c4d
commit
1f3d7b6d0c
52 changed files with 2077 additions and 2021 deletions
|
@ -53,7 +53,7 @@ public :
|
|||
/// Construct the music with a buffer size
|
||||
///
|
||||
/// \param bufferSize : Size of the internal buffer, expressed in number of samples
|
||||
/// (ie. size taken by the music in memory) (44100 by default)
|
||||
/// (ie. size taken by the music in memory)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Music(std::size_t bufferSize = 44100);
|
||||
|
|
|
@ -65,11 +65,11 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
/// Construct the sound from its parameters
|
||||
///
|
||||
/// \param buffer : Sound buffer to play (NULL by default)
|
||||
/// \param loop : Loop flag (false by default)
|
||||
/// \param pitch : Value of the pitch (1 by default)
|
||||
/// \param volume : Volume (100 by default)
|
||||
/// \param position : Position (0, 0, 0 by default)
|
||||
/// \param buffer : Sound buffer to play
|
||||
/// \param loop : Loop flag
|
||||
/// \param pitch : Value of the pitch
|
||||
/// \param volume : Volume
|
||||
/// \param position : Position
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Sound(const SoundBuffer& buffer, bool loop = false, float pitch = 1.f, float volume = 100.f, const Vector3f& position = Vector3f(0, 0, 0));
|
||||
|
|
|
@ -53,7 +53,7 @@ public :
|
|||
/// \param red : Red component (0 .. 255)
|
||||
/// \param green : Green component (0 .. 255)
|
||||
/// \param blue : Blue component (0 .. 255)
|
||||
/// \param alpha : Alpha (opacity) component (0 .. 255) (255 by default)
|
||||
/// \param alpha : Alpha (opacity) component (0 .. 255)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = 255);
|
||||
|
|
|
@ -63,10 +63,10 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
///
|
||||
/// \param position : Position of the object ((0, 0) by default)
|
||||
/// \param scale : Scale factor ((1, 1) by default)
|
||||
/// \param rotation : Orientation, in degrees (0 by default)
|
||||
/// \param color : Color of the object (white by default)
|
||||
/// \param position : Position of the object
|
||||
/// \param scale : Scale factor
|
||||
/// \param rotation : Orientation, in degrees
|
||||
/// \param color : Color of the object
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Drawable(const Vector2f& position = Vector2f(0, 0), const Vector2f& scale = Vector2f(1, 1), float rotation = 0.f, const Color& color = Color(255, 255, 255));
|
||||
|
|
|
@ -65,7 +65,7 @@ public :
|
|||
/// Load the font from a file
|
||||
///
|
||||
/// \param filename : Font file to load
|
||||
/// \param charSize : Size of characters in bitmap - the bigger, the higher quality (30 by default)
|
||||
/// \param charSize : Size of characters in bitmap - the bigger, the higher quality
|
||||
/// \param charset : Characters set to generate (by default, contains the ISO-8859-1 printable characters)
|
||||
///
|
||||
/// \return True if loading was successful
|
||||
|
@ -78,7 +78,7 @@ public :
|
|||
///
|
||||
/// \param data : Pointer to the data to load
|
||||
/// \param sizeInBytes : Size of the data, in bytes
|
||||
/// \param charSize : Size of characters in bitmap - the bigger, the higher quality (30 by default)
|
||||
/// \param charSize : Size of characters in bitmap - the bigger, the higher quality
|
||||
/// \param charset : Characters set to generate (by default, contains the ISO-8859-1 printable characters)
|
||||
///
|
||||
/// \return True if loading was successful
|
||||
|
|
|
@ -67,7 +67,7 @@ public :
|
|||
///
|
||||
/// \param width : Image width
|
||||
/// \param height : Image height
|
||||
/// \param color : Image color (black by default)
|
||||
/// \param color : Image color
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Image(unsigned int width, unsigned int height, const Color& color = Color(0, 0, 0));
|
||||
|
@ -136,7 +136,7 @@ public :
|
|||
///
|
||||
/// \param width : Image width
|
||||
/// \param height : Image height
|
||||
/// \param color : Image color (black by default)
|
||||
/// \param color : Image color
|
||||
///
|
||||
/// \return True if creation was successful
|
||||
///
|
||||
|
@ -147,7 +147,7 @@ public :
|
|||
/// Create transparency mask from a specified colorkey
|
||||
///
|
||||
/// \param transparentColor : Color to become transparent
|
||||
/// \param alpha : Alpha value to assign to transparent pixels (0 by default)
|
||||
/// \param alpha : Alpha value to assign to transparent pixels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void CreateMaskFromColor(const Color& transparentColor, Uint8 alpha = 0);
|
||||
|
@ -160,8 +160,8 @@ public :
|
|||
/// \param source : Source image to copy
|
||||
/// \param destX : X coordinate of the destination position
|
||||
/// \param destY : Y coordinate of the destination position
|
||||
/// \param sourceRect : Sub-rectangle of the source image to copy (empty by default - entire image)
|
||||
/// \param applyAlpha : Should the copy take in account the source transparency? (false by default)
|
||||
/// \param sourceRect : Sub-rectangle of the source image to copy
|
||||
/// \param applyAlpha : Should the copy take in account the source transparency?
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Copy(const Image& source, unsigned int destX, unsigned int destY, const IntRect& sourceRect = IntRect(0, 0, 0, 0), bool applyAlpha = false);
|
||||
|
|
|
@ -76,7 +76,7 @@ public :
|
|||
/// Activate of deactivate the render-image as the current target
|
||||
/// for rendering
|
||||
///
|
||||
/// \param active : True to activate, false to deactivate (true by default)
|
||||
/// \param active : True to activate, false to deactivate
|
||||
///
|
||||
/// \return True if operation was successful, false otherwise
|
||||
///
|
||||
|
|
|
@ -57,8 +57,8 @@ public :
|
|||
///
|
||||
/// \param mode : Video mode to use
|
||||
/// \param title : Title of the window
|
||||
/// \param style : Window style (Resize | Close by default)
|
||||
/// \param settings : Additional settings for the underlying OpenGL context (see default constructor for default values)
|
||||
/// \param style : Window style
|
||||
/// \param settings : Additional settings for the underlying OpenGL context
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderWindow(VideoMode mode, const std::string& title, unsigned long style = Style::Resize | Style::Close, const ContextSettings& settings = ContextSettings());
|
||||
|
|
|
@ -54,8 +54,8 @@ public :
|
|||
/// Add a point to the shape
|
||||
///
|
||||
/// \param x, y : Position of the point
|
||||
/// \param color : Color of the point (white by default)
|
||||
/// \param outlineColor : Outline color of the point (black by default)
|
||||
/// \param color : Color of the point
|
||||
/// \param outlineColor : Outline color of the point
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void AddPoint(float x, float y, const Color& color = Color(255, 255, 255), const Color& outlineColor = Color(0, 0, 0));
|
||||
|
@ -64,8 +64,8 @@ public :
|
|||
/// Add a point to the shape
|
||||
///
|
||||
/// \param position : Position of the point
|
||||
/// \param color : Color of the point (white by default)
|
||||
/// \param outlineColor : Outline color of the point (black by default)
|
||||
/// \param color : Color of the point
|
||||
/// \param outlineColor : Outline color of the point
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void AddPoint(const Vector2f& position, const Color& color = Color(255, 255, 255), const Color& outlineColor = Color(0, 0, 0));
|
||||
|
@ -186,8 +186,8 @@ public :
|
|||
/// \param p2x, p2y : Position second point
|
||||
/// \param thickness : Line thickness
|
||||
/// \param color : Color used to draw the line
|
||||
/// \param outline : Outline width (0 by default)
|
||||
/// \param outlineColor : Color used to draw the outline (black by default)
|
||||
/// \param outline : Outline width
|
||||
/// \param outlineColor : Color used to draw the outline
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Shape Line(float p1x, float p1y, float p2x, float p2y, float thickness, const Color& color, float outline = 0.f, const Color& outlineColor = sf::Color(0, 0, 0));
|
||||
|
@ -199,8 +199,8 @@ public :
|
|||
/// \param p2 : Position second point
|
||||
/// \param thickness : Line thickness
|
||||
/// \param color : Color used to draw the line
|
||||
/// \param outline : Outline width (0 by default)
|
||||
/// \param outlineColor : Color used to draw the outline (black by default)
|
||||
/// \param outline : Outline width
|
||||
/// \param outlineColor : Color used to draw the outline
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Shape Line(const Vector2f& p1, const Vector2f& p2, float thickness, const Color& color, float outline = 0.f, const Color& outlineColor = sf::Color(0, 0, 0));
|
||||
|
@ -211,8 +211,8 @@ public :
|
|||
/// \param p1x, p1y : Position of the first point
|
||||
/// \param p2x, p2y : Position second point
|
||||
/// \param color : Color used to fill the rectangle
|
||||
/// \param outline : Outline width (0 by default)
|
||||
/// \param outlineColor : Color used to draw the outline (black by default)
|
||||
/// \param outline : Outline width
|
||||
/// \param outlineColor : Color used to draw the outline
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Shape Rectangle(float p1x, float p1y, float p2x, float p2y, const Color& color, float outline = 0.f, const Color& outlineColor = sf::Color(0, 0, 0));
|
||||
|
@ -223,8 +223,8 @@ public :
|
|||
/// \param p1 : Position of the first point
|
||||
/// \param p2 : Position second point
|
||||
/// \param color : Color used to fill the rectangle
|
||||
/// \param outline : Outline width (0 by default)
|
||||
/// \param outlineColor : Color used to draw the outline (black by default)
|
||||
/// \param outline : Outline width
|
||||
/// \param outlineColor : Color used to draw the outline
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Shape Rectangle(const Vector2f& p1, const Vector2f& p2, const Color& color, float outline = 0.f, const Color& outlineColor = sf::Color(0, 0, 0));
|
||||
|
@ -235,8 +235,8 @@ public :
|
|||
/// \param x, y : Position of the center
|
||||
/// \param radius : Radius
|
||||
/// \param color : Color used to fill the circle
|
||||
/// \param outline : Outline width (0 by default)
|
||||
/// \param outlineColor : Color used to draw the outline (black by default)
|
||||
/// \param outline : Outline width
|
||||
/// \param outlineColor : Color used to draw the outline
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Shape Circle(float x, float y, float radius, const Color& color, float outline = 0.f, const Color& outlineColor = sf::Color(0, 0, 0));
|
||||
|
@ -247,8 +247,8 @@ public :
|
|||
/// \param center : Position of the center
|
||||
/// \param radius : Radius
|
||||
/// \param color : Color used to fill the circle
|
||||
/// \param outline : Outline width (0 by default)
|
||||
/// \param outlineColor : Color used to draw the outline (black by default)
|
||||
/// \param outline : Outline width
|
||||
/// \param outlineColor : Color used to draw the outline
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Shape Circle(const Vector2f& center, float radius, const Color& color, float outline = 0.f, const Color& outlineColor = sf::Color(0, 0, 0));
|
||||
|
|
|
@ -55,10 +55,10 @@ public :
|
|||
/// Construct the sprite from a source image
|
||||
///
|
||||
/// \param image : Image of the sprite
|
||||
/// \param position : Position of the sprite (0, 0 by default)
|
||||
/// \param scale : Scale factor (1, 1 by default)
|
||||
/// \param rotation : Orientation, in degrees (0 by default)
|
||||
/// \param color : Color of the sprite (white by default)
|
||||
/// \param position : Position of the sprite
|
||||
/// \param scale : Scale factor
|
||||
/// \param rotation : Orientation, in degrees
|
||||
/// \param color : Color of the sprite
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Sprite(const Image& image, const Vector2f& position = Vector2f(0, 0), const Vector2f& scale = Vector2f(1, 1), float rotation = 0.f, const Color& color = Color(255, 255, 255, 255));
|
||||
|
@ -67,7 +67,7 @@ public :
|
|||
/// Change the image of the sprite
|
||||
///
|
||||
/// \param image : New image
|
||||
/// \param adjustToNewSize : If true, the SubRect of the sprite will be adjusted to the size of the new image (false by default)
|
||||
/// \param adjustToNewSize : If true, the SubRect of the sprite will be adjusted to the size of the new image
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetImage(const Image& image, bool adjustToNewSize = false);
|
||||
|
|
|
@ -66,8 +66,8 @@ public :
|
|||
/// Construct the string from any kind of text
|
||||
///
|
||||
/// \param text : Text assigned to the string
|
||||
/// \param font : Font used to draw the string (SFML built-in font by default)
|
||||
/// \param size : Characters size (30 by default)
|
||||
/// \param font : Font used to draw the string
|
||||
/// \param size : Characters size
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit String(const Unicode::Text& text, const Font& font = Font::GetDefaultFont(), float size = 30.f);
|
||||
|
|
|
@ -136,8 +136,8 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
///
|
||||
/// \param code : Response status code (InvalidResponse by default)
|
||||
/// \param message : Response message (empty by default)
|
||||
/// \param code : Response status code
|
||||
/// \param message : Response message
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response(Status code = InvalidResponse, const std::string& message = "");
|
||||
|
@ -387,7 +387,7 @@ public :
|
|||
///
|
||||
/// \param distantFile : Path of the distant file to download
|
||||
/// \param destPath : Where to put to file on the local computer
|
||||
/// \param mode : Transfer mode (binary by default)
|
||||
/// \param mode : Transfer mode
|
||||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
|
@ -399,7 +399,7 @@ public :
|
|||
///
|
||||
/// \param localFile : Path of the local file to upload
|
||||
/// \param destPath : Where to put to file on the server
|
||||
/// \param mode : Transfer mode (binary by default)
|
||||
/// \param mode : Transfer mode
|
||||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
|
@ -412,7 +412,7 @@ private :
|
|||
/// Send a command to the FTP server
|
||||
///
|
||||
/// \param command : Command to send
|
||||
/// \param parameter : Command parameter ("" by default)
|
||||
/// \param parameter : Command parameter
|
||||
///
|
||||
/// \return Server response to the request
|
||||
///
|
||||
|
|
|
@ -68,9 +68,9 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
///
|
||||
/// \param method : Method to use for the request (Get by default)
|
||||
/// \param URI : Target URI ("/" by default -- index page)
|
||||
/// \param body : Content of the request's body (empty by default)
|
||||
/// \param method : Method to use for the request
|
||||
/// \param URI : Target URI
|
||||
/// \param body : Content of the request's body
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Request(Method method = Get, const std::string& URI = "/", const std::string& body = "");
|
||||
|
|
|
@ -88,7 +88,7 @@ public :
|
|||
/// This function will block if the socket is blocking
|
||||
///
|
||||
/// \param connected : Socket containing the connection with the connected client
|
||||
/// \param address : Pointer to an address to fill with client infos (NULL by default)
|
||||
/// \param address : Pointer to an address to fill with client infos
|
||||
///
|
||||
/// \return Status code
|
||||
///
|
||||
|
|
|
@ -53,7 +53,7 @@ public :
|
|||
/// \brief Construct the thread from a function pointer
|
||||
///
|
||||
/// \param function Entry point of the thread
|
||||
/// \param userData Data to pass to the thread function (NULL by default)
|
||||
/// \param userData Data to pass to the thread function
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Thread(FuncType function, void* userData = NULL);
|
||||
|
|
|
@ -51,7 +51,7 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
/// \brief Default constructor
|
||||
///
|
||||
/// \param value Optional value to initalize the variable (NULL by default)
|
||||
/// \param value Optional value to initalize the variable
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
ThreadLocal(void* value = NULL);
|
||||
|
|
|
@ -45,7 +45,7 @@ public :
|
|||
////////////////////////////////////////////////////////////
|
||||
/// \brief Default constructor
|
||||
///
|
||||
/// \param value Optional value to initalize the variable (NULL by default)
|
||||
/// \param value Optional value to initalize the variable
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
ThreadLocalPtr(T* value = NULL);
|
||||
|
|
|
@ -115,7 +115,7 @@ public :
|
|||
/// \param end : Iterator pointing to the end of the input sequence
|
||||
/// \param output : Iterator pointing to the beginning of the output sequence
|
||||
/// \param replacement : Replacement character for characters not convertible to output encoding ('?' by default -- use 0 to use no replacement character)
|
||||
/// \param locale : Locale to use for conversion (uses the current one by default)
|
||||
/// \param locale : Locale to use for conversion
|
||||
///
|
||||
/// \return Iterator to the end of the output sequence which has been written
|
||||
///
|
||||
|
@ -130,7 +130,7 @@ public :
|
|||
/// \param begin : Iterator pointing to the beginning of the input sequence
|
||||
/// \param end : Iterator pointing to the end of the input sequence
|
||||
/// \param output : Iterator pointing to the beginning of the output sequence
|
||||
/// \param locale : Locale to use for conversion (uses the current one by default)
|
||||
/// \param locale : Locale to use for conversion
|
||||
///
|
||||
/// \return Iterator to the end of the output sequence which has been written
|
||||
///
|
||||
|
|
|
@ -40,56 +40,33 @@ namespace priv
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Class holding a valid drawing context
|
||||
/// \brief Class holding a valid drawing context
|
||||
///
|
||||
/// If you need to make OpenGL / graphics 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,
|
||||
/// and for most of the classes from the Graphics package.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// \code
|
||||
/// void ThreadFunction(void*)
|
||||
/// {
|
||||
/// sf::Context context;
|
||||
/// // from now on, you have a valid context
|
||||
///
|
||||
/// // you can make OpenGL calls
|
||||
/// glClear(GL_DEPTH_BUFFER_BIT);
|
||||
///
|
||||
/// // as well as using objects from the graphics package
|
||||
/// sf::Image Img;
|
||||
/// Img.LoadFromFile("image.png");
|
||||
/// }
|
||||
/// // the context is automatically deactivated and destroyed
|
||||
/// // by the sf::Context destructor
|
||||
/// \endcode
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API Context : NonCopyable
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor -- creates and activates the context
|
||||
/// \brief Default constructor
|
||||
///
|
||||
/// The constructor creates and activates the context
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Context();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor -- deactivates and destroys the context
|
||||
/// \brief Destructor
|
||||
///
|
||||
/// The desctructor deactivates and destroys the context
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
~Context();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Activate or deactivate explicitely the context
|
||||
/// \brief Activate or deactivate explicitely the context
|
||||
///
|
||||
/// \param active : True to activate, false to deactivate
|
||||
/// \param active True to activate, false to deactivate
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetActive(bool active);
|
||||
|
@ -106,3 +83,43 @@ private :
|
|||
|
||||
|
||||
#endif // SFML_CONTEXT_HPP
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \class sf::Context
|
||||
///
|
||||
/// If you need to make OpenGL / graphics 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,
|
||||
/// and for most of the classes from the Graphics package.
|
||||
///
|
||||
/// 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:
|
||||
/// \code
|
||||
/// void ThreadFunction(void*)
|
||||
/// {
|
||||
/// sf::Context context;
|
||||
/// // from now on, you have a valid context
|
||||
///
|
||||
/// // you can make OpenGL calls
|
||||
/// glClear(GL_DEPTH_BUFFER_BIT);
|
||||
///
|
||||
/// // as well as using objects from the graphics package
|
||||
/// sf::Image image;
|
||||
/// image.LoadFromFile("image.png");
|
||||
/// }
|
||||
/// // the context is automatically deactivated and destroyed
|
||||
/// // by the sf::Context destructor
|
||||
/// \endcode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,17 +29,17 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Structure defining the settings of the OpenGL
|
||||
/// context attached to a window
|
||||
/// \brief Structure defining the settings of the OpenGL
|
||||
/// context attached to a window
|
||||
////////////////////////////////////////////////////////////
|
||||
struct ContextSettings
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
/// \brief Default constructor
|
||||
///
|
||||
/// \param depth : Depth buffer bits (24 by default)
|
||||
/// \param stencil : Stencil buffer bits (8 by default)
|
||||
/// \param antialiasing : Antialiasing level (0 by default)
|
||||
/// \param depth Depth buffer bits
|
||||
/// \param stencil Stencil buffer bits
|
||||
/// \param antialiasing Antialiasing level
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit ContextSettings(unsigned int depth = 24, unsigned int stencil = 8, unsigned int antialiasing = 0) :
|
||||
|
|
|
@ -33,80 +33,81 @@
|
|||
|
||||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Definition of key codes for keyboard events
|
||||
////////////////////////////////////////////////////////////
|
||||
namespace Key
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Definition of key codes for keyboard events
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Code
|
||||
{
|
||||
A = 'a',
|
||||
B = 'b',
|
||||
C = 'c',
|
||||
D = 'd',
|
||||
E = 'e',
|
||||
F = 'f',
|
||||
G = 'g',
|
||||
H = 'h',
|
||||
I = 'i',
|
||||
J = 'j',
|
||||
K = 'k',
|
||||
L = 'l',
|
||||
M = 'm',
|
||||
N = 'n',
|
||||
O = 'o',
|
||||
P = 'p',
|
||||
Q = 'q',
|
||||
R = 'r',
|
||||
S = 's',
|
||||
T = 't',
|
||||
U = 'u',
|
||||
V = 'v',
|
||||
W = 'w',
|
||||
X = 'x',
|
||||
Y = 'y',
|
||||
Z = 'z',
|
||||
Num0 = '0',
|
||||
Num1 = '1',
|
||||
Num2 = '2',
|
||||
Num3 = '3',
|
||||
Num4 = '4',
|
||||
Num5 = '5',
|
||||
Num6 = '6',
|
||||
Num7 = '7',
|
||||
Num8 = '8',
|
||||
Num9 = '9',
|
||||
Escape = 256,
|
||||
LControl,
|
||||
LShift,
|
||||
LAlt,
|
||||
LSystem, ///< OS specific key (left side) : windows (Win and Linux), apple (MacOS), ...
|
||||
RControl,
|
||||
RShift,
|
||||
RAlt,
|
||||
RSystem, ///< OS specific key (right side) : windows (Win and Linux), apple (MacOS), ...
|
||||
Menu,
|
||||
LBracket, ///< [
|
||||
RBracket, ///< ]
|
||||
SemiColon, ///< ;
|
||||
Comma, ///< ,
|
||||
Period, ///< .
|
||||
Quote, ///< '
|
||||
Slash, ///< /
|
||||
BackSlash,
|
||||
Tilde, ///< ~
|
||||
Equal, ///< =
|
||||
Dash, ///< -
|
||||
Space,
|
||||
Return,
|
||||
Back,
|
||||
Tab,
|
||||
PageUp,
|
||||
PageDown,
|
||||
End,
|
||||
Home,
|
||||
Insert,
|
||||
Delete,
|
||||
A = 'a', ///< The A key
|
||||
B = 'b', ///< The B key
|
||||
C = 'c', ///< The C key
|
||||
D = 'd', ///< The D key
|
||||
E = 'e', ///< The E key
|
||||
F = 'f', ///< The F key
|
||||
G = 'g', ///< The G key
|
||||
H = 'h', ///< The H key
|
||||
I = 'i', ///< The I key
|
||||
J = 'j', ///< The J key
|
||||
K = 'k', ///< The K key
|
||||
L = 'l', ///< The L key
|
||||
M = 'm', ///< The M key
|
||||
N = 'n', ///< The N key
|
||||
O = 'o', ///< The O key
|
||||
P = 'p', ///< The P key
|
||||
Q = 'q', ///< The Q key
|
||||
R = 'r', ///< The R key
|
||||
S = 's', ///< The S key
|
||||
T = 't', ///< The T key
|
||||
U = 'u', ///< The U key
|
||||
V = 'v', ///< The V key
|
||||
W = 'w', ///< The W key
|
||||
X = 'x', ///< The X key
|
||||
Y = 'y', ///< The Y key
|
||||
Z = 'z', ///< The Z key
|
||||
Num0 = '0', ///< The 0 key
|
||||
Num1 = '1', ///< The 1 key
|
||||
Num2 = '2', ///< The 2 key
|
||||
Num3 = '3', ///< The 3 key
|
||||
Num4 = '4', ///< The 4 key
|
||||
Num5 = '5', ///< The 5 key
|
||||
Num6 = '6', ///< The 6 key
|
||||
Num7 = '7', ///< The 7 key
|
||||
Num8 = '8', ///< The 8 key
|
||||
Num9 = '9', ///< The 9 key
|
||||
Escape = 256, ///< The Escape key
|
||||
LControl, ///< The left Control key
|
||||
LShift, ///< The left Shift key
|
||||
LAlt, ///< The left Alt key
|
||||
LSystem, ///< The left OS specific key : windows (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 : windows (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
|
||||
Back, ///< 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, ///< +
|
||||
Subtract, ///< -
|
||||
Multiply, ///< *
|
||||
|
@ -115,180 +116,194 @@ namespace Key
|
|||
Right, ///< Right arrow
|
||||
Up, ///< Up arrow
|
||||
Down, ///< Down arrow
|
||||
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,
|
||||
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 F8 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
|
||||
|
||||
Count // Keep last -- total number of keyboard keys
|
||||
Count ///< Keep last -- the total number of keyboard keys
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Definition of button codes for mouse events
|
||||
////////////////////////////////////////////////////////////
|
||||
namespace Mouse
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Definition of button codes for mouse events
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Button
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Middle,
|
||||
XButton1,
|
||||
XButton2,
|
||||
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
|
||||
|
||||
Count // Keep last -- total number of mouse buttons
|
||||
Count ///< Keep last -- the total number of mouse buttons
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Definition of joystick axis for joystick events
|
||||
////////////////////////////////////////////////////////////
|
||||
namespace Joy
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Definition of joystick axis for joystick events
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Axis
|
||||
{
|
||||
AxisX,
|
||||
AxisY,
|
||||
AxisZ,
|
||||
AxisR,
|
||||
AxisU,
|
||||
AxisV,
|
||||
AxisPOV,
|
||||
AxisX, ///< The X axis
|
||||
AxisY, ///< The Y axis
|
||||
AxisZ, ///< The Z axis
|
||||
AxisR, ///< The R axis
|
||||
AxisU, ///< The U axis
|
||||
AxisV, ///< The V axis
|
||||
AxisPOV, ///< The Point-Of-View axis (hat)
|
||||
|
||||
Count // Keep last -- total number of joystick axis
|
||||
Count ///< Keep last -- the total number of joystick axis
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Event defines a system event and its parameters
|
||||
/// \brief Defines a system event and its parameters
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class Event
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Keyboard event parameters
|
||||
/// \brief Keyboard event parameters (KeyPressed, KeyReleased)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct KeyEvent
|
||||
{
|
||||
Key::Code Code;
|
||||
bool Alt;
|
||||
bool Control;
|
||||
bool Shift;
|
||||
Key::Code 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?
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Text event parameters
|
||||
/// \brief Text event parameters (TextEntered)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct TextEvent
|
||||
{
|
||||
Uint32 Unicode;
|
||||
Uint32 Unicode; ///< UTF-32 unicode value of the character
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Mouse move event parameters
|
||||
/// \brief Mouse move event parameters (MouseMoved)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct MouseMoveEvent
|
||||
{
|
||||
int X;
|
||||
int Y;
|
||||
int X; ///< X position of the mouse, relative to the left of the owner window
|
||||
int Y; ///< Y position of the mouse, relative to the top of the owner window
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Mouse buttons events parameters
|
||||
/// \brief Mouse buttons events parameters
|
||||
/// (MouseButtonPressed, MouseButtonReleased)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct MouseButtonEvent
|
||||
{
|
||||
Mouse::Button Button;
|
||||
int X;
|
||||
int Y;
|
||||
Mouse::Button Button; ///< Code of the button that has been pressed
|
||||
int X; ///< X position of the mouse, relative to the left of the owner window
|
||||
int Y; ///< Y position of the mouse, relative to the top of the owner window
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Mouse wheel events parameters
|
||||
/// \brief Mouse wheel events parameters (MouseWheelMoved)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct MouseWheelEvent
|
||||
{
|
||||
int Delta;
|
||||
int Delta; ///< Number of ticks the wheel has moved (positive is up, negative is down)
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Joystick axis move event parameters
|
||||
/// \brief Joystick axis move event parameters (JoyMoved)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct JoyMoveEvent
|
||||
{
|
||||
unsigned int JoystickId;
|
||||
Joy::Axis Axis;
|
||||
float Position;
|
||||
unsigned int JoystickId; ///< Index of the joystick (0 or 1)
|
||||
Joy::Axis Axis; ///< Axis on which the joystick moved
|
||||
float Position; ///< New position on the axis (in range [-100, 100])
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Joystick buttons events parameters
|
||||
/// \brief Joystick buttons events parameters
|
||||
/// (JoyButtonPressed, JoyButtonReleased)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct JoyButtonEvent
|
||||
{
|
||||
unsigned int JoystickId;
|
||||
unsigned int Button;
|
||||
unsigned int JoystickId; ///< Index of the joystick (0 or 1)
|
||||
unsigned int Button; ///< Index of the button that has been pressed
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Size events parameters
|
||||
/// \brief Size events parameters (Resized)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct SizeEvent
|
||||
{
|
||||
unsigned int Width;
|
||||
unsigned int Height;
|
||||
unsigned int Width; ///< New width, in pixels
|
||||
unsigned int Height; ///< New height, in pixels
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Enumeration of the different types of events
|
||||
/// \brief Enumeration of the different types of events
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum EventType
|
||||
{
|
||||
Closed,
|
||||
Resized,
|
||||
LostFocus,
|
||||
GainedFocus,
|
||||
TextEntered,
|
||||
KeyPressed,
|
||||
KeyReleased,
|
||||
MouseWheelMoved,
|
||||
MouseButtonPressed,
|
||||
MouseButtonReleased,
|
||||
MouseMoved,
|
||||
MouseEntered,
|
||||
MouseLeft,
|
||||
JoyButtonPressed,
|
||||
JoyButtonReleased,
|
||||
JoyMoved,
|
||||
Closed, ///< The window requested to be closed
|
||||
Resized, ///< The window was resized
|
||||
LostFocus, ///< The window lost the focus
|
||||
GainedFocus, ///< The window gained the focus
|
||||
TextEntered, ///< A character was entered
|
||||
KeyPressed, ///< A key was pressed
|
||||
KeyReleased, ///< A key was released
|
||||
MouseWheelMoved, ///< The mouse wheel was scrolled
|
||||
MouseButtonPressed, ///< A mouse button was pressed
|
||||
MouseButtonReleased, ///< A mouse button was released
|
||||
MouseMoved, ///< The mouse cursor moved
|
||||
MouseEntered, ///< The mouse cursor entered the area of the window
|
||||
MouseLeft, ///< The mouse cursor left the area of the window
|
||||
JoyButtonPressed, ///< A joystick button was pressed
|
||||
JoyButtonReleased, ///< A joystick button was released
|
||||
JoyMoved, ///< The joystick moved along an axis
|
||||
|
||||
Count // Keep last -- total number of event types
|
||||
Count ///< Keep last -- the total number of event types
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -298,14 +313,14 @@ public :
|
|||
|
||||
union
|
||||
{
|
||||
KeyEvent Key;
|
||||
TextEvent Text;
|
||||
MouseMoveEvent MouseMove;
|
||||
MouseButtonEvent MouseButton;
|
||||
MouseWheelEvent MouseWheel;
|
||||
JoyMoveEvent JoyMove;
|
||||
JoyButtonEvent JoyButton;
|
||||
SizeEvent Size;
|
||||
KeyEvent Key; ///< Key event parameters
|
||||
TextEvent Text; ///< Text event parameters
|
||||
MouseMoveEvent MouseMove; ///< Mouse move event parameters
|
||||
MouseButtonEvent MouseButton; ///< Mouse button event parameters
|
||||
MouseWheelEvent MouseWheel; ///< Mouse wheel event parameters
|
||||
JoyMoveEvent JoyMove; ///< Joystick move event parameters
|
||||
JoyButtonEvent JoyButton; ///< Joystick button event parameters
|
||||
SizeEvent Size; ///< Size event parameters
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -313,3 +328,45 @@ public :
|
|||
|
||||
|
||||
#endif // SFML_EVENT_HPP
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \class sf::Event
|
||||
///
|
||||
/// sf::Event holds all the informations about a system event
|
||||
/// that just happened. Events are retrieved using the
|
||||
/// sf::Window::GetEvent function.
|
||||
///
|
||||
/// 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:
|
||||
/// \code
|
||||
/// sf::Event event;
|
||||
/// while (window.GetEvent(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::Key::Escape))
|
||||
/// window.Close();
|
||||
///
|
||||
/// // The window was resized
|
||||
/// if (event.Type == sf::Event::Resized)
|
||||
/// DoSomethingWithTheNewSize(event.Size.Width, event.Size.Height);
|
||||
///
|
||||
/// // etc ...
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -37,24 +37,24 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Input handles real-time input from keyboard and mouse.
|
||||
/// Use it instead of events to handle continuous moves and more
|
||||
/// game-friendly inputs
|
||||
/// \brief Give access to the real-time states of keyboard,
|
||||
/// mouse and joysticks
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API Input : public WindowListener, NonCopyable
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
/// \brief Default constructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Input();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the state of a key
|
||||
/// \brief Get the current state of a key (pressed or released)
|
||||
///
|
||||
/// \param key : Key to check
|
||||
/// \param key Code of the key to test
|
||||
///
|
||||
/// \return True if key is down, false if key is up
|
||||
///
|
||||
|
@ -62,9 +62,9 @@ public :
|
|||
bool IsKeyDown(Key::Code key) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the state of a mouse button
|
||||
/// \brief Get the current state of a mouse button (pressed or released)
|
||||
///
|
||||
/// \param button : Button to check
|
||||
/// \param button Code of the mouse button to check
|
||||
///
|
||||
/// \return True if button is down, false if button is up
|
||||
///
|
||||
|
@ -72,10 +72,10 @@ public :
|
|||
bool IsMouseButtonDown(Mouse::Button button) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the state of a joystick button
|
||||
/// \brief Get the current state of a joystick button (pressed or released)
|
||||
///
|
||||
/// \param joystick : Identifier of the joystick to check (0 or 1)
|
||||
/// \param button : Button to check
|
||||
/// \param joystick Index of the joystick to test (0 or 1)
|
||||
/// \param button Index of the button to test
|
||||
///
|
||||
/// \return True if button is down, false if button is up
|
||||
///
|
||||
|
@ -83,28 +83,37 @@ public :
|
|||
bool IsJoystickButtonDown(unsigned int joystick, unsigned int button) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the mouse X position
|
||||
/// \brief Get the current mouse X position
|
||||
///
|
||||
/// \return Current mouse left position, relative to owner window
|
||||
/// The returned position is relative to the left border
|
||||
/// of the owner window.
|
||||
///
|
||||
/// \return Current mouse left position
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
int GetMouseX() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the mouse Y position
|
||||
/// \brief Get the current mouse Y position
|
||||
///
|
||||
/// \return Current mouse top position, relative to owner window
|
||||
/// The returned position is relative to the top border
|
||||
/// of the owner window.
|
||||
///
|
||||
/// \return Current mouse top position
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
int GetMouseY() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get a joystick axis position
|
||||
/// \brief Get the current position of a joystick axis
|
||||
///
|
||||
/// \param joystick : Identifier of the joystick to check (0 or 1)
|
||||
/// \param axis : Axis to get
|
||||
/// The returned position is in the range [-100, 100], except
|
||||
/// the POV which is an angle and is thus defined in [0, 360].
|
||||
///
|
||||
/// \return Current axis position, in the range [-100, 100] (except for POV, which is [0, 360])
|
||||
/// \param joystick Index of the joystick to test (0 or 1)
|
||||
/// \param axis Axis to test
|
||||
///
|
||||
/// \return Current axis position
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
float GetJoystickAxis(unsigned int joystick, Joy::Axis axis) const;
|
||||
|
@ -112,7 +121,9 @@ public :
|
|||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see WindowListener::OnEvent
|
||||
/// \brief Called each time an event is received from the attached window
|
||||
///
|
||||
/// \param event Event received
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnEvent(const Event& event);
|
||||
|
@ -122,7 +133,7 @@ private :
|
|||
////////////////////////////////////////////////////////////
|
||||
bool myKeys[Key::Count]; ///< Array containing the state of all keyboard keys
|
||||
bool myMouseButtons[Mouse::Count]; ///< Array containing the state of all mouse buttons
|
||||
bool myJoystickButtons[2][16]; ///< Array containing the state of all joysticks buttons
|
||||
bool myJoystickButtons[2][32]; ///< Array containing the state of all joysticks buttons
|
||||
int myMouseX; ///< Mouse position on X
|
||||
int myMouseY; ///< Mouse position on Y
|
||||
float myJoystickAxis[2][Joy::Count]; ///< Joysticks position on each axis
|
||||
|
@ -132,3 +143,43 @@ private :
|
|||
|
||||
|
||||
#endif // SFML_INPUT_HPP
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \class sf::Input
|
||||
///
|
||||
/// sf::Input provides a way to access the state of keys,
|
||||
/// mouse buttons, mouse position, joystick buttons and
|
||||
/// jostick axis.
|
||||
///
|
||||
/// sf::Input provides the same informations as the event
|
||||
/// system, but these informations can be accessed at any time,
|
||||
/// which is more convenient in many situations.
|
||||
///
|
||||
/// For example, to move an entity you can decide to catch the
|
||||
/// sf::Event::KeyPressed event on arrow keys. But if you do so,
|
||||
/// you will only receive one event when the key gets pressed
|
||||
/// (or repeated events if you activated this feature), thus the
|
||||
/// entity will not move smoothly. The best solution here is to
|
||||
/// use sf::Input::IsKeyDown so that you can update your entity's
|
||||
/// position at every iteration of your game loop, not only when you
|
||||
/// catch a KeyPressed event.
|
||||
///
|
||||
/// Note that instances of sf::Input cannot be created directly,
|
||||
/// they must be retrieved from a window (sf::Window) with its
|
||||
/// GetInput() function.
|
||||
///
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// // Retrieve the input object attached to our window
|
||||
/// const sf::Input& input = window.GetInput();
|
||||
///
|
||||
/// // Move an entity according to the current keys state
|
||||
/// float offset = 5 * window.GetFrameTime(); // 5 pixels/sec
|
||||
/// if (input.IsKeyDown(sf::Key::Left)) entity.Move(-offset, 0);
|
||||
/// if (input.IsKeyDown(sf::Key::Right)) entity.Move( offset, 0);
|
||||
/// if (input.IsKeyDown(sf::Key::Up)) entity.Move(0, -offset);
|
||||
/// if (input.IsKeyDown(sf::Key::Down)) entity.Move(0, offset);
|
||||
/// \endcode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -35,32 +35,33 @@
|
|||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// VideoMode defines a video mode (width, height, bpp, frequency)
|
||||
/// and provides static functions for getting modes supported
|
||||
/// by the display device
|
||||
/// \brief VideoMode defines a video mode (width, height, bpp)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API VideoMode
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
/// \brief Default constructor
|
||||
///
|
||||
/// This constructors initializes all members to 0.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
VideoMode();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Construct the video mode with its attributes
|
||||
/// \brief Construct the video mode with its attributes
|
||||
///
|
||||
/// \param width : Width in pixels
|
||||
/// \param height : Height in pixels
|
||||
/// \param bitsPerPixel : Pixel depths in bits per pixel (32 by default)
|
||||
/// \param width Width in pixels
|
||||
/// \param height Height in pixels
|
||||
/// \param bitsPerPixel Pixel depths in bits per pixel
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
VideoMode(unsigned int width, unsigned int height, unsigned int bitsPerPixel = 32);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the current desktop video mode
|
||||
/// \brief Get the current desktop video mode
|
||||
///
|
||||
/// \return Current desktop video mode
|
||||
///
|
||||
|
@ -68,11 +69,13 @@ public :
|
|||
static VideoMode GetDesktopMode();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get a valid video mode
|
||||
/// Index must be in range [0, GetModesCount()[
|
||||
/// Modes are sorted from best to worst
|
||||
/// \brief Get a valid video mode
|
||||
///
|
||||
/// \param index : Index of video mode to get
|
||||
/// The parameter \index must be in the range [0, GetModesCount()[.
|
||||
/// Modes are sorted from best to worst, so that
|
||||
/// sf::VideoMode::GetMode(0) will always give the best.
|
||||
///
|
||||
/// \param index Index of video mode to get
|
||||
///
|
||||
/// \return Corresponding video mode (invalid mode if index is out of range)
|
||||
///
|
||||
|
@ -80,41 +83,29 @@ public :
|
|||
static VideoMode GetMode(std::size_t index);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get valid video modes count
|
||||
/// \brief Get the total number of valid video modes available
|
||||
///
|
||||
/// \return Number of valid video modes available
|
||||
/// The validity of video modes is only relevant when using
|
||||
/// fullscreen windows; otherwise any video mode can be used
|
||||
/// with no restriction.
|
||||
///
|
||||
/// \return Number of valid video modes available for fullscreen mode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static std::size_t GetModesCount();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Tell whether or not the video mode is supported
|
||||
/// \brief Tell whether or not the video mode is valid
|
||||
///
|
||||
/// \return True if video mode is supported, false otherwise
|
||||
/// The validity of video modes is only relevant when using
|
||||
/// fullscreen windows; otherwise any video mode can be used
|
||||
/// with no restriction.
|
||||
///
|
||||
/// \return True if the video mode is valid for fullscreen mode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsValid() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Comparison operator overload -- tell if two video modes are equal
|
||||
///
|
||||
/// \param other : Video mode to compare
|
||||
///
|
||||
/// \return True if modes are equal
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool operator ==(const VideoMode& other) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Comparison operator overload -- tell if two video modes are different
|
||||
///
|
||||
/// \param other : Video mode to compare
|
||||
///
|
||||
/// \return True if modes are different
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool operator !=(const VideoMode& other) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -123,7 +114,81 @@ public :
|
|||
unsigned int BitsPerPixel; ///< Video mode pixel depth, in bits per pixels
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Overload of binary == operator
|
||||
///
|
||||
/// This operator compares strict equality between two modes,
|
||||
/// i.e. it checks if all their members are equal.
|
||||
///
|
||||
/// \param left Left operand
|
||||
/// \param right Right operand
|
||||
///
|
||||
/// \return True if modes are equal
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SFML_API bool operator ==(const VideoMode& left, const VideoMode& right);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Overload of binary != operator
|
||||
///
|
||||
/// This operator compares strict difference between two modes,
|
||||
/// i.e. it checks if not all their members are equal.
|
||||
///
|
||||
/// \param left Left operand
|
||||
/// \param right Right operand
|
||||
///
|
||||
/// \return True if modes are different
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SFML_API bool operator !=(const VideoMode& left, const VideoMode& right);
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_VIDEOMODE_HPP
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \class sf::VideoMode
|
||||
///
|
||||
/// 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 two static functions for retrieving
|
||||
/// the list of all the video modes supported by the system:
|
||||
/// GetModesCount() to get the number of video modes in the
|
||||
/// list, and GetMode() to retrieve a particular mode
|
||||
/// from the list.
|
||||
///
|
||||
/// A custom video mode can also be checked directly 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:
|
||||
/// \code
|
||||
/// // Display the list of all the video modes available for fullscreen
|
||||
/// for (std::size_t i = 0; i < sf::VideoMode::GetModesCount(); ++i)
|
||||
/// {
|
||||
/// sf::VideoMode mode = sf::VideoMode::GetMode(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");
|
||||
/// \endcode
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -68,8 +68,8 @@ public :
|
|||
///
|
||||
/// \param mode : Video mode to use
|
||||
/// \param title : Title of the window
|
||||
/// \param style : Window style (Resize | Close by default)
|
||||
/// \param settings : Additional settings for the underlying OpenGL context (see default constructor for default values)
|
||||
/// \param style : Window style
|
||||
/// \param settings : Additional settings for the underlying OpenGL context
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Window(VideoMode mode, const std::string& title, unsigned long style = Style::Resize | Style::Close, const ContextSettings& settings = ContextSettings());
|
||||
|
@ -78,7 +78,7 @@ public :
|
|||
/// Construct the window from an existing control
|
||||
///
|
||||
/// \param handle : Platform-specific handle of the control
|
||||
/// \param settings : Additional settings for the underlying OpenGL context (see default constructor for default values)
|
||||
/// \param settings : Additional settings for the underlying OpenGL context
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Window(WindowHandle handle, const ContextSettings& settings = ContextSettings());
|
||||
|
@ -94,8 +94,8 @@ public :
|
|||
///
|
||||
/// \param mode : Video mode to use
|
||||
/// \param title : Title of the window
|
||||
/// \param style : Window style (Resize | Close by default)
|
||||
/// \param Settings : Additional settings for the underlying OpenGL context (see default constructor for default values)
|
||||
/// \param style : Window style
|
||||
/// \param Settings : Additional settings for the underlying OpenGL context
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Create(VideoMode mode, const std::string& title, unsigned long style = Style::Resize | Style::Close, const ContextSettings& settings = ContextSettings());
|
||||
|
@ -104,7 +104,7 @@ public :
|
|||
/// Create (or recreate) the window from an existing control
|
||||
///
|
||||
/// \param handle : Platform-specific handle of the control
|
||||
/// \param settings : Additional settings for the underlying OpenGL context (see default constructor for default values)
|
||||
/// \param settings : Additional settings for the underlying OpenGL context
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Create(WindowHandle handle, const ContextSettings& settings = ContextSettings());
|
||||
|
@ -236,7 +236,7 @@ public :
|
|||
/// Activate or deactivate the window as the current target
|
||||
/// for rendering
|
||||
///
|
||||
/// \param active : True to activate, false to deactivate (true by default)
|
||||
/// \param active : True to activate, false to deactivate
|
||||
///
|
||||
/// \return True if operation was successful, false otherwise
|
||||
///
|
||||
|
|
|
@ -36,17 +36,17 @@ namespace sf
|
|||
class Event;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Base class for classes that want to receive events
|
||||
/// from a window (for internal use only)
|
||||
/// \brief Base class for classes that want to receive events
|
||||
/// from a window (for internal use only)
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API WindowListener
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Called each time an event is received from attached window
|
||||
/// \brief Called each time an event is received from the attached window
|
||||
///
|
||||
/// \param event : Event received
|
||||
/// \param event Event received
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnEvent(const Event& event) = 0;
|
||||
|
@ -54,7 +54,7 @@ public :
|
|||
protected :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
/// \brief Destructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual ~WindowListener() {}
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
|
||||
namespace sf
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Enumeration of window creation styles
|
||||
/// \brief Enumeration of the window styles
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
namespace Style
|
||||
{
|
||||
|
@ -44,7 +44,6 @@ namespace Style
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue