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: 69647f4fa5024e1b5f6e966d8d0caa0174707cd3 (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
#include "drape/glextensions_list.hpp"
#include "drape/glfunctions.hpp"

#include "base/assert.hpp"

#include "std/target_os.hpp"

namespace dp
{
GLExtensionsList::GLExtensionsList(dp::ApiVersion apiVersion)
{
#if defined(OMIM_OS_MOBILE)
  CheckExtension(TextureNPOT, "GL_OES_texture_npot");
  if (apiVersion == dp::ApiVersion::OpenGLES2)
  {
#ifdef OMIM_OS_ANDROID
    SetExtension(VertexArrayObject, false);
#else
    CheckExtension(VertexArrayObject, "GL_OES_vertex_array_object");
#endif
    CheckExtension(MapBuffer, "GL_OES_mapbuffer");
    CheckExtension(UintIndices, "GL_OES_element_index_uint");
    CheckExtension(MapBufferRange, "GL_EXT_map_buffer_range");
  }
  else
  {
    SetExtension(VertexArrayObject, true);
    SetExtension(MapBuffer, true);
    SetExtension(MapBufferRange, true);
    SetExtension(UintIndices, true);
  }
#elif defined(OMIM_OS_WINDOWS)
  m_impl->CheckExtension(TextureNPOT, "GL_ARB_texture_non_power_of_two");
  SetExtension(MapBuffer, true);
  SetExtension(UintIndices, true);
  if (apiVersion == dp::ApiVersion::OpenGLES2)
  {
    SetExtension(VertexArrayObject, false);
    SetExtension(MapBufferRange, false);
  }
  else
  {
    SetExtension(VertexArrayObject, true);
    SetExtension(MapBufferRange, true);
  }
#else
  CheckExtension(TextureNPOT, "GL_ARB_texture_non_power_of_two");
  SetExtension(MapBuffer, true);
  SetExtension(UintIndices, true);
  if (apiVersion == dp::ApiVersion::OpenGLES2)
  {
    CheckExtension(VertexArrayObject, "GL_APPLE_vertex_array_object");
    SetExtension(MapBufferRange, false);
  }
  else
  {
    SetExtension(VertexArrayObject, true);
    SetExtension(MapBufferRange, true);
  }
#endif
}

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

bool GLExtensionsList::IsSupported(ExtensionName extName) const
{
  auto const it = m_supportedMap.find(extName);
  if (it != m_supportedMap.end())
    return it->second;

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

void GLExtensionsList::CheckExtension(ExtensionName enumName, std::string const & extName)
{
  m_supportedMap[enumName] = GLFunctions::glHasExtension(extName);
}

void GLExtensionsList::SetExtension(ExtensionName enumName, bool isSupported)
{
  m_supportedMap[enumName] = isSupported;
}
}  // namespace dp