NGL  6.5
The NCCA Graphics Library
VAOFactory.cpp
Go to the documentation of this file.
1 #include "VAOFactory.h"
2 #include <iostream>
3 
4 
5 namespace ngl
6 {
7  std::unordered_map<std::string, std::function<AbstractVAO *(GLenum _mode)>> VAOFactory::m_vaoCreators;
8 
9  void VAOFactory::registerVAOCreator(const std::string &_type,std::function<AbstractVAO *(GLenum _mode)> _cb)
10  {
11  m_vaoCreators[_type] = _cb;
12  }
13 
15  {
16  m_vaoCreators.erase(_type);
17  }
18 
20  {
21 
22  auto it = m_vaoCreators.find(_type);
23  if (it != m_vaoCreators.end())
24  {
25  // call the creation callback to construct this derived type
26  return it->second(_mode);
27  }
28  return nullptr;
29  }
30 
31 
33  {
34  std::cout<<"******************************\n";
35  std::cout<<"VAOFactory Creators List \n";
36  std::cout<<"******************************\n";
37  for(auto c : m_vaoCreators)
38  {
39  std::cout<<"Creator "<<c.first<<" registered \n";
40  }
41  std::cout<<"******************************\n";
42  }
43 
44 }
static AbstractVAO * createVAO(const std::string &_type, GLenum _mode=GL_TRIANGLES)
Definition: VAOFactory.cpp:19
const GLfloat * c
Definition: glew.h:16629
static void registerVAOCreator(const std::string &_type, std::function< AbstractVAO *(GLenum _mode)> _cb)
Add a new vao creator to our factory.
Definition: VAOFactory.cpp:9
unsigned int GLenum
Definition: glew.h:278
implementation files for RibExport class
Definition: AABB.cpp:22
static void listCreators()
debug function to list all creators
Definition: VAOFactory.cpp:32
base class for all VAO from the VAOFactory this defines the base class type with simple draw / bind b...
Definition: AbstractVAO.h:34
static std::unordered_map< std::string, std::function< AbstractVAO *(GLenum _mode)> > m_vaoCreators
Definition: VAOFactory.h:67
GLsizei const GLchar *const * string
Definition: glew.h:1847
static void unregisterVAOCreator(const std::string &_type)
Remove an existing vao creator from the map.
Definition: VAOFactory.cpp:14