| 
    KiCad PCB EDA Suite
    
   | 
 
Class to control vertex container and GPU with possibility of emulating old-style OpenGL 1.0 state machine using modern OpenGL methods. More...
#include <vertex_manager.h>
Public Member Functions | |
| VERTEX_MANAGER (bool aCached) | |
| void | Map () | 
| Map vertex buffer.   | |
| void | Unmap () | 
| Unmap vertex buffer.   | |
| bool | Reserve (unsigned int aSize) | 
| Allocate space for vertices, so it will be used with subsequent Vertex() calls.   | |
| bool | Vertex (const VERTEX &aVertex) | 
| Add a vertex with the given coordinates to the currently set item.   | |
| bool | Vertex (GLfloat aX, GLfloat aY, GLfloat aZ) | 
| Add a vertex with the given coordinates to the currently set item.   | |
| bool | Vertex (const VECTOR2D &aXY, GLfloat aZ) | 
| Add a vertex with the given coordinates to the currently set item.   | |
| bool | Vertices (const VERTEX aVertices[], unsigned int aSize) | 
| Add one or more vertices to the currently set item.   | |
| void | Color (const COLOR4D &aColor) | 
| Change currently used color that will be applied to newly added vertices.   | |
| void | Color (GLfloat aRed, GLfloat aGreen, GLfloat aBlue, GLfloat aAlpha) | 
| Change currently used color that will be applied to newly added vertices.   | |
| void | Shader (GLfloat aShaderType, GLfloat aParam1=0.0f, GLfloat aParam2=0.0f, GLfloat aParam3=0.0f) | 
| Change currently used shader and its parameters that will be applied to newly added vertices.   | |
| void | Translate (GLfloat aX, GLfloat aY, GLfloat aZ) | 
| Multiply the current matrix by a translation matrix, so newly vertices will be translated by the given vector.   | |
| void | Rotate (GLfloat aAngle, GLfloat aX, GLfloat aY, GLfloat aZ) | 
| Multiply the current matrix by a rotation matrix, so the newly vertices will be rotated by the given angles.   | |
| void | Scale (GLfloat aX, GLfloat aY, GLfloat aZ) | 
| Multiply the current matrix by a scaling matrix, so the newly vertices will be scaled by the given factors.   | |
| void | PushMatrix () | 
| Push the current transformation matrix stack.   | |
| void | PopMatrix () | 
| Pop the current transformation matrix stack.   | |
| void | SetItem (VERTEX_ITEM &aItem) const | 
| Set an item to start its modifications.   | |
| void | FinishItem () const | 
| Clean after adding an item.   | |
| void | FreeItem (VERTEX_ITEM &aItem) const | 
| Free the memory occupied by the item, so it is no longer stored in the container.   | |
| void | ChangeItemColor (const VERTEX_ITEM &aItem, const COLOR4D &aColor) const | 
| Change the color of all vertices owned by an item.   | |
| void | ChangeItemDepth (const VERTEX_ITEM &aItem, GLfloat aDepth) const | 
| Change the depth of all vertices owned by an item.   | |
| VERTEX * | GetVertices (const VERTEX_ITEM &aItem) const | 
| Return a pointer to the vertices owned by an item.   | |
| const glm::mat4 & | GetTransformation () const | 
| void | SetShader (SHADER &aShader) const | 
| Set a shader program that is going to be used during rendering.   | |
| void | Clear () const | 
| Remove all the stored vertices from the container.   | |
| void | BeginDrawing () const | 
| Prepare buffers and items to start drawing.   | |
| void | DrawItem (const VERTEX_ITEM &aItem) const | 
| Draw an item to the buffer.   | |
| void | EndDrawing () const | 
| Finish drawing operations.   | |
| void | EnableDepthTest (bool aEnabled) | 
| Enable/disable Z buffer depth test.   | |
Protected Member Functions | |
| void | putVertex (VERTEX &aTarget, GLfloat aX, GLfloat aY, GLfloat aZ) const | 
| Apply all transformation to the given coordinates and store them at the specified target.   | |
Protected Attributes | |
| std::shared_ptr< VERTEX_CONTAINER > | m_container | 
| Container for vertices, may be cached or noncached.   | |
| std::shared_ptr< GPU_MANAGER > | m_gpu | 
| GPU manager for data transfers and drawing operations.   | |
| bool | m_noTransform | 
| State machine variables True in case there is no need to transform vertices.   | |
| glm::mat4 | m_transform | 
| Currently used transform matrix.   | |
| std::stack< glm::mat4 > | m_transformStack | 
| Stack of transformation matrices, used for Push/PopMatrix.   | |
| GLubyte | m_color [COLOR_STRIDE] | 
| Currently used color.   | |
| GLfloat | m_shader [SHADER_STRIDE] | 
| Currently used shader and its parameters.   | |
| VERTEX * | m_reserved | 
| Currently reserved chunk to store vertices.   | |
| unsigned int | m_reservedSpace | 
| Currently available reserved space.   | |
Class to control vertex container and GPU with possibility of emulating old-style OpenGL 1.0 state machine using modern OpenGL methods.
Definition at line 53 of file vertex_manager.h.
| VERTEX_MANAGER::VERTEX_MANAGER | ( | bool | aCached | ) | 
| 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 52 of file vertex_manager.cpp.
References m_container, m_gpu, m_noTransform, m_reserved, m_reservedSpace, m_shader, m_transform, KIGFX::VERTEX_CONTAINER::MakeContainer(), KIGFX::GPU_MANAGER::MakeManager(), and KIGFX::SHADER_STRIDE.
| void VERTEX_MANAGER::BeginDrawing | ( | ) | const | 
Prepare buffers and items to start drawing.
Definition at line 262 of file vertex_manager.cpp.
References m_gpu.
| void VERTEX_MANAGER::ChangeItemColor | ( | const VERTEX_ITEM & | aItem, | 
| const COLOR4D & | aColor ) const | 
Change 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 204 of file vertex_manager.cpp.
References KIGFX::COLOR4D::a, KIGFX::VERTEX::a, KIGFX::COLOR4D::b, KIGFX::VERTEX::b, KIGFX::COLOR4D::g, KIGFX::VERTEX::g, KIGFX::VERTEX_ITEM::GetOffset(), KIGFX::VERTEX_ITEM::GetSize(), m_container, KIGFX::COLOR4D::r, and KIGFX::VERTEX::r.
| void VERTEX_MANAGER::ChangeItemDepth | ( | const VERTEX_ITEM & | aItem, | 
| GLfloat | aDepth ) const | 
Change 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 224 of file vertex_manager.cpp.
References KIGFX::VERTEX_ITEM::GetOffset(), KIGFX::VERTEX_ITEM::GetSize(), m_container, and KIGFX::VERTEX::z.
| void VERTEX_MANAGER::Clear | ( | ) | const | 
Remove all the stored vertices from the container.
Definition at line 256 of file vertex_manager.cpp.
References m_container.
      
  | 
  inline | 
