1 #ifndef OGLPLUS_GL_API_TYPE_UTILS_HPP
9 #define OGLPLUS_GL_API_TYPE_UTILS_HPP
11 #include "../math/vector.hpp"
15 #include <type_traits>
17 namespace eagine::oglp {
23 (std::is_same_v<T, gl_types::ubyte_type> ||
24 std::is_same_v<T, gl_types::byte_type> ||
25 std::is_same_v<T, gl_types::ushort_type> ||
26 std::is_same_v<T, gl_types::short_type> ||
27 std::is_same_v<T, gl_types::uint_type> ||
28 std::is_same_v<T, gl_types::int_type> ||
29 std::is_same_v<T, gl_types::float_type> ||
30 std::is_same_v<T, gl_types::double_type>);
36 #ifdef GL_UNSIGNED_BYTE
37 return GL_UNSIGNED_BYTE;
52 constexpr
auto data_type_of(type_identity<gl_types::ushort_type>) noexcept
54 #ifdef GL_UNSIGNED_SHORT
55 return GL_UNSIGNED_SHORT;
61 constexpr
auto data_type_of(type_identity<gl_types::short_type>) noexcept
70 constexpr
auto data_type_of(type_identity<gl_types::uint_type>) noexcept
72 #ifdef GL_UNSIGNED_INT
73 return GL_UNSIGNED_INT;
79 constexpr
auto data_type_of(type_identity<gl_types::int_type>) noexcept
88 constexpr
auto data_type_of(type_identity<gl_types::float_type>) noexcept
97 constexpr
auto data_type_of(type_identity<gl_types::double_type>) noexcept
106 template <
typename T,
int N,
bool V>
107 constexpr
auto data_type_of(type_identity<vector<T, N, V>>) noexcept {
111 template <
typename T,
int N,
bool V>
112 constexpr
auto data_type_of(type_identity<tvec<T, N, V>>) noexcept {
120 template <
typename T>
131 template <
typename T>
140 template <
typename T>
147 template <
typename T>
149 is_gl_data_type_v<T> && std::is_integral_v<T>,
151 #ifdef GL_RED_INTEGER
152 return GL_RED_INTEGER;
158 template <
typename T>
159 constexpr
auto pixel_format_of(type_identity<T>) noexcept -> std::enable_if_t<
160 is_gl_data_type_v<T> && !std::is_integral_v<T>,
169 template <
typename T,
bool V>
170 constexpr
auto pixel_format_of(type_identity<vector<T, 2, V>>) noexcept
173 gl_types::enum_type> {
175 return GL_RG_INTEGER;
181 template <
typename T,
bool V>
182 constexpr
auto pixel_format_of(type_identity<vector<T, 2, V>>) noexcept
185 gl_types::enum_type> {
193 template <
typename T,
bool V>
194 constexpr
auto pixel_format_of(type_identity<vector<T, 3, V>>) noexcept
197 gl_types::enum_type> {
198 #ifdef GL_RGB_INTEGER
199 return GL_RGB_INTEGER;
205 template <
typename T,
bool V>
206 constexpr
auto pixel_format_of(type_identity<vector<T, 3, V>>) noexcept
209 gl_types::enum_type> {
217 template <
typename T,
bool V>
218 constexpr
auto pixel_format_of(type_identity<vector<T, 4, V>>) noexcept
221 gl_types::enum_type> {
222 #ifdef GL_RGBA_INTEGER
223 return GL_RGBA_INTEGER;
229 template <
typename T,
bool V>
230 constexpr
auto pixel_format_of(type_identity<vector<T, 4, V>>) noexcept
233 gl_types::enum_type> {
245 typename = std::enable_if_t<is_gl_data_type_v<T>>>
247 -> gl_types::enum_type {
255 template <
typename T>
274 -> gl_types::enum_type {
285 -> gl_types::enum_type {
305 -> gl_types::enum_type {
316 -> gl_types::enum_type {
336 -> gl_types::enum_type {
347 -> gl_types::enum_type {
367 -> gl_types::enum_type {
378 -> gl_types::enum_type {
398 -> gl_types::enum_type {
409 -> gl_types::enum_type {
420 -> gl_types::enum_type {
440 -> gl_types::enum_type {
451 -> gl_types::enum_type {
462 -> gl_types::enum_type {
482 -> gl_types::enum_type {
493 -> gl_types::enum_type {
504 -> gl_types::enum_type {
512 template <
typename T,
int N,
bool V>
521 template <
typename T>
528 #endif // OGLPLUS_GL_API_TYPE_UTILS_HPP