Loading...
Searching...
No Matches
hellfire::InstancedRenderableComponent Class Reference

#include <InstancedRenderableComponent.h>

Inheritance diagram for hellfire::InstancedRenderableComponent:
Collaboration diagram for hellfire::InstancedRenderableComponent:

Classes

struct  InstanceData
 

Public Member Functions

 InstancedRenderableComponent ()=default
 
 InstancedRenderableComponent (std::shared_ptr< Mesh > mesh, size_t max_instances=1000)
 
 ~InstancedRenderableComponent () override
 
void set_mesh (std::shared_ptr< Mesh > mesh)
 
std::shared_ptr< Meshget_mesh () const
 
bool has_mesh () const
 
void set_material (std::shared_ptr< Material > material)
 
std::shared_ptr< Materialget_material () const
 
void add_instance (const InstanceData &instance)
 
void update_instance (size_t index, const InstanceData &instance)
 
void clear_instances ()
 
void reserve_instances (size_t count)
 
void set_instances (const std::vector< InstanceData > &instances)
 
void add_instances (const std::vector< InstanceData > &instances)
 
size_t get_instance_count () const
 
size_t get_max_instances () const
 
const std::vector< InstanceData > & get_instances () const
 
void prepare_for_draw ()
 
void bind_instance_buffers ()
 
void unbind_instance_buffers ()
 
- Public Member Functions inherited from hellfire::Component
virtual ~Component ()=default
 
Entityget_owner () const
 
virtual void on_added (Entity *owner)
 
virtual void on_removed ()
 

Private Member Functions

void setup_instance_buffers ()
 
void cleanup_buffers ()
 
void update_gpu_buffer () const
 
void setup_instanced_vertex_attributes ()
 
void enable_instance_attributes ()
 
void disable_instance_attributes ()
 

Private Attributes

std::shared_ptr< Meshmesh_
 
std::shared_ptr< Materialmaterial_
 
std::vector< InstanceDatainstances_
 
size_t max_instances_
 
bool needs_gpu_update_
 
bool vertex_attributes_setup_ = false
 
GLuint instance_vbo_
 
GLuint transform_buffer_
 
GLuint color_buffer_
 
GLuint scale_buffer_
 

Detailed Description

Definition at line 24 of file InstancedRenderableComponent.h.

Constructor & Destructor Documentation

◆ InstancedRenderableComponent() [1/2]

hellfire::InstancedRenderableComponent::InstancedRenderableComponent ( )
default

◆ InstancedRenderableComponent() [2/2]

hellfire::InstancedRenderableComponent::InstancedRenderableComponent ( std::shared_ptr< Mesh mesh,
size_t  max_instances = 1000 
)
explicit

Definition at line 6 of file InstancedRenderableComponent.cpp.

◆ ~InstancedRenderableComponent()

hellfire::InstancedRenderableComponent::~InstancedRenderableComponent ( )
override

Definition at line 15 of file InstancedRenderableComponent.cpp.

Member Function Documentation

◆ add_instance()

void hellfire::InstancedRenderableComponent::add_instance ( const InstanceData instance)

Definition at line 19 of file InstancedRenderableComponent.cpp.

◆ add_instances()

void hellfire::InstancedRenderableComponent::add_instances ( const std::vector< InstanceData > &  instances)

Definition at line 50 of file InstancedRenderableComponent.cpp.

◆ bind_instance_buffers()

void hellfire::InstancedRenderableComponent::bind_instance_buffers ( )

Definition at line 63 of file InstancedRenderableComponent.cpp.

◆ cleanup_buffers()

void hellfire::InstancedRenderableComponent::cleanup_buffers ( )
private

Definition at line 79 of file InstancedRenderableComponent.cpp.

◆ clear_instances()

void hellfire::InstancedRenderableComponent::clear_instances ( )

Definition at line 33 of file InstancedRenderableComponent.cpp.

◆ disable_instance_attributes()

void hellfire::InstancedRenderableComponent::disable_instance_attributes ( )
private

Definition at line 159 of file InstancedRenderableComponent.cpp.

◆ enable_instance_attributes()

void hellfire::InstancedRenderableComponent::enable_instance_attributes ( )
private

Definition at line 150 of file InstancedRenderableComponent.cpp.

◆ get_instance_count()

size_t hellfire::InstancedRenderableComponent::get_instance_count ( ) const
inline

Definition at line 59 of file InstancedRenderableComponent.h.

◆ get_instances()

const std::vector< InstanceData > & hellfire::InstancedRenderableComponent::get_instances ( ) const
inline

Definition at line 61 of file InstancedRenderableComponent.h.

◆ get_material()

std::shared_ptr< Material > hellfire::InstancedRenderableComponent::get_material ( ) const
inline

Definition at line 48 of file InstancedRenderableComponent.h.

◆ get_max_instances()

size_t hellfire::InstancedRenderableComponent::get_max_instances ( ) const
inline

Definition at line 60 of file InstancedRenderableComponent.h.

◆ get_mesh()

std::shared_ptr< Mesh > hellfire::InstancedRenderableComponent::get_mesh ( ) const
inline

Definition at line 43 of file InstancedRenderableComponent.h.

◆ has_mesh()

bool hellfire::InstancedRenderableComponent::has_mesh ( ) const
inline

Definition at line 44 of file InstancedRenderableComponent.h.

◆ prepare_for_draw()

void hellfire::InstancedRenderableComponent::prepare_for_draw ( )

Definition at line 56 of file InstancedRenderableComponent.cpp.

◆ reserve_instances()

void hellfire::InstancedRenderableComponent::reserve_instances ( size_t  count)

Definition at line 38 of file InstancedRenderableComponent.cpp.

◆ set_instances()

void hellfire::InstancedRenderableComponent::set_instances ( const std::vector< InstanceData > &  instances)

Definition at line 42 of file InstancedRenderableComponent.cpp.

◆ set_material()

void hellfire::InstancedRenderableComponent::set_material ( std::shared_ptr< Material material)
inline

Definition at line 47 of file InstancedRenderableComponent.h.

◆ set_mesh()

void hellfire::InstancedRenderableComponent::set_mesh ( std::shared_ptr< Mesh mesh)
inline

Definition at line 42 of file InstancedRenderableComponent.h.

◆ setup_instance_buffers()

void hellfire::InstancedRenderableComponent::setup_instance_buffers ( )
private

Definition at line 72 of file InstancedRenderableComponent.cpp.

◆ setup_instanced_vertex_attributes()

void hellfire::InstancedRenderableComponent::setup_instanced_vertex_attributes ( )
private

Definition at line 126 of file InstancedRenderableComponent.cpp.

◆ unbind_instance_buffers()

void hellfire::InstancedRenderableComponent::unbind_instance_buffers ( )

Definition at line 68 of file InstancedRenderableComponent.cpp.

◆ update_gpu_buffer()

void hellfire::InstancedRenderableComponent::update_gpu_buffer ( ) const
private

Definition at line 91 of file InstancedRenderableComponent.cpp.

◆ update_instance()

void hellfire::InstancedRenderableComponent::update_instance ( size_t  index,
const InstanceData instance 
)

Definition at line 26 of file InstancedRenderableComponent.cpp.

Member Data Documentation

◆ color_buffer_

GLuint hellfire::InstancedRenderableComponent::color_buffer_
private

Definition at line 79 of file InstancedRenderableComponent.h.

◆ instance_vbo_

GLuint hellfire::InstancedRenderableComponent::instance_vbo_
private

Definition at line 77 of file InstancedRenderableComponent.h.

◆ instances_

std::vector<InstanceData> hellfire::InstancedRenderableComponent::instances_
private

Definition at line 71 of file InstancedRenderableComponent.h.

◆ material_

std::shared_ptr<Material> hellfire::InstancedRenderableComponent::material_
private

Definition at line 70 of file InstancedRenderableComponent.h.

◆ max_instances_

size_t hellfire::InstancedRenderableComponent::max_instances_
private

Definition at line 72 of file InstancedRenderableComponent.h.

◆ mesh_

std::shared_ptr<Mesh> hellfire::InstancedRenderableComponent::mesh_
private

Definition at line 69 of file InstancedRenderableComponent.h.

◆ needs_gpu_update_

bool hellfire::InstancedRenderableComponent::needs_gpu_update_
private

Definition at line 73 of file InstancedRenderableComponent.h.

◆ scale_buffer_

GLuint hellfire::InstancedRenderableComponent::scale_buffer_
private

Definition at line 80 of file InstancedRenderableComponent.h.

◆ transform_buffer_

GLuint hellfire::InstancedRenderableComponent::transform_buffer_
private

Definition at line 78 of file InstancedRenderableComponent.h.

◆ vertex_attributes_setup_

bool hellfire::InstancedRenderableComponent::vertex_attributes_setup_ = false
private

Definition at line 74 of file InstancedRenderableComponent.h.


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