Stellarium 0.12.2
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
StelQGLArrayVertexBufferBackend Class Reference

Base class for QGL-using vertex buffer backends based on separate attribute arrays. More...

#include <StelQGLArrayVertexBufferBackend.hpp>

Public Member Functions

virtual void addVertex (const void *const vertexInPtr)
 Add a new vertex to the buffer. More...
 
virtual void getVertex (const int index, void *const vertexOutPtr) const
 Get a vertex from the buffer. More...
 
virtual void setVertex (const int index, const void *const vertexInPtr)
 Rewrite a vertex in the buffer. More...
 
virtual void lock ()
 Lock the buffer. Must be called before drawing. More...
 
virtual void unlock ()
 Unlock the buffer. Must be called to modify the buffer after drawing. More...
 
virtual void clear ()
 Clear the buffer, removing all vertices. More...
 
void projectVertices (StelProjector *projector, class StelQGLIndexBuffer *indexBuffer)
 Use a StelProjector to project vertex positions. More...
 
int length () const
 Get the number of vertices in the buffer. More...
 
PrimitiveType getPrimitiveType () const
 Return graphics primitive type formed by the vertices of the buffer,. More...
 
- Public Member Functions inherited from StelVertexBufferBackend
 StelVertexBufferBackend (const QVector< StelVertexAttribute > &attributes)
 Construct a StelVertexBufferBackend, specifying attributes of the vertex type. More...
 
virtual ~StelVertexBufferBackend ()
 Required to ensure that derived classes get properly deallocated. More...
 
void validateVertexType (const int vertexSize)
 Assert that the user-specified (in StelVertexBuffer) vertex type is valid. More...
 

Protected Member Functions

 StelQGLArrayVertexBufferBackend (const PrimitiveType type, const QVector< StelVertexAttribute > &attributes)
 Construct a StelQGLArrayVertexBufferBackend. More...
 

Protected Attributes

bool locked
 Is the vertex buffer locked (i.e. ready to draw?). More...
 
PrimitiveType primitiveType
 Graphics primitive type formed by the vertices of this buffer. More...
 
int vertexCount
 Number of vertices in the buffer. More...
 
int vertexCapacity
 Number of vertices we have allocated space for. More...
 
void * attributeBuffers [AttributeInterpretation_MAX]
 Buffers storing vertex attributes. More...
 
bool usingProjectedPositions
 Are we using vertex positions projected by a StelProjector? More...
 
Vec3fprojectedPositions
 Projected vertex positions to draw when we're projecting vertices with a StelProjector. More...
 
int projectedPositionsCapacity
 Allocated capacity of the projectedPositions array. More...
 
- Protected Attributes inherited from StelVertexBufferBackend
const Attributes attributes
 Specifies layout of vertex attributes in the vertex type. More...
 

Detailed Description

Base class for QGL-using vertex buffer backends based on separate attribute arrays.

Note
This is an internal class of the Renderer subsystem and should not be used elsewhere.

Definition at line 33 of file StelQGLArrayVertexBufferBackend.hpp.

Constructor & Destructor Documentation

StelQGLArrayVertexBufferBackend::StelQGLArrayVertexBufferBackend ( const PrimitiveType  type,
const QVector< StelVertexAttribute > &  attributes 
)
protected

Construct a StelQGLArrayVertexBufferBackend.

Initializes vertex attribute buffers.

Parameters
typeGraphics primitive type stored in the buffer.
attributesSpecifications of vertex attributes that will be stored in the buffer.

Member Function Documentation

virtual void StelQGLArrayVertexBufferBackend::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.

Parameters
vertexInPtrPointer to the beginning of the vertex. Data members of the vertex must match vertex attributes of the buffer.

Implements StelVertexBufferBackend.

virtual void StelQGLArrayVertexBufferBackend::clear ( )
inlinevirtual

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 57 of file StelQGLArrayVertexBufferBackend.hpp.

