OGLplus  (0.59.0) a C++ wrapper for rendering APIs

result.hpp
Go to the documentation of this file.
1 #ifndef OGLPLUS_GL_API_RESULT_HPP
9 #define OGLPLUS_GL_API_RESULT_HPP
10 
11 #include "config.hpp"
12 #include <eagine/anything.hpp>
13 #include <eagine/c_api_wrap.hpp>
14 #include <eagine/string_span.hpp>
15 
16 namespace eagine::oglp {
17 //------------------------------------------------------------------------------
23 public:
24  constexpr auto error_code(anything) noexcept -> auto& {
25  return *this;
26  }
27 
29  constexpr auto message() const noexcept -> string_view {
30  return {"GL function not available"};
31  }
32 
33 private:
34 };
35 //------------------------------------------------------------------------------
41 public:
43  explicit constexpr operator bool() const noexcept {
44  return gl_types::error_code_no_error(_error_code);
45  }
46 
47  constexpr auto error_code(gl_types::enum_type ec) noexcept -> auto& {
48  _error_code = ec;
49  return *this;
50  }
51 
53  auto message() const noexcept -> string_view {
54 #ifdef GL_INVALID_ENUM
55  if(_error_code == GL_INVALID_ENUM) {
56  return {"invalid enum value"};
57  }
58 #endif
59 #ifdef GL_INVALID_VALUE
60  if(_error_code == GL_INVALID_VALUE) {
61  return {"invalid value"};
62  }
63 #endif
64 #ifdef GL_INVALID_OPERATION
65  if(_error_code == GL_INVALID_OPERATION) {
66  return {"invalid operation"};
67  }
68 #endif
69 #ifdef GL_INVALID_FRAMEBUFFER_OPERATION
70  if(_error_code == GL_INVALID_FRAMEBUFFER_OPERATION) {
71  return {"invalid framebuffer operation"};
72  }
73 #endif
74 #ifdef GL_NO_ERROR
75  if(_error_code == GL_NO_ERROR) {
76  return {"no error"};
77  }
78 #endif
79 #ifdef GL_STACK_OVERFLOW
80  if(_error_code == GL_STACK_OVERFLOW) {
81  return {"stack overflow"};
82  }
83 #endif
84 #ifdef GL_STACK_UNDERFLOW
85  if(_error_code == GL_STACK_UNDERFLOW) {
86  return {"stack underflow"};
87  }
88 #endif
89 #ifdef GL_TABLE_TOO_LARGE
90  if(_error_code == GL_TABLE_TOO_LARGE) {
91  return {"table too large"};
92  }
93 #endif
94 #ifdef GL_CONTEXT_LOST
95  if(_error_code == GL_CONTEXT_LOST) {
96  return {"rendering context lost"};
97  }
98 #endif
99 #ifdef GL_OUT_OF_MEMORY
100  if(_error_code == GL_OUT_OF_MEMORY) {
101  return {"out of memory"};
102  }
103 #endif
104  return {"unknown error"};
105  }
106 
107 private:
108  gl_types::enum_type _error_code{
109 #ifdef GL_NO_ERROR
110  GL_NO_ERROR
111 #endif
112  };
113 };
114 //------------------------------------------------------------------------------
119 template <typename Result>
121 //------------------------------------------------------------------------------
126 template <typename Result>
128 //------------------------------------------------------------------------------
133 template <typename Result>
135 //------------------------------------------------------------------------------
141 template <typename Result>
142 using gl_combined_result = api_combined_result<Result, gl_result_info>;
143 //------------------------------------------------------------------------------
144 } // namespace eagine::oglp
145 
146 #endif // OGLPLUS_GL_API_RESULT_HPP
Class wrapping the result of a C-API function call.
Definition: c_api_wrap.hpp:210
Class storing information about call result for unavailable GL functions.
Definition: result.hpp:22
api_no_result< Result, gl_no_result_info > gl_no_result
Alias for always-invalid result of a missing GL API function call.
Definition: result.hpp:120
Typed enumeration for GL error code constants.
Definition: enum_types.hpp:32
api_combined_result< Result, gl_result_info > gl_combined_result
Alias for a result that may come from mutiple difference GL API functions.
Definition: result.hpp:142
constexpr auto message() const noexcept -> string_view
Returns a message associated with the result.
Definition: result.hpp:29
GLenum enum_type
Enumeration type.
Definition: config.hpp:52
static constexpr auto error_code_no_error(enum_type ec) noexcept -> bool
Tests if the specified error code represents no-error value.
Definition: config.hpp:136
auto message() const noexcept -> string_view
Returns a message associated with the result.
Definition: result.hpp:53
Class storing information about a GL function call result.
Definition: result.hpp:40
api_result< Result, Info, api_result_validity::maybe > api_opt_result
Alias for conditionally-valid result of a C-API function call.
Definition: c_api_wrap.hpp:218
api_result< Result, Info, api_result_validity::never > api_no_result
Alias for always-invalid result of a C-API function call.
Definition: c_api_wrap.hpp:226
Type that can by constructed from single argument of any other type.
Definition: anything.hpp:16
api_opt_result< Result, gl_result_info > gl_opt_result
Alias for conditionally-valid result of a GL API function call.
Definition: result.hpp:134

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).