lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
Loading...
Searching...
No Matches
texture.hpp
Go to the documentation of this file.
1
11
12#pragma once
13
14#include <glad/glad.h>
15
16#include <string>
17
18namespace lmgl {
19
20namespace renderer {
21
29class Texture {
30 public:
39 Texture(int width, int height);
40
50 Texture(unsigned int id, int width, int height);
51
59 Texture(const std::string &fpath);
60
62 ~Texture();
63
71 void bind(unsigned int slot = 0) const;
72
78 void unbind() const;
79
88 void resize(int width, int height);
89
95 inline int get_width() const { return m_width; }
96
102 inline int get_height() const { return m_height; }
103
109 inline unsigned int get_id() const { return m_renderer_id; }
110
119 void set_data(void *data, unsigned int size);
120
121 private:
123 unsigned int m_renderer_id;
124
126 std::string m_file_path;
127
129 int m_width, m_height;
130
132 GLenum m_internal_format;
133
135 GLenum m_data_format;
136
142 void init_texture_params();
143};
144
145} // namespace renderer
146
147} // namespace lmgl
void resize(int width, int height)
Resizes the texture to new dimensions.
Definition texture.cpp:68
Texture(int width, int height)
Constructor for creating a texture with specified width and height.
Definition texture.cpp:13
unsigned int get_id() const
Gets the OpenGL renderer ID of the texture.
Definition texture.hpp:109
void bind(unsigned int slot=0) const
Binds the texture to a specified texture slot.
Definition texture.cpp:61
int get_height() const
Gets the height of the texture.
Definition texture.hpp:102
~Texture()
Destructor for the Texture class.
Definition texture.cpp:52
void unbind() const
Unbinds the texture.
Definition texture.cpp:66
void set_data(void *data, unsigned int size)
Sets the data of the texture.
Definition texture.cpp:75
int get_width() const
Gets the width of the texture.
Definition texture.hpp:95
Namespace for rendering-related classes and functions.
Definition buffer.cpp:9
Forward declarations for Assimp Material structure.
Definition model_loader.cpp:12