NGL  6.5
The NCCA Graphics Library
NGLInit.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 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 #include "NGLInit.h"
18 #include "ShaderLib.h"
19 #include "VAOPrimitives.h"
20 #include "VAOFactory.h"
21 #include "SimpleVAO.h"
22 #include "MultiBufferVAO.h"
23 #include "SimpleIndexVAO.h"
24 
25 #if defined(LINUX) || defined(WIN32)
26  #include <cstdlib>
27 #endif
28 //----------------------------------------------------------------------------------------------------------------------
31 //----------------------------------------------------------------------------------------------------------------------
32 
33 
34 namespace ngl
35 {
36 //----------------------------------------------------------------------------------------------------------------------
37 
38 
40 {
41 #ifndef USINGIOS_
42  // set this first so that new driver features are included.
43  glewExperimental = true;
44  // now init glew
45  GLenum err = glewInit();
46  // error check
47  if (GLEW_OK != err)
48  {
49  std::cerr<<"Error: "<<glewGetErrorString(err)<<"\n";
50  }
51  // now see if NGL can run in this environment
52  std::cout<<"Using GLEW "<<glewGetString(GLEW_VERSION)<<"\n";
53  if(!glewIsSupported("GL_VERSION_3_2") )
54  {
55  std::cerr<<"To run these demos you need a modern OpenGL Version\n";
56  std::cerr<<"The lowest level OpenGL we support is 3.2\n";
57  std::cerr<<"It could be you don't have the correct drivers installed\n";
58  std::cerr<<"Or if linux on a laptop it could be using the intel driver and not the GPU\n";
59  std::cerr<<"for more info contact Jon\n";
60 
61  }
62  int majorVersion,minorVersion;
63  glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
64  glGetIntegerv(GL_MINOR_VERSION, &minorVersion);
65  #ifdef NGL_DEBUG
66  std::cerr <<"ngl:: configured with GL version "<<majorVersion<<"."<<minorVersion<<"\n";
67  #endif
71 #endif
72 }
73 
74 //----------------------------------------------------------------------------------------------------------------------
76 {
77 }
78 
79 
80 } // end of ngl namespace
81 
82 
83 
84 
NGLInit()
dtor
Definition: NGLInit.cpp:39
static AbstractVAO * create(GLenum _mode=GL_TRIANGLES)
creator method for the factory
basic class to initialise the NGL library
GLEWAPI const GLubyte *GLEWAPIENTRY glewGetString(GLenum name)
GLEWAPI GLenum GLEWAPIENTRY glewInit(void)
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
main shader loader / manager class for GLSL shaders
implementation files for RibExport class
Definition: AABB.cpp:22
GLEWAPI GLboolean GLEWAPIENTRY glewIsSupported(const char *name)
#define GL_MAJOR_VERSION
Definition: glew.h:2070
#define GLEW_OK
Definition: glew.h:20050
static AbstractVAO * create(GLenum _mode=GL_TRIANGLES)
creator method for the factory
Definition: SimpleVAO.h:42
GLEWAPI const GLubyte *GLEWAPIENTRY glewGetErrorString(GLenum error)
~NGLInit()
dtor
Definition: NGLInit.cpp:75
GLAPI void GLAPIENTRY glGetIntegerv(GLenum pname, GLint *params)
#define GLEW_VERSION
Definition: glew.h:20057
#define GL_MINOR_VERSION
Definition: glew.h:2071
static AbstractVAO * create(GLenum _mode=GL_TRIANGLES)
creator method for the factory
GLEWAPI GLboolean glewExperimental
Definition: glew.h:20086