From 879046aadd167c3963ec76f4b1c6e9c533267bbc Mon Sep 17 00:00:00 2001 From: ExMix Date: Tue, 17 Sep 2013 17:13:39 +0300 Subject: drape basics --- drape/texture.hpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 drape/texture.hpp (limited to 'drape/texture.hpp') 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); + + void Bind(int8_t uniformLocation); + bool IsEnabled() const; + const string & GetUniformName() const; + void SetIsEnabled(bool isEnabled); + void SetTexture(WeakPointer 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 m_texture; +}; -- cgit v1.2.3