NGL  6.5
The NCCA Graphics Library
VAOPrimitives.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 Jon Macey
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #ifndef VAOPRIMITIVES_H_
18 #define VAOPRIMITIVES_H_
19 
20 // must include types.h first for Real
21 #include "Singleton.h"
22 #include "Types.h"
23 #include "Vec3.h"
24 #include "AbstractVAO.h"
25 #include <vector>
26 #include <string>
27 #include <unordered_map>
28 #include <memory>
29 
30 namespace ngl
31 {
32 //----------------------------------------------------------------------------------------------------------------------
39 //----------------------------------------------------------------------------------------------------------------------
40 // a simple structure to hold our vertex data this is a
41 // legacy format form GLDebugger as we could set to 2 3 3 format
42 struct vertData
43 {
52 };
53 
54 class NGL_DLLEXPORT VAOPrimitives : public Singleton<VAOPrimitives>
55 {
56 
57  friend class Singleton<VAOPrimitives>;
58  friend class Vec3;
59 
60 public :
61  //----------------------------------------------------------------------------------------------------------------------
64  //----------------------------------------------------------------------------------------------------------------------
65  void draw( const std::string &_name ) noexcept;
66  //----------------------------------------------------------------------------------------------------------------------
70  //----------------------------------------------------------------------------------------------------------------------
71  void draw( const std::string &_name,GLenum _mode ) noexcept;
72  //----------------------------------------------------------------------------------------------------------------------
77  //----------------------------------------------------------------------------------------------------------------------
78  void createSphere( const std::string &_name, Real _radius, int _precision ) noexcept;
79  //----------------------------------------------------------------------------------------------------------------------
85  //----------------------------------------------------------------------------------------------------------------------
86  void createLineGrid( const std::string &_name, Real _width, Real _depth, int _steps ) noexcept;
87 
88 
89  //----------------------------------------------------------------------------------------------------------------------
96  //----------------------------------------------------------------------------------------------------------------------
97  void createCylinder( const std::string &_name,const Real _radius, Real _height, unsigned int _slices, unsigned int _stacks) noexcept;
98  //----------------------------------------------------------------------------------------------------------------------
105  //----------------------------------------------------------------------------------------------------------------------
106  void createCone(const std::string &_name, Real _base, Real _height, unsigned int _slices, unsigned int _stacks ) noexcept;
107  //----------------------------------------------------------------------------------------------------------------------
112  //----------------------------------------------------------------------------------------------------------------------
113  void createDisk( const std::string &_name, Real _radius, unsigned int _slices ) noexcept;
114  //----------------------------------------------------------------------------------------------------------------------
122  //----------------------------------------------------------------------------------------------------------------------
123  void createTorus(const std::string &_name, Real _minorRadius, Real _majorRadius,unsigned int _nSides, unsigned int _nRings, bool _flipTX=false ) noexcept;
124  //----------------------------------------------------------------------------------------------------------------------
134  //----------------------------------------------------------------------------------------------------------------------
135  void createTrianglePlane( const std::string &_name,const Real _width,const Real _depth,const int _wP, const int _dP,const Vec3 &_vN ) noexcept;
136 
137  //----------------------------------------------------------------------------------------------------------------------
143  //----------------------------------------------------------------------------------------------------------------------
144 
145  void createCapsule(const std::string &_name,const Real _radius=1.0f, const Real _height=2.0f, const int _precision=20) noexcept;
146 
147  //----------------------------------------------------------------------------------------------------------------------
152  //----------------------------------------------------------------------------------------------------------------------
153  void loadBinary( const std::string &_name, const std::string &_fName,const GLenum _type ) noexcept;
154  //----------------------------------------------------------------------------------------------------------------------
157  //----------------------------------------------------------------------------------------------------------------------
158  void clear() noexcept;
160  AbstractVAO * getVAOFromName(const std::string &_name);
161 
162 private :
163  //----------------------------------------------------------------------------------------------------------------------
165  //----------------------------------------------------------------------------------------------------------------------
166  std::unordered_map <std::string,AbstractVAO *> m_createdVAOs;
167 
168  //----------------------------------------------------------------------------------------------------------------------
170  //----------------------------------------------------------------------------------------------------------------------
171  VAOPrimitives() noexcept;
172  //----------------------------------------------------------------------------------------------------------------------
174  //----------------------------------------------------------------------------------------------------------------------
175  virtual ~VAOPrimitives(){clear();}
176  //----------------------------------------------------------------------------------------------------------------------
182  //----------------------------------------------------------------------------------------------------------------------
183  void createVAOFromHeader( const std::string &_name, Real const *_data, unsigned int _Size ) noexcept;
184 
185  //----------------------------------------------------------------------------------------------------------------------
188  //----------------------------------------------------------------------------------------------------------------------
189  void createDefaultVAOs() noexcept;
190  //----------------------------------------------------------------------------------------------------------------------
196  //----------------------------------------------------------------------------------------------------------------------
197  void createVAO( const std::string &_name, const std::vector <vertData> &_data, const GLenum _mode ) noexcept;
198  //----------------------------------------------------------------------------------------------------------------------
203  //----------------------------------------------------------------------------------------------------------------------
204  void fghCircleTable(std::unique_ptr<Real[]> &io_sint, std::unique_ptr<Real[]> &io_cost, int _n ) noexcept;
205 
206 };
207 
208 }// end ngl namespace
209 #endif
main definition of types and namespace
#define NGL_DLLEXPORT
Definition: Types.h:65
Definition: format.h:316
ngl::Real y
Definition: VAOPrimitives.h:50
unsigned int GLenum
Definition: glew.h:278
simple Vec3 encapsulates a 3 float object like glsl vec3 but not maths use the Vec3 class for maths a...
Definition: Vec3.h:51
implementation files for RibExport class
Definition: AABB.cpp:22
PRECISION Real
create a variable called Real which is the main data type we use (GLfloat for most cases) ...
Definition: Types.h:127
base class for all VAO from the VAOFactory this defines the base class type with simple draw / bind b...
Definition: AbstractVAO.h:34
a simple 3 tuple container for compatibility with glsl
ngl::Real nx
Definition: VAOPrimitives.h:46
ngl::Real nz
Definition: VAOPrimitives.h:48
ngl::Real v
Definition: VAOPrimitives.h:45
ngl::Real ny
Definition: VAOPrimitives.h:47
VAO based object primitives used for fast openGL drawing this is a singelton class so we use the inst...
Definition: VAOPrimitives.h:54
ngl::Real u
Definition: VAOPrimitives.h:44
a simple singleton template inherited by other classes
ngl::Real x
Definition: VAOPrimitives.h:49
ngl::Real z
Definition: VAOPrimitives.h:51
GLsizei const GLchar *const * string
Definition: glew.h:1847
Singleton template added to NGL framework 20/04/10 by jmacey.
Definition: Singleton.h:40
GLclampf f
Definition: glew.h:3511