![]() |
Stellarium
0.16.1
|
Encapsulates vertex data stored in the OpenGL server memory, which can be used for fast drawing commands, without repeated CPU-GPU data uploads. More...
#include <StelOpenGLArray.hpp>
Public Types | |
enum | AttributeLocation { ATTLOC_VERTEX, ATTLOC_TEXCOORD, ATTLOC_NORMAL, ATTLOC_TANGENT, ATTLOC_BITANGENT, ATTLOC_SIZE } |
Specifies the attribute location used for the glVertexAttribPointer calls. More... | |
Public Member Functions | |
StelOpenGLArray () | |
Constructs an empty StelOpenGLArray. More... | |
~StelOpenGLArray () | |
Releases the OpenGL data, if it has not happened yet. More... | |
void | clear () |
Releases the OpenGL data. Requires a valid context. More... | |
bool | load (const StelOBJ *obj, bool useTangents=true) |
Loads the data from the given OBJ file into OpenGL buffers. More... | |
void | bind () |
Binds this array for drawing/manipulating with OpenGL. More... | |
void | release () |
Releases the bound array data. More... | |
void | draw () const |
Issues a glDrawElements call for all indices stored in this array. More... | |
void | draw (int offset, int count) const |
Issues a glDrawElements call for the count indices starting at offset Does not bind the array first. More... | |
const QOpenGLBuffer & | getVertexBuffer () const |
Returns the buffer used for the vertex data. More... | |
const QOpenGLBuffer & | getIndexBuffer () const |
Returns the buffer used for the element index data. More... | |
const QOpenGLVertexArrayObject & | getVAO () const |
Returns the VAO which is used, when possible. More... | |
GLenum | getIndexBufferType () const |
Returns the type used for element index data in this instance. More... | |
size_t | getIndexBufferTypeSize () const |
Returns the size in bytes for the type from getIndexBufferType() More... | |
int | getIndexCount () const |
Returns the number of indices stored in this array. More... | |
Static Public Member Functions | |
static void | initGL () |
Initializes some global GL state. Requires a valid bound GL context. More... | |
static bool | supportsVertexArrayObject () |
Returns true if the hardware supports use of vertex array objects. More... | |
static bool | supportsIntegerElementIndex () |
Returns true if the hardware supports use of (unsigned) integer element indices, instead of just byte and short. More... | |
Encapsulates vertex data stored in the OpenGL server memory, which can be used for fast drawing commands, without repeated CPU-GPU data uploads.
Each StelOpenGLArray uses a single vertex buffer for vertex data, an element index buffer, and a vertex array object for faster binding if the hardware supports it.
Definition at line 40 of file StelOpenGLArray.hpp.
Specifies the attribute location used for the glVertexAttribPointer calls.
Shaders should be configured to use these locations before linking, so that a single vertex format can be used for all shaders.
Definition at line 46 of file StelOpenGLArray.hpp.
StelOpenGLArray::StelOpenGLArray | ( | ) |
Constructs an empty StelOpenGLArray.
No OpenGL objects are created with this call, so this can be used without a GL context.
StelOpenGLArray::~StelOpenGLArray | ( | ) |
Releases the OpenGL data, if it has not happened yet.
void StelOpenGLArray::bind | ( | ) |
Binds this array for drawing/manipulating with OpenGL.
void StelOpenGLArray::clear | ( | ) |
Releases the OpenGL data. Requires a valid context.
|
inline |
Issues a glDrawElements call for all indices stored in this array.
Does not bind the array first.
Definition at line 93 of file StelOpenGLArray.hpp.
|
inline |
Issues a glDrawElements call for the count
indices starting at offset
Does not bind the array first.
Definition at line 99 of file StelOpenGLArray.hpp.
|
inline |
Returns the buffer used for the element index data.
Definition at line 107 of file StelOpenGLArray.hpp.
|
inline |
Returns the type used for element index data in this instance.
This is either GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT or GL_UNSIGNED_INT (if hardware supports it). The actual type is chosen depending on the requirements of the data passed into load().
Definition at line 114 of file StelOpenGLArray.hpp.
|
inline |
Returns the size in bytes for the type from getIndexBufferType()
Definition at line 116 of file StelOpenGLArray.hpp.
|
inline |
Returns the number of indices stored in this array.
Definition at line 118 of file StelOpenGLArray.hpp.
|
inline |
Returns the VAO which is used, when possible.
Definition at line 109 of file StelOpenGLArray.hpp.
|
inline |
Returns the buffer used for the vertex data.
Definition at line 105 of file StelOpenGLArray.hpp.
|
static |
Initializes some global GL state. Requires a valid bound GL context.
bool StelOpenGLArray::load | ( | const StelOBJ * | obj, |
bool | useTangents = true |
||
) |
Loads the data from the given OBJ file into OpenGL buffers.
The StelOBJ instance is not required after this constructor, the data has been copied to OpenGL.
The data is stored in an interleaved format, i.e. the vertex buffer is a vector of StelOBJ::Vertex structs
obj | The StelOBJ instance which data should be transferred to GL |
useTangents | Whether to also load tangent/bitangent data, or skip it to save GL memory |
void StelOpenGLArray::release | ( | ) |
Releases the bound array data.
|
inlinestatic |
Returns true if the hardware supports use of (unsigned) integer element indices, instead of just byte and short.
This is required for loading larger models (>65535 vertices) without manual splitting
Definition at line 130 of file StelOpenGLArray.hpp.
|
inlinestatic |
Returns true if the hardware supports use of vertex array objects.
These are used if possible to increase performance, because the driver does not need to re-validate the vertex attribute state for each draw call.
Definition at line 127 of file StelOpenGLArray.hpp.