mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 03:12:36 +01:00
50 lines
1.0 KiB
C++
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
|