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:
LaurentGom 2009-10-15 08:37:32 +00:00
parent 49ebb40c4d
commit 1f3d7b6d0c
52 changed files with 2077 additions and 2021 deletions

View File

@ -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);

View File

@ -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));

View File

@ -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);

View File

@ -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));

View File

@ -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

View File

@ -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);

View File

@ -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
///

View File

@ -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());

View File

@ -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));

View File

@ -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);

View File

@ -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);

View File

@ -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
///

View File

@ -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 = "");

View File

@ -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
///

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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
///

View File

@ -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
///
////////////////////////////////////////////////////////////

View File

@ -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) :

View File

@ -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
///
////////////////////////////////////////////////////////////

View File

@ -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
///
////////////////////////////////////////////////////////////

View File

@ -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
///
////////////////////////////////////////////////////////////

View File

@ -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
///

View File

@ -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() {}

View File

@ -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

View File

@ -23,8 +23,8 @@ public :
/// Construct the QSFMLCanvas
///
/// \param size : Initial size of the widget
/// \param frameTime : Frame duration, in milliseconds (0 by default)
/// \param parent : Parent of the widget (NULL by default)
/// \param frameTime : Frame duration, in milliseconds
/// \param parent : Parent of the widget
///
////////////////////////////////////////////////////////////
QSFMLCanvas(const QSize& size, unsigned int frameTime = 0, QWidget* parent = NULL);

View File

@ -19,11 +19,11 @@ public :
////////////////////////////////////////////////////////////
/// Construct the wxSFMLCanvas
///
/// \param parent : Parent of the control (NULL by default)
/// \param id : Identifier of the control (-1 by default)
/// \param position : Position of the control (wxDefaultPosition by default)
/// \param size : Size of the control (wxDefaultSize by default)
/// \param style : Style of the control (0 by default)
/// \param parent : Parent of the control
/// \param id : Identifier of the control
/// \param position : Position of the control
/// \param size : Size of the control
/// \param style : Style of the control
///
////////////////////////////////////////////////////////////
wxSFMLCanvas(wxWindow* parent = NULL, wxWindowID id = -1, const wxPoint& position = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0);

View File

