Radium Engine  1.5.0
Ra::Engine::Data::AttribArrayDisplayable Class Referenceabstract

#include <Engine/Data/Mesh.hpp>

+ Inheritance diagram for Ra::Engine::Data::AttribArrayDisplayable:
+ Collaboration diagram for Ra::Engine::Data::AttribArrayDisplayable:

Public Types

enum  MeshRenderMode : uint {
  RM_POINTS = 0x0000 , RM_LINES = 0x0001 , RM_LINE_LOOP = 0x0002 , RM_LINE_STRIP = 0x0003 ,
  RM_TRIANGLES = 0x0004 , RM_TRIANGLE_STRIP = 0x0005 , RM_TRIANGLE_FAN = 0x0006 , RM_QUADS = 0x0007 ,
  RM_QUAD_STRIP = 0x0008 , RM_POLYGON = 0x0009 , RM_LINES_ADJACENCY = 0x000A , RM_LINE_STRIP_ADJACENCY = 0x000B ,
  RM_TRIANGLES_ADJACENCY = 0x000C , RM_TRIANGLE_STRIP_ADJACENCY = 0x000D , RM_PATCHES = 0x000E
}
 
- Public Types inherited from Ra::Engine::Data::Displayable
enum  PickingRenderMode {
  PKM_POINTS = 0 , PKM_LINES = 1 , PKM_LINE_ADJ = 2 , PKM_TRI = 3 ,
  NO_PICKING
}
 

Public Member Functions

 AttribArrayDisplayable (const std::string &name, MeshRenderMode renderMode=RM_TRIANGLES)
 
 AttribArrayDisplayable (const AttribArrayDisplayable &rhs)=delete
 
void operator= (const AttribArrayDisplayable &rhs)=delete
 
void setRenderMode (MeshRenderMode mode)
 Set the render mode.
 
MeshRenderMode getRenderMode () const
 Get the render mode.
 
void updateGL () override=0
 
Ra::Core::Utils::optional< gl::GLuint > getVboHandle (const std::string &name)
 Get opengl's vbo handle (uint) corresponding to attrib name. More...
 
Ra::Core::Utils::optional< gl::GLuint > getVaoHandle ()
 Get opengl's vao handle (uint). More...
 
const std::string & getName () const
 Returns the name of the mesh.
 

Mark attrib data as dirty, forcing an update of the OpenGL buffer.

void setDirty (const Core::Geometry::MeshAttrib &type)
 
void setDirty (const std::string &name)
 
void setDirty (unsigned int index)
 

Core::Geometry getters.

virtual const Core::Geometry::AttribArrayGeometrygetAttribArrayGeometry () const =0
 
virtual Core::Geometry::AttribArrayGeometrygetAttribArrayGeometry ()=0
 
- Public Member Functions inherited from Ra::Engine::Data::Displayable
 Displayable (const std::string &name)
 
 Displayable (const Displayable &rhs)=delete
 
void operator= (const Displayable &rhs)=delete
 
PickingRenderMode pickingRenderMode () const
 Returns the picking rendermode advised by the object (default PickingRenderMode::NO_PICKING)
 
const std::string & getName () const
 Returns the name of the mesh.
 
virtual const Core::Geometry::AbstractGeometrygetAbstractGeometry () const =0
 
virtual Core::Geometry::AbstractGeometrygetAbstractGeometry ()=0
 
virtual void render (const ShaderProgram *prog)=0
 
virtual size_t getNumFaces () const
 
virtual size_t getNumVertices () const
 

Protected Member Functions

void updatePickingRenderMode ()
 Update the picking render mode according to the object render mode.
 

Protected Attributes

std::unique_ptr< globjects::VertexArray > m_vao
 
MeshRenderMode m_renderMode { MeshRenderMode::RM_TRIANGLES }
 
std::vector< std::unique_ptr< globjects::Buffer > > m_vbos
 
std::vector< bool > m_dataDirty
 
std::map< std::string, unsigned int > m_handleToBuffer
 
bool m_isDirty { false }
 General dirty bit of the mesh. More...
 
- Protected Attributes inherited from Ra::Engine::Data::Displayable
PickingRenderMode m_pickingRenderMode { NO_PICKING }
 

Detailed Description

A class representing an openGL general mesh to be displayed. It stores the vertex attributes, indices, and can be rendered with a specific render mode (e.g. GL_TRIANGLES or GL_LINES). It maintains the attributes and keeps them in sync with the GPU.

Note
Attribute names are used to automatic location binding when using shaders.

Definition at line 51 of file Mesh.hpp.

Member Enumeration Documentation

◆ MeshRenderMode

Render mode enum used when render()/ values taken from OpenGL specification

See also
https://www.khronos.org/registry/OpenGL/api/GL/glcorearb.h

Definition at line 57 of file Mesh.hpp.

Member Function Documentation

◆ getVaoHandle()

Ra::Core::Utils::optional< gl::GLuint > Ra::Engine::Data::AttribArrayDisplayable::getVaoHandle ( )

Get opengl's vao handle (uint).

If vao is not initialized, the returned optional is empty

Definition at line 153 of file Mesh.cpp.

◆ getVboHandle()

Ra::Core::Utils::optional< gl::GLuint > Ra::Engine::Data::AttribArrayDisplayable::getVboHandle ( const std::string &  name)

Get opengl's vbo handle (uint) corresponding to attrib name.

If vbo is not initialized or name do not correponds to an actual attrib name, the returned optional is empty

Definition at line 158 of file Mesh.cpp.

◆ setDirty() [1/3]

void Ra::Engine::Data::AttribArrayDisplayable::setDirty ( const Core::Geometry::MeshAttrib &  type)

Use g_attribName to find the corresponding name and call setDirty(const std::string& name).

Parameters
typethe data to set to MeshAttrib

Definition at line 139 of file Mesh.cpp.

◆ setDirty() [2/3]

void Ra::Engine::Data::AttribArrayDisplayable::setDirty ( const std::string &  name)
Parameters
namedata buffer name to set to dirty

Definition at line 119 of file Mesh.cpp.

◆ setDirty() [3/3]

void Ra::Engine::Data::AttribArrayDisplayable::setDirty ( unsigned int  index)

If index is greater than then number of buffer, this function as no effect.

Parameters
indexthe data buffer index to set to dirty.

Definition at line 132 of file Mesh.cpp.

◆ updateGL()

void Ra::Engine::Data::AttribArrayDisplayable::updateGL ( )
overridepure virtual

This function is called at the start of the rendering. It will update the necessary openGL buffers.

Implements Ra::Engine::Data::Displayable.

Implemented in Ra::Engine::Data::CoreGeometryDisplayable< T >, and Ra::Engine::Data::CoreGeometryDisplayable< Core::Geometry::PointCloud >.

Member Data Documentation

◆ m_isDirty

bool Ra::Engine::Data::AttribArrayDisplayable::m_isDirty { false }
protected

General dirty bit of the mesh.

Must be equivalent of the "or" of the other dirty flags. An empty mesh is not dirty

Definition at line 169 of file Mesh.hpp.


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