2019-03-20 16:15:44 +09:00

29 lines
597 B
C++

#include "Texture.h"
Texture::Texture(std::string file_name, GLuint enum_rgb)
{
int width, height, channel;
unsigned char * image;
glActiveTexture(GL_TEXTURE0);
glGenTextures(1, &tex_ref);
glBindTexture(GL_TEXTURE_2D, tex_ref);
image = stbi_load(file_name.c_str(), &width, &height, &channel, 0);
glTexImage2D(GL_TEXTURE_2D, 0, enum_rgb, width, height, 0, enum_rgb,
GL_UNSIGNED_BYTE, image);
glGenerateMipmap(GL_TEXTURE_2D);
stbi_image_free(image);
glBindTexture(GL_TEXTURE_2D, 0);
}
Texture::Texture(const Texture &other)
{
tex_ref = other.tex_ref;
}
Texture::~Texture()
{
}