1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-10-06 09:07:19 +02:00
openrw/rwcore/gl/TextureData.hpp
2019-01-20 20:00:00 +01:00

51 lines
1.0 KiB
C++

#ifndef _LIBRW_TEXTUREDATA_HPP_
#define _LIBRW_TEXTUREDATA_HPP_
#include <gl/gl_core_3_3.h>
#include <glm/vec2.hpp>
#include <map>
#include <memory>
#include <string>
/**
* Stores a handle and metadata about a loaded texture.
*/
class TextureData {
public:
TextureData(GLuint name, const glm::ivec2& dims, bool alpha)
: texName(name), size(dims), hasAlpha(alpha) {
}
~TextureData() {
glDeleteTextures(1, &texName);
}
GLuint getName() const {
return texName;
}
const glm::ivec2& getSize() const {
return size;
}
bool isTransparent() const {
return hasAlpha;
}
typedef std::shared_ptr<TextureData> Handle;
static Handle create(GLuint name, const glm::ivec2& size,
bool transparent) {
return std::make_shared<TextureData>(name, size, transparent);
}
private:
GLuint texName;
glm::ivec2 size;
bool hasAlpha;
};
using TextureArchive = std::map<std::string, TextureData::Handle>;
#endif