4#include <QOpenGLBuffer>
5#include <QOpenGLTexture>
18template<VertexArrayBase::VertexMember VertexMembers>
95 template<typename VertexType, typename FieldType>
141 } VT_PositionNormalColor;
205 size_t start{std::numeric_limits<size_t>::max()};
265 QOpenGLBuffer
vbo{QOpenGLBuffer::VertexBuffer};
269 QOpenGLBuffer
ebo{QOpenGLBuffer::IndexBuffer};
275 QOpenGLTexture* _texture{
nullptr};
281#include <xgl/TVertexArray.hpp>
Counted vector having additional methods and operators for ease of usage. This template class extends...
Definition TVector.h:20
Color class used in vertex arrays and has layout of 4 x GLfloat.
Definition Color.h:15
A 4x4 matrix class used in arrays and has layout of 16x GLfloat.
Definition Matrix.h:15
Shader program having a default vertex and fragment shader.
Definition ShaderProgram.h:13
OpenGL base class and wrapper template for vertex arrays. Automates most of the things needed for pri...
Definition TVertexArray.h:20
TVector< Vertex > _vertices
Holds the data of the vertices before being copied to OpenGL memory.
Definition TVertexArray.h:187
bool setup() override
Sets up the vertex array for the OpenGL context.
void setupLayout()
Sets up the layout of the Vertex structure for OpenGL.
void paint() final
Overridden from base class VertexArrayBase. Uses old style OpenGL without a shader program.
~TVertexArray() override
Virtual destructor.
void draw() final
Overridden from base class VertexArrayBase. Uses new style OpenGL with a shader program.
TVertexArray(ShaderProgram *sp)
Constructor.
ShaderProgram * shaderProgram()
Gets the associated shader program.
void callModifyContext(const ModeRange &mr, bool before, bool draw, size_t mode_index)
Calls the function modifyContext when overridden.
void clearData() override
Clears the data to generate array buffers.
QOpenGLBuffer vbo
Holds the vertex buffer object.
Definition TVertexArray.h:265
void setTexture(QOpenGLTexture *texture)
Assigns the texture.
bool hasTexture() const final
Overridden from base class VertexArrayBase.
std::conditional_t< VertexMembers==vmPosition, VT_Position, std::conditional_t< VertexMembers==(vmPosition|vmColor), VT_PositionColor, std::conditional_t< VertexMembers==(vmPosition|vmNormal), VT_PositionNormal, std::conditional_t< VertexMembers==(vmPosition|vmNormal|vmColor), VT_PositionNormalColor, std::conditional_t< VertexMembers==(vmPosition|vmTexCoord), VT_PositionTexture, std::conditional_t< VertexMembers==(vmPosition|vmNormal|vmTexCoord), VT_PositionNormalTexture, std::conditional_t< VertexMembers==(vmPosition|vmNormal|vmColor|vmTexCoord), VT_PositionNormalColorTexture, void > > > > > > > Vertex
Conditional vertex structure type. Used for memory locations.
Definition TVertexArray.h:183
TVector< GLuint > IndexVectorType
Type definition for storing indices.
Definition TVertexArray.h:224
bool checkData() const
Check the data integrity of indices to vertices,.
bool hasColor() const final
Overridden from base class VertexArrayBase.
IndexVectorType _indices
Holds the data of the indices for solid and wire drawing.
Definition TVertexArray.h:229
TVector< ModeRange > _modes
Modes to call glDrawArrays() or glDrawElements() depending on the _indices member not being empty.
Definition TVertexArray.h:234
void setAttribPointer(ShaderProgram::Attribute sa, size_t offset)
Makes a call to setVertexAttribPointer().
NormalsDataType getNormalsData() const override
Overridden from base class.
QOpenGLBuffer ebo
Holds the index buffer object for solid drawing.
Definition TVertexArray.h:269
Base class for Vertex array derived classes.
Definition VertexArrayBase.h:14
@ vmTexCoord
Definition VertexArrayBase.h:36
@ vmColor
Definition VertexArrayBase.h:34
@ vmPosition
Definition VertexArrayBase.h:30
@ vmNormal
Definition VertexArrayBase.h:32
TVector< std::pair< vector3f, vector3f > > NormalsDataType
Type for extracting normals from all used vertices.
Definition VertexArrayBase.h:116
static const Color & getDefaultColor()
Gets the default color used by the vertex structures when not set by the derived class....
Definition DemoRenderer.h:6
QFlags< ECullingFlag > CullingState
Type to contain bitmapped culling settings.
Definition Types.h:63
@ cfBackside
Definition Types.h:55
@ cfDisabled
Definition Types.h:47
@ cfCCW
Definition Types.h:51
std::array< GLfloat, 2 > vector2f
Type which correspond with a GLSL type and used to implement Vertex structures.
Definition Types.h:17
std::array< GLfloat, 3 > vector3f
Type which correspond with a GLSL type and used to implement Vertex structures.
Definition Types.h:21
Modes to be called on the available indices.
Definition TVertexArray.h:193
Matrix matrix
Matrix set before rendering.
Definition TVertexArray.h:214
size_t stop
Stop index of the indices that belong to this mode.
Definition TVertexArray.h:201
GLenum mode
Mode to call glDrawArrays() with to get a wire model.
Definition TVertexArray.h:197
Color color
Color set before rendering. Only set when not (0,0,0,0).
Definition TVertexArray.h:210
size_t start
Start index of the indices that belong to this mode.
Definition TVertexArray.h:205
CullingState culling
Required culling state.
Definition TVertexArray.h:218
Available structure for a typical selection of members.
Definition TVertexArray.h:110
vector3f position
Definition TVertexArray.h:111
Available structure for a typical selection of members.
Definition TVertexArray.h:157
vector3f normal
Definition TVertexArray.h:159
vector2f texture
Definition TVertexArray.h:161
vector3f position
Definition TVertexArray.h:158
Available structure for a typical selection of members.
Definition TVertexArray.h:137
vector3f normal
Definition TVertexArray.h:139
vector3f position
Definition TVertexArray.h:138
Available structure for a typical selection of members.
Definition TVertexArray.h:147
vector2f texture
Definition TVertexArray.h:150
vector3f normal
Definition TVertexArray.h:149
vector3f position
Definition TVertexArray.h:148
Available structure for a typical selection of members.
Definition TVertexArray.h:119
vector3f position
Definition TVertexArray.h:120
vector3f normal
Definition TVertexArray.h:121
Available structure for a typical selection of members.
Definition TVertexArray.h:128
vector3f position
Definition TVertexArray.h:129
vector2f texture
Definition TVertexArray.h:130
Available structure for a typical selection of members.
Definition TVertexArray.h:102
vector3f position
Definition TVertexArray.h:103