Blender  V3.3
glew-mx.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2014 Blender Foundation. All rights reserved. */
3 
8 #include "glew-mx.h"
9 
10 #include <stdio.h>
11 #include <stdlib.h>
12 
13 #define CASE_CODE_RETURN_STR(code) \
14  case code: \
15  return #code;
16 
17 static const char *get_glew_error_enum_string(GLenum error)
18 {
19  switch (error) {
20  CASE_CODE_RETURN_STR(GLEW_OK) /* also GLEW_NO_ERROR */
21  CASE_CODE_RETURN_STR(GLEW_ERROR_NO_GL_VERSION)
22  CASE_CODE_RETURN_STR(GLEW_ERROR_GL_VERSION_10_ONLY)
23  CASE_CODE_RETURN_STR(GLEW_ERROR_GLX_VERSION_11_ONLY)
24 #ifdef WITH_GLEW_ES
25  CASE_CODE_RETURN_STR(GLEW_ERROR_NOT_GLES_VERSION)
26  CASE_CODE_RETURN_STR(GLEW_ERROR_GLES_VERSION)
27  CASE_CODE_RETURN_STR(GLEW_ERROR_NO_EGL_VERSION)
28  CASE_CODE_RETURN_STR(GLEW_ERROR_EGL_VERSION_10_ONLY)
29 #endif
30  default:
31  return NULL;
32  }
33 }
34 
35 GLenum glew_chk(GLenum error, const char *file, int line, const char *text)
36 {
37  if (error != GLEW_OK) {
38  const char *code = get_glew_error_enum_string(error);
39  const char *msg = (const char *)glewGetErrorString(error);
40 
41  if (error == GLEW_ERROR_NO_GL_VERSION)
42  return GLEW_OK;
43 
44 #ifndef NDEBUG
45  fprintf(stderr,
46  "%s(%d):[%s] -> GLEW Error (0x%04X): %s: %s\n",
47  file,
48  line,
49  text,
50  error,
51  code ? code : "<no symbol>",
52  msg ? msg : "<no message>");
53 #else
54  (void)file;
55  (void)line;
56  (void)text;
57  fprintf(stderr,
58  "GLEW Error (0x%04X): %s: %s\n",
59  error,
60  code ? code : "<no symbol>",
61  msg ? msg : "<no message>");
62 #endif
63  }
64 
65  return error;
66 }
FILE * file
SyclQueue void void size_t num_bytes void
GLenum glew_chk(GLenum error, const char *file, int line, const char *text)
Definition: glew-mx.c:35
static const char * get_glew_error_enum_string(GLenum error)
Definition: glew-mx.c:17
#define CASE_CODE_RETURN_STR(code)
Definition: glew-mx.c:13
static void error(const char *str)
Definition: meshlaplacian.c:51