SFML 2.5.1

- Main Page
- Related Pages
- Topics
- Namespaces
- Classes
- Files

- File List
- File Members

VertexArray.hpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef SFML_VERTEXARRAY_HPP
26#define SFML_VERTEXARRAY_HPP
27
29// Headers
31#include <SFML/Graphics/Export.hpp>
32#include <SFML/Graphics/Vertex.hpp>
33#include <SFML/Graphics/PrimitiveType.hpp>
34#include <SFML/Graphics/Rect.hpp>
35#include <SFML/Graphics/Drawable.hpp>
36#include <vector>
37
38
39namespace sf
40{
45 class SFML_GRAPHICS_API VertexArray : public Drawable
46{
47public:
48
55 VertexArray();
56
64 explicit VertexArray(PrimitiveType type, std::size_t vertexCount = 0);
65
72 std::size_t getVertexCount() const;
73
88 Vertex& operator [](std::size_t index);
89
104 const Vertex& operator [](std::size_t index) const;
105
115 void clear();
116
129 void resize(std::size_t vertexCount);
130
137 void append(const Vertex& vertex);
138
153 void setPrimitiveType(PrimitiveType type);
154
161 PrimitiveType getPrimitiveType() const;
162
172 FloatRect getBounds() const;
173
174private:
175
183 virtual void draw(RenderTarget& target, RenderStates states) const;
184
185private:
186
188 // Member data
190 std::vector<Vertex> m_vertices;
191 PrimitiveType m_primitiveType;
192};
193
194} // namespace sf
195
196
197#endif // SFML_VERTEXARRAY_HPP
198
199
sf::Drawable
Abstract base class for objects that can be drawn to a render target.
Definition Drawable.hpp:45
sf::Rect< float >
sf::RenderStates
Define the states used for drawing to a RenderTarget.
Definition RenderStates.hpp:46
sf::RenderTarget
Base class for all render targets (window, texture, ...)
Definition RenderTarget.hpp:53
sf::VertexArray
Define a set of one or more 2D primitives.
Definition VertexArray.hpp:46
sf::VertexArray::resize
void resize(std::size_t vertexCount)
Resize the vertex array.
sf::VertexArray::VertexArray
VertexArray()
Default constructor.
sf::VertexArray::clear
void clear()
Clear the vertex array.
sf::VertexArray::VertexArray
VertexArray(PrimitiveType type, std::size_t vertexCount=0)
Construct the vertex array with a type and an initial number of vertices.
sf::VertexArray::append
void append(const Vertex &vertex)
Add a vertex to the array.
sf::VertexArray::getPrimitiveType
PrimitiveType getPrimitiveType() const
Get the type of primitives drawn by the vertex array.
sf::VertexArray::setPrimitiveType
void setPrimitiveType(PrimitiveType type)
Set the type of primitives to draw.
sf::VertexArray::getBounds
FloatRect getBounds() const
Compute the bounding rectangle of the vertex array.
sf::VertexArray::getVertexCount
std::size_t getVertexCount() const
Return the vertex count.
sf::Vertex
Define a point with color and texture coordinates.
Definition Vertex.hpp:43
sf::PrimitiveType
PrimitiveType
Types of primitives that a sf::VertexArray can render.
Definition PrimitiveType.hpp:40