@ -32,8 +32,6 @@
namespace sf
{
////////////////////////////////////////////////////////////
/// Default constructor -- creates and activates the context
////////////////////////////////////////////////////////////
Context::Context()
{
myContext = priv::ContextGL::New();
@ -41,8 +39,6 @@ Context::Context()
}
////////////////////////////////////////////////////////////
/// Destructor -- deactivates and destroys the context
////////////////////////////////////////////////////////////
Context::~Context()
{
@ -51,8 +47,6 @@ Context::~Context()
}
////////////////////////////////////////////////////////////
/// Activate or deactivate explicitely the context
////////////////////////////////////////////////////////////
void Context::SetActive(bool active)
{

View File

@ -73,16 +73,12 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Create a new context, not associated to a window
////////////////////////////////////////////////////////////
ContextGL* ContextGL::New()
{
return new ContextType(&referenceContext);
}
////////////////////////////////////////////////////////////
/// Create a new context attached to a window
////////////////////////////////////////////////////////////
ContextGL* ContextGL::New(const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings)
{
@ -96,8 +92,6 @@ ContextGL* ContextGL::New(const WindowImpl* owner, unsigned int bitsPerPixel, co
}
////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
ContextGL::~ContextGL()
{
@ -112,8 +106,6 @@ ContextGL::~ContextGL()
}
////////////////////////////////////////////////////////////
/// Get the settings of the context
////////////////////////////////////////////////////////////
const ContextSettings& ContextGL::GetSettings() const
{
@ -121,9 +113,6 @@ const ContextSettings& ContextGL::GetSettings() const
}
////////////////////////////////////////////////////////////
/// Activate or deactivate the context as the current target
/// for rendering
////////////////////////////////////////////////////////////
bool ContextGL::SetActive(bool active)
{
@ -151,8 +140,6 @@ bool ContextGL::SetActive(bool active)
}
////////////////////////////////////////////////////////////
/// Default constructor
////////////////////////////////////////////////////////////
ContextGL::ContextGL()
{
@ -160,10 +147,6 @@ ContextGL::ContextGL()
}
////////////////////////////////////////////////////////////
/// Evaluate a pixel format configuration.
/// This functions can be used by implementations that have
/// several valid formats and want to get the best one
////////////////////////////////////////////////////////////
int ContextGL::EvaluateFormat(unsigned int bitsPerPixel, const ContextSettings& settings, int colorBits, int depthBits, int stencilBits, int antialiasing)
{

View File

@ -40,28 +40,35 @@ namespace priv
class WindowImpl;
////////////////////////////////////////////////////////////
/// Abstract class representing an OpenGL context
/// \brief Abstract class representing an OpenGL context
///
////////////////////////////////////////////////////////////
class ContextGL : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// Create a new context, not associated to a window
/// \brief Create a new context, not associated to a window
///
/// \return Pointer to the created context
/// This function automatically chooses the specialized class
/// to use according to the OS.
///
/// \return Pointer to the created context (don't forget to delete it)
///
////////////////////////////////////////////////////////////
static ContextGL* New();
////////////////////////////////////////////////////////////
/// Create a new context attached to a window
/// \brief Create a new context attached to a window
///
/// \param owner : Pointer to the owner window
/// \param bitsPerPixel : Pixel depth (in bits per pixel)
/// \param settings : Creation parameters
/// This function automatically chooses the specialized class
/// to use according to the OS.
///
/// \return Pointer to the created context
/// \param owner Pointer to the owner window
/// \param bitsPerPixel Pixel depth (in bits per pixel)
/// \param settings Creation parameters
///
/// \return Pointer to the created context (don't forget to delete it)
///
////////////////////////////////////////////////////////////
static ContextGL* New(const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings);
@ -69,13 +76,17 @@ public :
public :
////////////////////////////////////////////////////////////
/// Virtual destructor
/// \brief Destructor
///
////////////////////////////////////////////////////////////
virtual ~ContextGL();
////////////////////////////////////////////////////////////
/// Get the settings of the context
/// \brief Get the settings of the context
///
/// Note that these settings may be different than the ones
/// passed to the constructor; they are indeed adjusted if the
/// original settings are not directly supported by the system.
///
/// \return Structure containing the settings
///
@ -83,10 +94,16 @@ public :
const ContextSettings& GetSettings() const;
////////////////////////////////////////////////////////////
/// Activate or deactivate the context as the current target
/// for rendering
/// \brief Activate or deactivate the context as the current target
/// for rendering
///
/// \param active : True to activate, false to deactivate
/// A context 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 context can be active on a thread at a time, thus
/// the context previously active (if any) automatically gets deactivated.
///
/// \param active True to activate, false to deactivate
///
/// \return True if operation was successful, false otherwise
///
@ -94,13 +111,18 @@ public :
bool SetActive(bool active);
////////////////////////////////////////////////////////////
/// Display the contents of the context
/// \brief Display what has been rendered to the context so far
///
////////////////////////////////////////////////////////////
virtual void Display() = 0;
////////////////////////////////////////////////////////////
/// Enable / disable vertical synchronization
/// \brief 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).
///
/// \param enabled : True to enable v-sync, false to deactivate
///
@ -110,15 +132,18 @@ public :
protected :
////////////////////////////////////////////////////////////
/// Default constructor
/// \brief Default constructor
///
/// This constructor is meant for derived classes only.
///
////////////////////////////////////////////////////////////
ContextGL();
////////////////////////////////////////////////////////////
/// Make this context the current one
/// \brief Activate or deactivate the context as the current target
/// for rendering
///
/// \param active : True to activate, false to deactivate
/// \param active True to activate, false to deactivate
///
/// \return True on success, false if any error happened
///
@ -126,18 +151,21 @@ protected :
virtual bool MakeCurrent(bool active) = 0;
////////////////////////////////////////////////////////////
/// Evaluate a pixel format configuration.
/// \brief Evaluate a pixel format configuration
///
/// This functions can be used by implementations that have
/// several valid formats and want to get the best one
/// several valid formats and want to get the best one.
/// A score is returned for the given configuration: the
/// lower the score is, the better the configuration is.
///
/// \param bitsPerPixel : Requested pixel depth (bits per pixel)
/// \param settings : Requested additionnal settings
/// \param colorBits : Color bits of the configuration to evaluate
/// \param depthBits : Depth bits of the configuration to evaluate
/// \param stencilBits : Stencil bits of the configuration to evaluate
/// \param antialiasing : Antialiasing level of the configuration to evaluate
/// \param bitsPerPixel Requested pixel depth (bits per pixel)
/// \param settings Requested additionnal settings
/// \param colorBits Color bits of the configuration to evaluate
/// \param depthBits Depth bits of the configuration to evaluate
/// \param stencilBits Stencil bits of the configuration to evaluate
/// \param antialiasing Antialiasing level of the configuration to evaluate
///
/// \return Score of the configuration : the lower the better
/// \return Score of the configuration
///
////////////////////////////////////////////////////////////
static int EvaluateFormat(unsigned int bitsPerPixel, const ContextSettings& settings, int colorBits, int depthBits, int stencilBits, int antialiasing);

View File

@ -31,8 +31,6 @@
namespace sf
{
////////////////////////////////////////////////////////////
/// Default constructor
////////////////////////////////////////////////////////////
Input::Input() :
myMouseX(0),
myMouseY(0)
@ -43,7 +41,7 @@ myMouseY(0)
for (int i = 0; i < Mouse::Count; ++i)
myMouseButtons[i] = false;
for (int i = 0; i < 16; ++i)
for (int i = 0; i < 32; ++i)
{
myJoystickButtons[0][i] = false;
myJoystickButtons[1][i] = false;
@ -57,8 +55,6 @@ myMouseY(0)
}
////////////////////////////////////////////////////////////
/// Get the state of a key
////////////////////////////////////////////////////////////
bool Input::IsKeyDown(Key::Code key) const
{
@ -66,8 +62,6 @@ bool Input::IsKeyDown(Key::Code key) const
}
////////////////////////////////////////////////////////////
/// Get the state of a mouse button
////////////////////////////////////////////////////////////
bool Input::IsMouseButtonDown(Mouse::Button button) const
{
@ -75,20 +69,16 @@ bool Input::IsMouseButtonDown(Mouse::Button button) const
}
////////////////////////////////////////////////////////////
/// Get the state of a joystick button
////////////////////////////////////////////////////////////
bool Input::IsJoystickButtonDown(unsigned int joystick, unsigned int button) const
{
if ((joystick < 2) && (button < 16))
if ((joystick < 2) && (button < 32))
return myJoystickButtons[joystick][button];
else
return false;
}
////////////////////////////////////////////////////////////
/// Get the mouse left position
////////////////////////////////////////////////////////////
int Input::GetMouseX() const
{
@ -96,8 +86,6 @@ int Input::GetMouseX() const
}
////////////////////////////////////////////////////////////
/// Get the mouse top position
////////////////////////////////////////////////////////////
int Input::GetMouseY() const
{
@ -105,8 +93,6 @@ int Input::GetMouseY() const
}
////////////////////////////////////////////////////////////
/// Get a joystick axis position
////////////////////////////////////////////////////////////
float Input::GetJoystickAxis(unsigned int joystick, Joy::Axis axis) const
{
@ -114,8 +100,6 @@ float Input::GetJoystickAxis(unsigned int joystick, Joy::Axis axis) const
}
////////////////////////////////////////////////////////////
/// /see WindowListener::OnEvent
////////////////////////////////////////////////////////////
void Input::OnEvent(const Event& event)
{
@ -153,7 +137,7 @@ void Input::OnEvent(const Event& event)
for (int i = 0; i < Mouse::Count; ++i)
myMouseButtons[i] = false;
for (int i = 0; i < 16; ++i)
for (int i = 0; i < 32; ++i)
{
myJoystickButtons[0][i] = false;
myJoystickButtons[1][i] = false;

View File

@ -37,7 +37,8 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Structure holding the joystick state's parameters
/// \brief Structure holding the joystick state's parameters
///
////////////////////////////////////////////////////////////
struct JoystickState
{

View File

@ -37,8 +37,6 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Create a new context, not associated to a window
////////////////////////////////////////////////////////////
ContextGLX::ContextGLX(ContextGLX* shared) :
myWindow (0),
myContext (NULL),
@ -63,13 +61,10 @@ myOwnsWindow(true)
CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, ContextSettings(0, 0, 0));
// Activate the context
//if (shared)
SetActive(true);
SetActive(true);
}
////////////////////////////////////////////////////////////
/// Create a new context attached to a window
////////////////////////////////////////////////////////////
ContextGLX::ContextGLX(ContextGLX* shared, const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings) :
myWindow (0),
@ -87,13 +82,10 @@ myOwnsWindow(false)
CreateContext(shared, bitsPerPixel, settings);
// Activate the context
//if (shared)
SetActive(true);
SetActive(true);
}
////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
ContextGLX::~ContextGLX()
{
@ -120,8 +112,6 @@ ContextGLX::~ContextGLX()
}
////////////////////////////////////////////////////////////
/// \see Context::MakeCurrent
////////////////////////////////////////////////////////////
bool ContextGLX::MakeCurrent(bool active)
{
@ -149,8 +139,6 @@ bool ContextGLX::MakeCurrent(bool active)
}
////////////////////////////////////////////////////////////
/// \see Context::Display
////////////////////////////////////////////////////////////
void ContextGLX::Display()
{
@ -159,8 +147,6 @@ void ContextGLX::Display()
}
////////////////////////////////////////////////////////////
/// \see Context::UseVerticalSync
////////////////////////////////////////////////////////////
void ContextGLX::UseVerticalSync(bool enabled)
{
@ -171,8 +157,6 @@ void ContextGLX::UseVerticalSync(bool enabled)
}
////////////////////////////////////////////////////////////
/// Check if a context is active on the current thread
////////////////////////////////////////////////////////////
bool ContextGLX::IsContextActive()
{
@ -180,8 +164,6 @@ bool ContextGLX::IsContextActive()
}
////////////////////////////////////////////////////////////
/// Create the context
////////////////////////////////////////////////////////////
void ContextGLX::CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, const ContextSettings& settings)
{

View File

@ -38,57 +38,70 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Linux (GLX) implementation of OpenGL contexts
/// \brief Linux (GLX) implementation of OpenGL contexts
///
////////////////////////////////////////////////////////////
class ContextGLX : public ContextGL
{
public :
////////////////////////////////////////////////////////////
/// Create a new context, not associated to a window
/// \brief Create a new context, not associated to a window
///
/// \param shared : Context to share the new one with (can be NULL)
/// \param shared Context to share the new one with (can be NULL)
///
////////////////////////////////////////////////////////////
ContextGLX(ContextGLX* shared);
////////////////////////////////////////////////////////////
/// Create a new context attached to a window
/// \brief Create a new context attached to a window
///
/// \param shared : Context to share the new one with (can be NULL)
/// \param owner : Pointer to the owner window
/// \param bitsPerPixel : Pixel depth (in bits per pixel)
/// \param settings : Creation parameters
/// \param shared Context to share the new one with (can be NULL)
/// \param owner Pointer to the owner window
/// \param bitsPerPixel Pixel depth (in bits per pixel)
/// \param settings Creation parameters
///
////////////////////////////////////////////////////////////
ContextGLX(ContextGLX* shared, const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings);
////////////////////////////////////////////////////////////
/// Destructor
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~ContextGLX();
////////////////////////////////////////////////////////////
/// \see Context::MakeCurrent
/// \brief Activate or deactivate the context as the current target
/// for rendering
///
/// \param active True to activate, false to deactivate
///
/// \return True on success, false if any error happened
///
////////////////////////////////////////////////////////////
virtual bool MakeCurrent(bool active);
////////////////////////////////////////////////////////////
/// \see Context::Display
/// \brief Display what has been rendered to the context so far
///
////////////////////////////////////////////////////////////
virtual void Display();
////////////////////////////////////////////////////////////
/// \see Context::UseVerticalSync
/// \brief 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).
///
/// \param enabled : True to enable v-sync, false to deactivate
///
////////////////////////////////////////////////////////////
virtual void UseVerticalSync(bool enabled);
////////////////////////////////////////////////////////////
/// Check if a context is active on the current thread
/// \brief Check if a context is active on the current thread
///
/// \return True if there's an active context, false otherwise
///
@ -98,11 +111,11 @@ public :
private :
////////////////////////////////////////////////////////////
/// Create the context
/// \brief Create the context
///
/// \param shared : Context to share the new one with (can be NULL)
/// \param bitsPerPixel : Pixel depth, in bits per pixel
/// \param settings : Creation parameters
/// \param shared Context to share the new one with (can be NULL)
/// \param bitsPerPixel Pixel depth, in bits per pixel
/// \param settings Creation parameters
///
////////////////////////////////////////////////////////////
void CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, const ContextSettings& settings);

View File

@ -42,8 +42,6 @@ namespace priv
{
#if defined(SFML_SYSTEM_LINUX)
////////////////////////////////////////////////////////////
/// Initialize the instance and bind it to a physical joystick
////////////////////////////////////////////////////////////
void Joystick::Initialize(unsigned int index)
{
@ -74,8 +72,6 @@ void Joystick::Initialize(unsigned int index)
}
////////////////////////////////////////////////////////////
/// Update the current joystick and return its new state
////////////////////////////////////////////////////////////
JoystickState Joystick::UpdateState()
{
@ -109,8 +105,6 @@ JoystickState Joystick::UpdateState()
}
////////////////////////////////////////////////////////////
/// Get the number of axes supported by the joystick
////////////////////////////////////////////////////////////
unsigned int Joystick::GetAxesCount() const
{
@ -118,8 +112,6 @@ unsigned int Joystick::GetAxesCount() const
}
////////////////////////////////////////////////////////////
/// Get the number of buttons supported by the joystick
////////////////////////////////////////////////////////////
unsigned int Joystick::GetButtonsCount() const
{
@ -130,16 +122,12 @@ unsigned int Joystick::GetButtonsCount() const
#elif defined(SFML_SYSTEM_FREEBSD)
////////////////////////////////////////////////////////////
/// Initialize the instance and bind it to a physical joystick
////////////////////////////////////////////////////////////
void Joystick::Initialize(unsigned int index)
{
}
////////////////////////////////////////////////////////////
/// Update the current joystick and return its new state
////////////////////////////////////////////////////////////
JoystickState Joystick::UpdateState()
{
@ -147,8 +135,6 @@ JoystickState Joystick::UpdateState()
}
////////////////////////////////////////////////////////////
/// Get the number of axes supported by the joystick
////////////////////////////////////////////////////////////
unsigned int Joystick::GetAxesCount() const
{
@ -156,8 +142,6 @@ unsigned int Joystick::GetAxesCount() const
}
////////////////////////////////////////////////////////////
/// Get the number of buttons supported by the joystick
////////////////////////////////////////////////////////////
unsigned int Joystick::GetButtonsCount() const
{

View File

@ -35,22 +35,23 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Linux implementation of Joystick
/// \brief Linux implementation of Joystick
///
////////////////////////////////////////////////////////////
class Joystick
{
public :
////////////////////////////////////////////////////////////
/// Initialize the instance and bind it to a physical joystick
/// \brief Initialize the instance and bind it to a physical joystick
///
/// \param index : Index of the physical joystick to bind to
/// \param index Index of the physical joystick to bind to
///
////////////////////////////////////////////////////////////
void Initialize(unsigned int index);
////////////////////////////////////////////////////////////
/// Update the current joystick and return its new state
/// \brief Update the current joystick and return its new state
///
/// \return Current state of the joystick
///
@ -58,7 +59,7 @@ public :
JoystickState UpdateState();
////////////////////////////////////////////////////////////
/// Get the number of axes supported by the joystick
/// \brief Get the number of axes supported by the joystick
///
/// \return Number of axis
///
@ -66,7 +67,7 @@ public :
unsigned int GetAxesCount() const;
////////////////////////////////////////////////////////////
/// Get the number of buttons supported by the joystick
/// \brief Get the number of buttons supported by the joystick
///
/// \return Number of buttons
///

View File

@ -37,8 +37,6 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Get supported video modes
////////////////////////////////////////////////////////////
void VideoModeSupport::GetSupportedVideoModes(std::vector<VideoMode>& modes)
{
// First, clear array to fill
@ -111,8 +109,6 @@ void VideoModeSupport::GetSupportedVideoModes(std::vector<VideoMode>& modes)
}
////////////////////////////////////////////////////////////
/// Get current desktop video mode
////////////////////////////////////////////////////////////
VideoMode VideoModeSupport::GetDesktopVideoMode()
{

View File

@ -37,23 +37,23 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Linux implementation of VideoModeSupport
/// Give access to video mode related OS-specific functions
/// \brief Linux (X11) implementation of VideoModeSupport;
/// gives access to video mode related OS-specific functions
////////////////////////////////////////////////////////////
class VideoModeSupport
{
public :
////////////////////////////////////////////////////////////
/// Get supported video modes
/// \brief Get the list of all the supported video modes
///
/// \param modes : Array to fill with available video modes
/// \param modes Array to fill with available video modes
///
////////////////////////////////////////////////////////////
static void GetSupportedVideoModes(std::vector<VideoMode>& modes);
////////////////////////////////////////////////////////////
/// Get current desktop video mode
/// \brief Get the current desktop video mode
///
/// \return Current desktop video mode
///

View File

@ -46,10 +46,8 @@ namespace
PointerMotionMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask |
EnterWindowMask | LeaveWindowMask;
////////////////////////////////////////////////////////////
/// Filter the events received by windows
/// (only allow those matching a specific window)
////////////////////////////////////////////////////////////
Bool CheckEvent(::Display*, XEvent* event, XPointer userData)
{
// Just check if the event matches the window
@ -63,8 +61,6 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Create the window implementation from an existing control
////////////////////////////////////////////////////////////
WindowImplX11::WindowImplX11(WindowHandle handle) :
myWindow (0),
myInputMethod (NULL),
@ -103,8 +99,6 @@ myKeyRepeat (true)
}
////////////////////////////////////////////////////////////
/// Create the window implementation
////////////////////////////////////////////////////////////
WindowImplX11::WindowImplX11(VideoMode mode, const std::string& title, unsigned long style) :
myWindow (0),
@ -245,8 +239,6 @@ myKeyRepeat (true)
}
////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
WindowImplX11::~WindowImplX11()
{
@ -273,9 +265,6 @@ WindowImplX11::~WindowImplX11()
}
////////////////////////////////////////////////////////////
/// Get the display used by the window.
/// This functions is meant to be used internally by ContextGLX.
////////////////////////////////////////////////////////////
::Display* WindowImplX11::GetDisplay() const
{
@ -283,8 +272,6 @@ WindowImplX11::~WindowImplX11()
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::GetHandle
////////////////////////////////////////////////////////////
WindowHandle WindowImplX11::GetHandle() const
{
@ -292,8 +279,6 @@ WindowHandle WindowImplX11::GetHandle() const
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::ProcessEvents
////////////////////////////////////////////////////////////
void WindowImplX11::ProcessEvents()
{
@ -347,8 +332,6 @@ void WindowImplX11::ProcessEvents()
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::ShowMouseCursor
////////////////////////////////////////////////////////////
void WindowImplX11::ShowMouseCursor(bool show)
{
@ -357,8 +340,6 @@ void WindowImplX11::ShowMouseCursor(bool show)
}
////////////////////////////////////////////////////////////
/// /see sfWindowImpl::SetCursorPosition
////////////////////////////////////////////////////////////
void WindowImplX11::SetCursorPosition(unsigned int left, unsigned int top)
{
@ -367,8 +348,6 @@ void WindowImplX11::SetCursorPosition(unsigned int left, unsigned int top)
}
////////////////////////////////////////////////////////////
/// /see sfWindowImpl::SetPosition
////////////////////////////////////////////////////////////
void WindowImplX11::SetPosition(int left, int top)
{
@ -377,8 +356,6 @@ void WindowImplX11::SetPosition(int left, int top)
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetSize
////////////////////////////////////////////////////////////
void WindowImplX11::SetSize(unsigned int width, unsigned int height)
{
@ -387,8 +364,6 @@ void WindowImplX11::SetSize(unsigned int width, unsigned int height)
}
////////////////////////////////////////////////////////////
/// /see sfWindowImpl::Show
////////////////////////////////////////////////////////////
void WindowImplX11::Show(bool show)
{
@ -401,8 +376,6 @@ void WindowImplX11::Show(bool show)
}
////////////////////////////////////////////////////////////
/// /see sfWindowImpl::EnableKeyRepeat
////////////////////////////////////////////////////////////
void WindowImplX11::EnableKeyRepeat(bool enabled)
{
@ -410,8 +383,6 @@ void WindowImplX11::EnableKeyRepeat(bool enabled)
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetIcon
////////////////////////////////////////////////////////////
void WindowImplX11::SetIcon(unsigned int width, unsigned int height, const Uint8* pixels)
{
@ -473,8 +444,6 @@ void WindowImplX11::SetIcon(unsigned int width, unsigned int height, const Uint8
}
////////////////////////////////////////////////////////////
/// Switch to fullscreen mode
////////////////////////////////////////////////////////////
void WindowImplX11::SwitchToFullscreen(const VideoMode& mode)
{
@ -527,8 +496,6 @@ void WindowImplX11::SwitchToFullscreen(const VideoMode& mode)
}
////////////////////////////////////////////////////////////
/// Do some common initializations after the window has been created
////////////////////////////////////////////////////////////
void WindowImplX11::Initialize()
{
@ -568,8 +535,6 @@ void WindowImplX11::Initialize()
}
////////////////////////////////////////////////////////////
/// Create a transparent mouse cursor
////////////////////////////////////////////////////////////
void WindowImplX11::CreateHiddenCursor()
{
@ -590,8 +555,6 @@ void WindowImplX11::CreateHiddenCursor()
}
////////////////////////////////////////////////////////////
/// Cleanup graphical resources attached to the window
////////////////////////////////////////////////////////////
void WindowImplX11::CleanUp()
{
@ -622,8 +585,6 @@ void WindowImplX11::CleanUp()
}
////////////////////////////////////////////////////////////
/// Process an incoming event from the window
////////////////////////////////////////////////////////////
void WindowImplX11::ProcessEvent(XEvent windowEvent)
{
@ -856,8 +817,6 @@ void WindowImplX11::ProcessEvent(XEvent windowEvent)
}
////////////////////////////////////////////////////////////
/// Convert a X11 keysym to SFML key code
////////////////////////////////////////////////////////////
Key::Code WindowImplX11::KeysymToSF(KeySym symbol)
{

View File

@ -40,38 +40,40 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// WindowImplX11 is the Linux (X11) implementation of WindowImpl
/// \brief Linux (X11) implementation of WindowImpl
///
////////////////////////////////////////////////////////////
class WindowImplX11 : public WindowImpl
{
public :
////////////////////////////////////////////////////////////
/// Construct the window implementation from an existing control
/// \brief Construct the window implementation from an existing control
///
/// \param handle : Platform-specific handle of the control
/// \param handle Platform-specific handle of the control
///
////////////////////////////////////////////////////////////
WindowImplX11(WindowHandle handle);
////////////////////////////////////////////////////////////
/// Create the window implementation
/// \brief Create the window implementation
///
/// \param mode : Video mode to use
/// \param title : Title of the window
/// \param style : Window style (resizable, fixed, or fullscren)
/// \param mode Video mode to use
/// \param title Title of the window
/// \param style Window style (resizable, fixed, or fullscren)
///
////////////////////////////////////////////////////////////
WindowImplX11(VideoMode mode, const std::string& title, unsigned long style);
////////////////////////////////////////////////////////////
/// Destructor
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~WindowImplX11();
////////////////////////////////////////////////////////////
/// Get the display used by the window.
/// \brief Get the display used by the window
///
/// This functions is meant to be used internally by ContextGLX.
///
/// \return Pointer to the X display of the window
@ -82,97 +84,118 @@ public :
private :
////////////////////////////////////////////////////////////
/// /see WindowImpl::GetHandle
/// \brief Get the OS-specific handle of the window
///
/// \return Handle of the window
///
////////////////////////////////////////////////////////////
virtual WindowHandle GetHandle() const;
////////////////////////////////////////////////////////////
/// /see WindowImpl::ProcessEvents
/// \brief Process incoming events from operating system
///
////////////////////////////////////////////////////////////
virtual void ProcessEvents();
////////////////////////////////////////////////////////////
/// /see WindowImpl::ShowMouseCursor
/// \brief Show or hide the mouse cursor
///
/// \param show True to show, false to hide
///
////////////////////////////////////////////////////////////
virtual void ShowMouseCursor(bool show);
////////////////////////////////////////////////////////////
/// /see sfWindowImpl::SetCursorPosition
/// \brief Change the position of the mouse cursor
///
/// \param left Left coordinate of the cursor, relative to the window
/// \param top Top coordinate of the cursor, relative to the window
///
////////////////////////////////////////////////////////////
virtual void SetCursorPosition(unsigned int left, unsigned int top);
////////////////////////////////////////////////////////////
/// /see sfWindowImpl::SetPosition
/// \brief Change the position of the window on screen
///
/// \param left Left position
/// \param top Top position
///
////////////////////////////////////////////////////////////
virtual void SetPosition(int left, int top);
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetSize
/// \brief Change the size of the rendering region of the window
///
/// \param width New width
/// \param height New height
///
////////////////////////////////////////////////////////////
virtual void SetSize(unsigned int width, unsigned int height);
////////////////////////////////////////////////////////////
/// /see sfWindowImpl::Show
/// \brief Show or hide the window
///
/// \param show True to show, false to hide
///
////////////////////////////////////////////////////////////
virtual void Show(bool show);
////////////////////////////////////////////////////////////
/// /see sfWindowImpl::EnableKeyRepeat
/// \brief Enable or disable automatic key-repeat
///
/// \param enabled True to enable, false to disable
///
////////////////////////////////////////////////////////////
virtual void EnableKeyRepeat(bool enabled);
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetIcon
/// \brief Change the window's icon
///
/// \param width Icon's width, in pixels
/// \param height Icon's height, in pixels
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
///
////////////////////////////////////////////////////////////
virtual void SetIcon(unsigned int width, unsigned int height, const Uint8* pixels);
////////////////////////////////////////////////////////////
/// Switch to fullscreen mode
/// \brief Switch to fullscreen mode
///
/// \param Mode : video mode to switch to
/// \param Mode video mode to switch to
///
////////////////////////////////////////////////////////////
void SwitchToFullscreen(const VideoMode& mode);
////////////////////////////////////////////////////////////
/// Do some common initializations after the window has been created
/// \brief Do some common initializations after the window has been created
///
////////////////////////////////////////////////////////////
void Initialize();
////////////////////////////////////////////////////////////
/// Create a transparent mouse cursor
/// \brief Create a transparent mouse cursor
///
////////////////////////////////////////////////////////////
void CreateHiddenCursor();
////////////////////////////////////////////////////////////
/// Cleanup graphical resources attached to the window
/// \brief Cleanup graphical resources attached to the window
///
////////////////////////////////////////////////////////////
void CleanUp();
////////////////////////////////////////////////////////////
/// Process an incoming event from the window
/// \brief Process an incoming event from the window
///
/// \param windowEvent : Event which has been received
/// \param windowEvent Event which has been received
///
////////////////////////////////////////////////////////////
void ProcessEvent(XEvent windowEvent);
////////////////////////////////////////////////////////////
/// Convert a X11 keysym to SFML key code
/// \brief Convert a X11 keysym to SFML key code
///
/// \param symbol : keysym to convert
/// \param symbol Key symbol to convert
///
/// \return Corrsponding SFML key code
///

View File

@ -32,7 +32,7 @@
////////////////////////////////////////////////////////////
/// Internal data
/// Private data
////////////////////////////////////////////////////////////
namespace
{
@ -57,9 +57,7 @@ namespace
}
};
////////////////////////////////////////////////////////////
/// Get and sort valid video modes
////////////////////////////////////////////////////////////
// Get and sort valid video modes
static void InitializeModes()
{
// We request the array of valid modes
@ -74,8 +72,6 @@ namespace
namespace sf
{
////////////////////////////////////////////////////////////
/// Default constructor
////////////////////////////////////////////////////////////
VideoMode::VideoMode() :
Width (0),
Height (0),
@ -85,8 +81,6 @@ BitsPerPixel(0)
}
////////////////////////////////////////////////////////////
/// Construct the video mode with its attributes
////////////////////////////////////////////////////////////
VideoMode::VideoMode(unsigned int width, unsigned int height, unsigned int bitsPerPixel) :
Width (width),
@ -97,8 +91,6 @@ BitsPerPixel(bitsPerPixel)
}
////////////////////////////////////////////////////////////
/// Get the current desktop video mode
////////////////////////////////////////////////////////////
VideoMode VideoMode::GetDesktopMode()
{
@ -107,12 +99,10 @@ VideoMode VideoMode::GetDesktopMode()
}
////////////////////////////////////////////////////////////
/// Get a valid video mode
/// Index must be in range [0, GetModesCount()[
////////////////////////////////////////////////////////////
VideoMode VideoMode::GetMode(std::size_t index)
{
// Build and cache the list of valid modes on first call
if (supportedModes.empty())
InitializeModes();
@ -123,11 +113,10 @@ VideoMode VideoMode::GetMode(std::size_t index)
}
////////////////////////////////////////////////////////////
/// Get valid video modes count
////////////////////////////////////////////////////////////
std::size_t VideoMode::GetModesCount()
{
// Build and cache the list of valid modes on first call
if (supportedModes.empty())
InitializeModes();
@ -135,11 +124,10 @@ std::size_t VideoMode::GetModesCount()
}
////////////////////////////////////////////////////////////
/// Tell whether or not the video mode is supported
////////////////////////////////////////////////////////////
bool VideoMode::IsValid() const
{
// Build and cache the list of valid modes on first call
if (supportedModes.empty())
InitializeModes();
@ -148,22 +136,18 @@ bool VideoMode::IsValid() const
////////////////////////////////////////////////////////////
/// Comparison operator overload -- tell if two video modes are equal
////////////////////////////////////////////////////////////
bool VideoMode::operator ==(const VideoMode& other) const
bool operator ==(const VideoMode& left, const VideoMode& right)
{
return (Width == other.Width) &&
(Height == other.Height) &&
(BitsPerPixel == other.BitsPerPixel);
return (left.Width == right.Width) &&
(left.Height == right.Height) &&
(left.BitsPerPixel == right.BitsPerPixel);
}
////////////////////////////////////////////////////////////
/// Comparison operator overload -- tell if two video modes are different
////////////////////////////////////////////////////////////
bool VideoMode::operator !=(const VideoMode& other) const
bool operator !=(const VideoMode& left, const VideoMode& right)
{
return !(*this == other);
return !(left == right);
}
} // namespace sf

View File

@ -37,8 +37,6 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Create a new context, not associated to a window
////////////////////////////////////////////////////////////
ContextWGL::ContextWGL(ContextWGL* shared) :
myWindow (NULL),
myDC (NULL),
@ -57,13 +55,10 @@ myOwnsWindow(true)
CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, ContextSettings(0, 0, 0));
// Activate the context
//if (shared)
SetActive(true);
SetActive(true);
}
////////////////////////////////////////////////////////////
/// Create a new context attached to a window
////////////////////////////////////////////////////////////
ContextWGL::ContextWGL(ContextWGL* shared, const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings) :
myWindow (NULL),
@ -80,13 +75,10 @@ myOwnsWindow(false)
CreateContext(shared, bitsPerPixel, settings);
// Activate the context
//if (shared)
SetActive(true);
SetActive(true);
}
////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
ContextWGL::~ContextWGL()
{
@ -108,8 +100,6 @@ ContextWGL::~ContextWGL()
}
////////////////////////////////////////////////////////////
/// \see Context::MakeCurrent
////////////////////////////////////////////////////////////
bool ContextWGL::MakeCurrent(bool active)
{
@ -137,8 +127,6 @@ bool ContextWGL::MakeCurrent(bool active)
}
////////////////////////////////////////////////////////////
/// \see Context::Display
////////////////////////////////////////////////////////////
void ContextWGL::Display()
{
@ -147,8 +135,6 @@ void ContextWGL::Display()
}
////////////////////////////////////////////////////////////
/// \see Context::UseVerticalSync
////////////////////////////////////////////////////////////
void ContextWGL::UseVerticalSync(bool enabled)
{
@ -158,8 +144,6 @@ void ContextWGL::UseVerticalSync(bool enabled)
}
////////////////////////////////////////////////////////////
/// Check if a context is active on the current thread
////////////////////////////////////////////////////////////
bool ContextWGL::IsContextActive()
{
@ -167,8 +151,6 @@ bool ContextWGL::IsContextActive()
}
////////////////////////////////////////////////////////////
/// Create the context
////////////////////////////////////////////////////////////
void ContextWGL::CreateContext(ContextWGL* shared, unsigned int bitsPerPixel, const ContextSettings& settings)
{

View File

@ -37,57 +37,70 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Windows (WGL) implementation of OpenGL contexts
/// \brief Windows (WGL) implementation of OpenGL contexts
///
////////////////////////////////////////////////////////////
class ContextWGL : public ContextGL
{
public :
////////////////////////////////////////////////////////////
/// Create a new context, not associated to a window
/// \brief Create a new context, not associated to a window
///
/// \param shared : Context to share the new one with (can be NULL)
/// \param shared Context to share the new one with (can be NULL)
///
////////////////////////////////////////////////////////////
ContextWGL(ContextWGL* shared);
////////////////////////////////////////////////////////////
/// Create a new context attached to a window
/// \brief Create a new context attached to a window
///
/// \param shared : Context to share the new one with (can be NULL)
/// \param owner : Pointer to the owner window
/// \param bitsPerPixel : Pixel depth (in bits per pixel)
/// \param settings : Creation parameters
/// \param shared Context to share the new one with (can be NULL)
/// \param owner Pointer to the owner window
/// \param bitsPerPixel Pixel depth (in bits per pixel)
/// \param settings Creation parameters
///
////////////////////////////////////////////////////////////
ContextWGL(ContextWGL* shared, const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings);
////////////////////////////////////////////////////////////
/// Destructor
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~ContextWGL();
////////////////////////////////////////////////////////////
/// \see Context::MakeCurrent
/// \brief Activate or deactivate the context as the current target
/// for rendering
///
/// \param active True to activate, false to deactivate
///
/// \return True on success, false if any error happened
///
////////////////////////////////////////////////////////////
virtual bool MakeCurrent(bool active);
////////////////////////////////////////////////////////////
/// \see Context::Display
/// \brief Display what has been rendered to the context so far
///
////////////////////////////////////////////////////////////
virtual void Display();
////////////////////////////////////////////////////////////
/// \see Context::UseVerticalSync
/// \brief 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).
///
/// \param enabled : True to enable v-sync, false to deactivate
///
////////////////////////////////////////////////////////////
virtual void UseVerticalSync(bool enabled);
////////////////////////////////////////////////////////////
/// Check if a context is active on the current thread
/// \brief Check if a context is active on the current thread
///
/// \return True if there's an active context, false otherwise
///
@ -97,11 +110,11 @@ public :
private :
////////////////////////////////////////////////////////////
/// Create the context
/// \brief Create the context
///
/// \param shared : Context to share the new one with (can be NULL)
/// \param bitsPerPixel : Pixel depth, in bits per pixel
/// \param settings : Creation parameters
/// \param shared Context to share the new one with (can be NULL)
/// \param bitsPerPixel Pixel depth, in bits per pixel
/// \param settings Creation parameters
///
////////////////////////////////////////////////////////////
void CreateContext(ContextWGL* shared, unsigned int bitsPerPixel, const ContextSettings& settings);

View File

@ -37,8 +37,6 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Initialize the instance and bind it to a physical joystick
////////////////////////////////////////////////////////////
void Joystick::Initialize(unsigned int index)
{
// Reset state
@ -79,8 +77,6 @@ void Joystick::Initialize(unsigned int index)
}
////////////////////////////////////////////////////////////
/// Update the current joystick and return its new state
////////////////////////////////////////////////////////////
JoystickState Joystick::UpdateState()
{
@ -120,8 +116,6 @@ JoystickState Joystick::UpdateState()
}
////////////////////////////////////////////////////////////
/// Get the number of axes supported by the joystick
////////////////////////////////////////////////////////////
unsigned int Joystick::GetAxesCount() const
{
@ -129,8 +123,6 @@ unsigned int Joystick::GetAxesCount() const
}
////////////////////////////////////////////////////////////
/// Get the number of buttons supported by the joystick
////////////////////////////////////////////////////////////
unsigned int Joystick::GetButtonsCount() const
{

View File

@ -35,22 +35,23 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Win32 implementation of Joystick
/// \brief Windows implementation of Joystick
///
////////////////////////////////////////////////////////////
class Joystick
{
public :
////////////////////////////////////////////////////////////
/// Initialize the instance and bind it to a physical joystick
/// \brief Initialize the instance and bind it to a physical joystick
///
/// \param index : Index of the physical joystick to bind to
/// \param index Index of the physical joystick to bind to
///
////////////////////////////////////////////////////////////
void Initialize(unsigned int index);
////////////////////////////////////////////////////////////
/// Update the current joystick and return its new state
/// \brief Update the current joystick and return its new state
///
/// \return Current state of the joystick
///
@ -58,7 +59,7 @@ public :
JoystickState UpdateState();
////////////////////////////////////////////////////////////
/// Get the number of axes supported by the joystick
/// \brief Get the number of axes supported by the joystick
///
/// \return Number of axis
///
@ -66,7 +67,7 @@ public :
unsigned int GetAxesCount() const;
////////////////////////////////////////////////////////////
/// Get the number of buttons supported by the joystick
/// \brief Get the number of buttons supported by the joystick
///
/// \return Number of buttons
///

View File

@ -35,19 +35,17 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Get supported video modes
////////////////////////////////////////////////////////////
void VideoModeSupport::GetSupportedVideoModes(std::vector<VideoMode>& modes)
{
// First, clear array to fill
modes.clear();
// Enumerate all available video modes for primary display adapter
// Enumerate all available video modes for the primary display adapter
DEVMODE win32Mode;
win32Mode.dmSize = sizeof(win32Mode);
for (int count = 0; EnumDisplaySettings(NULL, count, &win32Mode); ++count)
{
// Convert to sfVideoMode
// Convert to sf::VideoMode
VideoMode mode(win32Mode.dmPelsWidth, win32Mode.dmPelsHeight, win32Mode.dmBitsPerPel);
// Add it only if it is not already in the array
@ -57,8 +55,6 @@ void VideoModeSupport::GetSupportedVideoModes(std::vector<VideoMode>& modes)
}
////////////////////////////////////////////////////////////
/// Get current desktop video mode
////////////////////////////////////////////////////////////
VideoMode VideoModeSupport::GetDesktopVideoMode()
{

View File

@ -37,23 +37,24 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Win32 implementation of VideoModeSupport
/// Give access to video mode related OS-specific functions
/// \brief Windows implementation of VideoModeSupport;
/// gives access to video mode related OS-specific functions
///
////////////////////////////////////////////////////////////
class VideoModeSupport
{
public :
////////////////////////////////////////////////////////////
/// Get supported video modes
/// \brief Get the list of all the supported video modes
///
/// \param Modes : Array to fill with available video modes
/// \param modes Array to fill with available video modes
///
////////////////////////////////////////////////////////////
static void GetSupportedVideoModes(std::vector<VideoMode>& modes);
////////////////////////////////////////////////////////////
/// Get current desktop video mode
/// \brief Get the current desktop video mode
///
/// \return Current desktop video mode
///

View File

@ -44,22 +44,22 @@
#endif
////////////////////////////////////////////////////////////
// Private data
////////////////////////////////////////////////////////////
namespace
{
unsigned int WindowCount = 0;
const char* ClassNameA = "SFML_Window";
const wchar_t* ClassNameW = L"SFML_Window";
sf::priv::WindowImplWin32* FullscreenWindow = NULL;
}
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
// Static member data
////////////////////////////////////////////////////////////
unsigned int WindowImplWin32::ourWindowCount = 0;
const char* WindowImplWin32::ourClassNameA = "SFML_Window";
const wchar_t* WindowImplWin32::ourClassNameW = L"SFML_Window";
WindowImplWin32* WindowImplWin32::ourFullscreenWindow = NULL;
////////////////////////////////////////////////////////////
/// Create the window implementation from an existing control
////////////////////////////////////////////////////////////
WindowImplWin32::WindowImplWin32(WindowHandle handle) :
myHandle (NULL),
myCallback (0),
@ -86,8 +86,6 @@ myIsCursorIn (false)
}
////////////////////////////////////////////////////////////
/// Create the window implementation
////////////////////////////////////////////////////////////
WindowImplWin32::WindowImplWin32(VideoMode mode, const std::string& title, unsigned long style) :
myHandle (NULL),
@ -98,7 +96,7 @@ myKeyRepeatEnabled(true),
myIsCursorIn (false)
{
// Register the window class at first call
if (ourWindowCount == 0)
if (WindowCount == 0)
RegisterWindowClass();
// Compute position and size
@ -136,11 +134,11 @@ myIsCursorIn (false)
wchar_t wTitle[256];
int count = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, title.c_str(), static_cast<int>(title.size()), wTitle, sizeof(wTitle) / sizeof(*wTitle));
wTitle[count] = L'\0';
myHandle = CreateWindowW(ourClassNameW, wTitle, win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this);
myHandle = CreateWindowW(ClassNameW, wTitle, win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this);
}
else
{
myHandle = CreateWindowA(ourClassNameA, title.c_str(), win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this);
myHandle = CreateWindowA(ClassNameA, title.c_str(), win32Style, left, top, width, height, NULL, NULL, GetModuleHandle(NULL), this);
}
// Switch to fullscreen if requested
@ -148,7 +146,7 @@ myIsCursorIn (false)
SwitchToFullscreen(mode);
// Increment window count
ourWindowCount++;
WindowCount++;
// Get the actual size of the window, which can be smaller even after the call to AdjustWindowRect
// This happens when the window is bigger than the desktop
@ -159,8 +157,6 @@ myIsCursorIn (false)
}
////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
WindowImplWin32::~WindowImplWin32()
{
@ -175,18 +171,18 @@ WindowImplWin32::~WindowImplWin32()
DestroyWindow(myHandle);
// Decrement the window count
ourWindowCount--;
WindowCount--;
// Unregister window class if we were the last window
if (ourWindowCount == 0)
if (WindowCount == 0)
{
if (HasUnicodeSupport())
{
UnregisterClassW(ourClassNameW, GetModuleHandle(NULL));
UnregisterClassW(ClassNameW, GetModuleHandle(NULL));
}
else
{
UnregisterClassA(ourClassNameA, GetModuleHandle(NULL));
UnregisterClassA(ClassNameA, GetModuleHandle(NULL));
}
}
}
@ -198,8 +194,6 @@ WindowImplWin32::~WindowImplWin32()
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::GetHandle
////////////////////////////////////////////////////////////
WindowHandle WindowImplWin32::GetHandle() const
{
@ -207,8 +201,6 @@ WindowHandle WindowImplWin32::GetHandle() const
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::ProcessEvents
////////////////////////////////////////////////////////////
void WindowImplWin32::ProcessEvents()
{
@ -225,8 +217,6 @@ void WindowImplWin32::ProcessEvents()
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::ShowMouseCursor
////////////////////////////////////////////////////////////
void WindowImplWin32::ShowMouseCursor(bool show)
{
@ -239,8 +229,6 @@ void WindowImplWin32::ShowMouseCursor(bool show)
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetCursorPosition
////////////////////////////////////////////////////////////
void WindowImplWin32::SetCursorPosition(unsigned int left, unsigned int top)
{
@ -250,8 +238,6 @@ void WindowImplWin32::SetCursorPosition(unsigned int left, unsigned int top)
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetPosition
////////////////////////////////////////////////////////////
void WindowImplWin32::SetPosition(int left, int top)
{
@ -259,8 +245,6 @@ void WindowImplWin32::SetPosition(int left, int top)
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetSize
////////////////////////////////////////////////////////////
void WindowImplWin32::SetSize(unsigned int width, unsigned int height)
{
@ -275,8 +259,6 @@ void WindowImplWin32::SetSize(unsigned int width, unsigned int height)
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::Show
////////////////////////////////////////////////////////////
void WindowImplWin32::Show(bool show)
{
@ -284,8 +266,6 @@ void WindowImplWin32::Show(bool show)
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::EnableKeyRepeat
////////////////////////////////////////////////////////////
void WindowImplWin32::EnableKeyRepeat(bool enabled)
{
@ -293,8 +273,6 @@ void WindowImplWin32::EnableKeyRepeat(bool enabled)
}
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetIcon
////////////////////////////////////////////////////////////
void WindowImplWin32::SetIcon(unsigned int width, unsigned int height, const Uint8* pixels)
{
@ -328,8 +306,6 @@ void WindowImplWin32::SetIcon(unsigned int width, unsigned int height, const Uin
}
////////////////////////////////////////////////////////////
/// Register the window class
////////////////////////////////////////////////////////////
void WindowImplWin32::RegisterWindowClass()
{
@ -345,7 +321,7 @@ void WindowImplWin32::RegisterWindowClass()
WindowClass.hCursor = 0;
WindowClass.hbrBackground = 0;
WindowClass.lpszMenuName = NULL;
WindowClass.lpszClassName = ourClassNameW;
WindowClass.lpszClassName = ClassNameW;
RegisterClassW(&WindowClass);
}
else
@ -360,14 +336,12 @@ void WindowImplWin32::RegisterWindowClass()
WindowClass.hCursor = 0;
WindowClass.hbrBackground = 0;
WindowClass.lpszMenuName = NULL;
WindowClass.lpszClassName = ourClassNameA;
WindowClass.lpszClassName = ClassNameA;
RegisterClassA(&WindowClass);
}
}
////////////////////////////////////////////////////////////
/// Switch to fullscreen mode
////////////////////////////////////////////////////////////
void WindowImplWin32::SwitchToFullscreen(const VideoMode& mode)
{
@ -394,7 +368,7 @@ void WindowImplWin32::SwitchToFullscreen(const VideoMode& mode)
ShowWindow(myHandle, SW_SHOW);
// Set "this" as the current fullscreen window
ourFullscreenWindow = this;
FullscreenWindow = this;
// SetPixelFormat can fail (really ?) if window style doesn't contain these flags
long style = GetWindowLong(myHandle, GWL_STYLE);
@ -402,16 +376,14 @@ void WindowImplWin32::SwitchToFullscreen(const VideoMode& mode)
}
////////////////////////////////////////////////////////////
/// Free all the graphical resources attached to the window
////////////////////////////////////////////////////////////
void WindowImplWin32::Cleanup()
{
// Restore the previous video mode (in case we were running in fullscreen)
if (ourFullscreenWindow == this)
if (FullscreenWindow == this)
{
ChangeDisplaySettings(NULL, 0);
ourFullscreenWindow = NULL;
FullscreenWindow = NULL;
}
// Unhide the mouse cursor (in case it was hidden)
@ -419,8 +391,6 @@ void WindowImplWin32::Cleanup()
}
////////////////////////////////////////////////////////////
/// Process a Win32 event
////////////////////////////////////////////////////////////
void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
{
@ -703,9 +673,6 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
}
////////////////////////////////////////////////////////////
/// Check the state of the shift keys on a key event,
/// and return the corresponding SF key code
////////////////////////////////////////////////////////////
Key::Code WindowImplWin32::GetShiftState(bool keyDown)
{
@ -734,8 +701,6 @@ Key::Code WindowImplWin32::GetShiftState(bool keyDown)
}
////////////////////////////////////////////////////////////
/// Convert a Win32 virtual key code to a SFML key code
////////////////////////////////////////////////////////////
Key::Code WindowImplWin32::VirtualKeyCodeToSF(WPARAM key, LPARAM flags)
{
@ -845,10 +810,6 @@ Key::Code WindowImplWin32::VirtualKeyCodeToSF(WPARAM key, LPARAM flags)
}
////////////////////////////////////////////////////////////
/// Check if the current version of the OS supports unicode
/// messages and functions ; Windows 95/98/Me may not support
/// it, whereas Windows NT/2000/XP/Vista will
////////////////////////////////////////////////////////////
bool WindowImplWin32::HasUnicodeSupport()
{
@ -867,8 +828,6 @@ bool WindowImplWin32::HasUnicodeSupport()
}
////////////////////////////////////////////////////////////
/// Function called whenever one of our windows receives a message
////////////////////////////////////////////////////////////
LRESULT CALLBACK WindowImplWin32::GlobalOnEvent(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)
{

View File

@ -39,32 +39,33 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// WindowImplWin32 is the Win32 implementation of WindowImpl
/// \brief Windows implementation of WindowImpl
///
////////////////////////////////////////////////////////////
class WindowImplWin32 : public WindowImpl
{
public :
////////////////////////////////////////////////////////////
/// Construct the window implementation from an existing control
/// \brief Construct the window implementation from an existing control
///
/// \param handle : Platform-specific handle of the control
/// \param handle Platform-specific handle of the control
///
////////////////////////////////////////////////////////////
WindowImplWin32(WindowHandle handle);
////////////////////////////////////////////////////////////
/// Create the window implementation
/// \brief Create the window implementation
///
/// \param mode : Video mode to use
/// \param title : Title of the window
/// \param style : Window style
/// \param mode Video mode to use
/// \param title Title of the window
/// \param style Window style
///
////////////////////////////////////////////////////////////
WindowImplWin32(VideoMode mode, const std::string& title, unsigned long style);
////////////////////////////////////////////////////////////
/// Destructor
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~WindowImplWin32();
@ -72,55 +73,76 @@ public :
private :
////////////////////////////////////////////////////////////
/// /see WindowImpl::GetHandle
/// \brief Get the OS-specific handle of the window
///
/// \return Handle of the window
///
////////////////////////////////////////////////////////////
virtual WindowHandle GetHandle() const;
////////////////////////////////////////////////////////////
/// /see WindowImpl::ProcessEvents
/// \brief Process incoming events from operating system
///
////////////////////////////////////////////////////////////
virtual void ProcessEvents();
////////////////////////////////////////////////////////////
/// /see WindowImpl::ShowMouseCursor
/// \brief Show or hide the mouse cursor
///
/// \param show True to show, false to hide
///
////////////////////////////////////////////////////////////
virtual void ShowMouseCursor(bool show);
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetCursorPosition
/// \brief Change the position of the mouse cursor
///
/// \param left Left coordinate of the cursor, relative to the window
/// \param top Top coordinate of the cursor, relative to the window
///
////////////////////////////////////////////////////////////
virtual void SetCursorPosition(unsigned int left, unsigned int top);
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetPosition
/// \brief Change the position of the window on screen
///
/// \param left Left position
/// \param top Top position
///
////////////////////////////////////////////////////////////
virtual void SetPosition(int left, int top);
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetSize
/// \brief Change the size of the rendering region of the window
///
/// \param width New width
/// \param height New height
///
////////////////////////////////////////////////////////////
virtual void SetSize(unsigned int width, unsigned int height);
////////////////////////////////////////////////////////////
/// /see WindowImpl::Show
/// \brief Show or hide the window
///
/// \param show True to show, false to hide
///
////////////////////////////////////////////////////////////
virtual void Show(bool show);
////////////////////////////////////////////////////////////
/// /see WindowImpl::EnableKeyRepeat
/// \brief Enable or disable automatic key-repeat
///
/// \param enabled True to enable, false to disable
///
////////////////////////////////////////////////////////////
virtual void EnableKeyRepeat(bool enabled);
////////////////////////////////////////////////////////////
/// /see WindowImpl::SetIcon
/// \brief Change the window's icon
///
/// \param width Icon's width, in pixels
/// \param height Icon's height, in pixels
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
///
////////////////////////////////////////////////////////////
virtual void SetIcon(unsigned int width, unsigned int height, const Uint8* pixels);
@ -132,34 +154,34 @@ private :
void RegisterWindowClass();
////////////////////////////////////////////////////////////
/// Switch to fullscreen mode
/// \brief Switch to fullscreen mode
///
/// \param mode : video mode to switch to
/// \param mode Video mode to switch to
///
////////////////////////////////////////////////////////////
void SwitchToFullscreen(const VideoMode& mode);
////////////////////////////////////////////////////////////
/// Free all the graphical resources attached to the window
/// \brief Free all the graphical resources attached to the window
///
////////////////////////////////////////////////////////////
void Cleanup();
////////////////////////////////////////////////////////////
/// Process a Win32 event
/// \brief Process a Win32 event
///
/// \param message : Message to process
/// \param wParam : First parameter of the event
/// \param lParam : Second parameter of the event
/// \param message Message to process
/// \param wParam First parameter of the event
/// \param lParam Second parameter of the event
///
////////////////////////////////////////////////////////////
void ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam);
////////////////////////////////////////////////////////////
/// Check the state of the shift keys on a key event,
/// and return the corresponding SF key code
/// \brief Check the state of the shift keys on a key event,
/// and return the corresponding SFML key code
///
/// \param keyDown : True for a keydown event, false for a keyup event
/// \param keyDown True for a keydown event, false for a keyup event
///
/// \return SFML key code corresponding to the shift key
///
@ -167,10 +189,10 @@ private :
static Key::Code GetShiftState(bool keyDown);
////////////////////////////////////////////////////////////
/// Convert a Win32 virtual key code to a SFML key code
/// \brief Convert a Win32 virtual key code to a SFML key code
///
/// \param key : Virtual key code to convert
/// \param flags : Additional flags
/// \param key Virtual key code to convert
/// \param flags Additional flags
///
/// \return SFML key code corresponding to the key
///
@ -178,9 +200,10 @@ private :
static Key::Code VirtualKeyCodeToSF(WPARAM key, LPARAM flags);
////////////////////////////////////////////////////////////
/// Check if the current version of the OS supports unicode
/// messages and functions ; Windows 95/98/Me may not support
/// it, whereas Windows NT/2000/XP/Vista will
/// \brief Check if the current version of the OS supports
/// unicode messages and functions ; Windows 95/98/Me
/// may not support it, whereas Windows NT/2000/XP/Vista
/// will
///
/// \return True if the OS supports unicode
///
@ -188,26 +211,18 @@ private :
static bool HasUnicodeSupport();
////////////////////////////////////////////////////////////
/// Function called whenever one of our windows receives a message
/// \brief Function called whenever one of our windows receives a message
///
/// \param handle : Win32 handle of the window
/// \param message : Message received
/// \param wParam : First parameter of the message
/// \param lParam : Second parameter of the message
/// \param handle Win32 handle of the window
/// \param message Message received
/// \param wParam First parameter of the message
/// \param lParam Second parameter of the message
///
/// \return Something...
/// \return True to discard the event after it has been processed
///
////////////////////////////////////////////////////////////
static LRESULT CALLBACK GlobalOnEvent(HWND handle, UINT message, WPARAM wParam, LPARAM lParam);
////////////////////////////////////////////////////////////
// Static member data
////////////////////////////////////////////////////////////
static unsigned int ourWindowCount; ///< Number of windows that we own
static const char* ourClassNameA; ///< Win32 window class name (ANSI version)
static const wchar_t* ourClassNameW; ///< Win32 window class name (unicode version)
static WindowImplWin32* ourFullscreenWindow; ///< Window currently in fullscreen
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////

View File

@ -54,16 +54,12 @@ namespace sf
namespace priv
{
////////////////////////////////////////////////////////////
/// Create a new window depending on the current OS
////////////////////////////////////////////////////////////
WindowImpl* WindowImpl::New(VideoMode mode, const std::string& title, unsigned long style)
{
return new WindowImplType(mode, title, style);
}
////////////////////////////////////////////////////////////
/// Create a new window depending on the current OS
////////////////////////////////////////////////////////////
WindowImpl* WindowImpl::New(WindowHandle handle)
{
@ -71,8 +67,6 @@ WindowImpl* WindowImpl::New(WindowHandle handle)
}
////////////////////////////////////////////////////////////
/// Default constructor
////////////////////////////////////////////////////////////
WindowImpl::WindowImpl() :
myWidth (0),
@ -88,8 +82,6 @@ myJoyThreshold(0.1f)
}
////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
WindowImpl::~WindowImpl()
{
@ -97,8 +89,6 @@ WindowImpl::~WindowImpl()
}
////////////////////////////////////////////////////////////
/// Add a listener to the window
////////////////////////////////////////////////////////////
void WindowImpl::AddListener(WindowListener* listener)
{
@ -107,8 +97,6 @@ void WindowImpl::AddListener(WindowListener* listener)
}
////////////////////////////////////////////////////////////
/// Remove a listener from the window
////////////////////////////////////////////////////////////
void WindowImpl::RemoveListener(WindowListener* listener)
{
@ -116,8 +104,6 @@ void WindowImpl::RemoveListener(WindowListener* listener)
}
////////////////////////////////////////////////////////////
/// Get the client width of the window
////////////////////////////////////////////////////////////
unsigned int WindowImpl::GetWidth() const
{
@ -125,8 +111,6 @@ unsigned int WindowImpl::GetWidth() const
}
////////////////////////////////////////////////////////////
/// Get the client height of the window
////////////////////////////////////////////////////////////
unsigned int WindowImpl::GetHeight() const
{
@ -134,9 +118,6 @@ unsigned int WindowImpl::GetHeight() const
}
////////////////////////////////////////////////////////////
/// Change the joystick threshold, ie. the value below which
/// no move event will be generated
////////////////////////////////////////////////////////////
void WindowImpl::SetJoystickThreshold(float threshold)
{
@ -144,8 +125,6 @@ void WindowImpl::SetJoystickThreshold(float threshold)
}
////////////////////////////////////////////////////////////
/// Process incoming events from operating system
////////////////////////////////////////////////////////////
void WindowImpl::DoEvents()
{
@ -157,8 +136,6 @@ void WindowImpl::DoEvents()
}
////////////////////////////////////////////////////////////
/// Send an event to listeners
////////////////////////////////////////////////////////////
void WindowImpl::SendEvent(const Event& event)
{
@ -169,8 +146,6 @@ void WindowImpl::SendEvent(const Event& event)
}
////////////////////////////////////////////////////////////
/// Read the joysticks state and generate the appropriate events
////////////////////////////////////////////////////////////
void WindowImpl::ProcessJoystickEvents()
{

View File

@ -45,30 +45,31 @@ class WindowListener;
namespace priv
{
////////////////////////////////////////////////////////////
/// Abstract base class for OS-specific window implementation
/// \brief Abstract base class for OS-specific window implementation
///
////////////////////////////////////////////////////////////
class WindowImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// Create a new window depending on the current OS
/// \brief Create a new window depending on the current OS
///
/// \param mode : Video mode to use
/// \param title : Title of the window
/// \param style : Window style
/// \param mode Video mode to use
/// \param title Title of the window
/// \param style Window style
///
/// \return Pointer to the created window
/// \return Pointer to the created window (don't forget to delete it)
///
////////////////////////////////////////////////////////////
static WindowImpl* New(VideoMode mode, const std::string& title, unsigned long style);
////////////////////////////////////////////////////////////
/// Create a new window depending on to the current OS
/// \brief Create a new window depending on to the current OS
///
/// \param handle : Platform-specific handle of the control
/// \param handle Platform-specific handle of the control
///
/// \return Pointer to the created window
/// \return Pointer to the created window (don't forget to delete it)
///
////////////////////////////////////////////////////////////
static WindowImpl* New(WindowHandle handle);
@ -76,29 +77,29 @@ public :
public :
////////////////////////////////////////////////////////////
/// Destructor
/// \brief Destructor
///
////////////////////////////////////////////////////////////
virtual ~WindowImpl();
////////////////////////////////////////////////////////////
/// Add a listener to the window
/// \brief Add a listener to the window
///
/// \param listener : Listener to add
/// \param listener Listener to add
///
////////////////////////////////////////////////////////////
void AddListener(WindowListener* listener);
////////////////////////////////////////////////////////////
/// Remove a listener from the window
/// \brief Remove a listener from the window
///
/// \param listener : Listener to remove
/// \param listener Listener to remove
///
////////////////////////////////////////////////////////////
void RemoveListener(WindowListener* listener);
////////////////////////////////////////////////////////////
/// Get the client width of the window
/// \brief Get the client width of the window
///
/// \return Width of the window in pixels
///
@ -106,7 +107,7 @@ public :
unsigned int GetWidth() const;
////////////////////////////////////////////////////////////
/// Get the client height of the window
/// \brief Get the client height of the window
///
/// \return Height of the window in pixels
///
@ -114,8 +115,8 @@ public :
unsigned int GetHeight() const;
////////////////////////////////////////////////////////////
/// Change the joystick threshold, ie. the value below which
/// no move event will be generated
/// \brief Change the joystick threshold, ie. the value below which
/// no move event will be generated
///
/// \param threshold : New threshold, in range [0, 100]
///
@ -123,13 +124,13 @@ public :
void SetJoystickThreshold(float threshold);
////////////////////////////////////////////////////////////
/// Process incoming events from operating system
/// \brief Process incoming events from operating system
///
////////////////////////////////////////////////////////////
void DoEvents();
////////////////////////////////////////////////////////////
/// Get the OS-specific handle of the window
/// \brief Get the OS-specific handle of the window
///
/// \return Handle of the window
///
@ -137,62 +138,62 @@ public :
virtual WindowHandle GetHandle() const = 0;
////////////////////////////////////////////////////////////
/// Show or hide the mouse cursor
/// \brief Show or hide the mouse cursor
///
/// \param show : True to show, false to hide
/// \param show True to show, false to hide
///
////////////////////////////////////////////////////////////
virtual void ShowMouseCursor(bool show) = 0;
////////////////////////////////////////////////////////////
/// Change the position of the mouse cursor
/// \brief Change the position of the mouse cursor
///
/// \param left : Left coordinate of the cursor, relative to the window
/// \param top : Top coordinate of the cursor, relative to the window
/// \param left Left coordinate of the cursor, relative to the window
/// \param top Top coordinate of the cursor, relative to the window
///
////////////////////////////////////////////////////////////
virtual void SetCursorPosition(unsigned int left, unsigned int top) = 0;
////////////////////////////////////////////////////////////
/// Change the position of the window on screen
/// \brief Change the position of the window on screen
///
/// \param left : Left position
/// \param top : Top position
/// \param left Left position
/// \param top Top position
///
////////////////////////////////////////////////////////////
virtual void SetPosition(int left, int top) = 0;
////////////////////////////////////////////////////////////
/// Change the size of the rendering region of the window
/// \brief Change the size of the rendering region of the window
///
/// \param width : New width
/// \param height : New height
/// \param width New width
/// \param height New height
///
////////////////////////////////////////////////////////////
virtual void SetSize(unsigned int width, unsigned int height) = 0;
////////////////////////////////////////////////////////////
/// Show or hide the window
/// \brief Show or hide the window
///
/// \param show : True to show, false to hide
/// \param show True to show, false to hide
///
////////////////////////////////////////////////////////////
virtual void Show(bool show) = 0;
////////////////////////////////////////////////////////////
/// Enable or disable automatic key-repeat
/// \brief Enable or disable automatic key-repeat
///
/// \param enabled : True to enable, false to disable
/// \param enabled True to enable, false to disable
///
////////////////////////////////////////////////////////////
virtual void EnableKeyRepeat(bool enabled) = 0;
////////////////////////////////////////////////////////////
/// Change the window's icon
/// \brief Change the window's icon
///
/// \param width : Icon's width, in pixels
/// \param height : Icon's height, in pixels
/// \param pixels : Pointer to the pixels in memory, format must be RGBA 32 bits
/// \param width Icon's width, in pixels
/// \param height Icon's height, in pixels
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
///
////////////////////////////////////////////////////////////
virtual void SetIcon(unsigned int width, unsigned int height, const Uint8* pixels) = 0;
@ -200,15 +201,15 @@ public :
protected :
////////////////////////////////////////////////////////////
/// Default constructor
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
WindowImpl();
////////////////////////////////////////////////////////////
/// Send an event to listeners (for derived classes only)
/// \brief Send an event to listeners (for derived classes only)
///
/// \param event : Event to send
/// \param event Event to send
///
////////////////////////////////////////////////////////////
void SendEvent(const Event& event);
@ -222,13 +223,13 @@ protected :
private :
////////////////////////////////////////////////////////////
/// Read the joysticks state and generate the appropriate events
/// \brief Read the joysticks state and generate the appropriate events
///
////////////////////////////////////////////////////////////
void ProcessJoystickEvents();
////////////////////////////////////////////////////////////
/// Process incoming events from operating system
/// \brief Process incoming events from operating system
///
////////////////////////////////////////////////////////////
virtual void ProcessEvents() = 0;