CGAL 5.0.2 - Three
|
#include <CGAL/Three/Primitive_container.h>
Inherited by CGAL::Three::Edge_container, CGAL::Three::Point_container, and CGAL::Three::Triangle_container.
The Primitive_container struct provides a base for the OpenGL data wrappers.
Public Member Functions | |
Primitive_container (int program, bool indexed) | |
Primitive_container ructor. More... | |
void | bindUniformValues (CGAL::Three::Viewer_interface *viewer) |
bindUniformValues sets the uniform variables for the concerned shaders. More... | |
virtual void | draw (CGAL::Three::Viewer_interface *viewer, bool is_color_uniform)=0 |
draw is the function that actually renders the data. More... | |
virtual void | initializeBuffers (CGAL::Three::Viewer_interface *viewer) |
initializeBuffers sends the data to the GPU memory. More... | |
virtual void | initGL (CGAL::Three::Viewer_interface *viewer)=0 |
initGL initializes the OpenGL containers. More... | |
void | removeViewer (CGAL::Three::Viewer_interface *viewer) |
removeViewer deletes and removes the Vao assigned to viewer from Vaos . More... | |
void | reset_vbos (Scene_item_rendering_helper::Gl_data_names) |
reset_vbos de-allocates the Vbo s. More... | |
void | setFlatDataSize (std::size_t) |
setFlatDataSize sets the number of un-indexed vertices of this container. More... | |
void | setIdxSize (std::size_t) |
setIdxDataSize sets the number of indexed vertices of this container. More... | |
void | setCenterSize (std::size_t) |
setCenterSize sets the number of instances of the item in this container. More... | |
bool | isGLInit (Viewer_interface *viewer) const |
Returns true if the container Vao s and Vbo s are created in the context of viewer . More... | |
void | allocate (std::size_t vbo_id, void *data, int datasize) |
allocate sets the data for a Vbo . More... | |
void | setVao (Viewer_interface *viewer, Vao *) |
setVao sets the Vao corresponding to viewer of this container. | |
void | setVbos (std::vector< Vbo *>) |
setVbos sets the vector of Vbo s for this container. More... | |
void | setVbo (std::size_t vbo_id, Vbo *vbo) |
setVbo sets the vbo_id th Vbo of this container to vbo . More... | |
void | setGLInit (Viewer_interface *viewer, bool) |
Use this to specify if the container Vao s and Vbo s are created in the context of viewer . | |
void | setTexture (Texture *) |
setter for the texture. | |
void | setTextureSize (const QSize &size) |
setter for the texture size. | |
void | setTextureData (int i, int j, int r, int g, int b) |
setter for the texture data at UV coordinates (i ,j ). | |
Vao * | getVao (Viewer_interface *viewer) const |
Returns the Vao bound to viewer . | |
Vbo * | getVbo (std::size_t id) const |
getVbo returns the id th Vbo of this container. | |
int | getProgram () const |
getProgram returns the OpenGL_program_IDs used with this container. | |
bool | isDataIndexed () |
isDataIndexed specifies if the data is indexed or not. More... | |
Texture * | getTexture () const |
getter for the texture. | |
GLuint | getTextureId () const |
getter for the texture id. | |
QSize | getTextureSize () const |
getter for the size of the texture. | |
bool | getClipping () const |
getter for the clipping. Default is true . | |
void | setInit (Viewer_interface *viewer, bool) |
Use this to specify if the container Vbo s are filled for viewer . | |
bool | isInit (Viewer_interface *viewer) const |
isInit returns true if the container Vbo s are filled for viewer . More... | |
std::size_t | getFlatDataSize () const |
getFlatDataSize returns the number of un-indexed vertices. More... | |
std::size_t | getIdxSize () const |
getIdxSize returns the number of indexed vertices. More... | |
int | getTupleSize () const |
getTupleSize returns the number of coordinates in one vertex. More... | |
std::size_t | getCenterSize () const |
getCenterSize returns the number of instances of the item in this container. More... | |
Setters for the shaders parameters. | |
void | setSelected (bool) |
Setter for the "selected" uniform parameter. | |
void | setColor (QColor) |
Setter for the "color" parameter. | |
void | setStride (std::size_t id, int stride) |
Setter for the "stride" parameter. | |
void | setOffset (std::size_t id, int offset) |
Setter for the "offset" parameter. | |
void | setTupleSize (int ts) |
setter for the tuple size: the number of coordinates of one vertex. | |
void | setClipping (bool b) |
setter for the clipping. If b is false , then the clipping box will have no effect. | |
Getters for the shaders parameters. | |
bool | isSelected () const |
getter for the "selected" parameter | |
QColor | getColor () const |
getter for the "color" parameter | |
CGAL::Three::Primitive_container::Primitive_container | ( | int | program, |
bool | indexed | ||
) |
Primitive_container ructor.
program | the QOpenGLShaderProgram used by the VAOs. |
indexed | must be true if the data is indexed, false otherwise. |
void CGAL::Three::Primitive_container::allocate | ( | std::size_t | vbo_id, |
void * | data, | ||
int | datasize | ||
) |
void CGAL::Three::Primitive_container::bindUniformValues | ( | CGAL::Three::Viewer_interface * | viewer | ) |
bindUniformValues sets the uniform variables for the concerned shaders.
Such variables are valid at every step of the pipeline. For example, the ModelViewProjection matrix, the uniform color or the is_selected state are uniform values. This function is called in the draw()
function.
Vbo
s data should be allocated for this function to be effective. Vao
s and the Vbo
s are created, in a valid OpenGL context. viewer | the active Viewer_interface |
|
pure virtual |
draw is the function that actually renders the data.
viewer | the active Viewer_interface . |
is_color_uniform | should be true if the item is unicolor. |
Implemented in CGAL::Three::Triangle_container, CGAL::Three::Edge_container, and CGAL::Three::Point_container.
std::size_t CGAL::Three::Primitive_container::getCenterSize | ( | ) | const |
getCenterSize returns the number of instances of the item in this container.
std::size_t CGAL::Three::Primitive_container::getFlatDataSize | ( | ) | const |
getFlatDataSize returns the number of un-indexed vertices.
std::size_t CGAL::Three::Primitive_container::getIdxSize | ( | ) | const |
getIdxSize returns the number of indexed vertices.
int CGAL::Three::Primitive_container::getTupleSize | ( | ) | const |
getTupleSize returns the number of coordinates in one vertex.
Default is 3.
|
pure virtual |
initGL initializes the OpenGL containers.
draw()
function of an item is always a safe place to call this.viewer | the active Viewer_interface . |
Implemented in CGAL::Three::Triangle_container, CGAL::Three::Edge_container, and CGAL::Three::Point_container.
|
virtual |
initializeBuffers sends the data to the GPU memory.
It actually fills up the buffers with the data provided by Vbo::allocate()
;
viewer | the active Viewer_interface . |
bool CGAL::Three::Primitive_container::isDataIndexed | ( | ) |
isDataIndexed specifies if the data is indexed or not.
This matters for the internal drawing functions.
bool CGAL::Three::Primitive_container::isGLInit | ( | Viewer_interface * | viewer | ) | const |
bool CGAL::Three::Primitive_container::isInit | ( | Viewer_interface * | viewer | ) | const |
isInit returns true
if the container Vbo
s are filled for viewer
.
void CGAL::Three::Primitive_container::removeViewer | ( | CGAL::Three::Viewer_interface * | viewer | ) |
removeViewer deletes and removes the Vao assigned to viewer
from Vaos
.
viewer | the Viewer_interface to remove. |
void CGAL::Three::Primitive_container::reset_vbos | ( | Scene_item_rendering_helper::Gl_data_names | ) |
void CGAL::Three::Primitive_container::setCenterSize | ( | std::size_t | ) |
setCenterSize sets the number of instances of the item in this container.
If the program of this container is not instanced, you can ignore this function.
void CGAL::Three::Primitive_container::setFlatDataSize | ( | std::size_t | ) |
setFlatDataSize sets the number of un-indexed vertices of this container.
If the vertices are indexed, you can ignore this function.
void CGAL::Three::Primitive_container::setIdxSize | ( | std::size_t | ) |
setIdxDataSize sets the number of indexed vertices of this container.
If the vertices are not indexed, you can ignore this function.
void CGAL::Three::Primitive_container::setVbo | ( | std::size_t | vbo_id, |
Vbo * | vbo | ||
) |
setVbo sets the vbo_id
th Vbo
of this container to vbo
.
vbo_id | |
vbo |