Change currently used color that will be applied to newly added vertices.
| aColor | is the new color. | 
Definition at line 140 of file vertex_manager.h.
References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, m_color, and KIGFX::COLOR4D::r.
      
  | 
  inline | 
Change 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 158 of file vertex_manager.h.
References m_color.
| void VERTEX_MANAGER::DrawItem | ( | const VERTEX_ITEM & | aItem | ) | const | 
Draw an item to the buffer.
| aItem | is the item to be drawn. | 
Definition at line 268 of file vertex_manager.cpp.
References m_gpu.
| void VERTEX_MANAGER::EnableDepthTest | ( | bool | aEnabled | ) | 
Enable/disable Z buffer depth test.
Definition at line 315 of file vertex_manager.cpp.
References m_gpu.
| void VERTEX_MANAGER::EndDrawing | ( | ) | const | 
| void VERTEX_MANAGER::FinishItem | ( | ) | const | 
Clean after adding an item.
Definition at line 189 of file vertex_manager.cpp.
References m_container, m_reserved, m_reservedSpace, and traceVertexManager.
| void VERTEX_MANAGER::FreeItem | ( | VERTEX_ITEM & | aItem | ) | const | 
Free 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 198 of file vertex_manager.cpp.
References m_container.
      
  | 
  inline | 
Definition at line 311 of file vertex_manager.h.
References m_transform.
| VERTEX * VERTEX_MANAGER::GetVertices | ( | const VERTEX_ITEM & | aItem | ) | const | 
Return a pointer to the vertices owned by an item.
| aItem | is the owner of vertices that are going to be returned. | 
Definition at line 241 of file vertex_manager.cpp.
References KIGFX::VERTEX_ITEM::GetOffset(), KIGFX::VERTEX_ITEM::GetSize(), and m_container.
| void VERTEX_MANAGER::Map | ( | ) | 
      
  | 
  inline | 
