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

glextensions_list.cpp « drape - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b9647ebefd43cdab307abc8dc691046d69095b96 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "drape/glextensions_list.hpp"
#include "drape/glfunctions.hpp"

#include "base/assert.hpp"

#include "std/string.hpp"

namespace dp
{

#ifdef DEBUG
  #include "std/map.hpp"

  class GLExtensionsList::Impl
  {
  public:
    void CheckExtension(GLExtensionsList::ExtensionName const & enumName, const string & extName)
    {
#ifdef OMIM_OS_ANDROID
      if (enumName == GLExtensionsList::VertexArrayObject)
        m_supportedMap[enumName] = false;
      else
#endif
        m_supportedMap[enumName] = GLFunctions::glHasExtension(extName);
    }

    void SetExtension(GLExtensionsList::ExtensionName const & enumName, bool isSupported)
    {
      m_supportedMap[enumName] = isSupported;
    }

    bool IsSupported(GLExtensionsList::ExtensionName const & enumName) const
    {
      map<GLExtensionsList::ExtensionName, bool>::const_iterator it = m_supportedMap.find(enumName);
      if (it != m_supportedMap.end())
        return it->second;

      ASSERT(false, ("Not all used extensions is checked"));
      return false;
    }

  private:
    map<GLExtensionsList::ExtensionName, bool> m_supportedMap;
  };
#else
  #include "std/set.hpp"

  class GLExtensionsList::Impl
  {
  public:
    void CheckExtension(GLExtensionsList::ExtensionName const & enumName, const string & extName)
    {
#ifdef OMIM_OS_ANDROID
      if (enumName == GLExtensionsList::VertexArrayObject)
        return;
#endif
      if (GLFunctions::glHasExtension(extName))
        m_supported.insert(enumName);
    }

    void SetExtension(GLExtensionsList::ExtensionName const & enumName, bool isSupported)
    {
      if (isSupported)
        m_supported.insert(enumName);
    }

    bool IsSupported(GLExtensionsList::ExtensionName const & enumName) const
    {
      if (m_supported.find(enumName) != m_supported.end())
        return true;

      return false;
    }

  private:
    set<GLExtensionsList::ExtensionName> m_supported;
  };
#endif

GLExtensionsList::GLExtensionsList()
  : m_impl(new Impl())
{
#if defined(OMIM_OS_MOBILE)
  m_impl->CheckExtension(VertexArrayObject, "GL_OES_vertex_array_object");
  m_impl->CheckExtension(RequiredInternalFormat, "GL_OES_required_internalformat");
  m_impl->CheckExtension(TextureNPOT, "GL_OES_texture_npot");
  m_impl->CheckExtension(MapBuffer, "GL_OES_mapbuffer");
  m_impl->CheckExtension(UintIndices, "GL_OES_element_index_uint");
  m_impl->CheckExtension(MapBufferRange, "GL_EXT_map_buffer_range");
#elif defined(OMIM_OS_WINDOWS)
  m_impl->CheckExtension(TextureNPOT, "GL_ARB_texture_non_power_of_two");
  m_impl->SetExtension(VertexArrayObject, false);
  m_impl->SetExtension(RequiredInternalFormat, false);
  m_impl->SetExtension(MapBuffer, true);
  m_impl->SetExtension(MapBufferRange, false);
  m_impl->SetExtension(UintIndices, true);
#else
  m_impl->CheckExtension(VertexArrayObject, "GL_APPLE_vertex_array_object");
  m_impl->CheckExtension(TextureNPOT, "GL_ARB_texture_non_power_of_two");
  m_impl->SetExtension(RequiredInternalFormat, false);
  m_impl->SetExtension(MapBuffer, true);
  m_impl->SetExtension(MapBufferRange, false);
  m_impl->SetExtension(UintIndices, true);
#endif
}

GLExtensionsList::~GLExtensionsList()
{
  delete m_impl;
}

GLExtensionsList & GLExtensionsList::Instance()
{
  static GLExtensionsList extList;
  return extList;
}

bool GLExtensionsList::IsSupported(ExtensionName const & extName) const
{
  return m_impl->IsSupported(extName);
}

} // namespace dp