RavEngine
Loading...
Searching...
No Matches
Utilities.hpp
1#pragma once
2#include <effolkronium/random.hpp>
3#include <sstream>
4#include <type_traits>
5#include <ranges>
6#include <functional>
7#if !RVE_SERVER
8#include <RGL/Types.hpp>
9#endif
10
11namespace RavEngine{
12
16template <typename E>
17inline constexpr auto to_underlying(E e) noexcept
18{
19 return static_cast<std::underlying_type_t<E>>(e);
20}
21
25template<typename T>
27 T* ptr;
28public:
29 PointerInputBinder(decltype(ptr) ptr) : ptr(ptr){}
30
31 size_t get_id() const{
32 return reinterpret_cast<size_t>(ptr);
33 }
34 T* get() const{
35 return ptr;
36 }
37};
38
45template<class T>
46static inline std::string FormatWithSep(T value)
47{
48 std::stringstream ss;
49 ss.imbue(std::locale(""));
50 ss << std::fixed << value;
51 return ss.str();
52}
53
54//shortcut for defining static symbols
55#define STATIC(T) decltype(T) T
56
57//random generation
58using Random = effolkronium::random_static;
59
60auto Enumerate(const auto& data) {
61 return data | std::views::transform([i = 0](const auto& value) mutable {
62 return std::make_pair(i++, value);
63 });
64}
65
66auto Enumerate(auto& data) {
67 return data | std::views::transform([i = 0](auto&& value) mutable {
68 return std::make_pair(i++, std::reference_wrapper(value));
69 });
70}
71
77#if !RVE_SERVER
78RGLShaderLibraryPtr LoadShaderByFilename(const std::string& name, RGLDevicePtr device);
79#endif
80
81void DumpTextFloat(float* ptr, uint16_t size);
82void DumpTextFloatGraph(float* ptr, uint16_t size);
83
84}
Definition Utilities.hpp:26
Base template class for random with static API and static internal member storage.
Definition random.hpp:182
Definition concurrentqueue.h:747
Definition Animation.hpp:6
constexpr auto to_underlying(E e) noexcept
Definition Utilities.hpp:17
RGLShaderLibraryPtr LoadShaderByFilename(const std::string &name, RGLDevicePtr device)
Definition Utilities.cpp:42