-
Notifications
You must be signed in to change notification settings - Fork 0
/
texture.h
42 lines (33 loc) · 1.24 KB
/
texture.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef TANKS_TEXTURE_H
#define TANKS_TEXTURE_H
#include <QOpenGLExtraFunctions>
#include <filesystem>
/**
* Handles loading a 2D texture or cubemap from disk, storing its
* type and GPU resource handles, and cleaning them up when destroyed.
* The class is not copyable, but it is movable with std::move
*
* @author Tyson Cox
*/
class Texture : private QOpenGLExtraFunctions {
GLenum textype;
unsigned int texture;
void loadTex(const std::filesystem::path& path);
void loadCubemap(const std::filesystem::path& path);
public:
Texture();
Texture(const Texture& other) = delete;
Texture(Texture&& other);
~Texture();
Texture& operator=(const Texture& other) = delete;
Texture& operator=(Texture&& other) noexcept;
/** Get the texture's type (suitable GLenum for passing into glBindTexture) */
GLenum type();
/** Get the texture's GPU resource handle */
unsigned int handle();
/** Load a regular texture from a file */
static Texture fromFile(const std::filesystem::path& path);
/** Load a cubemap from a folder containing exactly 6 images, and up to one optional json metadata file */
static Texture cubemapFromFolder(const std::filesystem::path& path);
};
#endif //TANKS_TEXTURE_H