NGL
6.5
The NCCA Graphics Library
|
VAO based object primitives used for fast openGL drawing this is a singelton class so we use the instance method to get access and construct the only instance. More...
#include <VAOPrimitives.h>
Public Member Functions | |
void | draw (const std::string &_name) noexcept |
Draw one of the VBO's created via a name lookup. More... | |
void | draw (const std::string &_name, GLenum _mode) noexcept |
Draw one of the VBO's created via a name lookup. More... | |
void | createSphere (const std::string &_name, Real _radius, int _precision) noexcept |
create a triangulated Sphere as a vbo with auto generated texture cords More... | |
void | createLineGrid (const std::string &_name, Real _width, Real _depth, int _steps) noexcept |
create a line based grid (like the maya ground plane) More... | |
void | createCylinder (const std::string &_name, const Real _radius, Real _height, unsigned int _slices, unsigned int _stacks) noexcept |
create a Quad Cylinder as a vbo with auto generated texture cords More... | |
void | createCone (const std::string &_name, Real _base, Real _height, unsigned int _slices, unsigned int _stacks) noexcept |
create a Quad Cone as a vao with auto generated texture cords More... | |
void | createDisk (const std::string &_name, Real _radius, unsigned int _slices) noexcept |
create a trinagle fan disk (use as end caps for Cylinder etc) More... | |
void | createTorus (const std::string &_name, Real _minorRadius, Real _majorRadius, unsigned int _nSides, unsigned int _nRings, bool _flipTX=false) noexcept |
create a VBO based torus from rings of quads. More... | |
void | createTrianglePlane (const std::string &_name, const Real _width, const Real _depth, const int _wP, const int _dP, const Vec3 &_vN) noexcept |
create a triangulated plane as a vbo with auto generated texture cords More... | |
void | createCapsule (const std::string &_name, const Real _radius=1.0f, const Real _height=2.0f, const int _precision=20) noexcept |
create a triangulated capsule (Cylinder with spherical ends) More... | |
void | loadBinary (const std::string &_name, const std::string &_fName, const GLenum _type) noexcept |
load a VBO from a binary file created from Obj2VBO program More... | |
void | clear () noexcept |
clear the VAO elements created (is also called by dtor) This is usefull if you don't want the default primitives More... | |
AbstractVAO * | getVAOFromName (const std::string &_name) |
get the raw VAO so we can map it etc More... | |
Public Member Functions inherited from ngl::Singleton< VAOPrimitives > | |
Singleton (const Singleton &)=delete | |
Singleton & | operator= (const Singleton &)=delete |
Private Member Functions | |
VAOPrimitives () noexcept | |
default constructor More... | |
virtual | ~VAOPrimitives () |
dtor More... | |
void | createVAOFromHeader (const std::string &_name, Real const *_data, unsigned int _Size) noexcept |
create a VAO from a static header file of data in the TNV format this will usually be created from the Obj2VBO program in the Models directory More... | |
void | createDefaultVAOs () noexcept |
create the default VAO's this is done by the ctor anyway but can be called if the clear method is called. Note you will need to incude VAOHeaders in the client side More... | |
void | createVAO (const std::string &_name, const std::vector< vertData > &_data, const GLenum _mode) noexcept |
the method to actually create the VAO from the various other methods Note this is used in conjunction with the vertData struct More... | |
void | fghCircleTable (std::unique_ptr< Real[]> &io_sint, std::unique_ptr< Real[]> &io_cost, int _n) noexcept |
create the elements of a circle this is borrowed from freeglut More... | |
Private Attributes | |
std::unordered_map< std::string, AbstractVAO * > | m_createdVAOs |
a map to store the VAO by name More... | |
Friends | |
class | Singleton< VAOPrimitives > |
class | Vec3 |
Additional Inherited Members | |
Static Public Member Functions inherited from ngl::Singleton< VAOPrimitives > | |
static VAOPrimitives * | instance () |
Get the instance. More... | |
Protected Member Functions inherited from ngl::Singleton< VAOPrimitives > | |
Singleton () | |
Constructor. More... | |
virtual | ~Singleton () |
Destructor. More... | |
Static Protected Member Functions inherited from ngl::Singleton< VAOPrimitives > | |
static void | killSingleton () |
Static Protected Attributes inherited from ngl::Singleton< VAOPrimitives > | |
static VAOPrimitives * | s_instance |
unique instance of the singleton More... | |
VAO based object primitives used for fast openGL drawing this is a singelton class so we use the instance method to get access and construct the only instance.
Definition at line 54 of file VAOPrimitives.h.
|
privatenoexcept |
default constructor
Definition at line 34 of file VAOPrimitives.cpp.
References createDefaultVAOs().
|
inlineprivatevirtual |
dtor
Definition at line 175 of file VAOPrimitives.h.
|
noexcept |
clear the VAO elements created (is also called by dtor) This is usefull if you don't want the default primitives
Definition at line 879 of file VAOPrimitives.cpp.
References m_createdVAOs.
|
noexcept |
create a triangulated capsule (Cylinder with spherical ends)
[in] | _name | the name of the object created used when drawing |
[in] | _radius | the radius of the capsule |
[in] | _height | the height of the capsule |
[in] | _precision | the precision of the tri mesh created (number of steps) |
Definition at line 228 of file VAOPrimitives.cpp.
References createVAO(), GL_TRIANGLES, ngl::vertData::nx, ngl::vertData::ny, ngl::vertData::nz, ngl::vertData::x, ngl::vertData::y, and ngl::vertData::z.
|
noexcept |
create a Quad Cone as a vao with auto generated texture cords
[in] | _name | the name of the object created used when drawing |
[in] | _base | the base radius of the cone |
[in] | _height | the height of the cone |
[in] | _slices | the number of quad elements around the cone |
[in] | _stacks | the number of quad elements along the centeral axis |
Definition at line 518 of file VAOPrimitives.cpp.
References createVAO(), fghCircleTable(), GL_TRIANGLE_STRIP, ngl::vertData::nx, ngl::vertData::ny, ngl::vertData::nz, ngl::vertData::u, ngl::vertData::v, ngl::vertData::x, ngl::vertData::y, and ngl::vertData::z.
|
noexcept |
create a Quad Cylinder as a vbo with auto generated texture cords
[in] | _name | the name of the object created used when drawing |
[in] | _radius | the base radius of the Cylinder |
[in] | _height | the height of the Cylinder |
[in] | _slices | the number of quad elements around the Cylinder |
[in] | _stacks | the number of quad elements along the centeral axis |
Definition at line 411 of file VAOPrimitives.cpp.
References createVAO(), fghCircleTable(), GL_TRIANGLES, ngl::vertData::nx, ngl::vertData::ny, ngl::vertData::nz, ngl::vertData::u, ngl::vertData::v, ngl::vertData::x, ngl::vertData::y, and ngl::vertData::z.
|
privatenoexcept |
create the default VAO's this is done by the ctor anyway but can be called if the clear method is called. Note you will need to incude VAOHeaders in the client side
Definition at line 14 of file createDefaultVAOs.cpp.
References ngl::buddah, ngl::buddahSIZE, ngl::bunny, ngl::bunnySIZE, createVAOFromHeader(), ngl::cube, ngl::cubeSIZE, ngl::dodecahedron, ngl::dodecahedronSIZE, ngl::dragon, ngl::dragonSIZE, ngl::football, ngl::footballSIZE, ngl::icosahedron, ngl::icosahedronSIZE, ngl::Octahedron, ngl::OctahedronSIZE, ngl::teapot, ngl::teapotSIZE, tetrahedron, tetrahedronSIZE, ngl::troll, and ngl::trollSIZE.
|
noexcept |
create a trinagle fan disk (use as end caps for Cylinder etc)
[in] | _name | the name of the object created used when drawing |
[in] | _radius | the disk radius |
[in] | _slices | the number of triangles to form the disk |
Definition at line 587 of file VAOPrimitives.cpp.
References createVAO(), fghCircleTable(), GL_TRIANGLE_FAN, ngl::vertData::nx, ngl::vertData::ny, ngl::vertData::nz, ngl::vertData::u, ngl::vertData::v, ngl::vertData::x, ngl::vertData::y, and ngl::vertData::z.
|
noexcept |
create a line based grid (like the maya ground plane)
[in] | _name | the name of the object created used when drawing |
[in] | _width | the width of the grid |
[in] | _depth | the depth of the grid |
[in] | _steps | the number of steps for the grid |
Definition at line 112 of file VAOPrimitives.cpp.
References createVAO(), GL_LINES, ngl::vertData::x, ngl::vertData::y, and ngl::vertData::z.
|
noexcept |
create a triangulated Sphere as a vbo with auto generated texture cords
[in] | _name | the name of the object created used when drawing |
[in] | _radius | the sphere radius |
[in] | _precision | the number of triange subdivisions to use |
Definition at line 164 of file VAOPrimitives.cpp.
References createVAO(), GL_TRIANGLE_STRIP, ngl::vertData::nx, ngl::vertData::ny, ngl::vertData::nz, ngl::PI2, ngl::TWO_PI, ngl::vertData::u, ngl::vertData::v, ngl::vertData::x, ngl::vertData::y, and ngl::vertData::z.
|
noexcept |
create a VBO based torus from rings of quads.
[in] | _name | the name of the VBO created for calling with the draw method |
[in] | _minorRadius | the inner radius of the torus |
[in] | _majorRadius | the outer radius of the torus. |
[in] | _nSides | the precision (number of quads) for the majorRadius |
[in] | _nRings | the precision (number of quads) for the minor Radius |
[in] | _flipTX | flip the texture co-ord generation default false. |
Definition at line 634 of file VAOPrimitives.cpp.
References createVAO(), GL_TRIANGLES, ngl::vertData::nx, ngl::vertData::ny, ngl::vertData::nz, ngl::vertData::u, ngl::vertData::v, ngl::vertData::x, ngl::vertData::y, and ngl::vertData::z.
|
noexcept |
create a triangulated plane as a vbo with auto generated texture cords
[in] | _name | the name of the object created used when drawing |
[in] | _width | the width of the plane based on the center of the plane being at 0,0,0 |
[in] | _depth | the height of the plane based on the center of the plane being at 0,0,0 |
[in] | _wP | the precision of the width, this is basically the steps (per quad) which will be triangulated for each (wP == 1 will give 1 quad mad of 2 tris) |
[in] | _dP | the precision of the Depth, this is basically the steps (per quad) which will be triangulated for each (wP == 1 will give 1 quad mad of 2 tris) |
[in] | _vN | The Vertex normal (used for each vertex) |
Definition at line 798 of file VAOPrimitives.cpp.
References createVAO(), GL_TRIANGLES, ngl::vertData::nx, ngl::vertData::ny, ngl::vertData::nz, ngl::vertData::u, ngl::vertData::v, ngl::vertData::x, ngl::vertData::y, and ngl::vertData::z.
|
privatenoexcept |
the method to actually create the VAO from the various other methods Note this is used in conjunction with the vertData struct
[in] | _name | the name to store in the map of the VBO |
[in] | _data | the raw data packed into the vertData structure |
[in] | _mode | the mode to draw |
Definition at line 335 of file VAOPrimitives.cpp.
References ngl::AbstractVAO::bind(), ngl::VAOFactory::createVAO(), GL_FLOAT, m_createdVAOs, ngl::AbstractVAO::setData(), ngl::AbstractVAO::setNumIndices(), ngl::AbstractVAO::setVertexAttributePointer(), and ngl::AbstractVAO::unbind().
|
privatenoexcept |
create a VAO from a static header file of data in the TNV format this will usually be created from the Obj2VBO program in the Models directory
[in] | _name | the name reference for the VBO lookup |
[in] | _data | a pointer to the data to load |
[in] | _Size | the size of the array of data to load |
Definition at line 75 of file VAOPrimitives.cpp.
References ngl::AbstractVAO::bind(), ngl::VAOFactory::createVAO(), GL_FLOAT, GL_TRIANGLES, m_createdVAOs, ngl::AbstractVAO::setData(), ngl::AbstractVAO::setNumIndices(), ngl::AbstractVAO::setVertexAttributePointer(), and ngl::AbstractVAO::unbind().
|
noexcept |
Draw one of the VBO's created via a name lookup.
[in] | _name | the name of the VBO to lookup in the VBO map |
Definition at line 42 of file VAOPrimitives.cpp.
References m_createdVAOs.
|
noexcept |
Draw one of the VBO's created via a name lookup.
[in] | _name | the name of the VBO to lookup in the VBO map |
[in] | _mode | the draw mode for the VBO override the default |
Definition at line 58 of file VAOPrimitives.cpp.
References m_createdVAOs.
|
privatenoexcept |
create the elements of a circle this is borrowed from freeglut
[in,out] | io_sint | a pointer to the sin elements of the table |
[in,out] | io_cost | a pointer to the cos element of the table |
[in] | _n | the number of points to calculate. |
Definition at line 385 of file VAOPrimitives.cpp.
References ngl::PI.
AbstractVAO * ngl::VAOPrimitives::getVAOFromName | ( | const std::string & | _name | ) |
get the raw VAO so we can map it etc
Definition at line 896 of file VAOPrimitives.cpp.
References m_createdVAOs.
|
noexcept |
load a VBO from a binary file created from Obj2VBO program
[in] | _name | the name of the VBO to be stored as ref to this object |
[in] | _fName | the name of the file to load. |
[in] | _type | the draw mode type |
|
friend |
Definition at line 57 of file VAOPrimitives.h.
|
friend |
Definition at line 58 of file VAOPrimitives.h.
|
private |
a map to store the VAO by name
Definition at line 166 of file VAOPrimitives.h.