jGL
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
jGL::ShapeRenderer Class Referenceabstract

Renders shapes with optional rendering priority. More...

#include <shapeRenderer.h>

Inheritance diagram for jGL::ShapeRenderer:
Inheritance graph
[legend]
Collaboration diagram for jGL::ShapeRenderer:
Collaboration graph
[legend]

Classes

struct  UpdateInfo
 Control updated data for drawing. More...
 

Public Member Functions

 ShapeRenderer (size_t sizeHint=8)
 Construct a new ShapeRenderer.
 
 ShapeRenderer (std::shared_ptr< Shader > shader, size_t sizeHint=8)
 Construct a new ShapeRenderer.
 
ShapegetShape (ShapeId id)
 
const TransformgetTransform (ShapeId id)
 
const glm::vec4 * getColour (ShapeId id)
 
virtual void draw (std::shared_ptr< Shader > shader, std::multimap< RenderPriority, ShapeId > &ids, UpdateInfo info=UpdateInfo())
 Draw with overriding render priority and shader.
 
virtual void draw (std::multimap< RenderPriority, ShapeId > &ids, UpdateInfo info=UpdateInfo())
 Draw with overriding render priority.
 
virtual void draw (std::shared_ptr< Shader > shader, UpdateInfo info=UpdateInfo())
 Draw with overriding shader and cached priorities.
 
virtual void draw (UpdateInfo info=UpdateInfo())
 Draw with default shader and cached priorities.
 
bool hasId (const ShapeId id) const
 
virtual void setProjection (glm::mat4 p)
 
- Public Member Functions inherited from PriorityStore< Shape >
 PriorityStore (uint64_t sizeHint=8)
 Construct a new Priority Store with a reserved size.
 
virtual void clear ()
 
virtual void add (Shape s, ElementId id, Priority priority=0)
 Insert an element.
 
virtual void remove (ElementId id)
 
void updatePriority (ElementId id, Priority newPriority)
 
std::vector< std::pair< Info, Shape > > vectorise (std::multimap< Priority, ElementId > &oids)
 Return a vector from overriding priorities.
 
Shape & operator[] (ElementId id)
 
std::vector< std::pair< Info, Shape > >::const_iterator begin () const
 
std::vector< std::pair< Info, Shape > >::const_iterator end () const
 
uint64_t size () const
 
bool hasId (const ElementId id) const
 

Protected Member Functions

virtual void draw (std::shared_ptr< Shader > shader, std::vector< std::pair< Info, Shape > > &shapes, UpdateInfo info=UpdateInfo())=0
 

Protected Attributes

std::shared_ptr< Shadershader
 
glm::mat4 projection = glm::mat4(0.0f)
 
- Protected Attributes inherited from PriorityStore< Shape >
std::unordered_map< ElementId, std::pair< Shape, Priority > > idToElement
 
std::vector< std::pair< Info, Shape > > cache
 

Detailed Description

Renders shapes with optional rendering priority.

Remarks
Currently Circle and Rectangle are defined as shaders.

Constructor & Destructor Documentation

◆ ShapeRenderer() [1/2]

jGL::ShapeRenderer::ShapeRenderer ( size_t  sizeHint = 8)
inline

Construct a new ShapeRenderer.

Parameters
sizeHintHint at the number of shapes

◆ ShapeRenderer() [2/2]

jGL::ShapeRenderer::ShapeRenderer ( std::shared_ptr< Shader shader,
size_t  sizeHint = 8 
)
inline

Construct a new ShapeRenderer.

Parameters
shaderThe default shader to use
sizeHintHint at the number of shapes

Member Function Documentation

◆ draw() [1/5]

virtual void jGL::ShapeRenderer::draw ( std::multimap< RenderPriority, ShapeId > &  ids,
UpdateInfo  info = UpdateInfo() 
)
inlinevirtual

Draw with overriding render priority.

Parameters
idsRender priorities for the Sprites.
Remarks
Only ShapeIds appearing in the ids argument will be rendered in this draw call.
Overriding priorities with many shapes performs poorly on cpu. Consider ShapeRenderer::updatePriority to cache priorities.

◆ draw() [2/5]

virtual void jGL::ShapeRenderer::draw ( std::shared_ptr< Shader shader,
std::multimap< RenderPriority, ShapeId > &  ids,
UpdateInfo  info = UpdateInfo() 
)
inlinevirtual

Draw with overriding render priority and shader.

Parameters
shaderA Shader to draw all the Sprites with.
idsRender priorities for the Sprites.
Remarks
Only ShapeIds appearing in the ids argument will be rendered in this draw call.
Overriding priorities with many shapes performs poorly on cpu. Consider ShapeRenderer::updatePriority to cache priority.

◆ draw() [3/5]

virtual void jGL::ShapeRenderer::draw ( std::shared_ptr< Shader shader,
std::vector< std::pair< Info, Shape > > &  shapes,
UpdateInfo  info = UpdateInfo() 
)
protectedpure virtual

◆ draw() [4/5]

virtual void jGL::ShapeRenderer::draw ( std::shared_ptr< Shader shader,
UpdateInfo  info = UpdateInfo() 
)
inlinevirtual

Draw with overriding shader and cached priorities.

Parameters
shaderA Shader to draw all the Sprites with.

◆ draw() [5/5]

virtual void jGL::ShapeRenderer::draw ( UpdateInfo  info = UpdateInfo())
inlinevirtual

Draw with default shader and cached priorities.

◆ getColour()

const glm::vec4 * jGL::ShapeRenderer::getColour ( ShapeId  id)
inline

◆ getShape()

Shape & jGL::ShapeRenderer::getShape ( ShapeId  id)
inline

◆ getTransform()

const Transform * jGL::ShapeRenderer::getTransform ( ShapeId  id)
inline

◆ hasId()

bool jGL::ShapeRenderer::hasId ( const ShapeId  id) const
inline

◆ setProjection()

virtual void jGL::ShapeRenderer::setProjection ( glm::mat4  p)
inlinevirtual

Member Data Documentation

◆ projection

glm::mat4 jGL::ShapeRenderer::projection = glm::mat4(0.0f)
protected

◆ shader

std::shared_ptr<Shader> jGL::ShapeRenderer::shader
protected

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