SFML 2.5.1

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

- File List
- File Members

VertexBuffer.hpp
1 //
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_VERTEXBUFFER_HPP
26 #define SFML_VERTEXBUFFER_HPP
27
29 // Headers
31 #include <SFML/Graphics/Export.hpp>
32 #include <SFML/Graphics/PrimitiveType.hpp>
33 #include <SFML/Graphics/Drawable.hpp>
34 #include <SFML/Window/GlResource.hpp>
35
36
37 namespace sf
38 {
39 class RenderTarget;
40 class Vertex;
41
46 class SFML_GRAPHICS_API VertexBuffer : public Drawable, private GlResource
47 {
48 public:
49
60 enum Usage
61 {
62 Stream,
63 Dynamic,
64 Static
65 };
66
73 VertexBuffer();
74
83 explicit VertexBuffer(PrimitiveType type);
84
93 explicit VertexBuffer(Usage usage);
94
105 VertexBuffer(PrimitiveType type, Usage usage);
106
113 VertexBuffer(const VertexBuffer& copy);
114
119 ~VertexBuffer();
120
137 bool create(std::size_t vertexCount);
138
145 std::size_t getVertexCount() const;
146
165 bool update(const Vertex* vertices);
166
198 bool update(const Vertex* vertices, std::size_t vertexCount, unsigned int offset);
199
208 bool update(const VertexBuffer& vertexBuffer);
209
218 VertexBuffer& operator =(const VertexBuffer& right);
219
226 void swap(VertexBuffer& right);
227
238 unsigned int getNativeHandle() const;
239
251 void setPrimitiveType(PrimitiveType type);
252
259 PrimitiveType getPrimitiveType() const;
260
276 void setUsage(Usage usage);
277
284 Usage getUsage() const;
285
307 static void bind(const VertexBuffer* vertexBuffer);
308
319 static bool isAvailable();
320
321 private:
322
330 virtual void draw(RenderTarget& target, RenderStates states) const;
331
332 private:
333
335 // Member data
337 unsigned int m_buffer;
338 std::size_t m_size;
339 PrimitiveType m_primitiveType;
340 Usage m_usage;
341 };
342
343 } // namespace sf
344
345
346 #endif // SFML_VERTEXBUFFER_HPP
347
348
sf::PrimitiveType
PrimitiveType
Types of primitives that a sf::VertexArray can render.
Definition: PrimitiveType.hpp:39
sf::RenderStates
Define the states used for drawing to a RenderTarget.
Definition: RenderStates.hpp:45
sf::VertexBuffer
Vertex buffer storage for one or more 2D primitives.
Definition: VertexBuffer.hpp:46
sf::VertexBuffer::Dynamic
Occasionally changing data.
Definition: VertexBuffer.hpp:63
sf::Vertex
Define a point with color and texture coordinates.
Definition: Vertex.hpp:42
sf::RenderTarget
Base class for all render targets (window, texture, ...)
Definition: RenderTarget.hpp:52
sf::Drawable
Abstract base class for objects that can be drawn to a render target.
Definition: Drawable.hpp:44
sf::VertexBuffer::Usage
Usage
Usage specifiers.
Definition: VertexBuffer.hpp:60
sf
Definition: AlResource.hpp:34
sf::VertexBuffer::Stream
Constantly changing data.
Definition: VertexBuffer.hpp:62
sf::GlResource
Base class for classes that require an OpenGL context.
Definition: GlResource.hpp:46