PrimitiveType StelQGLArrayVertexBufferBackend::getPrimitiveType ( ) const
inline

Return graphics primitive type formed by the vertices of the buffer,.

Definition at line 81 of file StelQGLArrayVertexBufferBackend.hpp.

virtual void StelQGLArrayVertexBufferBackend::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.

Parameters
indexIndex of the vertex to read.
vertexOutPtrPointer to the beginning of the output vertex. Data members of the vertex must match vertex attributes of the buffer.

Implements StelVertexBufferBackend.

int StelQGLArrayVertexBufferBackend::length ( ) const
inline

Get the number of vertices in the buffer.

Definition at line 75 of file StelQGLArrayVertexBufferBackend.hpp.

virtual void StelQGLArrayVertexBufferBackend::lock ( )
inlinevirtual

Lock the buffer. Must be called before drawing.

Implements StelVertexBufferBackend.

Definition at line 47 of file StelQGLArrayVertexBufferBackend.hpp.

void StelQGLArrayVertexBufferBackend::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.

Parameters
projectorProjector to project the vertices.
indexBufferIndex buffer specifying which vertices to project. If NULL, all vertices are projected.
virtual void StelQGLArrayVertexBufferBackend::setVertex ( const int  index,
const void *const  vertexInPtr 
)
inlinevirtual

Rewrite a vertex in the buffer.

StelVertexBuffer guarantees that when this is called, buffer is not locked and index is in range.

Parameters
indexIndex of the vertex to set.
vertexInPtrPointer 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 42 of file StelQGLArrayVertexBufferBackend.hpp.

virtual void StelQGLArrayVertexBufferBackend::unlock ( )
inlinevirtual

Unlock the buffer. Must be called to modify the buffer after drawing.

Implements StelVertexBufferBackend.

Definition at line 52 of file StelQGLArrayVertexBufferBackend.hpp.

Member Data Documentation

void* StelQGLArrayVertexBufferBackend::attributeBuffers[AttributeInterpretation_MAX]
protected

Buffers storing vertex attributes.

Attribute interpretation is an index specifying the buffer. Buffers not used by the vertex format are NULL.

Definition at line 103 of file StelQGLArrayVertexBufferBackend.hpp.

bool StelQGLArrayVertexBufferBackend::locked
protected

Is the vertex buffer locked (i.e. ready to draw?).

Definition at line 88 of file StelQGLArrayVertexBufferBackend.hpp.

PrimitiveType StelQGLArrayVertexBufferBackend::primitiveType
protected

Graphics primitive type formed by the vertices of this buffer.

Definition at line 91 of file StelQGLArrayVertexBufferBackend.hpp.

Vec3f* StelQGLArrayVertexBufferBackend::projectedPositions
protected

Projected vertex positions to draw when we're projecting vertices with a StelProjector.

This replaces the buffer with Position interpretation during drawing when usingProjectedPositions is true. The positions are projected by projectVertices().

Definition at line 118 of file StelQGLArrayVertexBufferBackend.hpp.

int StelQGLArrayVertexBufferBackend::projectedPositionsCapacity
protected

Allocated capacity of the projectedPositions array.

Definition at line 121 of file StelQGLArrayVertexBufferBackend.hpp.

bool StelQGLArrayVertexBufferBackend::usingProjectedPositions
protected

Are we using vertex positions projected by a StelProjector?

(Instead of just 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 112 of file StelQGLArrayVertexBufferBackend.hpp.

int StelQGLArrayVertexBufferBackend::vertexCapacity
protected

Number of vertices we have allocated space for.

Definition at line 97 of file StelQGLArrayVertexBufferBackend.hpp.

int StelQGLArrayVertexBufferBackend::vertexCount
protected

Number of vertices in the buffer.

Definition at line 94 of file StelQGLArrayVertexBufferBackend.hpp.


The documentation for this class was generated from the following file: