NVIDIA DeepStream SDK API Reference

9.2 Release
sources/libs/ds3d/glprocess/gl_common.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef DS3D_GLPROCESS_GL_COMMON_H
19 #define DS3D_GLPROCESS_GL_COMMON_H
20 
21 #include "ds3d/common/common.h"
22 #include "ds3d/common/hpp/obj.hpp"
23 
24 #include <GLES3/gl3.h>
25 #include <EGL/egl.h>
26 
27 // Include GLEW before GLFW to use the latest GL libraries:
28 //#define GLEW_STATIC
29 //#include <GL/glew.h>
30 #define GLFW_INCLUDE_NONE
31 #include <GLFW/glfw3.h>
32 
33 #undef DS3D_RETURN_GLFW_ERROR
34 #define DS3D_RETURN_GLFW_ERROR(fmt, ...) \
35  do { \
36  const char* __description = nullptr; \
37  int __glfw_code = glfwGetError(&__description); \
38  if (!__description) \
39  __description = ""; \
40  DS3D_FAILED_RETURN( \
41  __glfw_code == GLFW_NO_ERROR, ErrCode::kGL, "GLFW error: %s, " fmt, __description, \
42  ##__VA_ARGS__); \
43  } while (0)
44 
45 
46 #undef DS3D_GL_FAILED_RETURN
47 #define DS3D_GL_FAILED_RETURN(ret, fmt, ...) \
48  do { \
49  GLenum __gl_err = glGetError(); \
50  DS3D_FAILED_RETURN( \
51  __gl_err == GL_NO_ERROR, ret, "GL error: %s, " fmt, \
52  ::ds3d::gl::GLErrorString(__gl_err), ##__VA_ARGS__); \
53  } while (0)
54 
55 #undef DS3D_RETURN_GL_ERROR
56 #define DS3D_RETURN_GL_ERROR(fmt, ...) DS3D_GL_FAILED_RETURN(ErrCode::kGL, fmt, ##__VA_ARGS__)
57 
58 namespace ds3d { namespace gl {
59 
60 using mat4f = std::vector<vec4f>;
61 
62 inline const char*
63 GLErrorString(GLenum err)
64 {
65  switch (err) {
66 #define _GL_ERROR_CASE_STR(value) \
67  case value: \
68  return #value
69  _GL_ERROR_CASE_STR(GL_NO_ERROR);
70  _GL_ERROR_CASE_STR(GL_INVALID_ENUM);
71  _GL_ERROR_CASE_STR(GL_INVALID_VALUE);
72  _GL_ERROR_CASE_STR(GL_INVALID_OPERATION);
73  _GL_ERROR_CASE_STR(GL_INVALID_FRAMEBUFFER_OPERATION);
74  _GL_ERROR_CASE_STR(GL_OUT_OF_MEMORY);
75 #undef _GL_ERROR_CASE_STR
76  default:
77  return "Unknown GL error";
78  }
79 }
80 
81 }} // namespace ds3d::gl
82 
83 #endif // DS3D_GLPROCESS_GL_COMMON_H
ds3d::gl::mat4f
std::vector< vec4f > mat4f
Definition: sources/libs/ds3d/glprocess/gl_common.h:60
ds3d::gl::GLErrorString
const char * GLErrorString(GLenum err)
Definition: sources/libs/ds3d/glprocess/gl_common.h:63
_GL_ERROR_CASE_STR
#define _GL_ERROR_CASE_STR(value)
ds3d
Definition: includes/ds3d/common/abi_dataprocess.h:25