Stellarium 0.12.1
List of all members | Classes | Public Member Functions | Protected Attributes
StelVertexBufferBackend Class Referenceabstract

Base class of all vertex buffer backends. More...

#include <StelVertexBufferBackend.hpp>

Public Member Functions

 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...
 
virtual void addVertex (const void *const vertexInPtr)=0
 Add a new vertex to the buffer. More...
 
virtual void getVertex (const int index, void *const vertexOutPtr) const =0
 Get a vertex from the buffer. More...
 
virtual void setVertex (const int index, const void *const vertexInPtr)=0
 Rewrite a vertex in the buffer. More...
 
virtual void lock ()=0
 Lock the buffer. Must be called before drawing. More...
 
virtual void unlock ()=0
 Unlock the buffer. Must be called to modify the buffer after drawing. More...
 
virtual void clear ()=0
 Clear the buffer, removing all vertices. More...
 
void validateVertexType (const int vertexSize)
 Assert that the user-specified (in StelVertexBuffer) vertex type is valid. More...
 

Protected Attributes

const Attributes attributes
 Specifies layout of vertex attributes in the vertex type. More...
 

Detailed Description

Base class of all vertex buffer backends.

This is where the vertex buffer logic is implemented.

The backend doesn't directly know the vertex type (since templating doesn't mix with virtual inheritance), so it works with raw (void) pointers.

Vertex format is described by the attributes data member. Each item in attributes specifies a vertex attribute (such as a position or normal), and these correspond to the data members of the user-specified vertex struct which is the template parameter of the StelVertexBuffer class.

StelVertexBufferBackend is always owned by a StelVertexBuffer and can't exist separately. Only the StelRenderer backend has direct access to StelVertexBufferBackend's implementation.

When the user asks StelRenderer to create a vertex buffer, the renderer backend first creates its own implementation of the vertex buffer backend, and then wraps it up in a StelVertexBuffer.

See Also
StelVertexBuffer, StelRenderer
Note
This is an internal class of the Renderer subsystem and should not be used elsewhere.

Definition at line 55 of file StelVertexBufferBackend.hpp.

Constructor & Destructor Documentation

StelVertexBufferBackend::StelVertexBufferBackend ( const QVector< StelVertexAttribute > &  attributes)
inline

Construct a StelVertexBufferBackend, specifying attributes of the vertex type.

Definition at line 87 of file StelVertexBufferBackend.hpp.

virtual StelVertexBufferBackend::~StelVertexBufferBackend ( )
inlinevirtual

Required to ensure that derived classes get properly deallocated.

Definition at line 93 of file StelVertexBufferBackend.hpp.

Member Function Documentation

virtual void StelVertexBufferBackend::addVertex ( const void *const  vertexInPtr)
pure 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.

Implemented in StelQGLInterleavedArrayVertexBufferBackend, and StelQGLArrayVertexBufferBackend.

virtual void StelVertexBufferBackend::clear ( )
pure 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.

Implemented in StelQGLInterleavedArrayVertexBufferBackend, and StelQGLArrayVertexBufferBackend.

virtual void StelVertexBufferBackend::getVertex ( const int  index,
void *const  vertexOutPtr 
) const
pure 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.

Implemented in StelQGLInterleavedArrayVertexBufferBackend, and StelQGLArrayVertexBufferBackend.

virtual void StelVertexBufferBackend::lock ( )
pure virtual

Lock the buffer. Must be called before drawing.

Implemented in StelQGLInterleavedArrayVertexBufferBackend, and StelQGLArrayVertexBufferBackend.

virtual void StelVertexBufferBackend::setVertex ( const int  index,
const void *const  vertexInPtr 
)
pure virtual

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.

Implemented in StelQGLInterleavedArrayVertexBufferBackend, and StelQGLArrayVertexBufferBackend.

virtual void StelVertexBufferBackend::unlock ( )
pure virtual

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

Implemented in StelQGLInterleavedArrayVertexBufferBackend, and StelQGLArrayVertexBufferBackend.

void StelVertexBufferBackend::validateVertexType ( const int  vertexSize)
inline

Assert that the user-specified (in StelVertexBuffer) vertex type is valid.

Definition at line 139 of file StelVertexBufferBackend.hpp.

Member Data Documentation

const Attributes StelVertexBufferBackend::attributes
protected

Specifies layout of vertex attributes in the vertex type.

Definition at line 160 of file StelVertexBufferBackend.hpp.


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