Brenta Engine 1.2
Loading...
Searching...
No Matches
texture.hpp
1// SPDX-License-Identifier: MIT
2// Author: Giovanni Santini
3// Mail: giovanni.santini@proton.me
4// Github: @San7o
5
6#pragma once
7
8#include <glad/glad.h>
9#include <string>
10
11namespace brenta
12{
13
20{
21public:
22
23 unsigned int id;
24 std::string type;
25 std::string path;
26
32 static void active_texture(GLenum texture);
33
43 static unsigned int load(const std::string &path, bool flip = true);
44
53 static void bind_id(GLenum target, unsigned int id,
54 GLint wrapping = GL_REPEAT,
55 GLint filtering_min = GL_NEAREST,
56 GLint filtering_mag = GL_NEAREST,
57 GLboolean has_mipmap = GL_TRUE,
58 GLint mipmap_min = GL_LINEAR_MIPMAP_LINEAR,
59 GLint mipmap_mag = GL_LINEAR);
60
72 texture(const std::string &path,
73 bool flip = true,
74 const std::string &type = "texture_diffuse");
75 constexpr texture(texture&& other) noexcept
76 {
77 this->id = other.id;
78 this->path = other.path;
79 this->type = other.type;
80 other.id = 0;
81 }
82
83 constexpr texture& operator=(texture&&other) noexcept
84 {
85 this->id = other.id;
86 this->type = other.type;
87 this->path = other.path;
88 other.id = 0;
89 return *this;
90 }
91
92 ~texture();
93
94 unsigned int get_id() const;
95
96 void bind(GLenum target,
97 GLint wrapping = GL_REPEAT,
98 GLint filtering_min = GL_NEAREST,
99 GLint filtering_mag = GL_NEAREST,
100 GLboolean has_mpmap = GL_TRUE,
101 GLint mipmap_min = GL_LINEAR_MIPMAP_LINEAR,
102 GLint mipmap_mag = GL_LINEAR);
103
104private:
105
106 static void set_texture_wrapping(GLint wrapping);
107 static void set_texture_filtering(GLint filtering_min, GLint filtering_mag);
108 static void set_mipmap(GLboolean has_mipmap, GLint mipmap_min,
109 GLint mipmap_mag);
110 static void read_image(const char *path, bool flip);
111
112};
113
114} // namespace brenta
Texture class.
Definition texture.hpp:20
static void active_texture(GLenum texture)
Activate a texture unit.
Definition texture.cpp:39
texture()
Empty constructor, does nothing.
Definition texture.hpp:64
static unsigned int load(const std::string &path, bool flip=true)
Load a texture from a file.
Definition texture.cpp:44
static void bind_id(GLenum target, unsigned int id, GLint wrapping=GL_REPEAT, GLint filtering_min=GL_NEAREST, GLint filtering_mag=GL_NEAREST, GLboolean has_mipmap=GL_TRUE, GLint mipmap_min=GL_LINEAR_MIPMAP_LINEAR, GLint mipmap_mag=GL_LINEAR)
Bind a texture.
Definition texture.cpp:53