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

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

@ -1,103 +1,101 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Linux/VideoModeSupport.hpp>
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#include <algorithm>
#include <iostream>
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
/// Get supported video modes
////////////////////////////////////////////////////////////
void VideoModeSupport::GetSupportedVideoModes(std::vector<VideoMode>& modes)
{
// First, clear array to fill
modes.clear();
// Open a connection with the X server
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Linux/VideoModeSupport.hpp>
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#include <algorithm>
#include <iostream>
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
void VideoModeSupport::GetSupportedVideoModes(std::vector<VideoMode>& modes)
{
// First, clear array to fill
modes.clear();
// Open a connection with the X server
Display* disp = XOpenDisplay(NULL);
if (disp)
{
// Retrieve the default screen number
int screen = DefaultScreen(disp);
// Check if the XRandR extension is present
int version;
if (XQueryExtension(disp, "RANDR", &version, &version, &version))
{
// Get the current configuration
XRRScreenConfiguration* config = XRRGetScreenInfo(disp, RootWindow(disp, screen));
if (config)
{
// Get the available screen sizes
int nbSizes;
XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes);
if (sizes && (nbSizes > 0))
{
// Get the list of supported depths
int nbDepths = 0;
int* depths = XListDepths(disp, screen, &nbDepths);
if (depths && (nbDepths > 0))
{
// Combine depths and sizes to fill the array of supported modes
for (int i = 0; i < nbDepths; ++i)
{
for (int j = 0; j < nbSizes; ++j)
{
// Convert to VideoMode
VideoMode mode(sizes[j].width, sizes[j].height, depths[i]);
// Add it only if it is not already in the array
if (std::find(modes.begin(), modes.end(), mode) == modes.end())
modes.push_back(mode);
}
}
}
}
// Free the configuration instance
XRRFreeScreenConfigInfo(config);
}
else
{
// Failed to get the screen configuration
std::cerr << "Failed to retrieve the screen configuration while trying to get the supported video modes" << std::endl;
}
}
else
{
// XRandr extension is not supported : we cannot get the video modes
std::cerr << "Failed to use the XRandR extension while trying to get the supported video modes" << std::endl;
// Retrieve the default screen number
int screen = DefaultScreen(disp);
// Check if the XRandR extension is present
int version;
if (XQueryExtension(disp, "RANDR", &version, &version, &version))
{
// Get the current configuration
XRRScreenConfiguration* config = XRRGetScreenInfo(disp, RootWindow(disp, screen));
if (config)
{
// Get the available screen sizes
int nbSizes;
XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes);
if (sizes && (nbSizes > 0))
{
// Get the list of supported depths
int nbDepths = 0;
int* depths = XListDepths(disp, screen, &nbDepths);
if (depths && (nbDepths > 0))
{
// Combine depths and sizes to fill the array of supported modes
for (int i = 0; i < nbDepths; ++i)
{
for (int j = 0; j < nbSizes; ++j)
{
// Convert to VideoMode
VideoMode mode(sizes[j].width, sizes[j].height, depths[i]);
// Add it only if it is not already in the array
if (std::find(modes.begin(), modes.end(), mode) == modes.end())
modes.push_back(mode);
}
}
}
}
// Free the configuration instance
XRRFreeScreenConfigInfo(config);
}
else
{
// Failed to get the screen configuration
std::cerr << "Failed to retrieve the screen configuration while trying to get the supported video modes" << std::endl;
}
}
else
{
// XRandr extension is not supported : we cannot get the video modes
std::cerr << "Failed to use the XRandR extension while trying to get the supported video modes" << std::endl;
}
// Close the connection with the X server
@ -105,71 +103,69 @@ void VideoModeSupport::GetSupportedVideoModes(std::vector<VideoMode>& modes)
}
else
{
// We couldn't connect to the X server
std::cerr << "Failed to connect to the X server while trying to get the supported video modes" << std::endl;
// We couldn't connect to the X server
std::cerr << "Failed to connect to the X server while trying to get the supported video modes" << std::endl;
}
}
////////////////////////////////////////////////////////////
/// Get current desktop video mode
////////////////////////////////////////////////////////////
VideoMode VideoModeSupport::GetDesktopVideoMode()
{
VideoMode desktopMode;
// Open a connection with the X server
}
////////////////////////////////////////////////////////////
VideoMode VideoModeSupport::GetDesktopVideoMode()
{
VideoMode desktopMode;
// Open a connection with the X server
Display* disp = XOpenDisplay(NULL);
if (disp)
{
// Retrieve the default screen number
int screen = DefaultScreen(disp);
// Check if the XRandR extension is present
int version;
if (XQueryExtension(disp, "RANDR", &version, &version, &version))
{
// Get the current configuration
XRRScreenConfiguration* config = XRRGetScreenInfo(disp, RootWindow(disp, screen));
if (config)
{
// Get the current video mode
Rotation currentRotation;
int currentMode = XRRConfigCurrentConfiguration(config, &currentRotation);
// Get the available screen sizes
int nbSizes;
XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes);
if (sizes && (nbSizes > 0))
desktopMode = VideoMode(sizes[currentMode].width, sizes[currentMode].height, DefaultDepth(disp, screen));
// Free the configuration instance
XRRFreeScreenConfigInfo(config);
}
else
{
// Failed to get the screen configuration
std::cerr << "Failed to retrieve the screen configuration while trying to get the desktop video modes" << std::endl;
}
}
else
{
// XRandr extension is not supported : we cannot get the video modes
std::cerr << "Failed to use the XRandR extension while trying to get the desktop video modes" << std::endl;
}
// Retrieve the default screen number
int screen = DefaultScreen(disp);
// Check if the XRandR extension is present
int version;
if (XQueryExtension(disp, "RANDR", &version, &version, &version))
{
// Get the current configuration
XRRScreenConfiguration* config = XRRGetScreenInfo(disp, RootWindow(disp, screen));
if (config)
{
// Get the current video mode
Rotation currentRotation;
int currentMode = XRRConfigCurrentConfiguration(config, &currentRotation);
// Get the available screen sizes
int nbSizes;
XRRScreenSize* sizes = XRRConfigSizes(config, &nbSizes);
if (sizes && (nbSizes > 0))
desktopMode = VideoMode(sizes[currentMode].width, sizes[currentMode].height, DefaultDepth(disp, screen));
// Free the configuration instance
XRRFreeScreenConfigInfo(config);
}
else
{
// Failed to get the screen configuration
std::cerr << "Failed to retrieve the screen configuration while trying to get the desktop video modes" << std::endl;
}
}
else
{
// XRandr extension is not supported : we cannot get the video modes
std::cerr << "Failed to use the XRandR extension while trying to get the desktop video modes" << std::endl;
}
// Close the connection with the X server
XCloseDisplay(disp);
}
else
{
// We couldn't connect to the X server
std::cerr << "Failed to connect to the X server while trying to get the desktop video modes" << std::endl;
// We couldn't connect to the X server
std::cerr << "Failed to connect to the X server while trying to get the desktop video modes" << std::endl;
}
return desktopMode;
}
} // namespace priv
} // namespace sf
return desktopMode;
}
} // namespace priv
} // namespace sf

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

