jubilant-funicular
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
nta::PrimitiveBatch Class Reference

represents a collection of primitives to be drawn More...

#include <PrimitiveBatch.h>

Collaboration diagram for nta::PrimitiveBatch:
Collaboration graph
[legend]

Public Member Functions

 PrimitiveBatch ()
 constructor and destructor
 
int numPrimitives () const
 returns number of primitives to be rendered
 
void init ()
 initializes the batch
 
void begin ()
 begins collection of primitive
 
void end ()
 ends collection of primitive and prepares for rendering
 
void addPrimitive (Primitive *primitive)
 adds a primitive to the batch
 
void addPrimitive (const std::initializer_list< Vertex2D > &vertices, GLuint textureID=-1, float depth=NTA_DEFAULT_DEPTH)
 
template<class Iterator >
void addPrimitive (Iterator first, Iterator last, GLuint textureID=-1, float depth=NTA_DEFAULT_DEPTH)
 
void addPrimitive (std::size_t numSides, crvec2 center=glm::vec2(0), float sideLength=1.0, crvec4 color=glm::vec4(1), float orientation=0., float depth=NTA_DEFAULT_DEPTH)
 
void render () const
 renders the primitives
 

Private Member Functions

void createVertexArrayObject ()
 creates vertex array object
 
void createRenderBatches ()
 creates render batches More...
 
void sortPrimitives ()
 sorts primitives
 
GLenum toPrimitiveType (unsigned int numVertices) const
 return primitive to be drawn
 

Static Private Member Functions

static bool compareTexture (Primitive *lhs, Primitive *rhs)
 comparers used for sorting
 
static bool comparePrimitive (Primitive *lhs, Primitive *rhs)
 
static bool compareDepth (Primitive *lhs, Primitive *rhs)
 

Private Attributes

std::vector< Primitive * > m_primitives
 
std::vector< RenderBatchm_renderBatches
 the render batches used to draw the primitives
 
GLuint m_vao = 0
 ids for the vertex buffer object and vertex array object used for rendering
 
GLuint m_vbo = 0
 

Detailed Description

represents a collection of primitives to be drawn

Definition at line 46 of file PrimitiveBatch.h.

Member Function Documentation

◆ createRenderBatches()

void nta::PrimitiveBatch::createRenderBatches ( )
private

creates render batches

Todo:
Render all Primitives using trianges since

Definition at line 86 of file PrimitiveBatch.cpp.

Referenced by end().

Member Data Documentation

◆ m_primitives

std::vector<Primitive*> nta::PrimitiveBatch::m_primitives
private

the primitives to be drawn

Todo:
store primitives on the stack

Definition at line 62 of file PrimitiveBatch.h.

Referenced by addPrimitive(), begin(), createRenderBatches(), numPrimitives(), and sortPrimitives().


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