Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
misc.hpp
Go to the documentation of this file.
1 
23 #ifndef __MISC__
24 #define __MISC__
25 
26 #include <GL/glew.h>
27 #include <GL/glu.h>
28 
29 #include <iostream>
30 #include <string>
31 #include <cstdlib>
32 
33 #define stringify( x ) stringify_literal( x )
34 #define stringify_literal( x ) # x
35 
36 namespace Tucano
37 {
38 
39 namespace Misc
40 {
41 
42 
53 inline void errorCheckFunc (std::string file, int line, std::string message = "")
54 {
55  //OpenGL Error Handling Function:
56  GLenum ErrorCheckValue = glGetError();
57  if (ErrorCheckValue != GL_NO_ERROR)
58  {
59  std::cerr << "GL error in " << file << " line " << line << " : " << gluErrorString(ErrorCheckValue) << std::endl;
60  std::cerr << message.c_str() << std::endl;
61  exit(EXIT_FAILURE);
62  }
63 }
64 
68 inline void initGlew (void)
69 {
70 
71  glewExperimental = true;
72  GLenum glewInitResult = glewInit();
73  if (GLEW_OK != glewInitResult)
74  {
75  std::cerr << "Error: " << glewGetErrorString(glewInitResult) << std::endl;
76  exit(EXIT_FAILURE);
77  }
78 
79  #ifdef TUCANODEBUG
80  errorCheckFunc(__FILE__, __LINE__);
81  std::cout << "GLEW INFO: OpenGL Version: " << glGetString(GL_VERSION) << std::endl << std::endl;
82  #endif
83 
84 }
85 
86 }
87 }
88 #endif
Definition: bufferobject.hpp:34
void errorCheckFunc(std::string file, int line, std::string message="")
GL error check method.
Definition: misc.hpp:53
void initGlew(void)
Initialize Glew.
Definition: misc.hpp:68