2013-06-21 16:49:29 +00:00
|
|
|
#pragma once
|
|
|
|
|
2013-07-09 05:44:24 +00:00
|
|
|
#include "ResourceManager.h"
|
2013-06-21 16:49:29 +00:00
|
|
|
|
|
|
|
#include <string>
|
2013-07-17 03:41:39 +00:00
|
|
|
#include <Eigen/Dense>
|
2013-06-21 16:49:29 +00:00
|
|
|
#include "../platform.h"
|
|
|
|
#include GLHEADER
|
|
|
|
|
2013-07-09 05:44:24 +00:00
|
|
|
class TextureResource : public IReloadable
|
2013-06-21 16:49:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-01-19 18:23:01 +00:00
|
|
|
static std::shared_ptr<TextureResource> get(const std::string& path, bool tile = false);
|
2013-06-21 16:49:29 +00:00
|
|
|
|
2013-07-09 05:44:24 +00:00
|
|
|
virtual ~TextureResource();
|
2013-06-21 16:49:29 +00:00
|
|
|
|
2013-10-04 23:09:54 +00:00
|
|
|
void unload(std::shared_ptr<ResourceManager>& rm) override;
|
|
|
|
void reload(std::shared_ptr<ResourceManager>& rm) override;
|
2013-07-09 05:44:24 +00:00
|
|
|
|
2014-01-19 18:23:01 +00:00
|
|
|
bool isTiled() const;
|
2013-07-10 11:29:43 +00:00
|
|
|
Eigen::Vector2i getSize() const;
|
2013-07-09 05:44:24 +00:00
|
|
|
void bind() const;
|
|
|
|
|
2013-09-20 23:55:05 +00:00
|
|
|
void initFromMemory(const char* image, size_t length);
|
2013-06-21 16:49:29 +00:00
|
|
|
|
|
|
|
private:
|
2014-01-19 18:23:01 +00:00
|
|
|
TextureResource(const std::string& path, bool tile);
|
2013-07-09 05:44:24 +00:00
|
|
|
|
|
|
|
void initFromPath();
|
|
|
|
void initFromResource(const ResourceData data);
|
|
|
|
void deinit();
|
|
|
|
|
2013-07-10 11:29:43 +00:00
|
|
|
Eigen::Vector2i mTextureSize;
|
2013-06-21 16:49:29 +00:00
|
|
|
GLuint mTextureID;
|
2013-07-09 05:44:24 +00:00
|
|
|
const std::string mPath;
|
2014-01-19 18:23:01 +00:00
|
|
|
const bool mTile;
|
2013-07-09 05:44:24 +00:00
|
|
|
|
2014-01-19 18:23:01 +00:00
|
|
|
typedef std::pair<std::string, bool> TextureKeyType;
|
|
|
|
static std::map< TextureKeyType, std::weak_ptr<TextureResource> > sTextureMap;
|
2013-06-21 16:49:29 +00:00
|
|
|
};
|