1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-15 06:52:34 +02:00
openrw/rwcore/gl/TextureData.hpp
Daniel Evans 4fd92a1549 Rename rwlib library to "core" to fit its new role
Also move up source files into the root directory, as there's nothing else in this directory
2018-08-09 20:28:24 +01:00

50 lines
1.0 KiB
C++

#ifndef _LIBRW_TEXTUREDATA_HPP_
#define _LIBRW_TEXTUREDATA_HPP_
#include <gl/gl_core_3_3.h>
#include <glm/glm.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