blob: 259ccc278cf578d7e6b2d44e36351bb440b3849c (
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
|
#include "drape/shader.hpp"
#include "drape/gl_functions.hpp"
#include "base/assert.hpp"
namespace dp
{
namespace
{
glConst ConvertType(Shader::Type t)
{
if (t == Shader::Type::VertexShader)
return gl_const::GLVertexShader;
return gl_const::GLFragmentShader;
}
} // namespace
Shader::Shader(std::string const & shaderName, std::string const & shaderSource,
std::string const & defines, Type type)
: m_shaderName(shaderName)
, m_glID(0)
{
m_glID = GLFunctions::glCreateShader(ConvertType(type));
GLFunctions::glShaderSource(m_glID, shaderSource, defines);
std::string errorLog;
bool const result = GLFunctions::glCompileShader(m_glID, errorLog);
CHECK(result, (m_shaderName, "> Shader compile error : ", errorLog));
}
Shader::~Shader()
{
GLFunctions::glDeleteShader(m_glID);
}
uint32_t Shader::GetID() const
{
return m_glID;
}
} // namespace dp
|