![]() |
Stellarium 0.12.0 | ||
| Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · Renderer · File Structure |
Base class for QGL-using vertex buffer backends based on interleaved attribute arrays. More...
#include <StelQGLInterleavedArrayVertexBufferBackend.hpp>
Public Member Functions | |
| virtual void | addVertex (const void *const vertexInPtr) |
| Add a new vertex to the buffer. | |
| virtual void | getVertex (const int index, void *const vertexOutPtr) const |
| Get a vertex from the buffer. | |
| virtual void | setVertex (const int index, const void *const vertexInPtr) |
| Rewrite a vertex in the buffer. | |
| virtual void | lock () |
| Lock the buffer. Must be called before drawing. | |
| virtual void | unlock () |
| Unlock the buffer. Must be called to modify the buffer after drawing. | |
| virtual void | clear () |
| Clear the buffer, removing all vertices. | |
| void | projectVertices (StelProjector *projector, class StelQGLIndexBuffer *indexBuffer) |
| Use a StelProjector to project vertex positions. | |
| int | length () const |
| Get the number of vertices in the buffer. | |
| PrimitiveType | getPrimitiveType () const |
| Return graphics primitive type formed by the vertices of the buffer,. | |
Protected Member Functions | |
| StelQGLInterleavedArrayVertexBufferBackend (const PrimitiveType type, const QVector< StelVertexAttribute > &attributes) | |
| Construct a StelQGLInterleavedArrayVertexBufferBackend. | |
Protected Attributes | |
| bool | locked |
| Is the vertex buffer locked (i.e. ready to draw?). | |
| PrimitiveType | primitiveType |
| Graphics primitive type formed by the vertices of this buffer. | |
| int | vertexCount |
| Number of vertices in the buffer. | |
| int | vertexCapacity |
| Number of vertices we have allocated space for. | |
| int | vertexBytes |
| Size of a single vertex in bytes. | |
| int | vertexStride |
| Size allocated for a single vertex (size of a vertex in the vertices array). | |
| char * | vertices |
| Vertices of the buffer. | |
| bool | usingProjectedPositions |
| Are we using vertex positions projected by a StelProjector? | |
| Vec3f * | projectedPositions |
| Projected vertex positions to draw when we're projecting vertices with a StelProjector. | |
| int | projectedPositionsCapacity |
| Allocated space in the projectedPositions array. | |
Base class for QGL-using vertex buffer backends based on interleaved attribute arrays.
Vertex attributes are interleaved in a single array instead of having separate arrays for each attribute. E.g. for a vertex format with a Vec3f position and a Vec2f texcoord, the attributes are stored like this:
VVVTTVVVTTVVV...
Definition at line 42 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
| StelQGLInterleavedArrayVertexBufferBackend::StelQGLInterleavedArrayVertexBufferBackend | ( | const PrimitiveType | type, | |
| const QVector< StelVertexAttribute > & | attributes | |||
| ) | [protected] |
Construct a StelQGLInterleavedArrayVertexBufferBackend.
Initializes vertex attribute buffers.
| type | Graphics primitive type stored in the buffer. | |
| attributes | Specifications of vertex attributes that will be stored in the buffer. |
| virtual void StelQGLInterleavedArrayVertexBufferBackend::addVertex | ( | const void *const | vertexInPtr | ) | [virtual] |
Add a new vertex to the buffer.
StelVertexBuffer guarantees that when this is called, buffer is not locked and index is in range.
| vertexInPtr | Pointer to the beginning of the vertex. Data members of the vertex must match vertex attributes of the buffer. |
Implements StelVertexBufferBackend.
| virtual void StelQGLInterleavedArrayVertexBufferBackend::clear | ( | ) | [inline, virtual] |
Clear the buffer, removing all vertices.
The backend implementation might reuse previously allocated storage after clearing, so calling clear() might be more efficient than destroying a buffer and then constructing a new one.
Implements StelVertexBufferBackend.
Definition at line 68 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
| PrimitiveType StelQGLInterleavedArrayVertexBufferBackend::getPrimitiveType | ( | ) | const [inline] |
Return graphics primitive type formed by the vertices of the buffer,.
Definition at line 92 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
| virtual void StelQGLInterleavedArrayVertexBufferBackend::getVertex | ( | const int | index, | |
| void *const | vertexOutPtr | |||
| ) | const [virtual] |
Get a vertex from the buffer.
StelVertexBuffer guarantees that when this is called, buffer is not locked and index is in range.
| index | Index of the vertex to read. | |
| vertexOutPtr | Pointer to the beginning of the output vertex. Data members of the vertex must match vertex attributes of the buffer. |
Implements StelVertexBufferBackend.
| int StelQGLInterleavedArrayVertexBufferBackend::length | ( | ) | const [inline] |
Get the number of vertices in the buffer.
Definition at line 86 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
| virtual void StelQGLInterleavedArrayVertexBufferBackend::lock | ( | ) | [inline, virtual] |
Lock the buffer. Must be called before drawing.
Implements StelVertexBufferBackend.
Definition at line 58 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
| void StelQGLInterleavedArrayVertexBufferBackend::projectVertices | ( | StelProjector * | projector, | |
| class StelQGLIndexBuffer * | indexBuffer | |||
| ) |
Use a StelProjector to project vertex positions.
Can be called only immediately before drawing. The projected vertex positions are only used for one draw call - another one might use a different/modified projector or index buffer.
| projector | Projector to project the vertices. | |
| indexBuffer | Index buffer specifying which vertices to project. If NULL, all vertices are projected. |
| virtual void StelQGLInterleavedArrayVertexBufferBackend::setVertex | ( | const int | index, | |
| const void *const | vertexInPtr | |||
| ) | [inline, virtual] |
Rewrite a vertex in the buffer.
StelVertexBuffer guarantees that when this is called, buffer is not locked and index is in range.
| index | Index of the vertex to set. | |
| vertexInPtr | Pointer to the beginning of the vertex that will rewrite the vertex in the buffer. Data members of the vertex must match vertex attributes of the buffer. |
Implements StelVertexBufferBackend.
Definition at line 53 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
| virtual void StelQGLInterleavedArrayVertexBufferBackend::unlock | ( | ) | [inline, virtual] |
Unlock the buffer. Must be called to modify the buffer after drawing.
Implements StelVertexBufferBackend.
Definition at line 63 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
bool StelQGLInterleavedArrayVertexBufferBackend::locked [protected] |
Is the vertex buffer locked (i.e. ready to draw?).
Definition at line 99 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
PrimitiveType StelQGLInterleavedArrayVertexBufferBackend::primitiveType [protected] |
Graphics primitive type formed by the vertices of this buffer.
Definition at line 102 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
Projected vertex positions to draw when we're projecting vertices with a StelProjector.
This is a simple array of projected vertex positions (unprojected positions are in the vertices array interleaved with other attributes). usingProjectedPositions is true. The positions are projected by projectVertices().
Definition at line 143 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
Allocated space in the projectedPositions array.
Definition at line 146 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
bool StelQGLInterleavedArrayVertexBufferBackend::usingProjectedPositions [protected] |
Are we using vertex positions projected by a StelProjector?
(Instead of letting OpenGL handle the projection)
This is set to true by projectVertices() and back to false by the draw call immediately after. The projected positions can only be used for one draw call, as for another one the StelProjector might be different/modified.
Definition at line 136 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
int StelQGLInterleavedArrayVertexBufferBackend::vertexBytes [protected] |
Size of a single vertex in bytes.
Definition at line 111 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
int StelQGLInterleavedArrayVertexBufferBackend::vertexCapacity [protected] |
Number of vertices we have allocated space for.
Definition at line 108 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
int StelQGLInterleavedArrayVertexBufferBackend::vertexCount [protected] |
Number of vertices in the buffer.
Definition at line 105 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
int StelQGLInterleavedArrayVertexBufferBackend::vertexStride [protected] |
Size allocated for a single vertex (size of a vertex in the vertices array).
Used for alignment.
Definition at line 116 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
char* StelQGLInterleavedArrayVertexBufferBackend::vertices [protected] |
Vertices of the buffer.
Vertices are stored in an interleaved format; e.g. if the vertex format has a Vec3f vertex and Vec2f texcoord, the vertices are stored like this (every character represents a single float):
VVVTTVVVTTVVV...
Note: On 64bit, this is aligned to 16 bytes by default.
Definition at line 127 of file StelQGLInterleavedArrayVertexBufferBackend.hpp.
1.6.3