[shader] Moved 'a_pos' GL attribute to Shader
Avoids duplicated code in all derived classes.
This commit is contained in:
@@ -12,7 +12,6 @@ CollisionBoxShader::CollisionBoxShader()
|
||||
shaders[BOX_SHADER].vertex,
|
||||
shaders[BOX_SHADER].fragment
|
||||
) {
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
a_extrude = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_extrude"));
|
||||
a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data"));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ public:
|
||||
Uniform<float> u_maxzoom = {"u_maxzoom", *this};
|
||||
|
||||
protected:
|
||||
int32_t a_pos = -1;
|
||||
int32_t a_extrude = -1;
|
||||
int32_t a_data = -1;
|
||||
};
|
||||
|
||||
@@ -12,7 +12,6 @@ CircleShader::CircleShader()
|
||||
shaders[CIRCLE_SHADER].vertex,
|
||||
shaders[CIRCLE_SHADER].fragment
|
||||
) {
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
}
|
||||
|
||||
void CircleShader::bind(char *offset) {
|
||||
|
||||
@@ -17,9 +17,6 @@ public:
|
||||
Uniform<std::array<float, 4>> u_color = {"u_color", *this};
|
||||
Uniform<float> u_size = {"u_size", *this};
|
||||
Uniform<float> u_blur = {"u_blur", *this};
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ DotShader::DotShader()
|
||||
shaders[DOT_SHADER].vertex,
|
||||
shaders[DOT_SHADER].fragment
|
||||
) {
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
}
|
||||
|
||||
void DotShader::bind(char *offset) {
|
||||
|
||||
@@ -16,9 +16,6 @@ public:
|
||||
Uniform<std::array<float, 4>> u_color = {"u_color", *this};
|
||||
Uniform<float> u_size = {"u_size", *this};
|
||||
Uniform<float> u_blur = {"u_blur", *this};
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ IconShader::IconShader()
|
||||
shaders[ICON_SHADER].vertex,
|
||||
shaders[ICON_SHADER].fragment
|
||||
) {
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
a_offset = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_offset"));
|
||||
a_data1 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data1"));
|
||||
a_data2 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data2"));
|
||||
|
||||
@@ -25,7 +25,6 @@ public:
|
||||
Uniform<float> u_extra = {"u_extra", *this};
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
int32_t a_offset = -1;
|
||||
int32_t a_data1 = -1;
|
||||
int32_t a_data2 = -1;
|
||||
|
||||
@@ -12,7 +12,6 @@ LineShader::LineShader()
|
||||
shaders[LINE_SHADER].vertex,
|
||||
shaders[LINE_SHADER].fragment
|
||||
) {
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data"));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ public:
|
||||
UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
int32_t a_data = -1;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ LinepatternShader::LinepatternShader()
|
||||
shaders[LINEPATTERN_SHADER].vertex,
|
||||
shaders[LINEPATTERN_SHADER].fragment
|
||||
) {
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data"));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ public:
|
||||
UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
int32_t a_data = -1;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ LineSDFShader::LineSDFShader()
|
||||
shaders[LINESDF_SHADER].vertex,
|
||||
shaders[LINESDF_SHADER].fragment
|
||||
) {
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data"));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ public:
|
||||
UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
int32_t a_data = -1;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ OutlineShader::OutlineShader()
|
||||
shaders[OUTLINE_SHADER].vertex,
|
||||
shaders[OUTLINE_SHADER].fragment
|
||||
) {
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
}
|
||||
|
||||
void OutlineShader::bind(char *offset) {
|
||||
|
||||
@@ -15,9 +15,6 @@ public:
|
||||
UniformMatrix<4> u_matrix = {"u_matrix", *this};
|
||||
Uniform<std::array<float, 4>> u_color = {"u_color", *this};
|
||||
Uniform<std::array<float, 2>> u_world = {"u_world", *this};
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ PatternShader::PatternShader()
|
||||
shaders[PATTERN_SHADER].vertex,
|
||||
shaders[PATTERN_SHADER].fragment
|
||||
) {
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
}
|
||||
|
||||
void PatternShader::bind(char *offset) {
|
||||
|
||||
@@ -22,9 +22,6 @@ public:
|
||||
Uniform<int32_t> u_image = {"u_image", *this};
|
||||
UniformMatrix<3> u_patternmatrix_a = {"u_patternmatrix_a", *this};
|
||||
UniformMatrix<3> u_patternmatrix_b = {"u_patternmatrix_b", *this};
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ PlainShader::PlainShader()
|
||||
shaders[PLAIN_SHADER].vertex,
|
||||
shaders[PLAIN_SHADER].fragment
|
||||
) {
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
}
|
||||
|
||||
void PlainShader::bind(char *offset) {
|
||||
|
||||
@@ -14,9 +14,6 @@ public:
|
||||
|
||||
UniformMatrix<4> u_matrix = {"u_matrix", *this};
|
||||
Uniform<std::array<float, 4>> u_color = {"u_color", *this};
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ RasterShader::RasterShader()
|
||||
shaders[RASTER_SHADER].vertex,
|
||||
shaders[RASTER_SHADER].fragment
|
||||
) {
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
}
|
||||
|
||||
void RasterShader::bind(char *offset) {
|
||||
|
||||
@@ -21,9 +21,6 @@ public:
|
||||
Uniform<float> u_saturation_factor = {"u_saturation_factor", *this};
|
||||
Uniform<float> u_contrast_factor = {"u_contrast_factor", *this};
|
||||
Uniform<std::array<float, 3>> u_spin_weights = {"u_spin_weights", *this};
|
||||
|
||||
private:
|
||||
int32_t a_pos = -1;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ SDFShader::SDFShader()
|
||||
shaders[SDF_SHADER].vertex,
|
||||
shaders[SDF_SHADER].fragment
|
||||
) {
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
a_offset = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_offset"));
|
||||
a_data1 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data1"));
|
||||
a_data2 = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data2"));
|
||||
|
||||
@@ -27,7 +27,6 @@ public:
|
||||
Uniform<float> u_extra = {"u_extra", *this};
|
||||
|
||||
protected:
|
||||
int32_t a_pos = -1;
|
||||
int32_t a_offset = -1;
|
||||
int32_t a_data1 = -1;
|
||||
int32_t a_data2 = -1;
|
||||
|
||||
@@ -97,6 +97,8 @@ Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSo
|
||||
MBGL_CHECK_ERROR(glDeleteShader(vertShader));
|
||||
MBGL_CHECK_ERROR(glDetachShader(program, fragShader));
|
||||
MBGL_CHECK_ERROR(glDeleteShader(fragShader));
|
||||
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#ifndef MBGL_RENDERER_SHADER
|
||||
#define MBGL_RENDERER_SHADER
|
||||
|
||||
#include <mbgl/platform/gl.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -19,6 +21,9 @@ public:
|
||||
return program;
|
||||
}
|
||||
|
||||
protected:
|
||||
GLint a_pos = -1;
|
||||
|
||||
private:
|
||||
bool compileShader(uint32_t *shader, uint32_t type, const char *source);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user