#include "image.h" #include "gl.h" #include "stb_image.h" Image::Image() { data = 0; } Image::Image(const std::string& filename) { load(filename); } Image::~Image() { if(data) { stbi_image_free(data); } } void Image::load(const std::string& filename) { int w, h, ch; data = stbi_load(filename.c_str(), &w, &h, &ch, 4); width = w; height = h; if(ch == 4) { format = GL_RGBA; } else { format = GL_RGBA; } } unsigned int Image::w() const { return width; } unsigned int Image::h() const { return height; } unsigned int Image::f() const { return format; } const void* Image::d() const { return data; }