53 m_noTransform( true ),
55 m_reserved( nullptr ),
85 static bool show_err_reserve =
true;
86 static bool show_err_alloc =
true;
90 if( show_err_reserve )
92 DisplayError(
nullptr, wxT(
"VERTEX_MANAGER::Reserve: Did not use all previous vertices allocated" ) );
93 show_err_reserve =
false;
103 DisplayError(
nullptr, wxT(
"VERTEX_MANAGER::Reserve: Vertex allocation error" ) );
104 show_err_alloc =
false;
119 static bool show_err =
true;
136 if( newVertex ==
nullptr )
140 DisplayError(
nullptr, wxT(
"VERTEX_MANAGER::Vertex: Vertex allocation error" ) );
157 static bool show_err =
true;
162 if( newVertex ==
nullptr )
166 DisplayError(
nullptr, wxT(
"VERTEX_MANAGER::Vertices: Vertex allocation error" ) );
174 for(
unsigned int i = 0; i < aSize; ++i )
176 putVertex( newVertex[i], aVertices[i].x, aVertices[i].y, aVertices[i].z );
192 wxLogTrace(
traceVertexManager, wxS(
"Did not use all previous vertices allocated" ) );
206 unsigned int size = aItem.
GetSize();
211 for(
unsigned int i = 0; i < size; ++i )
213 vertex->
r = aColor.
r * 255.0;
214 vertex->
g = aColor.
g * 255.0;
215 vertex->
b = aColor.
b * 255.0;
216 vertex->
a = aColor.
a * 255.0;
226 unsigned int size = aItem.
GetSize();
231 for(
unsigned int i = 0; i < size; ++i )
252 m_gpu->SetShader( aShader );
264 m_gpu->BeginDrawing();
270 m_gpu->DrawIndices( &aItem );
293 glm::vec4 transVertex( aX, aY, aZ, 1.0f );
296 aTarget.
x = transVertex.x;
297 aTarget.
y = transVertex.y;
298 aTarget.
z = transVertex.z;
317 m_gpu->EnableDepthTest( aEnabled );
A color representation with 4 components: red, green, blue, alpha.
static GPU_MANAGER * MakeManager(VERTEX_CONTAINER *aContainer)
Provide the access to the OpenGL shaders.
static VERTEX_CONTAINER * MakeContainer(bool aCached)
Return a pointer to a new container of an appropriate type.
unsigned int GetOffset() const
Return data offset in the container.
unsigned int GetSize() const
Return information about number of vertices stored.
void EndDrawing() const
Finish drawing operations.
bool Vertex(const VERTEX &aVertex)
Add a vertex with the given coordinates to the currently set item.
void Map()
Map vertex buffer.
bool m_noTransform
State machine variables True in case there is no need to transform vertices.
void SetItem(VERTEX_ITEM &aItem) const
Set an item to start its modifications.
void Clear() const
Remove all the stored vertices from the container.
void BeginDrawing() const
Prepare buffers and items to start drawing.
void ChangeItemColor(const VERTEX_ITEM &aItem, const COLOR4D &aColor) const
Change the color of all vertices owned by an item.
bool Reserve(unsigned int aSize)
Allocate space for vertices, so it will be used with subsequent Vertex() calls.
void FinishItem() const
Clean after adding an item.
void ChangeItemDepth(const VERTEX_ITEM &aItem, GLfloat aDepth) const
Change the depth of all vertices owned by 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 putVertex(VERTEX &aTarget, GLfloat aX, GLfloat aY, GLfloat aZ) const
Apply all transformation to the given coordinates and store them at the specified target.
void EnableDepthTest(bool aEnabled)
Enable/disable Z buffer depth test.
glm::mat4 m_transform
Currently used transform matrix.
VERTEX_MANAGER(bool aCached)
unsigned int m_reservedSpace
Currently available reserved space.
VERTEX * GetVertices(const VERTEX_ITEM &aItem) const
Return a pointer to the vertices owned by an item.
VERTEX * m_reserved
Currently reserved chunk to store vertices.
GLubyte m_color[COLOR_STRIDE]
Currently used color.
GLfloat m_shader[SHADER_STRIDE]
Currently used shader and its parameters.
void Unmap()
Unmap vertex buffer.
bool Vertices(const VERTEX aVertices[], unsigned int aSize)
Add one or more vertices to the currently set item.
void SetShader(SHADER &aShader) const
Set a shader program that is going to be used during rendering.
std::shared_ptr< GPU_MANAGER > m_gpu
GPU manager for data transfers and drawing operations.
std::shared_ptr< VERTEX_CONTAINER > m_container
Container for vertices, may be cached or noncached.
void DrawItem(const VERTEX_ITEM &aItem) const
Draw an item to the buffer.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
static const wxChar traceVertexManager[]
Flag to enable #VERTEX_MANAGER debugging output.
The Cairo implementation of the graphics abstraction layer.
static constexpr size_t SHADER_STRIDE
Class to store instances of VERTEX without caching.
Class to handle an item held in a container.