diff options
author | ExMix <rahuba.youri@mapswithme.com> | 2013-09-17 18:13:39 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:02:43 +0300 |
commit | 879046aadd167c3963ec76f4b1c6e9c533267bbc (patch) | |
tree | b1d3f59cd1833eebdb6ca527fede8eb01dadf22a /drape/texture.hpp | |
parent | 5bb03b18ebc30b14287ae101e12dd02f1fdc686c (diff) |
drape basics
Diffstat (limited to 'drape/texture.hpp')
-rw-r--r-- | drape/texture.hpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/drape/texture.hpp b/drape/texture.hpp new file mode 100644 index 0000000000..f03724d2a9 --- /dev/null +++ b/drape/texture.hpp @@ -0,0 +1,79 @@ +#pragma once + +#include "pointers.hpp" + +#include "../std/string.hpp" + +struct TextureInfo +{ + enum PixelType + { + FullRGBA, // 8 bit on channel + HalfRGBA // 4 bit on channel + }; + + TextureInfo() + : m_width(0), m_height(0), m_pixelType(FullRGBA) + { + } + + TextureInfo(uint32_t width, uint32_t height, PixelType type) + : m_width(width), m_height(height), m_pixelType(type) + { + } + + uint32_t m_width; + uint32_t m_height; + PixelType m_pixelType; +}; + +class Texture +{ +public: + Texture(TextureInfo const & info); + Texture(TextureInfo const & info, void * data); + + void Update(uint32_t x, uint32_t y, uint32_t width, uint32_t height, void * data); + + uint32_t GetID() const; + void Bind(); + + TextureInfo const & GetInfo() const; + + bool operator<(const Texture & other) const + { + return m_textureID < other.m_textureID; + } + +private: + void Init(TextureInfo const & info, void * data); + +private: + uint32_t m_textureID; + TextureInfo m_info; +}; + +class TextureBinding +{ +public: + TextureBinding(const string & uniformName, bool isEnabled, uint8_t samplerBlock, WeakPointer<Texture> texture); + + void Bind(int8_t uniformLocation); + bool IsEnabled() const; + const string & GetUniformName() const; + void SetIsEnabled(bool isEnabled); + void SetTexture(WeakPointer<Texture> texture); + + bool operator<(const TextureBinding & other) const + { + return m_isEnabled < other.m_isEnabled + || m_samplerBlock < other.m_samplerBlock + || m_texture < other.m_texture; + } + +private: + string m_uniformName; + bool m_isEnabled; + uint8_t m_samplerBlock; + WeakPointer<Texture> m_texture; +}; |