matf-rg-engine 1.0.0
Base for project for the Computer Graphics course at Faculty of Mathematics, University of Belgrade
Loading...
Searching...
No Matches
Texture.hpp
Go to the documentation of this file.
1
6#ifndef MATF_RG_PROJECT_TEXTURE_HPP
7#define MATF_RG_PROJECT_TEXTURE_HPP
8
9#include <string_view>
10#include <filesystem>
11#include <utility>
12
13namespace engine::resources {
14 class Shader;
15
19 enum class TextureType {
20 Regular,
21 Diffuse,
23 Normal,
24 Height,
25 };
26
31 class Texture {
32 friend class ResourcesController;
33
34 public:
48 static std::string_view uniform_name_convention(TextureType type);
49
53 void destroy();
54
59 TextureType type() const {
60 return m_type;
61 }
62
67 uint32_t id() const {
68 return m_id;
69 }
70
75 void bind(int32_t sampler);
76
81 const std::filesystem::path &path() const {
82 return m_path;
83 }
84
89 const std::string &name() const {
90 return m_name;
91 }
92
93 Texture() = default;
94
95 private:
103 Texture(uint32_t id, TextureType type, std::filesystem::path path, std::string name)
104 : m_id(id)
105 , m_type(type)
106 , m_path(std::move(path))
107 , m_name(std::move(name)) {
108 }
109
110 uint32_t m_id{};
112 std::filesystem::path m_path{};
113 std::string m_name{};
114 };
115} // namespace engine
116#endif//MATF_RG_PROJECT_TEXTURE_HPP
Manages app resources: Model, Texture, Shader, and Skybox.
Definition ResourcesController.hpp:21
Represents a texture object within the OpenGL context.
Definition Texture.hpp:31
TextureType m_type
Definition Texture.hpp:111
const std::filesystem::path & path() const
Returns the path to the texture file from which the texture was loaded.
Definition Texture.hpp:81
const std::string & name() const
Returns the name of the texture by which it can be referenced using the engine::resources::ResourcesC...
Definition Texture.hpp:89
TextureType type() const
Returns the type of the texture.
Definition Texture.hpp:59
static std::string_view uniform_name_convention(TextureType type)
Returns the uniform name convention for a given texture type. The convention is used by the Model cla...
Definition Texture.cpp:26
void destroy()
Destroys the texture object in the OpenGL context.
Definition Texture.cpp:16
Texture(uint32_t id, TextureType type, std::filesystem::path path, std::string name)
Constructs a Texture object.
Definition Texture.hpp:103
uint32_t m_id
Definition Texture.hpp:110
uint32_t id() const
Returns the OpenGL ID of the texture.
Definition Texture.hpp:67
std::string m_name
Definition Texture.hpp:113
std::filesystem::path m_path
Definition Texture.hpp:112
void bind(int32_t sampler)
Binds the texture to a given sampler.
Definition Texture.cpp:20
Definition GraphicsController.hpp:14
TextureType
Definition Texture.hpp:19