nngn
Loading...
Searching...
No Matches
handle.h
Go to the documentation of this file.
1#ifndef NNGN_GRAPHICS_OPENGL_HANDLE_H
2#define NNGN_GRAPHICS_OPENGL_HANDLE_H
3
4#include <utility>
5
6#include "utils/def.h"
7
8#include "opengl.h"
9
10namespace nngn {
11
12template<typename T> class OpenGLHandle {
13 u32 m_h = 0;
14public:
15 constexpr OpenGLHandle() = default;
16 explicit constexpr OpenGLHandle(u32 h) noexcept : m_h(h) {}
17 OpenGLHandle(const OpenGLHandle&) = delete;
18 OpenGLHandle(OpenGLHandle &&lhs) noexcept
19 { this->m_h = std::exchange(lhs.m_h, {}); }
22 { this->m_h = std::exchange(lhs.m_h, {}); }
23 ~OpenGLHandle() { static_cast<T*>(this)->destroy(); }
24 u32 id() const { return this->m_h; }
25 u32 &id() { return this->m_h; }
26};
27
28}
29
30#endif
Definition: handle.h:12
OpenGLHandle & operator=(const OpenGLHandle &)=delete
OpenGLHandle(const OpenGLHandle &)=delete
u32 & id()
Definition: handle.h:25
u32 m_h
Definition: handle.h:13
OpenGLHandle & operator=(OpenGLHandle &&lhs) noexcept
Definition: handle.h:21
constexpr OpenGLHandle(u32 h) noexcept
Definition: handle.h:16
OpenGLHandle(OpenGLHandle &&lhs) noexcept
Definition: handle.h:18
u32 id() const
Definition: handle.h:24
constexpr OpenGLHandle()=default
~OpenGLHandle()
Definition: handle.h:23
#define T(f0, f1, f2)
Definition: audio.cpp:7
std::uint32_t u32
Definition: def.h:14