KiCad PCB EDA Suite
|
#include <vertex_manager.h>
Public Member Functions | |
VERTEX_MANAGER (bool aCached) | |
Constructor. More... | |
void | Map () |
Function Map() maps vertex buffer. More... | |
void | Unmap () |
Function Unmap() unmaps vertex buffer. More... | |
bool | Reserve (unsigned int aSize) |
Function Reserve() allocates space for vertices, so it will be used with subsequent Vertex() calls. More... | |
bool | Vertex (const VERTEX &aVertex) |
Function Vertex() adds a vertex with the given coordinates to the currently set item. More... | |
bool | Vertex (GLfloat aX, GLfloat aY, GLfloat aZ) |
Function Vertex() adds a vertex with the given coordinates to the currently set item. More... | |
bool | Vertices (const VERTEX aVertices[], unsigned int aSize) |
Function Vertices() adds one or more vertices to the currently set item. More... | |
void | Color (const COLOR4D &aColor) |
Function Color() changes currently used color that will be applied to newly added vertices. More... | |
void | Color (GLfloat aRed, GLfloat aGreen, GLfloat aBlue, GLfloat aAlpha) |
Function Color() changes currently used color that will be applied to newly added vertices. More... | |
void | Shader (GLfloat aShaderType, GLfloat aParam1=0.0f, GLfloat aParam2=0.0f, GLfloat aParam3=0.0f) |
Function Shader() changes currently used shader and its parameters that will be applied to newly added vertices. More... | |
void | Translate (GLfloat aX, GLfloat aY, GLfloat aZ) |
Function Translate() multiplies the current matrix by a translation matrix, so newly vertices will be translated by the given vector. More... | |
void | Rotate (GLfloat aAngle, GLfloat aX, GLfloat aY, GLfloat aZ) |
Function Rotate() multiplies the current matrix by a rotation matrix, so the newly vertices will be rotated by the given angles. More... | |
void | Scale (GLfloat aX, GLfloat aY, GLfloat aZ) |
Function Scale() multiplies the current matrix by a scaling matrix, so the newly vertices will be scaled by the given factors. More... | |
void | PushMatrix () |
Function PushMatrix() pushes the current transformation matrix stack. More... | |
void | PopMatrix () |
Function PopMatrix() pops the current transformation matrix stack. More... | |
void | SetItem (VERTEX_ITEM &aItem) const |
Function SetItem() sets an item to start its modifications. More... | |
void | FinishItem () const |
Function FinishItem() does the cleaning after adding an item. More... | |
void | FreeItem (VERTEX_ITEM &aItem) const |
Function FreeItem() frees the memory occupied by the item, so it is no longer stored in the container. More... | |
void | ChangeItemColor (const VERTEX_ITEM &aItem, const COLOR4D &aColor) const |
Function ChangeItemColor() changes the color of all vertices owned by an item. More... | |
void | ChangeItemDepth (const VERTEX_ITEM &aItem, GLfloat aDepth) const |
Function ChangeItemDepth() changes the depth of all vertices owned by an item. More... | |
VERTEX * | GetVertices (const VERTEX_ITEM &aItem) const |
Function GetVertices() returns a pointer to the vertices owned by an item. More... | |
const glm::mat4 & | GetTransformation () const |
void | SetShader (SHADER &aShader) const |
Function SetShader() sets a shader program that is going to be used during rendering. More... | |
void | Clear () const |
Function Clear() removes all the stored vertices from the container. More... | |
void | BeginDrawing () const |
Function BeginDrawing() prepares buffers and items to start drawing. More... | |
void | DrawItem (const VERTEX_ITEM &aItem) const |
Function DrawItem() draws an item to the buffer. More... | |
void | EndDrawing () const |
Function EndDrawing() finishes drawing operations. More... | |
Protected Member Functions | |
void | putVertex (VERTEX &aTarget, GLfloat aX, GLfloat aY, GLfloat aZ) const |
Function putVertex() applies all transformation to the given coordinates and store them at the specified target. More... | |
Protected Attributes | |
std::shared_ptr< VERTEX_CONTAINER > | m_container |
Container for vertices, may be cached or noncached. More... | |
std::shared_ptr< GPU_MANAGER > | m_gpu |
GPU manager for data transfers and drawing operations. More... | |
bool | m_noTransform |
State machine variables True in case there is no need to transform vertices. More... | |
glm::mat4 | m_transform |
Currently used transform matrix. More... | |
std::stack< glm::mat4 > | m_transformStack |
Stack of transformation matrices, used for Push/PopMatrix. More... | |
GLubyte | m_color [COLOR_STRIDE] |
Currently used color. More... | |
GLfloat | m_shader [SHADER_STRIDE] |
Currently used shader and its parameters. More... | |
VERTEX * | m_reserved |
Currently reserved chunk to store vertices. More... | |
unsigned int | m_reservedSpace |
Currently available reserved space. More... | |
Definition at line 50 of file vertex_manager.h.
VERTEX_MANAGER::VERTEX_MANAGER | ( | bool | aCached | ) |
Constructor.
aCached | says if vertices should be cached in GPU or system memory. For data that does not change every frame, it is better to store vertices in GPU memory. |
Definition at line 40 of file vertex_manager.cpp.
References i, m_container, m_gpu, m_shader, KIGFX::VERTEX_CONTAINER::MakeContainer(), KIGFX::GPU_MANAGER::MakeManager(), and KIGFX::SHADER_STRIDE.
void VERTEX_MANAGER::BeginDrawing | ( | ) | const |
Function BeginDrawing() prepares buffers and items to start drawing.
Definition at line 233 of file vertex_manager.cpp.
References m_gpu.
Referenced by KIGFX::OPENGL_GAL::BeginDrawing(), and GetTransformation().
void VERTEX_MANAGER::ChangeItemColor | ( | const VERTEX_ITEM & | aItem, |
const COLOR4D & | aColor | ||
) | const |
Function ChangeItemColor() changes the color of all vertices owned by an item.
aItem | is the item to change. |
aColor | is the new color to be applied. |
Definition at line 175 of file vertex_manager.cpp.
References KIGFX::VERTEX::a, KIGFX::COLOR4D::a, KIGFX::VERTEX::b, KIGFX::COLOR4D::b, KIGFX::VERTEX::g, KIGFX::COLOR4D::g, KIGFX::VERTEX_ITEM::GetOffset(), KIGFX::VERTEX_ITEM::GetSize(), i, m_container, KIGFX::VERTEX::r, and KIGFX::COLOR4D::r.
Referenced by KIGFX::OPENGL_GAL::ChangeGroupColor(), and PopMatrix().
void VERTEX_MANAGER::ChangeItemDepth | ( | const VERTEX_ITEM & | aItem, |
GLfloat | aDepth | ||
) | const |
Function ChangeItemDepth() changes the depth of all vertices owned by an item.
aItem | is the item to change. |
aDepth | is the new color to be applied. |
Definition at line 195 of file vertex_manager.cpp.
References KIGFX::VERTEX_ITEM::GetOffset(), KIGFX::VERTEX_ITEM::GetSize(), i, m_container, and KIGFX::VERTEX::z.
Referenced by KIGFX::OPENGL_GAL::ChangeGroupDepth(), and PopMatrix().
void VERTEX_MANAGER::Clear | ( | ) | const |
Function Clear() removes all the stored vertices from the container.
Definition at line 227 of file vertex_manager.cpp.
References m_container.
Referenced by KIGFX::OPENGL_GAL::BeginDrawing(), KIGFX::OPENGL_GAL::ClearCache(), and GetTransformation().
|
inline |
Function Color() changes currently used color that will be applied to newly added vertices.
aColor | is the new color. |
Definition at line 129 of file vertex_manager.h.
References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, m_color, and KIGFX::COLOR4D::r.
Referenced by KIGFX::OPENGL_GAL::BitmapText(), KIGFX::OPENGL_GAL::DrawArc(), KIGFX::OPENGL_GAL::DrawArcSegment(), KIGFX::OPENGL_GAL::drawBitmapOverbar(), KIGFX::OPENGL_GAL::DrawCircle(), KIGFX::OPENGL_GAL::DrawLine(), KIGFX::OPENGL_GAL::drawPolygon(), KIGFX::OPENGL_GAL::drawPolyline(), KIGFX::OPENGL_GAL::DrawRectangle(), KIGFX::OPENGL_GAL::DrawSegment(), KIGFX::OPENGL_GAL::drawSemiCircle(), and KIGFX::OPENGL_GAL::drawTriangulatedPolyset().
|
inline |
Function Color() changes currently used color that will be applied to newly added vertices.
It is the equivalent of glColor4f() function.
aRed | is the red component of the new color. |
aGreen | is the green component of the new color. |
aBlue | is the blue component of the new color. |
aAlpha | is the alpha component of the new color. |
Definition at line 146 of file vertex_manager.h.
References m_color.
void VERTEX_MANAGER::DrawItem | ( | const VERTEX_ITEM & | aItem | ) | const |
Function DrawItem() draws an item to the buffer.
aItem | is the item to be drawn. |
Definition at line 239 of file vertex_manager.cpp.
References KIGFX::VERTEX_ITEM::GetOffset(), KIGFX::VERTEX_ITEM::GetSize(), and m_gpu.
Referenced by KIGFX::OPENGL_GAL::DrawGroup(), and GetTransformation().
void VERTEX_MANAGER::EndDrawing | ( | ) | const |
Function EndDrawing() finishes drawing operations.
Definition at line 248 of file vertex_manager.cpp.
References m_gpu.
Referenced by KIGFX::OPENGL_GAL::EndDrawing(), and GetTransformation().
void VERTEX_MANAGER::FinishItem | ( | ) | const |
Function FinishItem() does the cleaning after adding an item.
Definition at line 163 of file vertex_manager.cpp.
References m_container.
Referenced by KIGFX::OPENGL_GAL::EndGroup(), and PopMatrix().
void VERTEX_MANAGER::FreeItem | ( | VERTEX_ITEM & | aItem | ) | const |
Function FreeItem() frees the memory occupied by the item, so it is no longer stored in the container.
aItem | is the item to be freed |
Definition at line 169 of file vertex_manager.cpp.
References m_container.
Referenced by PopMatrix(), and KIGFX::VERTEX_ITEM::~VERTEX_ITEM().
|
inline |
Definition at line 300 of file vertex_manager.h.
References BeginDrawing(), Clear(), DrawItem(), EndDrawing(), m_transform, putVertex(), and SetShader().
Referenced by KIGFX::OPENGL_GAL::drawLineQuad().
VERTEX * VERTEX_MANAGER::GetVertices | ( | const VERTEX_ITEM & | aItem | ) | const |
Function GetVertices() returns a pointer to the vertices owned by an item.
aItem | is the owner of vertices that are going to be returned. |
Definition at line 212 of file vertex_manager.cpp.
References KIGFX::VERTEX_ITEM::GetOffset(), KIGFX::VERTEX_ITEM::GetSize(), and m_container.
Referenced by KIGFX::VERTEX_ITEM::GetVertices(), and PopMatrix().
void VERTEX_MANAGER::Map | ( | ) |
Function Map() maps vertex buffer.
Definition at line 52 of file vertex_manager.cpp.
References m_container.
Referenced by KIGFX::OPENGL_GAL::BeginUpdate().
|
inline |
Function PopMatrix() pops the current transformation matrix stack.
It is the equivalent of the glPopMatrix() function.
Definition at line 236 of file vertex_manager.h.
References ChangeItemColor(), ChangeItemDepth(), FinishItem(), FreeItem(), GetVertices(), m_noTransform, m_transform, m_transformStack, and SetItem().
Referenced by KIGFX::OPENGL_GAL::Restore().
|
inline |
Function PushMatrix() pushes the current transformation matrix stack.
It is the equivalent of the glPushMatrix() function.
Definition at line 223 of file vertex_manager.h.
References m_noTransform, m_transform, and m_transformStack.
Referenced by KIGFX::OPENGL_GAL::Save().
|
protected |
Function putVertex() applies all transformation to the given coordinates and store them at the specified target.
aTarget | is the place where the new vertex is going to be stored (it has to be allocated first). |
aX | is the X coordinate of the new vertex. |
aY | is the Y coordinate of the new vertex. |
aZ | is the Z coordinate of the new vertex. |
Definition at line 254 of file vertex_manager.cpp.
References KIGFX::VERTEX::a, KIGFX::VERTEX::b, KIGFX::VERTEX::g, m_color, m_noTransform, m_shader, m_transform, KIGFX::VERTEX::r, KIGFX::VERTEX::shader, KIGFX::SHADER_STRIDE, KIGFX::VERTEX::x, KIGFX::VERTEX::y, and KIGFX::VERTEX::z.
Referenced by GetTransformation(), Vertex(), and Vertices().
bool VERTEX_MANAGER::Reserve | ( | unsigned int | aSize | ) |
Function Reserve() allocates space for vertices, so it will be used with subsequent Vertex() calls.
aSize | is the number of vertices that should be available in the reserved space. |
Definition at line 64 of file vertex_manager.cpp.
References DisplayError(), m_container, m_reserved, and m_reservedSpace.
Referenced by KIGFX::OPENGL_GAL::DrawArc(), KIGFX::OPENGL_GAL::drawBitmapChar(), KIGFX::OPENGL_GAL::drawBitmapOverbar(), KIGFX::OPENGL_GAL::DrawCircle(), KIGFX::OPENGL_GAL::drawFilledSemiCircle(), KIGFX::OPENGL_GAL::drawLineQuad(), KIGFX::OPENGL_GAL::DrawRectangle(), and KIGFX::OPENGL_GAL::drawStrokedSemiCircle().
|
inline |
Function Rotate() multiplies the current matrix by a rotation matrix, so the newly vertices will be rotated by the given angles.
It is the equivalent of the glRotatef() function.
aAngle | is the angle of rotation, in radians. |
aX | is a multiplier for the X axis |
aY | is a multiplier for the Y axis |
aZ | is a multiplier for the Z axis. |
Definition at line 199 of file vertex_manager.h.
References m_transform.
Referenced by KIGFX::OPENGL_GAL::BitmapText(), KIGFX::OPENGL_GAL::drawFilledSemiCircle(), KIGFX::OPENGL_GAL::DrawSegment(), KIGFX::OPENGL_GAL::drawStrokedSemiCircle(), and KIGFX::OPENGL_GAL::Rotate().
|
inline |
Function Scale() multiplies the current matrix by a scaling matrix, so the newly vertices will be scaled by the given factors.
It is the equivalent of the glScalef() function.
aX | is the X axis scaling factor. |
aY | is the Y axis scaling factor. |
aZ | is the Z axis scaling factor. |
Definition at line 213 of file vertex_manager.h.
References m_transform, and scale.
Referenced by KIGFX::OPENGL_GAL::BitmapText(), and KIGFX::OPENGL_GAL::Scale().
void VERTEX_MANAGER::SetItem | ( | VERTEX_ITEM & | aItem | ) | const |
Function SetItem() sets an item to start its modifications.
After calling the function it is possible to add vertices using function Add().
aItem | is the item that is going to store vertices in the container. |
Definition at line 157 of file vertex_manager.cpp.
References m_container.
Referenced by PopMatrix(), and KIGFX::VERTEX_ITEM::VERTEX_ITEM().
void VERTEX_MANAGER::SetShader | ( | SHADER & | aShader | ) | const |
Function SetShader() sets a shader program that is going to be used during rendering.
aShader | is the object containing compiled and linked shader program. |
Definition at line 221 of file vertex_manager.cpp.
References m_gpu.
Referenced by GetTransformation(), and KIGFX::OPENGL_GAL::init().
|
inline |
Function Shader() changes currently used shader and its parameters that will be applied to newly added vertices.
Parameters depend on shader, for more information have a look at shaders source code.
aShaderType | is the a shader type to be applied. |
aParam1 | is the optional parameter for a shader. |
aParam2 | is the optional parameter for a shader. |
aParam3 | is the optional parameter for a shader. |
Definition at line 166 of file vertex_manager.h.
References m_shader.
Referenced by KIGFX::OPENGL_GAL::DrawArc(), KIGFX::OPENGL_GAL::drawBitmapChar(), KIGFX::OPENGL_GAL::drawBitmapOverbar(), KIGFX::OPENGL_GAL::DrawCircle(), KIGFX::OPENGL_GAL::drawFilledSemiCircle(), KIGFX::OPENGL_GAL::drawLineQuad(), KIGFX::OPENGL_GAL::drawPolygon(), KIGFX::OPENGL_GAL::DrawRectangle(), KIGFX::OPENGL_GAL::drawStrokedSemiCircle(), and KIGFX::OPENGL_GAL::drawTriangulatedPolyset().
|
inline |
Function Translate() multiplies the current matrix by a translation matrix, so newly vertices will be translated by the given vector.
It is the equivalent of the glTranslatef() function.
aX | is the X coordinate of a translation vector. |
aY | is the X coordinate of a translation vector. |
aZ | is the X coordinate of a translation vector. |
Definition at line 184 of file vertex_manager.h.
References m_transform.
Referenced by KIGFX::OPENGL_GAL::BitmapText(), KIGFX::OPENGL_GAL::DrawArc(), KIGFX::OPENGL_GAL::DrawArcSegment(), KIGFX::OPENGL_GAL::drawFilledSemiCircle(), KIGFX::OPENGL_GAL::DrawSegment(), KIGFX::OPENGL_GAL::drawStrokedSemiCircle(), and KIGFX::OPENGL_GAL::Translate().
void VERTEX_MANAGER::Unmap | ( | ) |
Function Unmap() unmaps vertex buffer.
Definition at line 58 of file vertex_manager.cpp.
References m_container.
Referenced by KIGFX::OPENGL_GAL::EndUpdate().
|
inline |
Function Vertex() adds a vertex with the given coordinates to the currently set item.
Color & shader parameters stored in aVertex are ignored, instead color & shader set by Color() and Shader() functions are used. Vertex coordinates will have the current transformation matrix applied.
aVertex | contains vertex coordinates. |
Definition at line 92 of file vertex_manager.h.
References Vertices(), KIGFX::VERTEX::x, KIGFX::VERTEX::y, and KIGFX::VERTEX::z.
Referenced by KIGFX::OPENGL_GAL::DrawArc(), KIGFX::OPENGL_GAL::drawBitmapChar(), KIGFX::OPENGL_GAL::drawBitmapOverbar(), KIGFX::OPENGL_GAL::DrawCircle(), KIGFX::OPENGL_GAL::drawFilledSemiCircle(), KIGFX::OPENGL_GAL::drawLineQuad(), KIGFX::OPENGL_GAL::DrawRectangle(), KIGFX::OPENGL_GAL::drawStrokedSemiCircle(), KIGFX::OPENGL_GAL::drawTriangulatedPolyset(), and VertexCallback().
bool VERTEX_MANAGER::Vertex | ( | GLfloat | aX, |
GLfloat | aY, | ||
GLfloat | aZ | ||
) |
Function Vertex() adds a vertex with the given coordinates to the currently set item.
Vertex coordinates will have the current transformation matrix applied.
aX | is the X coordinate of the new vertex. |
aY | is the Y coordinate of the new vertex. |
aZ | is the Z coordinate of the new vertex. |
Definition at line 90 of file vertex_manager.cpp.
References DisplayError(), m_container, m_reserved, m_reservedSpace, and putVertex().
bool VERTEX_MANAGER::Vertices | ( | const VERTEX | aVertices[], |
unsigned int | aSize | ||
) |
Function Vertices() adds one or more vertices to the currently set item.
It takes advantage of allocating memory in advance, so should be faster than adding vertices one by one. Color & shader parameters stored in aVertices are ignored, instead color & shader set by Color() and Shader() functions are used. All the vertex coordinates will have the current transformation matrix applied.
aVertices | contains vertices to be added |
aSize | is the number of vertices to be added. |
Definition at line 128 of file vertex_manager.cpp.
References DisplayError(), i, m_container, and putVertex().
Referenced by Vertex().
|
protected |
Currently used color.
Definition at line 364 of file vertex_manager.h.
Referenced by Color(), and putVertex().
|
protected |
Container for vertices, may be cached or noncached.
Definition at line 352 of file vertex_manager.h.
Referenced by ChangeItemColor(), ChangeItemDepth(), Clear(), FinishItem(), FreeItem(), GetVertices(), Map(), Reserve(), SetItem(), Unmap(), Vertex(), VERTEX_MANAGER(), and Vertices().
|
protected |
GPU manager for data transfers and drawing operations.
Definition at line 354 of file vertex_manager.h.
Referenced by BeginDrawing(), DrawItem(), EndDrawing(), SetShader(), and VERTEX_MANAGER().
|
protected |
State machine variables True in case there is no need to transform vertices.
Definition at line 358 of file vertex_manager.h.
Referenced by PopMatrix(), PushMatrix(), and putVertex().
|
protected |
Currently reserved chunk to store vertices.
Definition at line 369 of file vertex_manager.h.
|
protected |
Currently available reserved space.
Definition at line 372 of file vertex_manager.h.
|
protected |
Currently used shader and its parameters.
Definition at line 366 of file vertex_manager.h.
Referenced by putVertex(), Shader(), and VERTEX_MANAGER().
|
protected |
Currently used transform matrix.
Definition at line 360 of file vertex_manager.h.
Referenced by GetTransformation(), PopMatrix(), PushMatrix(), putVertex(), Rotate(), Scale(), and Translate().
|
protected |
Stack of transformation matrices, used for Push/PopMatrix.
Definition at line 362 of file vertex_manager.h.
Referenced by PopMatrix(), and PushMatrix().