File diff suppressed because it is too large Load diff

View file

@ -1,203 +1,226 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_WINDOWIMPLX11_HPP
#define SFML_WINDOWIMPLX11_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Event.hpp>
#include <SFML/Window/WindowImpl.hpp>
#include <X11/Xlib.h>
#include <set>
#include <string>
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
/// WindowImplX11 is the Linux (X11) implementation of WindowImpl
////////////////////////////////////////////////////////////
class WindowImplX11 : public WindowImpl
{
public :
////////////////////////////////////////////////////////////
/// Construct the window implementation from an existing control
///
/// \param handle : Platform-specific handle of the control
///
////////////////////////////////////////////////////////////
WindowImplX11(WindowHandle handle);
////////////////////////////////////////////////////////////
/// Create the window implementation
///
/// \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
///
////////////////////////////////////////////////////////////
~WindowImplX11();
////////////////////////////////////////////////////////////
/// Get the display used by the window.
/// This functions is meant to be used internally by ContextGLX.
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_WINDOWIMPLX11_HPP
#define SFML_WINDOWIMPLX11_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Event.hpp>
#include <SFML/Window/WindowImpl.hpp>
#include <X11/Xlib.h>
#include <set>
#include <string>
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
/// \brief Linux (X11) implementation of WindowImpl
///
////////////////////////////////////////////////////////////
class WindowImplX11 : public WindowImpl
{
public :
////////////////////////////////////////////////////////////
/// \brief Construct the window implementation from an existing control
///
/// \param handle Platform-specific handle of the control
///
////////////////////////////////////////////////////////////
WindowImplX11(WindowHandle handle);
////////////////////////////////////////////////////////////
/// \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)
///
////////////////////////////////////////////////////////////
WindowImplX11(VideoMode mode, const std::string& title, unsigned long style);
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~WindowImplX11();
////////////////////////////////////////////////////////////
/// \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
///
////////////////////////////////////////////////////////////
///
////////////////////////////////////////////////////////////
::Display* GetDisplay() const;
private :
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
///
/// \param Mode : video mode to switch to
///
////////////////////////////////////////////////////////////
void SwitchToFullscreen(const VideoMode& mode);
////////////////////////////////////////////////////////////
/// Do some common initializations after the window has been created
///
////////////////////////////////////////////////////////////
void Initialize();
////////////////////////////////////////////////////////////
/// Create a transparent mouse cursor
///
////////////////////////////////////////////////////////////
void CreateHiddenCursor();
////////////////////////////////////////////////////////////
/// Cleanup graphical resources attached to the window
///
////////////////////////////////////////////////////////////
void CleanUp();
////////////////////////////////////////////////////////////
/// Process an incoming event from the window
///
/// \param windowEvent : Event which has been received
///
////////////////////////////////////////////////////////////
void ProcessEvent(XEvent windowEvent);
////////////////////////////////////////////////////////////
/// Convert a X11 keysym to SFML key code
///
/// \param symbol : keysym to convert
///
/// \return Corrsponding SFML key code
///
////////////////////////////////////////////////////////////
static Key::Code KeysymToSF(KeySym symbol);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
::Window myWindow; ///< X11 structure defining our window
::Display* myDisplay; ///< Pointer to the display
////////////////////////////////////////////////////////////
/// \brief Switch to fullscreen mode
///
/// \param Mode video mode to switch to
///
////////////////////////////////////////////////////////////
void SwitchToFullscreen(const VideoMode& mode);
////////////////////////////////////////////////////////////
/// \brief Do some common initializations after the window has been created
///
////////////////////////////////////////////////////////////
void Initialize();
////////////////////////////////////////////////////////////
/// \brief Create a transparent mouse cursor
///
////////////////////////////////////////////////////////////
void CreateHiddenCursor();
////////////////////////////////////////////////////////////
/// \brief Cleanup graphical resources attached to the window
///
////////////////////////////////////////////////////////////
void CleanUp();
////////////////////////////////////////////////////////////
/// \brief Process an incoming event from the window
///
/// \param windowEvent Event which has been received
///
////////////////////////////////////////////////////////////
void ProcessEvent(XEvent windowEvent);
////////////////////////////////////////////////////////////
/// \brief Convert a X11 keysym to SFML key code
///
/// \param symbol Key symbol to convert
///
/// \return Corrsponding SFML key code
///
////////////////////////////////////////////////////////////
static Key::Code KeysymToSF(KeySym symbol);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
::Window myWindow; ///< X11 structure defining our window
::Display* myDisplay; ///< Pointer to the display
int myScreen; ///< Screen identifier
XIM myInputMethod; ///< Input method linked to the X display
XIC myInputContext; ///< Input context used to get unicode input in our window
bool myIsExternal; ///< Tell whether the window has been created externally or by SFML
Atom myAtomClose; ///< Atom used to identify the close event
int myOldVideoMode; ///< Video mode in use before we switch to fullscreen
Cursor myHiddenCursor; ///< As X11 doesn't provide cursor hidding, we must create a transparent one
bool myKeyRepeat; ///< Is the KeyRepeat feature enabled ?
XEvent myLastKeyReleaseEvent; ///< Last key release event we received (needed for discarding repeated key events)
};
} // namespace priv
} // namespace sf
#endif // SFML_WINDOWIMPLX11_HPP
XIM myInputMethod; ///< Input method linked to the X display
XIC myInputContext; ///< Input context used to get unicode input in our window
bool myIsExternal; ///< Tell whether the window has been created externally or by SFML
Atom myAtomClose; ///< Atom used to identify the close event
int myOldVideoMode; ///< Video mode in use before we switch to fullscreen
Cursor myHiddenCursor; ///< As X11 doesn't provide cursor hidding, we must create a transparent one
bool myKeyRepeat; ///< Is the KeyRepeat feature enabled ?
XEvent myLastKeyReleaseEvent; ///< Last key release event we received (needed for discarding repeated key events)
};
} // namespace priv
} // namespace sf
#endif // SFML_WINDOWIMPLX11_HPP

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;