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

prog_var_loc.hpp
Go to the documentation of this file.
1 #ifndef OGLPLUS_GL_API_PROG_VAR_LOC_HPP
9 #define OGLPLUS_GL_API_PROG_VAR_LOC_HPP
10 
11 #include "config.hpp"
12 #include <eagine/identifier.hpp>
13 
14 namespace eagine::oglp {
15 //------------------------------------------------------------------------------
18 template <identifier_t TagId>
20  using int_type = gl_types::int_type;
21  using uint_type = gl_types::uint_type;
22 
23 public:
26  constexpr prog_var_location() noexcept = default;
27 
29  explicit constexpr prog_var_location(int_type init) noexcept
30  : _location{init} {}
31 
33  auto is_active() const noexcept -> bool {
34  return _location >= 0;
35  }
36 
39  explicit constexpr operator bool() const noexcept {
40  return is_active();
41  }
42 
44  constexpr auto location() const noexcept -> int_type {
45  return _location;
46  }
47 
48  constexpr auto index() const noexcept -> uint_type {
49  if(_location < 0) {
50 #ifdef GL_INVALID_INDEX
51  return GL_INVALID_INDEX;
52 #endif
53  }
54  return uint_type(_location);
55  }
56 
58  explicit constexpr operator int_type() const noexcept {
59  return _location;
60  }
61 
63  friend constexpr auto
65  return a._location == b._location;
66  }
67 
69  friend constexpr auto
71  return a._location != b._location;
72  }
73 
75  friend constexpr auto
77  return a._location < b._location;
78  }
79 
80 private:
81  int_type _location{-1};
82 };
83 //------------------------------------------------------------------------------
94 
105 
116 
127 
138 
149 
160 
171 //------------------------------------------------------------------------------
172 } // namespace eagine::oglp
173 
174 #endif // OGLPLUS_GL_API_PROG_VAR_LOC_HPP
constexpr friend auto operator!=(prog_var_location a, prog_var_location b) noexcept
Nonequality comparison (compares the location numeric value).
Definition: prog_var_loc.hpp:70
#define EAGINE_ID_V(NAME)
Macro for constructing instances of eagine::identifier_t.
Definition: identifier.hpp:359
GLint int_type
Signed integer type.
Definition: config.hpp:70
GLuint uint_type
Unsigned integer type.
Definition: config.hpp:73
auto is_active() const noexcept -> bool
Indicates if this instance wraps an active program variable.
Definition: prog_var_loc.hpp:33
constexpr friend auto operator<(prog_var_location a, prog_var_location b) noexcept
Less-than comparison (compares the location numeric value).
Definition: prog_var_loc.hpp:76
constexpr friend auto operator==(prog_var_location a, prog_var_location b) noexcept
Equality comparison (compares the location numeric value).
Definition: prog_var_loc.hpp:64
constexpr prog_var_location() noexcept=default
Default constructor.
constexpr auto location() const noexcept -> int_type
Returns the location value.
Definition: prog_var_loc.hpp:44
Class wrapping GL shader program variable location.
Definition: prog_var_loc.hpp:19
constexpr prog_var_location(int_type init) noexcept
Explicit location initialization.
Definition: prog_var_loc.hpp:29

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