Pop the current transformation matrix stack.
It is the equivalent of the glPopMatrix() function.
Definition at line 252 of file vertex_manager.h.
References m_noTransform, m_transform, and m_transformStack.
      
  | 
  inline | 
Push the current transformation matrix stack.
It is the equivalent of the glPushMatrix() function.
Definition at line 239 of file vertex_manager.h.
References m_noTransform, m_transform, and m_transformStack.
      
  | 
  protected | 
Apply 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 280 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 Vertex(), and Vertices().
| bool VERTEX_MANAGER::Reserve | ( | unsigned int | aSize | ) | 
Allocate 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 79 of file vertex_manager.cpp.
References DisplayError(), m_container, m_reserved, and m_reservedSpace.
      
  | 
  inline | 
Multiply 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 214 of file vertex_manager.h.
References m_transform.
      
  | 
  inline | 
Multiply 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 229 of file vertex_manager.h.
References m_transform.
| void VERTEX_MANAGER::SetItem | ( | VERTEX_ITEM & | aItem | ) | const | 
Set 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 183 of file vertex_manager.cpp.
References m_container.
| void VERTEX_MANAGER::SetShader | ( | SHADER & | aShader | ) | const | 
Set a shader program that is going to be used during rendering.
| aShader | is the object containing compiled and linked shader program. | 
Definition at line 250 of file vertex_manager.cpp.
References m_gpu.
      
  | 
  inline | 
Change 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 179 of file vertex_manager.h.
References m_shader.
      
  | 
  inline | 
Multiply 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 198 of file vertex_manager.h.
References m_transform.
| void VERTEX_MANAGER::Unmap | ( | ) | 
      
  | 
  inline | 
Add a vertex with the given coordinates to the currently set item.
Vertex coordinates will have the current transformation matrix applied.
| aXY | are the XY coordinates of the new vertex. | 
| aZ | is the Z coordinate of the new vertex. | 
Definition at line 116 of file vertex_manager.h.
References Vertex(), VECTOR2< T >::x, and VECTOR2< T >::y.
      
  | 
  inline | 
Add 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 90 of file vertex_manager.h.
References Vertex(), KIGFX::VERTEX::x, KIGFX::VERTEX::y, and KIGFX::VERTEX::z.
Referenced by Vertex(), Vertex(), and VertexCallback().
| bool VERTEX_MANAGER::Vertex | ( | GLfloat | aX, | 
| GLfloat | aY, | ||
| GLfloat | aZ ) | 
Add 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 116 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 ) | 
Add 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 154 of file vertex_manager.cpp.
References DisplayError(), m_container, and putVertex().
      
  | 
  protected | 
Currently used color.
Definition at line 379 of file vertex_manager.h.
Referenced by Color(), Color(), and putVertex().
      
  | 
  protected | 
Container for vertices, may be cached or noncached.
Definition at line 363 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 366 of file vertex_manager.h.
Referenced by BeginDrawing(), DrawItem(), EnableDepthTest(), EndDrawing(), SetShader(), and VERTEX_MANAGER().
      
  | 
  protected | 
State machine variables True in case there is no need to transform vertices.
Definition at line 370 of file vertex_manager.h.
Referenced by PopMatrix(), PushMatrix(), putVertex(), and VERTEX_MANAGER().
      
  | 
  protected | 
Currently reserved chunk to store vertices.
Definition at line 385 of file vertex_manager.h.
Referenced by FinishItem(), Reserve(), Vertex(), and VERTEX_MANAGER().
      
  | 
  protected | 
Currently available reserved space.
Definition at line 388 of file vertex_manager.h.
Referenced by FinishItem(), Reserve(), Vertex(), and VERTEX_MANAGER().
      
  | 
  protected | 
Currently used shader and its parameters.
Definition at line 382 of file vertex_manager.h.
Referenced by putVertex(), Shader(), and VERTEX_MANAGER().
      
  | 
  protected | 
Currently used transform matrix.
Definition at line 373 of file vertex_manager.h.
Referenced by GetTransformation(), PopMatrix(), PushMatrix(), putVertex(), Rotate(), Scale(), Translate(), and VERTEX_MANAGER().
      
  | 
  protected | 
Stack of transformation matrices, used for Push/PopMatrix.
Definition at line 376 of file vertex_manager.h.
Referenced by PopMatrix(), and PushMatrix().