mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Updated the API documentation of RenderTarget, RenderImage and RenderWindow
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1413 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
fd10d2abfe
commit
0aaebddc7b
@ -40,31 +40,44 @@ namespace priv
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Target for 2D rendering into an image that can be reused
|
||||
/// in a sprite
|
||||
/// \brief Target for off-screen 2D rendering into an image
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API RenderImage : public RenderTarget
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
/// \brief Default constructor
|
||||
///
|
||||
/// Constructs an empty, invalid render-image. You must
|
||||
/// call Create to have a valid render-image.
|
||||
///
|
||||
/// \see Create
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImage();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
/// \brief Destructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual ~RenderImage();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create the render image from its dimensions
|
||||
/// \brief Create the render-image
|
||||
///
|
||||
/// \param width : Width of the render image
|
||||
/// \param height : Height of the render image
|
||||
/// \param depthBuffer : Do you want this render image to have a depth buffer?
|
||||
/// Before calling this function, the render-image is in
|
||||
/// an invalid state, thus it is mandatory to call it before
|
||||
/// doing anything with the render-image.
|
||||
/// The last parameter, \a depthBuffer, is useful if you want
|
||||
/// to use the render-image for 3D OpenGL rendering that requires
|
||||
/// a depth-buffer. Otherwise it is unnecessary, and you should
|
||||
/// leave this parameter to false (which is its default value).
|
||||
///
|
||||
/// \param width Width of the render-image
|
||||
/// \param height Height of the render-image
|
||||
/// \param depthBuffer Do you want this render-image to have a depth buffer?
|
||||
///
|
||||
/// \return True if creation has been successful
|
||||
///
|
||||
@ -72,27 +85,39 @@ public :
|
||||
bool Create(unsigned int width, unsigned int height, bool depthBuffer = false);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Enable or disable image smooth filter.
|
||||
/// This parameter is enabled by default
|
||||
/// \brief Enable or disable image smoothing
|
||||
///
|
||||
/// \param smooth : True to enable smoothing filter, false to disable it
|
||||
/// This function is similar to Image::SetSmooth.
|
||||
/// This parameter is enabled by default.
|
||||
///
|
||||
/// \param smooth True to enable smoothing, false to disable it
|
||||
///
|
||||
/// \see IsSmooth
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetSmooth(bool smooth);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Tells whether the smooth filtering is enabled or not
|
||||
/// \brief Tell whether the smooth filtering is enabled or not
|
||||
///
|
||||
/// \return True if image smoothing is enabled
|
||||
///
|
||||
/// \see SetSmooth
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool IsSmooth() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Activate of deactivate the render-image as the current target
|
||||
/// for rendering
|
||||
/// \brief Activate of deactivate the render-image for rendering
|
||||
///
|
||||
/// \param active : True to activate, false to deactivate
|
||||
/// This function makes the render-image's context current for
|
||||
/// future OpenGL rendering operations (so you shouldn't care
|
||||
/// about it if you're not doing direct OpenGL stuff).
|
||||
/// Only one context can be current on a thread, so if you
|
||||
/// want to draw OpenGL geometry to another render target
|
||||
/// (like a RenderWindow) don't forget to activate it again.
|
||||
///
|
||||
/// \param active True to activate, false to deactivate
|
||||
///
|
||||
/// \return True if operation was successful, false otherwise
|
||||
///
|
||||
@ -100,37 +125,66 @@ public :
|
||||
bool SetActive(bool active = true);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Update the contents of the target image
|
||||
/// \brief Update the contents of the target image
|
||||
///
|
||||
/// This function updates the target image with what
|
||||
/// has been drawn so far. Like for windows, calling this
|
||||
/// function is mandatory at the end of rendering. Not calling
|
||||
/// it may leave the image in an undefined state.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Display();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the width of the rendering region of the image
|
||||
/// \brief Return the width of the rendering region of the image
|
||||
///
|
||||
/// The returned value is the size that you passed to
|
||||
/// the Create function.
|
||||
///
|
||||
/// \return Width in pixels
|
||||
///
|
||||
/// \return GetHeight
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetWidth() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the height of the rendering region of the image
|
||||
/// \brief Return the height of the rendering region of the image
|
||||
///
|
||||
/// The returned value is the size that you passed to
|
||||
/// the Create function.
|
||||
///
|
||||
/// \return Height in pixels
|
||||
///
|
||||
/// \return GetWidth
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetHeight() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the target image
|
||||
/// \brief Get a read-only reference to the target image
|
||||
///
|
||||
/// \return Target image
|
||||
/// After drawing to the render-image and calling Display,
|
||||
/// you can retrieve the updated image using this function,
|
||||
/// and draw it using a sprite (for example).
|
||||
/// The internal sf::Image of a render-image is always the
|
||||
/// same instance, so that it is possible to call this function
|
||||
/// once and keep a reference to the image even after is it
|
||||
/// modified.
|
||||
///
|
||||
/// \return Const reference to the image
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Image& GetImage() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Check whether the system supports render images or not
|
||||
/// \brief Check whether the system supports render images or not
|
||||
///
|
||||
/// It is very important to always call this function before
|
||||
/// trying to use the RenderImage class, as the feature may not
|
||||
/// be supported on all platforms (especially very old ones).
|
||||
/// If this function returns false, then you won't be able
|
||||
/// to use the class at all.
|
||||
///
|
||||
/// \return True if the RenderImage class can be used
|
||||
///
|
||||
@ -140,7 +194,14 @@ public :
|
||||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// /see RenderTarget::Activate
|
||||
/// \brief Activate the targt efor rendering
|
||||
///
|
||||
/// This function is called by the base class
|
||||
/// everytime it's going to use OpenGL calls.
|
||||
///
|
||||
/// \param active True to make the target active, false to deactivate it
|
||||
///
|
||||
/// \return True if the function succeeded
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Activate(bool active);
|
||||
@ -156,3 +217,72 @@ private :
|
||||
|
||||
|
||||
#endif // SFML_RENDERIMAGE_HPP
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \class sf::RenderImage
|
||||
///
|
||||
/// sf::RenderImage is the little brother of sf::RenderWindow.
|
||||
/// It implements the same 2D drawing and OpenGL-related functions
|
||||
/// (see their base class sf::RenderTarget for more details),
|
||||
/// the difference is that the result is stored in an off-screen
|
||||
/// image rather than being show in a window.
|
||||
///
|
||||
/// Rendering to an image can be useful in a variety of situations:
|
||||
/// \li precomputing a complex static image (like a level's background from multiple tiles)
|
||||
/// \li applying post-effects to the whole scene with shaders
|
||||
/// \li creating a sprite from a 3D object rendered with OpenGL
|
||||
/// \li etc.
|
||||
///
|
||||
/// Usage example:
|
||||
///
|
||||
/// \code
|
||||
/// // First of all: make sure that rendering to image is supported
|
||||
/// if (!sf::RenderImage::IsAvailable())
|
||||
/// return -1;
|
||||
///
|
||||
/// // Create a new render-window
|
||||
/// sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
|
||||
///
|
||||
/// // Create a new render-image
|
||||
/// sf::RenderImage image;
|
||||
/// if (!image.Create(500, 500))
|
||||
/// return -1
|
||||
///
|
||||
/// // The main loop
|
||||
/// while (window.IsOpened())
|
||||
/// {
|
||||
/// // Event processing
|
||||
/// // ...
|
||||
///
|
||||
/// // Clear the whole image with red color
|
||||
/// image.Clear(sf::Color::Red);
|
||||
///
|
||||
/// // Draw stuff to the image
|
||||
/// image.Draw(sprite); // sprite is a sf::Sprite
|
||||
/// image.Draw(shape); // shape is a sf::Shape
|
||||
/// image.Draw(text); // text is a sf::Text
|
||||
///
|
||||
/// // We're done drawing to the image
|
||||
/// image.Display();
|
||||
///
|
||||
/// // Now we start rendering to the window, clear it first
|
||||
/// window.Clear();
|
||||
///
|
||||
/// // Draw the image
|
||||
/// sf::Sprite sprite(image.GetImage());
|
||||
/// window.Draw(sprite);
|
||||
///
|
||||
/// // End the current frame and display its contents on screen
|
||||
/// window.Display();
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
/// Like sf::RenderWindow, sf::RenderImage is still able to render direct
|
||||
/// OpenGL stuff. It is even possible to mix together OpenGL calls
|
||||
/// and regular SFML drawing commands. If you need a depth buffer for
|
||||
/// 3D rendering, don't forget to request it when calling RenderImage::Create.
|
||||
///
|
||||
/// \see sf::RenderTarget, sf::RenderWindow, sf::View
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -41,126 +41,221 @@ class Drawable;
|
||||
class Shader;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Base class for all render targets (window, image, ...)
|
||||
/// \brief Base class for all render targets (window, image, ...)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API RenderTarget : NonCopyable
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
/// \brief Destructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual ~RenderTarget();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Clear the entire target with a single color
|
||||
/// \brief Clear the entire target with a single color
|
||||
///
|
||||
/// \param color : Color to use to clear the render target
|
||||
/// This function is usually called once every frame,
|
||||
/// to clear the previous contents of the target.
|
||||
///
|
||||
/// \param color Fill color to use to clear the render target
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Clear(const Color& color = Color(0, 0, 0));
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Draw something into the target
|
||||
/// \brief Draw an object into the target
|
||||
///
|
||||
/// \param object : Object to draw
|
||||
/// This function draws anything that inherits from the
|
||||
/// sf::Drawable base class (sf::Sprite, sf::Shape, sf::Text,
|
||||
/// or even your own derived classes).
|
||||
///
|
||||
/// \param object Object to draw
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Draw(const Drawable& object);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Draw something into the target with a shader
|
||||
/// \brief Draw an object into the target with a shader
|
||||
///
|
||||
/// \param object : Object to draw
|
||||
/// \param shader : Shader to apply
|
||||
/// This function draws anything that inherits from the
|
||||
/// sf::Drawable base class (sf::Sprite, sf::Shape, sf::Text,
|
||||
/// or even your own derived classes).
|
||||
/// The shader alters the way that the pixels are processed
|
||||
/// right before being written to the render target.
|
||||
///
|
||||
/// \param object Object to draw
|
||||
/// \param shader Shader to use for drawing the object
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Draw(const Drawable& object, const Shader& shader);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the width of the rendering region of the target
|
||||
/// \brief Return the width of the rendering region of the target
|
||||
///
|
||||
/// \return Width in pixels
|
||||
///
|
||||
/// \see GetHeight
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetWidth() const = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the height of the rendering region of the target
|
||||
/// \brief Return the height of the rendering region of the target
|
||||
///
|
||||
/// \return Height in pixels
|
||||
///
|
||||
/// \see GetWidth
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetHeight() const = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change the current active view.
|
||||
/// \brief Change the current active view
|
||||
///
|
||||
/// \param view : New view to use (pass GetDefaultView() to set the default view)
|
||||
/// The new view will affect everything that is drawn, until
|
||||
/// another view is activated.
|
||||
/// The render target keeps its own copy of the view object,
|
||||
/// so it is not necessary to keep the original one alive
|
||||
/// as long as it is in use.
|
||||
/// To restore the original view of the target, you can pass
|
||||
/// the result of GetDefaultView() to this function.
|
||||
///
|
||||
/// \param view New view to use
|
||||
///
|
||||
/// \see GetView, GetDefaultView
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetView(const View& view);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the current view
|
||||
/// \brief Retrieve the view currently in use in the render target
|
||||
///
|
||||
/// \return Current view active in the window
|
||||
/// \return The view object that is currently used
|
||||
///
|
||||
/// \see SetView, GetDefaultView
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const View& GetView() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the default view of the window
|
||||
/// \brief Get the default view of the render target
|
||||
///
|
||||
/// \return Default view
|
||||
/// The default view has the initial size of the render target,
|
||||
/// and never changes after the target has been created.
|
||||
///
|
||||
/// \return The default view of the render target
|
||||
///
|
||||
/// \see SetView, GetView
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const View& GetDefaultView() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the viewport of a view applied to this target
|
||||
/// \brief Get the viewport of a view, applied to this render target
|
||||
///
|
||||
/// \param view Target view
|
||||
/// The viewport is defined in the view as a ratio, this function
|
||||
/// simply applies this ratio to the current dimensions of the
|
||||
/// render target to calculate the pixels rectangle that the viewport
|
||||
/// actually covers in the target.
|
||||
///
|
||||
/// \return Viewport rectangle, expressed in pixels in the current target
|
||||
/// \param view The view for which we want to compute the viewport
|
||||
///
|
||||
/// \return Viewport rectangle, expressed in pixels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
IntRect GetViewport(const View& view) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Convert a point in target coordinates into view coordinates
|
||||
/// This version uses the current view of the window
|
||||
/// \brief Convert a point from target coordinates to view coordinates
|
||||
///
|
||||
/// \param x : X coordinate of the point to convert, relative to the target
|
||||
/// \param y : Y coordinate of the point to convert, relative to the target
|
||||
/// Initially, a unit of the 2D world matches a pixel of the
|
||||
/// render target. But if you define a custom view, this
|
||||
/// assertion is not true anymore, ie. a point located at
|
||||
/// (10, 50) in your render target (for example a window) may
|
||||
/// map to the point (150, 75) in your 2D world -- for example
|
||||
/// if the view is translated by (140, 25).
|
||||
///
|
||||
/// \return Converted point
|
||||
/// For render windows, this function is typically used to find
|
||||
/// which point (or object) is located below the mouse cursor.
|
||||
///
|
||||
/// This version uses the current view of the render target.
|
||||
/// See the other overload to specify a custom view.
|
||||
///
|
||||
/// \param x X coordinate of the point to convert, relative to the render target
|
||||
/// \param y Y coordinate of the point to convert, relative to the render target
|
||||
///
|
||||
/// \return The converted point, in "world" units
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f ConvertCoords(unsigned int x, unsigned int y) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Convert a point in target coordinates into view coordinates
|
||||
/// This version uses the given view
|
||||
/// \brief Convert a point from target coordinates to view coordinates
|
||||
///
|
||||
/// \param x : X coordinate of the point to convert, relative to the target
|
||||
/// \param y : Y coordinate of the point to convert, relative to the target
|
||||
/// \param view : Target view to convert the point to
|
||||
/// Initially, a unit of the 2D world matches a pixel of the
|
||||
/// render target. But if you define a custom view, this
|
||||
/// assertion is not true anymore, ie. a point located at
|
||||
/// (10, 50) in your render target (for example a window) may
|
||||
/// map to the point (150, 75) in your 2D world -- for example
|
||||
/// if the view is translated by (140, 25).
|
||||
///
|
||||
/// \return Converted point
|
||||
/// For render windows, this function is typically used to find
|
||||
/// which point (or object) is located below the mouse cursor.
|
||||
///
|
||||
/// This version uses a custom view for calculations, see the other
|
||||
/// overload of the function to use the current view of the render
|
||||
/// target.
|
||||
///
|
||||
/// \param x X coordinate of the point to convert, relative to the render target
|
||||
/// \param y Y coordinate of the point to convert, relative to the render target
|
||||
/// \param view The view to use for converting the point
|
||||
///
|
||||
/// \return The converted point, in "world" units
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f ConvertCoords(unsigned int x, unsigned int y, const View& view) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Save the current OpenGL render states and matrices
|
||||
/// \brief Save the current OpenGL render states and matrices
|
||||
///
|
||||
/// This function can be used when you mix SFML drawing
|
||||
/// and direct OpenGL rendering. Combined with RestoreGLStates,
|
||||
/// it ensures that:
|
||||
/// \li SFML's internal states are not messed up by your OpenGL code
|
||||
/// \li your OpenGL states are not modified by a call to a SFML function
|
||||
///
|
||||
/// More specifically, it must be used around code that
|
||||
/// calls Draw functions. Example:
|
||||
/// \begincode
|
||||
/// // OpenGL code here...
|
||||
/// window.SaveGLStates();
|
||||
/// window.Draw(...);
|
||||
/// window.Draw(...);
|
||||
/// window.RestoreGLStates();
|
||||
/// // OpenGL code here...
|
||||
/// \endcode
|
||||
///
|
||||
/// Note that this function is quite expensive and should be
|
||||
/// used wisely. It is provided for convenience, and the best
|
||||
/// results will be achieved if you handle OpenGL states
|
||||
/// yourself (because you really know which states have really
|
||||
/// changed, and need to be saved / restored).
|
||||
///
|
||||
/// \see RestoreGLStates
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SaveGLStates();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Restore the previously saved OpenGL render states and matrices
|
||||
/// \brief Restore the previously saved OpenGL render states and matrices
|
||||
///
|
||||
/// See the description of SaveGLStates to get a detailed
|
||||
/// description of these functions.
|
||||
///
|
||||
/// \see SaveGLStates
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void RestoreGLStates();
|
||||
@ -168,13 +263,16 @@ public :
|
||||
protected :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
/// \brief Default constructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderTarget();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Called by the derived class when it's ready to be initialized
|
||||
/// \brief Performs the common initialization step after creation
|
||||
///
|
||||
/// The derived classes must call this function after the
|
||||
/// target is created and ready for drawing.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Initialize();
|
||||
@ -182,11 +280,15 @@ protected :
|
||||
private :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Activate the target for rendering
|
||||
/// \brief Activate the target for rendering
|
||||
///
|
||||
/// \param active : True to activate rendering, false to deactivate
|
||||
/// This function must be implemented by derived classes to make
|
||||
/// their OpenGL context current; it is called by the base class
|
||||
/// everytime it's going to use OpenGL calls.
|
||||
///
|
||||
/// \return True if activation succeeded
|
||||
/// \param active True to make the target active, false to deactivate it
|
||||
///
|
||||
/// \return True if the function succeeded
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Activate(bool active) = 0;
|
||||
@ -205,3 +307,29 @@ private :
|
||||
|
||||
|
||||
#endif // SFML_RENDERTARGET_HPP
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \class sf::RenderTarget
|
||||
///
|
||||
/// sf::RenderTarget defines the common behaviour of all the
|
||||
/// 2D render targets usable in the graphics module. It makes
|
||||
/// it possible to draw 2D entities like sprites, shapes, text
|
||||
/// without using any OpenGL command directly.
|
||||
///
|
||||
/// A sf::RenderTarget is also able to use views (sf::View),
|
||||
/// which are a kind of 2D cameras. With views you can globally
|
||||
/// scroll, rotate or zoom everything that is drawn,
|
||||
/// without having to transform every single entity. See the
|
||||
/// documentation of sf::View for more details and sample pieces of
|
||||
/// code about this class.
|
||||
///
|
||||
/// On top of that, render targets are still able to render direct
|
||||
/// OpenGL stuff. It is even possible to mix together OpenGL calls
|
||||
/// and regular SFML drawing commands. When doing so, make sure that
|
||||
/// OpenGL states are not messed up by calling the SaveGLStates /
|
||||
/// RestoreGLStates functions.
|
||||
///
|
||||
/// \see sf::RenderWindow, sf::RenderImage, sf::View
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -149,9 +149,9 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Activate the target for rendering
|
||||
///
|
||||
/// \param active True to activate rendering, false to deactivate
|
||||
/// \param active True to make the target active, false to deactivate it
|
||||
///
|
||||
/// \return True if activation succeeded
|
||||
/// \return True if the function succeeded
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool Activate(bool active);
|
||||
@ -177,10 +177,9 @@ private :
|
||||
/// and code samples.
|
||||
///
|
||||
/// On top of that, sf::RenderWindow adds more features related to
|
||||
/// 2D drawing with the graphics module, so that you don't need
|
||||
/// to use OpenGL to draw things. You can clear the window, and draw
|
||||
/// sprites, shapes or text. Here is a typical rendering / event loop
|
||||
/// with a sf::RenderWindow:
|
||||
/// 2D drawing with the graphics module (see its base class
|
||||
/// sf::RenderTarget for more details).
|
||||
/// Here is a typical rendering / event loop with a sf::RenderWindow:
|
||||
///
|
||||
/// \code
|
||||
/// // Declare and create a new render-window
|
||||
@ -214,21 +213,11 @@ private :
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
/// A sf::RenderWindow is also able to use views (sf::View),
|
||||
/// which are a kind of 2D cameras. With views you can scroll,
|
||||
/// rotate or zoom everything that is drawn to the window globally,
|
||||
/// without having to transform every single entity. See the
|
||||
/// documentation of sf::View for more details and sample pieces of
|
||||
/// code about this class.
|
||||
///
|
||||
/// Like sf::Window, sf::RenderWindow is still able to render direct
|
||||
/// OpenGL stuff. It is even possible to mix together OpenGL calls
|
||||
/// and regular SFML drawing commands. No particular setup is required,
|
||||
/// all you have to do is to call Flush() whenever you want to make
|
||||
/// sure that your SFML entities (sprites, shapes or texts) are
|
||||
/// actually drawn to the window, so that your OpenGL commands will draw
|
||||
/// on top of them (otherwise the rendering may be delayed internally by SFML,
|
||||
/// and probably happen *after* your OpenGL calls).
|
||||
/// and regular SFML drawing commands. When doing so, make sure that
|
||||
/// OpenGL states are not messed up by calling the SaveGLStates /
|
||||
/// RestoreGLStates functions.
|
||||
///
|
||||
/// \code
|
||||
/// // Create the render window
|
||||
@ -250,11 +239,9 @@ private :
|
||||
/// ...
|
||||
///
|
||||
/// // Draw a background sprite
|
||||
/// window.SaveGLStates();
|
||||
/// window.Draw(sprite);
|
||||
///
|
||||
/// // Flush the window, to make sure that the OpenGL object
|
||||
/// // will be rendered on top of the background sprite
|
||||
/// window.Flush();
|
||||
/// window.RestoreGLStates();
|
||||
///
|
||||
/// // Draw a 3D object using OpenGL
|
||||
/// glBegin(GL_QUADS);
|
||||
@ -263,7 +250,9 @@ private :
|
||||
/// glEnd();
|
||||
///
|
||||
/// // Draw text on top of the 3D object
|
||||
/// window.SaveGLStates();
|
||||
/// window.Draw(text);
|
||||
/// window.RestoreGLStates();
|
||||
///
|
||||
/// // Finally, display the rendered frame on screen
|
||||
/// window.Display();
|
||||
|
@ -34,8 +34,6 @@
|
||||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImage::RenderImage() :
|
||||
myRenderImage(NULL)
|
||||
{
|
||||
@ -43,8 +41,6 @@ myRenderImage(NULL)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderImage::~RenderImage()
|
||||
{
|
||||
@ -52,8 +48,6 @@ RenderImage::~RenderImage()
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Create the render image from its dimensions
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImage::Create(unsigned int width, unsigned int height, bool depthBuffer)
|
||||
{
|
||||
@ -98,8 +92,6 @@ bool RenderImage::Create(unsigned int width, unsigned int height, bool depthBuff
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Enable or disable image smoothing filter
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderImage::SetSmooth(bool smooth)
|
||||
{
|
||||
@ -107,8 +99,6 @@ void RenderImage::SetSmooth(bool smooth)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Tells whether the smooth filtering is enabled or not
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImage::IsSmooth() const
|
||||
{
|
||||
@ -116,9 +106,6 @@ bool RenderImage::IsSmooth() const
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Activate of deactivate the render-image as the current target
|
||||
/// for rendering
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImage::SetActive(bool active)
|
||||
{
|
||||
@ -126,8 +113,6 @@ bool RenderImage::SetActive(bool active)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Update the contents of the target
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderImage::Display()
|
||||
{
|
||||
@ -143,8 +128,6 @@ void RenderImage::Display()
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the width of the rendering region of the image
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int RenderImage::GetWidth() const
|
||||
{
|
||||
@ -152,8 +135,6 @@ unsigned int RenderImage::GetWidth() const
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the height of the rendering region of the image
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int RenderImage::GetHeight() const
|
||||
{
|
||||
@ -161,8 +142,6 @@ unsigned int RenderImage::GetHeight() const
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the target image
|
||||
////////////////////////////////////////////////////////////
|
||||
const Image& RenderImage::GetImage() const
|
||||
{
|
||||
@ -170,8 +149,6 @@ const Image& RenderImage::GetImage() const
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Check whether the system supports render images or not
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImage::IsAvailable()
|
||||
{
|
||||
@ -180,8 +157,6 @@ bool RenderImage::IsAvailable()
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Activate / deactivate the render image for rendering
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderImage::Activate(bool active)
|
||||
{
|
||||
|
@ -37,8 +37,6 @@
|
||||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Default constructor
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderTarget::RenderTarget() :
|
||||
myRenderer (*this),
|
||||
myStatesSaved (false),
|
||||
@ -48,8 +46,6 @@ myViewHasChanged(false)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
RenderTarget::~RenderTarget()
|
||||
{
|
||||
@ -57,8 +53,6 @@ RenderTarget::~RenderTarget()
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Clear the entire target with a single color
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderTarget::Clear(const Color& color)
|
||||
{
|
||||
@ -67,8 +61,6 @@ void RenderTarget::Clear(const Color& color)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Draw something on the window
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderTarget::Draw(const Drawable& object)
|
||||
{
|
||||
@ -99,8 +91,6 @@ void RenderTarget::Draw(const Drawable& object)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Draw something into the target with a shader
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderTarget::Draw(const Drawable& object, const Shader& shader)
|
||||
{
|
||||
@ -131,19 +121,15 @@ void RenderTarget::Draw(const Drawable& object, const Shader& shader)
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Change the current active view
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderTarget::SetView(const View& view)
|
||||
{
|
||||
// Save it
|
||||
// Save it for later use
|
||||
myCurrentView = view;
|
||||
myViewHasChanged = true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the current view
|
||||
////////////////////////////////////////////////////////////
|
||||
const View& RenderTarget::GetView() const
|
||||
{
|
||||
@ -151,8 +137,6 @@ const View& RenderTarget::GetView() const
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the default view of the window
|
||||
////////////////////////////////////////////////////////////
|
||||
const View& RenderTarget::GetDefaultView() const
|
||||
{
|
||||
@ -160,8 +144,6 @@ const View& RenderTarget::GetDefaultView() const
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the viewport of a view applied to this target
|
||||
////////////////////////////////////////////////////////////
|
||||
IntRect RenderTarget::GetViewport(const View& view) const
|
||||
{
|
||||
@ -176,9 +158,6 @@ IntRect RenderTarget::GetViewport(const View& view) const
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Convert a point in window coordinates into view coordinates
|
||||
/// This version uses the current view of the window
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f RenderTarget::ConvertCoords(unsigned int x, unsigned int y) const
|
||||
{
|
||||
@ -186,9 +165,6 @@ Vector2f RenderTarget::ConvertCoords(unsigned int x, unsigned int y) const
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Convert a point in window coordinates into view coordinates
|
||||
/// This version uses the given view
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f RenderTarget::ConvertCoords(unsigned int x, unsigned int y, const View& view) const
|
||||
{
|
||||
@ -203,8 +179,6 @@ Vector2f RenderTarget::ConvertCoords(unsigned int x, unsigned int y, const View&
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Save the current OpenGL render states and matrices
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderTarget::SaveGLStates()
|
||||
{
|
||||
@ -220,8 +194,6 @@ void RenderTarget::SaveGLStates()
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Restore the previously saved OpenGL render states and matrices
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderTarget::RestoreGLStates()
|
||||
{
|
||||
@ -236,8 +208,6 @@ void RenderTarget::RestoreGLStates()
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Called by the derived class when it's ready to be initialized
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderTarget::Initialize()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user