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

uniform_value.cpp « drape - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5f35aeb0d2dacfbedafc9da426e33a09d7a6cee9 (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
#include "drape/uniform_value.hpp"
#include "drape/gl_functions.hpp"

namespace dp
{
namespace
{
void ApplyInt(int8_t location, int32_t const * pointer, size_t componentCount)
{
  switch (componentCount)
  {
  case 1:
    GLFunctions::glUniformValuei(location, pointer[0]);
    break;
  case 2:
    GLFunctions::glUniformValuei(location, pointer[0], pointer[1]);
    break;
  case 3:
    GLFunctions::glUniformValuei(location, pointer[0], pointer[1], pointer[2]);
    break;
  case 4:
    GLFunctions::glUniformValuei(location, pointer[0], pointer[1], pointer[2], pointer[3]);
    break;
  default:
    ASSERT(false, ());
  }
}

void ApplyFloat(int8_t location, float const * pointer, size_t componentCount)
{
  switch (componentCount)
  {
  case 1:
    GLFunctions::glUniformValuef(location, pointer[0]);
    break;
  case 2:
    GLFunctions::glUniformValuef(location, pointer[0], pointer[1]);
    break;
  case 3:
    GLFunctions::glUniformValuef(location, pointer[0], pointer[1], pointer[2]);
    break;
  case 4:
    GLFunctions::glUniformValuef(location, pointer[0], pointer[1], pointer[2], pointer[3]);
    break;
  default:
    ASSERT(false, ());
  }
}

void ApplyMatrix(int8_t location, float const * matrix)
{
  GLFunctions::glUniformMatrix4x4Value(location, matrix);
}
}  // namespace

// static
void UniformValue::ApplyRaw(int8_t location, glsl::mat4 const & m)
{
  ASSERT_GREATER_OR_EQUAL(location, 0, ());
  ApplyMatrix(location, glsl::value_ptr(m));
}

// static
void UniformValue::ApplyRaw(int8_t location, float f)
{
  ApplyFloat(location, &f, 1);
}

// static
void UniformValue::ApplyRaw(int8_t location, glsl::vec2 const & v)
{
  ApplyFloat(location, glsl::value_ptr(v), 2);
}

// static
void UniformValue::ApplyRaw(int8_t location, glsl::vec3 const & v)
{
  ApplyFloat(location, glsl::value_ptr(v), 3);
}

// static
void UniformValue::ApplyRaw(int8_t location, glsl::vec4 const & v)
{
  ApplyFloat(location, glsl::value_ptr(v), 4);
}

// static
void UniformValue::ApplyRaw(int8_t location, int i)
{
  ApplyInt(location, &i, 1);
}

// static
void UniformValue::ApplyRaw(int8_t location, glsl::ivec2 const & v)
{
  ApplyInt(location, glsl::value_ptr(v), 2);
}

// static
void UniformValue::ApplyRaw(int8_t location, glsl::ivec3 const & v)
{
  ApplyInt(location, glsl::value_ptr(v), 3);
}

// static
void UniformValue::ApplyRaw(int8_t location, glsl::ivec4 const & v)
{
  ApplyInt(location, glsl::value_ptr(v), 4);
}
}  // namespace dp