CSCI441 OpenGL Library 5.9.0
CS@Mines CSCI441 Computer Graphics Course Library
Loading...
Searching...
No Matches
OpenGLUtils.hpp
Go to the documentation of this file.
1
15#ifndef CSCI441_OPENGL_UTILS_H
16#define CSCI441_OPENGL_UTILS_H
17
18#ifdef CSCI441_USE_GLEW
19 #include <GL/glew.h>
20#else
21 #include <glad/gl.h>
22#endif
23
24#include <glm/glm.hpp>
25
26#include <cstdio> // for printf()
27#include <cstdlib> // for atoi()
28
29//**********************************************************************************
30
35namespace CSCI441 {
39 static const glm::vec3 X_AXIS( 1.0f, 0.0f, 0.0f );
43 static const glm::vec3 Y_AXIS( 0.0f, 1.0f, 0.0f );
47 static const glm::vec3 Z_AXIS( 0.0f, 0.0f, 1.0f );
51 [[maybe_unused]] static const glm::vec3 X_AXIS_POS = X_AXIS;
55 [[maybe_unused]] static const glm::vec3 Y_AXIS_POS = Y_AXIS;
59 [[maybe_unused]] static const glm::vec3 Z_AXIS_POS = Z_AXIS;
63 [[maybe_unused]] static const glm::vec3 X_AXIS_NEG( -1.0f, 0.0f, 0.0f );
67 [[maybe_unused]] static const glm::vec3 Y_AXIS_NEG( 0.0f, -1.0f, 0.0f );
71 [[maybe_unused]] static const glm::vec3 Z_AXIS_NEG( 0.0f, 0.0f, -1.0f );
72
77 namespace OpenGLUtils {
81 void printOpenGLInfo();
85 [[maybe_unused]] void printOpenGLExtensions();
90 [[maybe_unused]] void checkOpenGLErrors();
91
97 [[maybe_unused]] const char* openGLErrorMessage(GLenum err);
98
104 [[maybe_unused]] const char* debugSourceToString(GLenum source);
110 [[maybe_unused]] const char* debugTypeToString(GLenum type);
116 [[maybe_unused]] const char* debugSeverityToString(GLenum severity);
117 };
118
119}
120
121//**********************************************************************************
122//**********************************************************************************
123// Internal definitions
124
125namespace CSCI441_INTERNAL {
126 void printOpenGLParamHeader(int MAJOR, int MINOR );
127 void printOpenGLParamIndexed(const char *FORMAT, GLenum name, GLuint index );
128 void printOpenGLParam(const char *FORMAT, GLenum name );
129 void printOpenGLParam2(const char *FORMAT, GLenum name );
130 void printOpenGLParam2f(const char *FORMAT, GLenum name );
131 [[maybe_unused]] void printOpenGLParam3(const char *FORMAT, GLenum name );
132 void printOpenGLParam4(const char *FORMAT, GLenum name );
133}
134
135//**********************************************************************************
136//**********************************************************************************
137// Outward facing function implementations
138
140 GLint major = 0, minor = 0, numExtensions = 0;
141 glGetIntegerv(GL_MAJOR_VERSION, &major);
142 glGetIntegerv(GL_MINOR_VERSION, &minor);
143 glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
144
145 fprintf( stdout, "\n[INFO]: /--------------------------------------------------------\\\n" );
146 fprintf( stdout, "[INFO]: | OpenGL Information |\n" );
147 fprintf( stdout, "[INFO]: |--------------------------------------------------------|\n" );
148 fprintf( stdout, "[INFO]: | OpenGL Version: %35s |\n", glGetString(GL_VERSION) );
149 fprintf( stdout, "[INFO]: | OpenGL Renderer: %35s |\n", glGetString(GL_RENDERER) );
150 fprintf( stdout, "[INFO]: | OpenGL Vendor: %35s |\n", glGetString(GL_VENDOR) );
151 fprintf( stdout, "[INFO]: | Shading Version: %35s |\n", glGetString(GL_SHADING_LANGUAGE_VERSION) );
152 fprintf( stdout, "[INFO]: | Number of Extensions: %30d |\n", numExtensions );
153
154 if( (major >= 2 && minor >= 0) || major > 2 ) {
155 CSCI441_INTERNAL::printOpenGLParamHeader( 2, 0 );
156 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Color Attachments: %26d |\n", GL_MAX_COLOR_ATTACHMENTS );
157 CSCI441_INTERNAL::printOpenGLParam2f("[INFO]: | Point Size Range: %24.2f %8.2f |\n", GL_POINT_SIZE_RANGE );
158 }
159
160 if( (major >= 2 && minor >= 1) || major > 2 ) {
161 CSCI441_INTERNAL::printOpenGLParamHeader( 2, 1 );
162 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Vertex Attributes: %26d |\n", GL_MAX_VERTEX_ATTRIBS );
163 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Vertex Uniforms: %28d |\n", GL_MAX_VERTEX_UNIFORM_COMPONENTS );
164 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Vertex Textures: %28d |\n", GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS );
165 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Vertex Outputs: %29d |\n", GL_MAX_VERTEX_OUTPUT_COMPONENTS );
166 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Fragment Inputs: %28d |\n", GL_MAX_FRAGMENT_INPUT_COMPONENTS );
167 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Fragment Uniforms: %26d |\n", GL_MAX_FRAGMENT_UNIFORM_COMPONENTS );
168 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Fragment Textures: %26d |\n", GL_MAX_TEXTURE_IMAGE_UNITS );
169 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Draw Buffers: %31d |\n", GL_MAX_DRAW_BUFFERS );
170 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Textures Combined: %26d |\n", GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS );
171 }
172
173 if( (major >= 3 && minor >= 0) || major > 3 ) {
174 CSCI441_INTERNAL::printOpenGLParamHeader( 3, 0 );
175 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Transform Feedback Buffers: %17d |\n", GL_MAX_TRANSFORM_FEEDBACK_BUFFERS );
176 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Transform Separate Attributes: %14d |\n", GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS );
177 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Transform Separate Components: %14d |\n", GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS );
178 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Transform Interleaved Buffers: %14d |\n", GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS );
179 }
180
181 if( (major >= 3 && minor >= 1) || major > 3 ) {
182 CSCI441_INTERNAL::printOpenGLParamHeader( 3, 1 );
183 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Fragment Uniform Blocks: %20d |\n", GL_MAX_FRAGMENT_UNIFORM_BLOCKS );
184 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Vertex Uniform Blocks: %22d |\n", GL_MAX_VERTEX_UNIFORM_BLOCKS );
185 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max Uniform Blocks Size: %20d bytes |\n", GL_MAX_UNIFORM_BLOCK_SIZE );
186 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Combined Uniform Blocks: %20d |\n", GL_MAX_COMBINED_UNIFORM_BLOCKS );
187 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Uniform Bindings: %27d |\n", GL_MAX_UNIFORM_BUFFER_BINDINGS );
188 }
189
190 if( (major >= 3 && minor >= 2) || major > 3 ) {
191 CSCI441_INTERNAL::printOpenGLParamHeader( 3, 2 );
192 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Geometry Uniforms: %26d |\n", GL_MAX_GEOMETRY_UNIFORM_COMPONENTS );
193 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Geometry Uniform Blocks: %20d |\n", GL_MAX_GEOMETRY_UNIFORM_BLOCKS );
194 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Geometry Textures: %26d |\n", GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS );
195 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Geometry Inputs: %28d |\n", GL_MAX_GEOMETRY_INPUT_COMPONENTS );
196 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Geometry Output Vertices: %19d |\n", GL_MAX_GEOMETRY_OUTPUT_VERTICES );
197 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Geometry Total Output Components: %11d |\n", GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS );
198 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Geometry Outputs: %27d |\n", GL_MAX_GEOMETRY_OUTPUT_COMPONENTS );
199 }
200
201 if( (major >= 4 && minor >= 0) || major > 4 ) {
202 CSCI441_INTERNAL::printOpenGLParamHeader( 4, 0 );
203 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Patch Vertices: %29d |\n", GL_MAX_PATCH_VERTICES );
204 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tessellation Level: %25d |\n", GL_MAX_TESS_GEN_LEVEL );
205 CSCI441_INTERNAL::printOpenGLParam4("[INFO]: | Default Tessellation Outer Levels: %7d %2d %2d %2d |\n", GL_PATCH_DEFAULT_OUTER_LEVEL );
206 CSCI441_INTERNAL::printOpenGLParam2("[INFO]: | Default Tessellation Inner Levels: %13d %2d |\n", GL_PATCH_DEFAULT_INNER_LEVEL );
207 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Control Inputs: %24d |\n", GL_MAX_GEOMETRY_INPUT_COMPONENTS );
208 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Control Uniforms: %22d |\n", GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS );
209 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Control Uniform Blocks: %16d |\n", GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS );
210 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Control Textures: %22d |\n", GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS );
211 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Control Outputs: %23d |\n", GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS );
212 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Evaluation Inputs: %21d |\n", GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS );
213 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Evaluation Uniforms: %19d |\n", GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS );
214 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Evaluation Uniform Blocks: %13d |\n", GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS );
215 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Evaluation Textures: %19d |\n", GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS );
216 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Evaluation Outputs: %20d |\n", GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS );
217 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Geometry Invocations: %23d |\n", GL_MAX_GEOMETRY_SHADER_INVOCATIONS );
218 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Vertex Streams: %29d |\n", GL_MAX_VERTEX_STREAMS );
219 }
220
221 if( (major >= 4 && minor >= 2) || major > 4 ) {
222 CSCI441_INTERNAL::printOpenGLParamHeader( 4, 2 );
223 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Vertex Atomic Counters: %21d |\n", GL_MAX_VERTEX_ATOMIC_COUNTERS );
224 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Control Atomic Counters: %15d |\n", GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS );
225 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Evaluation Atomic Counters: %12d |\n", GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS );
226 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Geometry Atomic Counters: %19d |\n", GL_MAX_GEOMETRY_ATOMIC_COUNTERS );
227 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Fragment Atomic Counters: %19d |\n", GL_MAX_FRAGMENT_ATOMIC_COUNTERS );
228 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Combined Atomic Counters: %19d |\n", GL_MAX_COMBINED_ATOMIC_COUNTERS );
229 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Vertex Atomic Counter Buffers: %14d |\n", GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS );
230 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Control Atomic Counter Buffers: %8d |\n", GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS );
231 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Evaluation Atomic Counter Buffers: %5d |\n", GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS );
232 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Geometry Atomic Counter Buffers: %12d |\n", GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS );
233 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Fragment Atomic Counter Buffers: %12d |\n", GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS );
234 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Combined Atomic Counter Buffers: %12d |\n", GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS );
235 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Atomic Counter Buffer Bindings: %13d |\n", GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS );
236 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Vertex Image Uniforms: %22d |\n", GL_MAX_VERTEX_IMAGE_UNIFORMS );
237 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Control Image Uniforms: %16d |\n", GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS );
238 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Evaluation Image Uniforms: %13d |\n", GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS );
239 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Geometry Image Uniforms: %20d |\n", GL_MAX_GEOMETRY_IMAGE_UNIFORMS );
240 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Fragment Image Uniforms: %20d |\n", GL_MAX_FRAGMENT_IMAGE_UNIFORMS );
241 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Combined Image Uniforms: %20d |\n", GL_MAX_IMAGE_UNITS );
242 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Shader Storage Buffer Bindings: %13d |\n", GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS );
243 }
244
245 if( (major >= 4 && minor >= 3) || major > 4 ) {
246 CSCI441_INTERNAL::printOpenGLParamHeader( 4, 3 );
247 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Compute Uniforms: %27d |\n", GL_MAX_COMPUTE_UNIFORM_COMPONENTS );
248 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Compute Uniform Blocks: %21d |\n", GL_MAX_COMPUTE_UNIFORM_BLOCKS );
249 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Compute Textures: %27d |\n", GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS );
250 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Compute Image Uniforms: %21d |\n", GL_MAX_COMPUTE_IMAGE_UNIFORMS );
251 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Compute Atomic Counters: %20d |\n", GL_MAX_COMPUTE_ATOMIC_COUNTERS );
252 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Compute Atomic Counter Buffers: %13d |\n", GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS );
253
254 CSCI441_INTERNAL::printOpenGLParamIndexed("[INFO]: | Max # Work Groups Per Dispatch: %6d", GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0 );
255 CSCI441_INTERNAL::printOpenGLParamIndexed(" %6d", GL_MAX_COMPUTE_WORK_GROUP_COUNT, 1 );
256 CSCI441_INTERNAL::printOpenGLParamIndexed(" %6d |\n", GL_MAX_COMPUTE_WORK_GROUP_COUNT, 2 );
257
258 CSCI441_INTERNAL::printOpenGLParamIndexed("[INFO]: | Max Work Groups Size: %16d", GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0 );
259 CSCI441_INTERNAL::printOpenGLParamIndexed(" %6d", GL_MAX_COMPUTE_WORK_GROUP_SIZE, 1 );
260 CSCI441_INTERNAL::printOpenGLParamIndexed(" %6d |\n", GL_MAX_COMPUTE_WORK_GROUP_SIZE, 2 );
261
262 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Invocations Per Work Group: %18d |\n", GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS );
263 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max Total Storage Size: %22d bytes |\n", GL_MAX_COMPUTE_SHARED_MEMORY_SIZE );
264 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Vertex Shader Storage Blocks: %15d |\n", GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS );
265 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Control Shader Storage Blocks: %9d |\n", GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS );
266 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Tess Evaluation Shader Storage Blocks: %6d |\n", GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS );
267 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Geometry Shader Storage Blocks: %13d |\n", GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS );
268 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Fragment Shader Storage Blocks: %13d |\n", GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS );
269 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Compute Shader Storage Blocks: %14d |\n", GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS );
270 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Combined Shader Storage Blocks: %13d |\n", GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS );
271 CSCI441_INTERNAL::printOpenGLParam( "[INFO]: | Max # Combined Shader Output Resources: %11d |\n", GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES );
272 }
273
274 fprintf( stdout, "[INFO]: \\--------------------------------------------------------/\n\n");
275}
276
277[[maybe_unused]]
279 GLint numExtensions = 0;
280 glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
281
282 fprintf( stdout, "[INFO]: Number of Extensions: %4d\n", numExtensions );
283 for (int i = 0; i < numExtensions; i++) {
284 fprintf( stdout, "[INFO]: Extension #%3d: %s \n", (i+1), glGetStringi(GL_EXTENSIONS, i) );
285 }
286}
287
288[[maybe_unused]]
290 GLenum err;
291 while( (err = glGetError()) != GL_NO_ERROR ) {
292 fprintf( stderr, "[ERROR]: OpenGL Error (%d): %s\n", err, CSCI441::OpenGLUtils::openGLErrorMessage(err) );
293 err = glGetError();
294 }
295}
296
297inline const char* CSCI441::OpenGLUtils::openGLErrorMessage(GLenum err) {
298 switch(err) {
299 case GL_NO_ERROR: return "No error";
300 case GL_INVALID_ENUM: return "Invalid enum";
301 case GL_INVALID_VALUE: return "Invalid value";
302 case GL_INVALID_OPERATION: return "Invalid operation";
303 case GL_STACK_OVERFLOW: return "Stack overflow";
304 case GL_STACK_UNDERFLOW: return "Stack underflow";
305 case GL_OUT_OF_MEMORY: return "Out of memory";
306 case GL_INVALID_FRAMEBUFFER_OPERATION: return "Invalid framebuffer operation";
307 case GL_CONTEXT_LOST: return "Context lost";
308 default: return "Unknown";
309 }
310}
311
312[[maybe_unused]]
313inline const char* CSCI441::OpenGLUtils::debugSourceToString(GLenum source) {
314 switch(source) {
315 case GL_DEBUG_SOURCE_API: return "API";
316 case GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "Window System";
317 case GL_DEBUG_SOURCE_SHADER_COMPILER: return "Shader Compiler";
318 case GL_DEBUG_SOURCE_THIRD_PARTY: return "Third Party";
319 case GL_DEBUG_SOURCE_APPLICATION: return "Application";
320 case GL_DEBUG_SOURCE_OTHER: return "Other";
321 default: return "Unknown";
322 }
323}
324
325[[maybe_unused]]
326inline const char* CSCI441::OpenGLUtils::debugTypeToString(GLenum type) {
327 switch(type) {
328 case GL_DEBUG_TYPE_ERROR: return "Error";
329 case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "Deprecated Behavior";
330 case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return "Undefined Behavior";
331 case GL_DEBUG_TYPE_PORTABILITY: return "Portability";
332 case GL_DEBUG_TYPE_PERFORMANCE: return "Performance";
333 case GL_DEBUG_TYPE_MARKER: return "Marker";
334 case GL_DEBUG_TYPE_PUSH_GROUP: return "Push Group";
335 case GL_DEBUG_TYPE_POP_GROUP: return "Pop Group";
336 case GL_DEBUG_TYPE_OTHER: return "Other";
337 default: return "Unknown";
338 }
339}
340
341[[maybe_unused]]
342inline const char* CSCI441::OpenGLUtils::debugSeverityToString(GLenum severity) {
343 switch(severity) {
344 case GL_DEBUG_SEVERITY_HIGH: return "High";
345 case GL_DEBUG_SEVERITY_MEDIUM: return "Medium";
346 case GL_DEBUG_SEVERITY_LOW: return "Low";
347 case GL_DEBUG_SEVERITY_NOTIFICATION: return "Notification";
348 default: return "Unknown";
349 }
350}
351
352//**********************************************************************************
353//**********************************************************************************
354// Internal function implementations
355
356inline void CSCI441_INTERNAL::printOpenGLParamHeader( const int MAJOR, const int MINOR ) {
357 fprintf( stdout, "[INFO]: >--------------------------------------------------------<\n" );
358 fprintf( stdout, "[INFO]: | OpenGL %d.%d Settings |\n", MAJOR, MINOR );
359 fprintf( stdout, "[INFO]: |--------------------------------------------------------|\n" );
360}
361
362inline void CSCI441_INTERNAL::printOpenGLParamIndexed(const char * const FORMAT, const GLenum name, const GLuint index ) {
363 GLint value = 0;
364 glGetIntegeri_v( name, index, &value );
365 fprintf(stdout, FORMAT, value );
366}
367
368inline void CSCI441_INTERNAL::printOpenGLParam(const char * const FORMAT, const GLenum name ) {
369 GLint value = 0;
370 glGetIntegerv( name, &value );
371 fprintf(stdout, FORMAT, value );
372}
373
374inline void CSCI441_INTERNAL::printOpenGLParam2(const char * const FORMAT, const GLenum name ) {
375 GLint values[2] = {0,0};
376 glGetIntegerv( name, values );
377 fprintf(stdout, FORMAT, values[0], values[1] );
378}
379
380inline void CSCI441_INTERNAL::printOpenGLParam2f(const char * const FORMAT, const GLenum name ) {
381 GLfloat values[2] = {0,0};
382 glGetFloatv( name, values );
383 fprintf(stdout, FORMAT, values[0], values[1] );
384}
385
386[[maybe_unused]]
387inline void CSCI441_INTERNAL::printOpenGLParam3(const char * const FORMAT, const GLenum name ) {
388 GLint values[3] = {0,0,0};
389 glGetIntegerv( name, values );
390 fprintf(stdout, FORMAT, values[0], values[1], values[2] );
391}
392
393inline void CSCI441_INTERNAL::printOpenGLParam4(const char * const FORMAT, const GLenum name ) {
394 GLint values[4] = {0,0,0,0};
395 glGetIntegerv( name, values );
396 fprintf(stdout, FORMAT, values[0], values[1], values[2], values[3] );
397}
398
399#endif // CSCI441_OPENGL_UTILS_H
const char * openGLErrorMessage(GLenum err)
Converts error value to string representation.
Definition: OpenGLUtils.hpp:297
void printOpenGLInfo()
Prints information about our OpenGL context.
Definition: OpenGLUtils.hpp:139
const char * debugSeverityToString(GLenum severity)
Converts debug severity value to string representation.
Definition: OpenGLUtils.hpp:342
void checkOpenGLErrors()
Checks if there are any OpenGL errors, printing them if so, and clearing the error flag.
Definition: OpenGLUtils.hpp:289
void printOpenGLExtensions()
Prints the list of available extensions.
Definition: OpenGLUtils.hpp:278
const char * debugTypeToString(GLenum type)
Converts debug type value to string representation.
Definition: OpenGLUtils.hpp:326
const char * debugSourceToString(GLenum source)
Converts debug source value to string representation.
Definition: OpenGLUtils.hpp:313
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17
contains OpenGL Utility functions