20 #ifndef _STELOPENGLARRAY_HPP_ 21 #define _STELOPENGLARRAY_HPP_ 23 #include "VecMath.hpp" 25 #include <QLoggingCategory> 26 #include <QOpenGLBuffer> 27 #include <QOpenGLFunctions> 28 #include <QOpenGLVertexArrayObject> 32 class QOpenGLFunctions;
34 Q_DECLARE_LOGGING_CATEGORY(stelOpenGLArray)
82 bool load(
const StelOBJ* obj,
bool useTangents =
true);
99 inline void draw(
int offset,
int count)
const 101 gl->glDrawElements(GL_TRIANGLES, count, m_indexBufferType, reinterpret_cast<const GLvoid*>(offset * m_indexBufferTypeSize));
109 const QOpenGLVertexArrayObject&
getVAO()
const {
return m_vao; }
121 static void initGL();
132 QOpenGLBuffer m_vertexBuffer;
133 QOpenGLBuffer m_indexBuffer;
134 QOpenGLVertexArrayObject m_vao;
135 GLenum m_indexBufferType;
136 size_t m_indexBufferTypeSize;
138 size_t m_memoryUsage;
140 quintptr m_offsets[ATTLOC_SIZE];
141 GLint m_sizes[ATTLOC_SIZE];
142 GLenum m_types[ATTLOC_SIZE];
143 GLsizei m_strides[ATTLOC_SIZE];
146 void releaseBuffers();
148 static QOpenGLFunctions* gl;
149 static bool s_vaosSupported;
150 static bool s_intElementBuffersSupported;
153 #endif // _STELOPENGLARRAY_HPP_ const QOpenGLBuffer & getVertexBuffer() const
Returns the buffer used for the vertex data.
void draw(int offset, int count) const
Issues a glDrawElements call for the count indices starting at offset Does not bind the array first...
This is the OpenGL attribute location where 3D vertex normals are mapped to.
Encapsulates vertex data stored in the OpenGL server memory, which can be used for fast drawing comma...
This is the OpenGL attribute location where vertex tangents are mapped to.
size_t getIndexBufferTypeSize() const
Returns the size in bytes for the type from getIndexBufferType()
const QOpenGLVertexArrayObject & getVAO() const
Returns the VAO which is used, when possible.
int getIndexCount() const
Returns the number of indices stored in this array.
This is the OpenGL attribute location where 2D vertex texture coordinates are mapped to...
This is the OpenGL attribute location where vertex bitangents are mapped to.
AttributeLocation
Specifies the attribute location used for the glVertexAttribPointer calls.
static bool supportsVertexArrayObject()
Returns true if the hardware supports use of vertex array objects.
Representation of a custom subset of a Wavefront .obj file, including only triangle data and material...
GLenum getIndexBufferType() const
Returns the type used for element index data in this instance.
This is the OpenGL attribute location where 3D vertex positions are mapped to.
const QOpenGLBuffer & getIndexBuffer() const
Returns the buffer used for the element index data.
void draw() const
Issues a glDrawElements call for all indices stored in this array.
static bool supportsIntegerElementIndex()
Returns true if the hardware supports use of (unsigned) integer element indices, instead of just byte...