Welcome to mirror list, hosted at ThFree Co, Russian Federation.

texture.hpp « drape - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 536d87150440427142172cb7e91e0750ede9526d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#pragma once

#include "pointers.hpp"

#include "../std/string.hpp"
#include "../std/stdint.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, RefPointer<Texture> texture);

  void Bind(int8_t uniformLocation);
  bool IsEnabled() const;
  const string & GetUniformName() const;
  void SetIsEnabled(bool isEnabled);
  void SetTexture(RefPointer<Texture> texture);

  bool operator<(const TextureBinding & other) const
  {
    return m_isEnabled < other.m_isEnabled
        || m_samplerBlock < other.m_samplerBlock
        || m_texture.IsContentLess(other.m_texture);
  }

private:
  string m_uniformName;
  bool m_isEnabled;
  uint8_t m_samplerBlock;
  RefPointer<Texture> m_texture;
};