20            glGenTextures(1, &
id);
 
 
   25            glDeleteTextures(1, &
id);
 
 
   28        virtual void upload(std::vector<std::byte> * data) {};
 
   30        inline void bind() { glBindTexture(GL_TEXTURE_2D, 
id); }
 
   32        inline void unbind() { glBindTexture(GL_TEXTURE_2D, 0); }
 
   34        void bind(
unsigned binding) 
 
   36            glActiveTexture(GL_TEXTURE0+binding);
 
 
   49        std::vector<std::byte> 
load_image(std::filesystem::path imageFilePath)
 
   51            unsigned char * pixels = stbi_load(imageFilePath.generic_string().c_str(), &
width, &
height, &
channels, 0);
 
   55                throw std::runtime_error(
"Failed to load texture: "+imageFilePath.generic_string());
 
   57            std::byte * bytes = 
reinterpret_cast<std::byte*
>(pixels);
 
   61            std::vector<std::byte> vdata(bytes, bytes+dim);
 
   62            stbi_image_free(pixels);
 
 
   66        std::vector<std::byte> 
load_image(std::vector<std::byte> imageFile)
 
   68            unsigned char * chData = 
reinterpret_cast<unsigned char*
>(imageFile.data());
 
   69            unsigned char * pixels = stbi_load_from_memory(chData, imageFile.size(), &
width, &
height, &
channels, 4);
 
   72                throw std::runtime_error(
"Failed to load texture from memory");
 
   74            std::byte * bytes = 
reinterpret_cast<std::byte*
>(pixels);
 
   78            std::vector<std::byte> vdata(bytes, bytes+dim);
 
   79            stbi_image_free(pixels);
 
 
 
   93            std::vector<std::byte> pixels = 
load_image(imageFile);
 
 
  101            std::vector<std::byte> pixels = 
load_image(data);
 
 
  107        void upload(std::vector<std::byte> pixels);
 
 
  118            std::vector<std::byte> pixels = 
load_image(imageFile);
 
 
  126            std::vector<std::byte> pixels = 
load_image(data);
 
 
  132        void upload(std::vector<std::byte> pixels);
 
 
  143            std::vector<std::byte> pixels = 
load_image(imageFile);
 
 
  151            std::vector<std::byte> pixels = 
load_image(data);
 
 
  164        void upload(std::vector<std::byte> pixels);
 
 
Definition glTexture.h:136
glTexture2DByte(std::vector< std::byte > data)
Definition glTexture.h:148
glTexture2DByte(std::vector< std::byte > pixels, int width, int height)
Definition glTexture.h:156
glTexture2DByte(std::filesystem::path imageFile)
Definition glTexture.h:140
void create(int width, int height)
Definition glTexture.cpp:133
void upload(std::vector< std::byte > pixels)
Definition glTexture.cpp:181
Definition glTexture.h:111
glTexture2DRGBA(std::filesystem::path imageFile)
Definition glTexture.h:115
void upload(std::vector< std::byte > pixels)
Definition glTexture.cpp:117
glTexture2DRGBA(std::vector< std::byte > data)
Definition glTexture.h:123
void create(int width, int height, int channels)
Definition glTexture.cpp:70
Definition glTexture.h:86
glTexture2DRGB(std::vector< std::byte > data)
Definition glTexture.h:98
void create(int width, int height, int channels)
Definition glTexture.cpp:5
void upload(std::vector< std::byte > pixels)
Definition glTexture.cpp:53
glTexture2DRGB(std::filesystem::path imageFile)
Definition glTexture.h:90
Definition glTexture.h:14
void unbind()
Definition glTexture.h:32
~glTexture()
Definition glTexture.h:23
std::vector< std::byte > load_image(std::vector< std::byte > imageFile)
Definition glTexture.h:66
std::vector< std::byte > load_image(std::filesystem::path imageFilePath)
Definition glTexture.h:49
virtual void upload(std::vector< std::byte > *data)
Definition glTexture.h:28
unsigned textureUnit
Definition glTexture.h:47
void generateMipMaps()
Definition glTexture.h:42
void bind()
Definition glTexture.h:30
GLuint id
Definition glTexture.h:46
void bind(unsigned binding)
Definition glTexture.h:34
glTexture()
Definition glTexture.h:18
int width
Definition texture.h:39
int height
Definition texture.h:39
int channels
Definition texture.h:39