SFML 2.6.1

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

- File List
- File Members

Loading...
Searching...
No Matches
VertexBuffer.hpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2023 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::Drawable
Abstract base class for objects that can be drawn to a render target.
Definition Drawable.hpp:45
sf::GlResource
Base class for classes that require an OpenGL context.
Definition GlResource.hpp:47
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::VertexBuffer
Vertex buffer storage for one or more 2D primitives.
Definition VertexBuffer.hpp:47
sf::VertexBuffer::getPrimitiveType
PrimitiveType getPrimitiveType() const
Get the type of primitives drawn by the vertex buffer.
sf::VertexBuffer::bind
static void bind(const VertexBuffer *vertexBuffer)
Bind a vertex buffer for rendering.
sf::VertexBuffer::VertexBuffer
VertexBuffer(const VertexBuffer &copy)
Copy constructor.
sf::VertexBuffer::VertexBuffer
VertexBuffer(PrimitiveType type, Usage usage)
Construct a VertexBuffer with a specific PrimitiveType and usage specifier.
sf::VertexBuffer::getNativeHandle
unsigned int getNativeHandle() const
Get the underlying OpenGL handle of the vertex buffer.
sf::VertexBuffer::swap
void swap(VertexBuffer &right)
Swap the contents of this vertex buffer with those of another.
sf::VertexBuffer::Usage
Usage
Usage specifiers.
Definition VertexBuffer.hpp:61
sf::VertexBuffer::Dynamic
@ Dynamic
Occasionally changing data.
Definition VertexBuffer.hpp:63
sf::VertexBuffer::Stream
@ Stream
Constantly changing data.
Definition VertexBuffer.hpp:62
sf::VertexBuffer::VertexBuffer
VertexBuffer(PrimitiveType type)
Construct a VertexBuffer with a specific PrimitiveType.
sf::VertexBuffer::update
bool update(const VertexBuffer &vertexBuffer)
Copy the contents of another buffer into this buffer.
sf::VertexBuffer::getUsage
Usage getUsage() const
Get the usage specifier of this vertex buffer.
sf::VertexBuffer::isAvailable
static bool isAvailable()
Tell whether or not the system supports vertex buffers.
sf::VertexBuffer::getVertexCount
std::size_t getVertexCount() const
Return the vertex count.
sf::VertexBuffer::setPrimitiveType
void setPrimitiveType(PrimitiveType type)
Set the type of primitives to draw.
sf::VertexBuffer::create
bool create(std::size_t vertexCount)
Create the vertex buffer.
sf::VertexBuffer::VertexBuffer
VertexBuffer()
Default constructor.
sf::VertexBuffer::setUsage
void setUsage(Usage usage)
Set the usage specifier of this vertex buffer.
sf::VertexBuffer::~VertexBuffer
~VertexBuffer()
Destructor.
sf::VertexBuffer::update
bool update(const Vertex *vertices)
Update the whole buffer from an array of vertices.
sf::VertexBuffer::update
bool update(const Vertex *vertices, std::size_t vertexCount, unsigned int offset)
Update a part of the buffer from an array of vertices.
sf::VertexBuffer::VertexBuffer
VertexBuffer(Usage usage)
Construct a VertexBuffer with a specific usage specifier.
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