KiCad PCB EDA Suite
KIGFX::GPU_MANAGER Class Referenceabstract

Class to handle uploading vertices and indices to GPU in drawing purposes. More...

#include <gpu_manager.h>

Inheritance diagram for KIGFX::GPU_MANAGER:
KIGFX::GPU_CACHED_MANAGER KIGFX::GPU_NONCACHED_MANAGER

Public Member Functions

virtual ~GPU_MANAGER ()
 
virtual void BeginDrawing ()=0
 Prepare the stored data to be drawn. More...
 
virtual void DrawIndices (unsigned int aOffset, unsigned int aSize)=0
 Make the GPU draw given range of vertices. More...
 
virtual void DrawAll ()=0
 Make the GPU draw all the vertices stored in the container. More...
 
virtual void EndDrawing ()=0
 Clear the container after drawing routines. More...
 
virtual void SetShader (SHADER &aShader)
 Allow using shaders with the stored data. More...
 
void EnableDepthTest (bool aEnabled)
 Enable/disable Z buffer depth test. More...
 

Static Public Member Functions

static GPU_MANAGERMakeManager (VERTEX_CONTAINER *aContainer)
 

Protected Member Functions

 GPU_MANAGER (VERTEX_CONTAINER *aContainer)
 Drawing status flag. More...
 

Protected Attributes

bool m_isDrawing
 Container that stores vertices data. More...
 
VERTEX_CONTAINERm_container
 Shader handling. More...
 
SHADERm_shader
 Location of shader attributes (for glVertexAttribPointer) More...
 
int m_shaderAttrib
 true: enable Z test when drawing More...
 
bool m_enableDepthTest
 

Detailed Description

Class to handle uploading vertices and indices to GPU in drawing purposes.

Definition at line 43 of file gpu_manager.h.

Constructor & Destructor Documentation

◆ ~GPU_MANAGER()

GPU_MANAGER::~GPU_MANAGER ( )
virtual

Definition at line 64 of file gpu_manager.cpp.

65 {
66 }

◆ GPU_MANAGER()

GPU_MANAGER::GPU_MANAGER ( VERTEX_CONTAINER aContainer)
protected

Drawing status flag.

Definition at line 54 of file gpu_manager.cpp.

54  :
55  m_isDrawing( false ),
56  m_container( aContainer ),
57  m_shader( nullptr ),
58  m_shaderAttrib( 0 ),
59  m_enableDepthTest( true )
60 {
61 }
int m_shaderAttrib
true: enable Z test when drawing
Definition: gpu_manager.h:98
VERTEX_CONTAINER * m_container
Shader handling.
Definition: gpu_manager.h:92
bool m_isDrawing
Container that stores vertices data.
Definition: gpu_manager.h:89
SHADER * m_shader
Location of shader attributes (for glVertexAttribPointer)
Definition: gpu_manager.h:95

Member Function Documentation

◆ BeginDrawing()

virtual void KIGFX::GPU_MANAGER::BeginDrawing ( )
pure virtual

Prepare the stored data to be drawn.

Implemented in KIGFX::GPU_NONCACHED_MANAGER, and KIGFX::GPU_CACHED_MANAGER.

◆ DrawAll()

virtual void KIGFX::GPU_MANAGER::DrawAll ( )
pure virtual

Make the GPU draw all the vertices stored in the container.

Implemented in KIGFX::GPU_NONCACHED_MANAGER, and KIGFX::GPU_CACHED_MANAGER.

◆ DrawIndices()

virtual void KIGFX::GPU_MANAGER::DrawIndices ( unsigned int  aOffset,
unsigned int  aSize 
)
pure virtual

Make the GPU draw given range of vertices.

Parameters
aOffsetis the beginning of the range.
aSizeis the number of vertices to be drawn.

Implemented in KIGFX::GPU_NONCACHED_MANAGER, and KIGFX::GPU_CACHED_MANAGER.

◆ EnableDepthTest()

void GPU_MANAGER::EnableDepthTest ( bool  aEnabled)

Enable/disable Z buffer depth test.

Definition at line 325 of file gpu_manager.cpp.

326 {
327  m_enableDepthTest = aEnabled;
328 }

References m_enableDepthTest.

◆ EndDrawing()

virtual void KIGFX::GPU_MANAGER::EndDrawing ( )
pure virtual

Clear the container after drawing routines.

Implemented in KIGFX::GPU_NONCACHED_MANAGER, and KIGFX::GPU_CACHED_MANAGER.

◆ MakeManager()

GPU_MANAGER * GPU_MANAGER::MakeManager ( VERTEX_CONTAINER aContainer)
static

Definition at line 45 of file gpu_manager.cpp.

46 {
47  if( aContainer->IsCached() )
48  return new GPU_CACHED_MANAGER( aContainer );
49  else
50  return new GPU_NONCACHED_MANAGER( aContainer );
51 }
virtual bool IsCached() const =0
Return true if the container caches vertex data in RAM or video memory.

References KIGFX::VERTEX_CONTAINER::IsCached().

Referenced by KIGFX::VERTEX_MANAGER::VERTEX_MANAGER().

◆ SetShader()

void GPU_MANAGER::SetShader ( SHADER aShader)
virtual

Allow using shaders with the stored data.

Parameters
aShaderis the object that allows using shaders.

Definition at line 69 of file gpu_manager.cpp.

70 {
71  m_shader = &aShader;
72  m_shaderAttrib = m_shader->GetAttribute( "attrShaderParams" );
73 
74  if( m_shaderAttrib == -1 )
75  {
76  DisplayError( nullptr, wxT( "Could not get the shader attribute location" ) );
77  }
78 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:271
int GetAttribute(const std::string &aAttributeName) const
Get an attribute location.
Definition: shader.cpp:172
int m_shaderAttrib
true: enable Z test when drawing
Definition: gpu_manager.h:98
SHADER * m_shader
Location of shader attributes (for glVertexAttribPointer)
Definition: gpu_manager.h:95

References DisplayError(), KIGFX::SHADER::GetAttribute(), m_shader, and m_shaderAttrib.

Member Data Documentation

◆ m_container

◆ m_enableDepthTest

bool KIGFX::GPU_MANAGER::m_enableDepthTest
protected

◆ m_isDrawing

bool KIGFX::GPU_MANAGER::m_isDrawing
protected

◆ m_shader

SHADER* KIGFX::GPU_MANAGER::m_shader
protected

Location of shader attributes (for glVertexAttribPointer)

Definition at line 95 of file gpu_manager.h.

Referenced by KIGFX::GPU_CACHED_MANAGER::EndDrawing(), KIGFX::GPU_NONCACHED_MANAGER::EndDrawing(), and SetShader().

◆ m_shaderAttrib

int KIGFX::GPU_MANAGER::m_shaderAttrib
protected

true: enable Z test when drawing

Definition at line 98 of file gpu_manager.h.

Referenced by KIGFX::GPU_CACHED_MANAGER::EndDrawing(), KIGFX::GPU_NONCACHED_MANAGER::EndDrawing(), and SetShader().


The documentation for this class was generated from the following files: