Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:58:14

0001 ////////////////////////////////////////////////////////////
0002 //
0003 // SFML - Simple and Fast Multimedia Library
0004 // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
0005 //
0006 // This software is provided 'as-is', without any express or implied warranty.
0007 // In no event will the authors be held liable for any damages arising from the use of this software.
0008 //
0009 // Permission is granted to anyone to use this software for any purpose,
0010 // including commercial applications, and to alter it and redistribute it freely,
0011 // subject to the following restrictions:
0012 //
0013 // 1. The origin of this software must not be misrepresented;
0014 //    you must not claim that you wrote the original software.
0015 //    If you use this software in a product, an acknowledgment
0016 //    in the product documentation would be appreciated but is not required.
0017 //
0018 // 2. Altered source versions must be plainly marked as such,
0019 //    and must not be misrepresented as being the original software.
0020 //
0021 // 3. This notice may not be removed or altered from any source distribution.
0022 //
0023 ////////////////////////////////////////////////////////////
0024 
0025 #ifndef SFML_VERTEX_HPP
0026 #define SFML_VERTEX_HPP
0027 
0028 ////////////////////////////////////////////////////////////
0029 // Headers
0030 ////////////////////////////////////////////////////////////
0031 #include <SFML/Graphics/Export.hpp>
0032 #include <SFML/Graphics/Color.hpp>
0033 #include <SFML/System/Vector2.hpp>
0034 
0035 
0036 namespace sf
0037 {
0038 ////////////////////////////////////////////////////////////
0039 /// \brief Define a point with color and texture coordinates
0040 ///
0041 ////////////////////////////////////////////////////////////
0042 class SFML_GRAPHICS_API Vertex
0043 {
0044 public:
0045 
0046     ////////////////////////////////////////////////////////////
0047     /// \brief Default constructor
0048     ///
0049     ////////////////////////////////////////////////////////////
0050     Vertex();
0051 
0052     ////////////////////////////////////////////////////////////
0053     /// \brief Construct the vertex from its position
0054     ///
0055     /// The vertex color is white and texture coordinates are (0, 0).
0056     ///
0057     /// \param thePosition Vertex position
0058     ///
0059     ////////////////////////////////////////////////////////////
0060     Vertex(const Vector2f& thePosition);
0061 
0062     ////////////////////////////////////////////////////////////
0063     /// \brief Construct the vertex from its position and color
0064     ///
0065     /// The texture coordinates are (0, 0).
0066     ///
0067     /// \param thePosition Vertex position
0068     /// \param theColor    Vertex color
0069     ///
0070     ////////////////////////////////////////////////////////////
0071     Vertex(const Vector2f& thePosition, const Color& theColor);
0072 
0073     ////////////////////////////////////////////////////////////
0074     /// \brief Construct the vertex from its position and texture coordinates
0075     ///
0076     /// The vertex color is white.
0077     ///
0078     /// \param thePosition  Vertex position
0079     /// \param theTexCoords Vertex texture coordinates
0080     ///
0081     ////////////////////////////////////////////////////////////
0082     Vertex(const Vector2f& thePosition, const Vector2f& theTexCoords);
0083 
0084     ////////////////////////////////////////////////////////////
0085     /// \brief Construct the vertex from its position, color and texture coordinates
0086     ///
0087     /// \param thePosition  Vertex position
0088     /// \param theColor     Vertex color
0089     /// \param theTexCoords Vertex texture coordinates
0090     ///
0091     ////////////////////////////////////////////////////////////
0092     Vertex(const Vector2f& thePosition, const Color& theColor, const Vector2f& theTexCoords);
0093 
0094     ////////////////////////////////////////////////////////////
0095     // Member data
0096     ////////////////////////////////////////////////////////////
0097     Vector2f  position;  //!< 2D position of the vertex
0098     Color     color;     //!< Color of the vertex
0099     Vector2f  texCoords; //!< Coordinates of the texture's pixel to map to the vertex
0100 };
0101 
0102 } // namespace sf
0103 
0104 
0105 #endif // SFML_VERTEX_HPP
0106 
0107 
0108 ////////////////////////////////////////////////////////////
0109 /// \class sf::Vertex
0110 /// \ingroup graphics
0111 ///
0112 /// A vertex is an improved point. It has a position and other
0113 /// extra attributes that will be used for drawing: in SFML,
0114 /// vertices also have a color and a pair of texture coordinates.
0115 ///
0116 /// The vertex is the building block of drawing. Everything which
0117 /// is visible on screen is made of vertices. They are grouped
0118 /// as 2D primitives (triangles, quads, ...), and these primitives
0119 /// are grouped to create even more complex 2D entities such as
0120 /// sprites, texts, etc.
0121 ///
0122 /// If you use the graphical entities of SFML (sprite, text, shape)
0123 /// you won't have to deal with vertices directly. But if you want
0124 /// to define your own 2D entities, such as tiled maps or particle
0125 /// systems, using vertices will allow you to get maximum performances.
0126 ///
0127 /// Example:
0128 /// \code
0129 /// // define a 100x100 square, red, with a 10x10 texture mapped on it
0130 /// sf::Vertex vertices[] =
0131 /// {
0132 ///     sf::Vertex(sf::Vector2f(  0,   0), sf::Color::Red, sf::Vector2f( 0,  0)),
0133 ///     sf::Vertex(sf::Vector2f(  0, 100), sf::Color::Red, sf::Vector2f( 0, 10)),
0134 ///     sf::Vertex(sf::Vector2f(100, 100), sf::Color::Red, sf::Vector2f(10, 10)),
0135 ///     sf::Vertex(sf::Vector2f(100,   0), sf::Color::Red, sf::Vector2f(10,  0))
0136 /// };
0137 ///
0138 /// // draw it
0139 /// window.draw(vertices, 4, sf::Quads);
0140 /// \endcode
0141 ///
0142 /// Note: although texture coordinates are supposed to be an integer
0143 /// amount of pixels, their type is float because of some buggy graphics
0144 /// drivers that are not able to process integer coordinates correctly.
0145 ///
0146 /// \see sf::VertexArray
0147 ///
0148 ////////////////////////////////////////////////////////////