Path Tracing
Loading...
Searching...
No Matches
texture.hpp
Go to the documentation of this file.
1#pragma once
2#include <GL/glew.h>
3#include <utility>
4
7class GLTexture {
8 GLuint id_ = 0;
9 GLenum target_ = 0;
10public:
11 GLTexture() = default;
13
14 GLTexture(const GLTexture&) = delete;
15 GLTexture& operator=(const GLTexture&) = delete;
16
17 GLTexture(GLTexture&& other) noexcept
18 : id_(std::exchange(other.id_, 0)), target_(std::exchange(other.target_, 0)) {}
19 GLTexture& operator=(GLTexture&& other) noexcept {
20 if(this != &other) {
21 reset();
22 id_ = std::exchange(other.id_, 0);
23 target_ = std::exchange(other.target_, 0);
24 }
25 return *this;
26 }
27
29 reset();
30 target_ = target;
31 glCreateTextures(target, 1, &id_);
32 }
33
34 void reset() {
35 if(id_) { glDeleteTextures(1, &id_); id_ = 0; target_ = 0; }
36 }
37
38 GLuint id() const { return id_; }
39 GLenum target() const { return target_; }
40 explicit operator bool() const { return id_ != 0; }
41};
void create(GLenum target)
Definition texture.hpp:28
GLTexture(const GLTexture &)=delete
void reset()
Definition texture.hpp:34
~GLTexture()
Definition texture.hpp:12
GLuint id() const
Definition texture.hpp:38
GLenum target() const
Definition texture.hpp:39
GLTexture(GLTexture &&other) noexcept
Definition texture.hpp:17
GLTexture & operator=(const GLTexture &)=delete
GLTexture()=default
GLTexture & operator=(GLTexture &&other) noexcept
Definition texture.hpp:19
unsigned int GLuint
Definition imgui_impl_opengl3_loader.h:147
unsigned int GLenum
Definition imgui_impl_opengl3_loader.h:140
#define glDeleteTextures
Definition imgui_impl_opengl3_loader.h:584