OGLplus (0.52.0) a C++ wrapper for OpenGL

gl.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_GL_1107121519_HPP
14 #define OGLPLUS_GL_1107121519_HPP
15 
16 #ifndef OGLPLUS_NO_SITE_CONFIG
17 #include <oglplus/config/site.hpp>
18 #endif
19 
20 #ifndef OGLPLUS_USE_GLCOREARB_H
21 #define OGLPLUS_USE_GLCOREARB_H 1
22 #endif
23 
24 #ifndef OGLPLUS_USE_GL3_H
25 #define OGLPLUS_USE_GL3_H 0
26 #endif
27 
28 #ifndef OGLPLUS_USE_GLEW
29 #define OGLPLUS_USE_GLEW 0
30 #endif
31 
32 #ifndef OGLPLUS_USE_GL3W
33 #define OGLPLUS_USE_GL3W 0
34 #endif
35 
36 
37 #ifndef OGLPLUS_NO_GL
38 
39 # if OGLPLUS_USE_GLCOREARB_H
40 # define GLCOREARB_PROTOTYPES
41 # define GL_GLEXT_PROTOTYPES
42 # include <GL/glcorearb.h>
43 # include <GL/glext.h>
44 
45 namespace oglplus {
46 struct GLAPIInitializer
47 {
48  GLAPIInitializer(
49  int /*gl_ver_major*/ = 3,
50  int /*gl_ver_minor*/ = 3
51  ){ }
52 };
53 } // namespace oglplus
54 
55 # elif OGLPLUS_USE_GL3_H
56 # define GL3_PROTOTYPES
57 # ifdef __APPLE__
58 # include <OpenGL/gl3.h>
59 # else
60 # include <GL3/gl3.h>
61 # endif
62 # define __gl_h_
63 # define __gl_h__
64 # define __glext_h_
65 # define __glext_h__
66 
67 namespace oglplus {
68 struct GLAPIInitializer
69 {
70  GLAPIInitializer(
71  int /*gl_ver_major*/ = 3,
72  int /*gl_ver_minor*/ = 3
73  ){ }
74 };
75 } // namespace oglplus
76 
77 # elif OGLPLUS_USE_GLEW
78 # include <GL/glew.h>
79 # include <stdexcept>
80 
81 namespace oglplus {
82 class GLAPIInitializer
83 {
84 public:
85  GLAPIInitializer(
86  int /*gl_ver_major*/ = 3,
87  int /*gl_ver_minor*/ = 3
88  )
89  {
90  glewExperimental = GL_TRUE;
91  GLenum init_result = glewInit();
92  glGetError();
93  if(init_result != GLEW_OK)
94  {
95  throw std::runtime_error(
96  "OpenGL/GLEW initialization error."
97  );
98  }
99  }
100 };
101 } // namespace oglplus
102 
103 # elif OGLPLUS_USE_GL3W
104 # define GL3_PROTOTYPES
105 # include <GL3/gl3w.h>
106 # include <stdexcept>
107 
108 namespace oglplus {
109 class GLAPIInitializer
110 {
111 public:
112  GLAPIInitializer(
113  int gl_ver_major = 3,
114  int gl_ver_minor = 3
115  )
116  {
117  auto init_failed = gl3wInit();
118  glGetError();
119  if(init_failed)
120  {
121  throw std::runtime_error(
122  "OpenGL/GL3W initialization error."
123  );
124  }
125  if(!gl3wIsSupported(gl_ver_major, gl_ver_minor))
126  {
127  throw std::runtime_error(
128  "Requested OpenGL version not supported"
129  );
130  }
131  }
132 };
133 } // namespace oglplus
134 
135 # else
136 # error "Some library including OpenGL symbols is required!"
137 # endif // OGLPLUS_USE_*
138 
139 #ifndef GL_VERTEX_ARRAY
140 #define GL_VERTEX_ARRAY 0x8074
141 #endif
142 
143 #ifndef GL_BUFFER
144 #define GL_BUFFER 0x82E0
145 #endif
146 
147 #ifndef GL_SHADER
148 #define GL_SHADER 0x82E1
149 #endif
150 
151 #ifndef GL_PROGRAM
152 #define GL_PROGRAM 0x82E2
153 #endif
154 
155 #ifndef GL_QUERY
156 #define GL_QUERY 0x82E3
157 #endif
158 
159 #ifndef GL_PROGRAM_PIPELINE
160 #define GL_PROGRAM_PIPELINE 0x82E4
161 #endif
162 
163 #ifndef GL_SAMPLER
164 #define GL_SAMPLER 0x82E6
165 #endif
166 
167 #ifndef GL_TRANSFORM_FEEDBACK
168 #define GL_TRANSFORM_FEEDBACK 0x8E22
169 #endif
170 
171 #ifndef GL_TEXTURE
172 #define GL_TEXTURE 0x1702
173 #endif
174 
175 #ifndef GL_FRAMEBUFFER
176 #define GL_FRAMEBUFFER 0x8D40
177 #endif
178 
179 #ifndef GL_RENDERBUFFER
180 #define GL_RENDERBUFFER 0x8D41
181 #endif
182 
183 #ifndef GL_POLYGON_MODE
184 #define GL_POLYGON_MODE 0x0B40
185 #endif
186 
187 #endif // OGLPLUS_NO_GL
188 
189 #endif // include guard

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).