[core] Move shader and uniform to gl directory

This commit is contained in:
John Firebaugh
2016-09-30 12:20:29 -07:00
parent 7a3bef091e
commit 73334ac8fa
29 changed files with 254 additions and 249 deletions

View File

@@ -67,9 +67,13 @@ set(MBGL_CORE_FILES
src/mbgl/gl/index_buffer.hpp
src/mbgl/gl/object.cpp
src/mbgl/gl/object.hpp
src/mbgl/gl/shader.cpp
src/mbgl/gl/shader.hpp
src/mbgl/gl/state.hpp
src/mbgl/gl/texture.hpp
src/mbgl/gl/types.hpp
src/mbgl/gl/uniform.cpp
src/mbgl/gl/uniform.hpp
src/mbgl/gl/value.cpp
src/mbgl/gl/value.hpp
src/mbgl/gl/vao.cpp
@@ -199,13 +203,9 @@ set(MBGL_CORE_FILES
src/mbgl/shader/raster_vertex.hpp
src/mbgl/shader/sdf_shader.cpp
src/mbgl/shader/sdf_shader.hpp
src/mbgl/shader/shader.cpp
src/mbgl/shader/shader.hpp
src/mbgl/shader/shaders.hpp
src/mbgl/shader/texture_rect_vertex.cpp
src/mbgl/shader/texture_rect_vertex.hpp
src/mbgl/shader/uniform.cpp
src/mbgl/shader/uniform.hpp
# sprite
include/mbgl/sprite/sprite_image.hpp

View File

@@ -73,7 +73,7 @@ void bindVertexAttribute(AttributeLocation location, const E (V::*)[N], const in
// This has to be a macro because it uses the offsetof macro, which is the only legal way to get a member offset.
#define MBGL_BIND_VERTEX_ATTRIBUTE(VertexType, member, offset) \
::mbgl::gl::bindVertexAttribute<offsetof(VertexType, member)>(Shader::member, &VertexType::member, offset)
::mbgl::gl::bindVertexAttribute<offsetof(VertexType, member)>(gl::Shader::member, &VertexType::member, offset)
} // namespace gl
} // namespace mbgl

View File

@@ -1,4 +1,4 @@
#include <mbgl/shader/shader.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/util/stopwatch.hpp>
@@ -15,11 +15,12 @@
#include <cassert>
namespace mbgl {
namespace gl {
Shader::Shader(const char* name_,
const char* vertexSource,
const char* fragmentSource,
gl::Context& context,
Context& context,
Defines defines)
: name(name_),
program(context.createProgram()),
@@ -71,7 +72,7 @@ Shader::Shader(const char* name_,
}
}
bool Shader::compileShader(gl::UniqueShader& shader, const GLchar *source) {
bool Shader::compileShader(UniqueShader& shader, const GLchar *source) {
GLint status = 0;
const GLsizei lengths = static_cast<GLsizei>(std::strlen(source));
@@ -107,8 +108,9 @@ Shader::~Shader() {
}
}
gl::UniformLocation Shader::getUniformLocation(const char* uniform) const {
UniformLocation Shader::getUniformLocation(const char* uniform) const {
return MBGL_CHECK_ERROR(glGetUniformLocation(program.get(), uniform));
}
} // namespace gl
} // namespace mbgl

51
src/mbgl/gl/shader.hpp Normal file
View File

@@ -0,0 +1,51 @@
#pragma once
#include <mbgl/gl/types.hpp>
#include <mbgl/gl/object.hpp>
#include <mbgl/util/noncopyable.hpp>
namespace mbgl {
namespace gl {
class Context;
class Shader : private util::noncopyable {
public:
~Shader();
const char* name;
ProgramID getID() const {
return program.get();
}
UniformLocation getUniformLocation(const char* uniform) const;
enum Defines : bool {
None = false,
Overdraw = true,
};
protected:
Shader(const char* name_,
const char* vertex,
const char* fragment,
Context&,
Defines defines = Defines::None);
public:
static constexpr AttributeLocation a_pos = 0;
static constexpr AttributeLocation a_extrude = 1;
static constexpr AttributeLocation a_offset = 2;
static constexpr AttributeLocation a_data = 3;
static constexpr AttributeLocation a_texture_pos = 4;
private:
bool compileShader(UniqueShader&, const char *source);
UniqueProgram program;
UniqueShader vertexShader;
UniqueShader fragmentShader;
};
} // namespace gl
} // namespace mbgl

View File

@@ -1,8 +1,9 @@
#include <mbgl/shader/uniform.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/gl/uniform.hpp>
#include <mbgl/gl/gl.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
namespace gl {
template <>
void Uniform<float>::bind(const float& t) {
@@ -52,4 +53,5 @@ void UniformMatrix<4>::bind(const std::array<float, 16>& t) {
// Add more as needed.
} // namespace gl
} // namespace mbgl

View File

@@ -1,10 +1,11 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/gl/shader.hpp>
#include <array>
namespace mbgl {
namespace gl {
template <typename T>
class Uniform {
@@ -24,7 +25,7 @@ private:
void bind(const T&);
T current;
gl::UniformLocation location;
UniformLocation location;
};
template <size_t C, size_t R = C>
@@ -53,7 +54,8 @@ private:
void bind(const T&);
T current;
gl::UniformLocation location;
UniformLocation location;
};
} // namespace gl
} // namespace mbgl

View File

@@ -30,7 +30,7 @@ void VertexArrayObject::bindVertexArrayObject(gl::Context& context) {
context.vertexArrayObject = *vertexArray;
}
void VertexArrayObject::verifyBinding(Shader& shader,
void VertexArrayObject::verifyBinding(gl::Shader& shader,
gl::BufferID vertexBuffer,
gl::BufferID elementsBuffer,
int8_t* offset) {
@@ -47,7 +47,7 @@ void VertexArrayObject::verifyBinding(Shader& shader,
}
}
void VertexArrayObject::storeBinding(Shader& shader,
void VertexArrayObject::storeBinding(gl::Shader& shader,
gl::BufferID vertexBuffer,
gl::BufferID elementsBuffer,
int8_t* offset) {

View File

@@ -1,6 +1,6 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/gl/vertex_buffer.hpp>
#include <mbgl/util/noncopyable.hpp>
@@ -57,11 +57,11 @@ public:
private:
void bindVertexArrayObject(gl::Context&);
void storeBinding(Shader& shader,
void storeBinding(gl::Shader& shader,
gl::BufferID vertexBuffer,
gl::BufferID elementsBuffer,
int8_t* offset);
void verifyBinding(Shader& shader,
void verifyBinding(gl::Shader& shader,
gl::BufferID vertexBuffer,
gl::BufferID elementsBuffer,
int8_t* offset);

View File

@@ -67,7 +67,7 @@ Painter::Painter(const TransformState& state_)
shaders = std::make_unique<Shaders>(context);
#ifndef NDEBUG
overdrawShaders = std::make_unique<Shaders>(context, Shader::Overdraw);
overdrawShaders = std::make_unique<Shaders>(context, gl::Shader::Overdraw);
#endif
// Reset GL values

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,21 +12,21 @@ template <class> class VertexBuffer;
class CircleVertex;
class CircleShader : public Shader {
class CircleShader : public gl::Shader {
public:
CircleShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<CircleVertex>&,
const int8_t* offset);
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<std::array<float, 2>> u_extrude_scale = {"u_extrude_scale", *this};
Uniform<float> u_devicepixelratio = {"u_devicepixelratio", *this};
Uniform<Color> u_color = {"u_color", *this};
Uniform<float> u_radius = {"u_radius", *this};
Uniform<float> u_blur = {"u_blur", *this};
Uniform<float> u_opacity = {"u_opacity", *this};
Uniform<int32_t> u_scale_with_map = {"u_scale_with_map", *this};
gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
gl::Uniform<std::array<float, 2>> u_extrude_scale = {"u_extrude_scale", *this};
gl::Uniform<float> u_devicepixelratio = {"u_devicepixelratio", *this};
gl::Uniform<Color> u_color = {"u_color", *this};
gl::Uniform<float> u_radius = {"u_radius", *this};
gl::Uniform<float> u_blur = {"u_blur", *this};
gl::Uniform<float> u_opacity = {"u_opacity", *this};
gl::Uniform<int32_t> u_scale_with_map = {"u_scale_with_map", *this};
};
} // namespace mbgl

View File

@@ -1,5 +1,5 @@
#include <mbgl/shader/circle_vertex.hpp>
#include <mbgl/shader/shader.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/uniform.hpp>
namespace mbgl {
@@ -11,17 +11,17 @@ template <class> class VertexBuffer;
class CollisionBoxVertex;
class CollisionBoxShader : public Shader {
class CollisionBoxShader : public gl::Shader {
public:
CollisionBoxShader(gl::Context&);
void bind(const gl::VertexBuffer<CollisionBoxVertex>&,
const int8_t* offset);
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<float> u_scale = {"u_scale", *this};
Uniform<float> u_zoom = {"u_zoom", *this};
Uniform<float> u_maxzoom = {"u_maxzoom", *this};
gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
gl::Uniform<float> u_scale = {"u_scale", *this};
gl::Uniform<float> u_zoom = {"u_zoom", *this};
gl::Uniform<float> u_maxzoom = {"u_maxzoom", *this};
};
} // namespace mbgl

View File

@@ -1,5 +1,5 @@
#include <mbgl/shader/collision_box_vertex.hpp>
#include <mbgl/shader/shader.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/uniform.hpp>
namespace mbgl {
@@ -11,21 +11,21 @@ template <class> class VertexBuffer;
class TextureRectVertex;
class IconShader : public Shader {
class IconShader : public gl::Shader {
public:
IconShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<TextureRectVertex>&,
const int8_t* offset);
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<std::array<float, 2>> u_extrude_scale = {"u_extrude_scale", *this};
Uniform<float> u_zoom = {"u_zoom", *this};
Uniform<float> u_opacity = {"u_opacity", *this};
Uniform<std::array<float, 2>> u_texsize = {"u_texsize", *this};
Uniform<int32_t> u_rotate_with_map = {"u_rotate_with_map", *this};
Uniform<int32_t> u_texture = {"u_texture", *this};
Uniform<int32_t> u_fadetexture = {"u_fadetexture", *this};
gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
gl::Uniform<std::array<float, 2>> u_extrude_scale = {"u_extrude_scale", *this};
gl::Uniform<float> u_zoom = {"u_zoom", *this};
gl::Uniform<float> u_opacity = {"u_opacity", *this};
gl::Uniform<std::array<float, 2>> u_texsize = {"u_texsize", *this};
gl::Uniform<int32_t> u_rotate_with_map = {"u_rotate_with_map", *this};
gl::Uniform<int32_t> u_texture = {"u_texture", *this};
gl::Uniform<int32_t> u_fadetexture = {"u_fadetexture", *this};
};
} // namespace mbgl

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,24 +12,24 @@ template <class> class VertexBuffer;
class LineVertex;
class LineShader : public Shader {
class LineShader : public gl::Shader {
public:
LineShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<LineVertex>&,
const int8_t* offset);
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<Color> u_color = {"u_color", *this};
Uniform<float> u_opacity = {"u_opacity", *this};
Uniform<float> u_ratio = {"u_ratio", *this};
Uniform<float> u_linewidth = {"u_linewidth", *this};
Uniform<float> u_gapwidth = {"u_gapwidth", *this};
Uniform<float> u_antialiasing = {"u_antialiasing", *this};
Uniform<float> u_blur = {"u_blur", *this};
Uniform<float> u_extra = {"u_extra", *this};
Uniform<float> u_offset = {"u_offset", *this};
UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
gl::Uniform<Color> u_color = {"u_color", *this};
gl::Uniform<float> u_opacity = {"u_opacity", *this};
gl::Uniform<float> u_ratio = {"u_ratio", *this};
gl::Uniform<float> u_linewidth = {"u_linewidth", *this};
gl::Uniform<float> u_gapwidth = {"u_gapwidth", *this};
gl::Uniform<float> u_antialiasing = {"u_antialiasing", *this};
gl::Uniform<float> u_blur = {"u_blur", *this};
gl::Uniform<float> u_extra = {"u_extra", *this};
gl::Uniform<float> u_offset = {"u_offset", *this};
gl::UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
};

View File

@@ -1,5 +1,5 @@
#include <mbgl/shader/line_vertex.hpp>
#include <mbgl/shader/shader.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/uniform.hpp>
namespace mbgl {
@@ -11,32 +11,32 @@ template <class> class VertexBuffer;
class LineVertex;
class LinepatternShader : public Shader {
class LinepatternShader : public gl::Shader {
public:
LinepatternShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<LineVertex>&,
const int8_t* offset);
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<float> u_linewidth = {"u_linewidth", *this};
Uniform<float> u_gapwidth = {"u_gapwidth", *this};
Uniform<float> u_antialiasing = {"u_antialiasing", *this};
Uniform<std::array<float, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
Uniform<std::array<float, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
Uniform<std::array<float, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
Uniform<std::array<float, 2>> u_pattern_size_b = {"u_pattern_size_b", *this};
Uniform<std::array<float, 2>> u_pattern_tl_b = {"u_pattern_tl_b", *this};
Uniform<std::array<float, 2>> u_pattern_br_b = {"u_pattern_br_b", *this};
Uniform<float> u_ratio = {"u_ratio", *this};
Uniform<float> u_point = {"u_point", *this};
Uniform<float> u_blur = {"u_blur", *this};
Uniform<float> u_fade = {"u_fade", *this};
Uniform<float> u_opacity = {"u_opacity", *this};
Uniform<float> u_extra = {"u_extra", *this};
Uniform<float> u_offset = {"u_offset", *this};
Uniform<int32_t> u_image = {"u_image", *this};
UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
gl::Uniform<float> u_linewidth = {"u_linewidth", *this};
gl::Uniform<float> u_gapwidth = {"u_gapwidth", *this};
gl::Uniform<float> u_antialiasing = {"u_antialiasing", *this};
gl::Uniform<std::array<float, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
gl::Uniform<std::array<float, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
gl::Uniform<std::array<float, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
gl::Uniform<std::array<float, 2>> u_pattern_size_b = {"u_pattern_size_b", *this};
gl::Uniform<std::array<float, 2>> u_pattern_tl_b = {"u_pattern_tl_b", *this};
gl::Uniform<std::array<float, 2>> u_pattern_br_b = {"u_pattern_br_b", *this};
gl::Uniform<float> u_ratio = {"u_ratio", *this};
gl::Uniform<float> u_point = {"u_point", *this};
gl::Uniform<float> u_blur = {"u_blur", *this};
gl::Uniform<float> u_fade = {"u_fade", *this};
gl::Uniform<float> u_opacity = {"u_opacity", *this};
gl::Uniform<float> u_extra = {"u_extra", *this};
gl::Uniform<float> u_offset = {"u_offset", *this};
gl::Uniform<int32_t> u_image = {"u_image", *this};
gl::UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
};
} // namespace mbgl

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,31 +12,31 @@ template <class> class VertexBuffer;
class LineVertex;
class LineSDFShader : public Shader {
class LineSDFShader : public gl::Shader {
public:
LineSDFShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<LineVertex>&,
const int8_t* offset);
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<Color> u_color = {"u_color", *this};
Uniform<float> u_opacity = {"u_opacity", *this};
Uniform<float> u_linewidth = {"u_linewidth", *this};
Uniform<float> u_gapwidth = {"u_gapwidth", *this};
Uniform<float> u_antialiasing = {"u_antialiasing", *this};
Uniform<float> u_ratio = {"u_ratio", *this};
Uniform<float> u_blur = {"u_blur", *this};
Uniform<std::array<float, 2>> u_patternscale_a = { "u_patternscale_a", *this};
Uniform<float> u_tex_y_a = {"u_tex_y_a", *this};
Uniform<std::array<float, 2>> u_patternscale_b = { "u_patternscale_b", *this};
Uniform<float> u_tex_y_b = {"u_tex_y_b", *this};
Uniform<int32_t> u_image = {"u_image", *this};
Uniform<float> u_sdfgamma = {"u_sdfgamma", *this};
Uniform<float> u_mix = {"u_mix", *this};
Uniform<float> u_extra = {"u_extra", *this};
Uniform<float> u_offset = {"u_offset", *this};
UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
gl::Uniform<Color> u_color = {"u_color", *this};
gl::Uniform<float> u_opacity = {"u_opacity", *this};
gl::Uniform<float> u_linewidth = {"u_linewidth", *this};
gl::Uniform<float> u_gapwidth = {"u_gapwidth", *this};
gl::Uniform<float> u_antialiasing = {"u_antialiasing", *this};
gl::Uniform<float> u_ratio = {"u_ratio", *this};
gl::Uniform<float> u_blur = {"u_blur", *this};
gl::Uniform<std::array<float, 2>> u_patternscale_a = { "u_patternscale_a", *this};
gl::Uniform<float> u_tex_y_a = {"u_tex_y_a", *this};
gl::Uniform<std::array<float, 2>> u_patternscale_b = { "u_patternscale_b", *this};
gl::Uniform<float> u_tex_y_b = {"u_tex_y_b", *this};
gl::Uniform<int32_t> u_image = {"u_image", *this};
gl::Uniform<float> u_sdfgamma = {"u_sdfgamma", *this};
gl::Uniform<float> u_mix = {"u_mix", *this};
gl::Uniform<float> u_extra = {"u_extra", *this};
gl::Uniform<float> u_offset = {"u_offset", *this};
gl::UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
};

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,17 +12,17 @@ template <class> class VertexBuffer;
class PlainVertex;
class OutlineShader : public Shader {
class OutlineShader : public gl::Shader {
public:
OutlineShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<PlainVertex>&,
const int8_t* offset);
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<Color> u_outline_color = {"u_outline_color", *this};
Uniform<float> u_opacity = {"u_opacity", *this};
Uniform<std::array<float, 2>> u_world = {"u_world", *this};
gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
gl::Uniform<Color> u_outline_color = {"u_outline_color", *this};
gl::Uniform<float> u_opacity = {"u_opacity", *this};
gl::Uniform<std::array<float, 2>> u_world = {"u_world", *this};
};
} // namespace mbgl

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/uniform.hpp>
namespace mbgl {
@@ -11,29 +11,29 @@ template <class> class VertexBuffer;
class PlainVertex;
class OutlinePatternShader : public Shader {
class OutlinePatternShader : public gl::Shader {
public:
OutlinePatternShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<PlainVertex>&,
const int8_t* offset);
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<std::array<float, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
Uniform<std::array<float, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
Uniform<std::array<float, 2>> u_pattern_tl_b = {"u_pattern_tl_b", *this};
Uniform<std::array<float, 2>> u_pattern_br_b = {"u_pattern_br_b", *this};
Uniform<float> u_opacity = {"u_opacity", *this};
Uniform<float> u_mix = {"u_mix", *this};
Uniform<float> u_scale_a = {"u_scale_a", *this};
Uniform<float> u_scale_b = {"u_scale_b", *this};
Uniform<float> u_tile_units_to_pixels = {"u_tile_units_to_pixels", *this};
Uniform<int32_t> u_image = {"u_image", *this};
Uniform<std::array<float, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
Uniform<std::array<float, 2>> u_pattern_size_b = {"u_pattern_size_b", *this};
Uniform<std::array<float, 2>> u_pixel_coord_upper = {"u_pixel_coord_upper", *this};
Uniform<std::array<float, 2>> u_pixel_coord_lower = {"u_pixel_coord_lower", *this};
Uniform<std::array<float, 2>> u_world = {"u_world", *this};
gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
gl::Uniform<std::array<float, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
gl::Uniform<std::array<float, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
gl::Uniform<std::array<float, 2>> u_pattern_tl_b = {"u_pattern_tl_b", *this};
gl::Uniform<std::array<float, 2>> u_pattern_br_b = {"u_pattern_br_b", *this};
gl::Uniform<float> u_opacity = {"u_opacity", *this};
gl::Uniform<float> u_mix = {"u_mix", *this};
gl::Uniform<float> u_scale_a = {"u_scale_a", *this};
gl::Uniform<float> u_scale_b = {"u_scale_b", *this};
gl::Uniform<float> u_tile_units_to_pixels = {"u_tile_units_to_pixels", *this};
gl::Uniform<int32_t> u_image = {"u_image", *this};
gl::Uniform<std::array<float, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
gl::Uniform<std::array<float, 2>> u_pattern_size_b = {"u_pattern_size_b", *this};
gl::Uniform<std::array<float, 2>> u_pixel_coord_upper = {"u_pixel_coord_upper", *this};
gl::Uniform<std::array<float, 2>> u_pixel_coord_lower = {"u_pixel_coord_lower", *this};
gl::Uniform<std::array<float, 2>> u_world = {"u_world", *this};
};
} // namespace mbgl

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/uniform.hpp>
namespace mbgl {
@@ -11,28 +11,28 @@ template <class> class VertexBuffer;
class PlainVertex;
class PatternShader : public Shader {
class PatternShader : public gl::Shader {
public:
PatternShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<PlainVertex>&,
const int8_t* offset);
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<std::array<float, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
Uniform<std::array<float, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
Uniform<std::array<float, 2>> u_pattern_tl_b = {"u_pattern_tl_b", *this};
Uniform<std::array<float, 2>> u_pattern_br_b = {"u_pattern_br_b", *this};
Uniform<float> u_opacity = {"u_opacity", *this};
Uniform<float> u_mix = {"u_mix", *this};
Uniform<float> u_scale_a = {"u_scale_a", *this};
Uniform<float> u_scale_b = {"u_scale_b", *this};
Uniform<float> u_tile_units_to_pixels = {"u_tile_units_to_pixels", *this};
Uniform<int32_t> u_image = {"u_image", *this};
Uniform<std::array<float, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
Uniform<std::array<float, 2>> u_pattern_size_b = {"u_pattern_size_b", *this};
Uniform<std::array<float, 2>> u_pixel_coord_upper = {"u_pixel_coord_upper", *this};
Uniform<std::array<float, 2>> u_pixel_coord_lower = {"u_pixel_coord_lower", *this};
gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
gl::Uniform<std::array<float, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
gl::Uniform<std::array<float, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
gl::Uniform<std::array<float, 2>> u_pattern_tl_b = {"u_pattern_tl_b", *this};
gl::Uniform<std::array<float, 2>> u_pattern_br_b = {"u_pattern_br_b", *this};
gl::Uniform<float> u_opacity = {"u_opacity", *this};
gl::Uniform<float> u_mix = {"u_mix", *this};
gl::Uniform<float> u_scale_a = {"u_scale_a", *this};
gl::Uniform<float> u_scale_b = {"u_scale_b", *this};
gl::Uniform<float> u_tile_units_to_pixels = {"u_tile_units_to_pixels", *this};
gl::Uniform<int32_t> u_image = {"u_image", *this};
gl::Uniform<std::array<float, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
gl::Uniform<std::array<float, 2>> u_pattern_size_b = {"u_pattern_size_b", *this};
gl::Uniform<std::array<float, 2>> u_pixel_coord_upper = {"u_pixel_coord_upper", *this};
gl::Uniform<std::array<float, 2>> u_pixel_coord_lower = {"u_pixel_coord_lower", *this};
};
} // namespace mbgl

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,16 +12,16 @@ template <class> class VertexBuffer;
class PlainVertex;
class PlainShader : public Shader {
class PlainShader : public gl::Shader {
public:
PlainShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<PlainVertex>&,
const int8_t* offset);
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<Color> u_color = {"u_color", *this};
Uniform<float> u_opacity = {"u_opacity", *this};
gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
gl::Uniform<Color> u_color = {"u_color", *this};
gl::Uniform<float> u_opacity = {"u_opacity", *this};
};
} // namespace mbgl

View File

@@ -1,5 +1,5 @@
#include <mbgl/shader/plain_vertex.hpp>
#include <mbgl/shader/shader.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/uniform.hpp>
namespace mbgl {
@@ -11,26 +11,26 @@ template <class> class VertexBuffer;
class RasterVertex;
class RasterShader : public Shader {
class RasterShader : public gl::Shader {
public:
RasterShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<RasterVertex>&,
const int8_t* offset);
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<int32_t> u_image0 = {"u_image0", *this};
Uniform<int32_t> u_image1 = {"u_image1", *this};
Uniform<float> u_opacity0 = {"u_opacity0", *this};
Uniform<float> u_opacity1 = {"u_opacity1", *this};
Uniform<float> u_buffer_scale = {"u_buffer_scale", *this};
Uniform<float> u_brightness_low = {"u_brightness_low", *this};
Uniform<float> u_brightness_high = {"u_brightness_high", *this};
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};
Uniform<std::array<float, 2>> u_tl_parent = {"u_tl_parent", *this};
Uniform<float> u_scale_parent = {"u_scale_parent", *this};
gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
gl::Uniform<int32_t> u_image0 = {"u_image0", *this};
gl::Uniform<int32_t> u_image1 = {"u_image1", *this};
gl::Uniform<float> u_opacity0 = {"u_opacity0", *this};
gl::Uniform<float> u_opacity1 = {"u_opacity1", *this};
gl::Uniform<float> u_buffer_scale = {"u_buffer_scale", *this};
gl::Uniform<float> u_brightness_low = {"u_brightness_low", *this};
gl::Uniform<float> u_brightness_high = {"u_brightness_high", *this};
gl::Uniform<float> u_saturation_factor = {"u_saturation_factor", *this};
gl::Uniform<float> u_contrast_factor = {"u_contrast_factor", *this};
gl::Uniform<std::array<float, 3>> u_spin_weights = {"u_spin_weights", *this};
gl::Uniform<std::array<float, 2>> u_tl_parent = {"u_tl_parent", *this};
gl::Uniform<float> u_scale_parent = {"u_scale_parent", *this};
};
} // namespace mbgl

View File

@@ -1,5 +1,5 @@
#include <mbgl/shader/raster_vertex.hpp>
#include <mbgl/shader/shader.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {

View File

@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,28 +12,28 @@ template <class> class VertexBuffer;
class TextureRectVertex;
class SDFShader : public Shader {
class SDFShader : public gl::Shader {
public:
SDFShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<TextureRectVertex>&,
const int8_t* offset);
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<std::array<float, 2>> u_extrude_scale = {"u_extrude_scale", *this};
Uniform<Color> u_color = {"u_color", *this};
Uniform<float> u_opacity = {"u_opacity", *this};
Uniform<std::array<float, 2>> u_texsize = {"u_texsize", *this};
Uniform<float> u_buffer = {"u_buffer", *this};
Uniform<float> u_gamma = {"u_gamma", *this};
Uniform<float> u_zoom = {"u_zoom", *this};
Uniform<float> u_pitch = {"u_pitch", *this};
Uniform<float> u_bearing = {"u_bearing", *this};
Uniform<float> u_aspect_ratio = {"u_aspect_ratio", *this};
Uniform<int32_t> u_rotate_with_map = {"u_rotate_with_map", *this};
Uniform<int32_t> u_pitch_with_map = {"u_pitch_with_map", *this};
Uniform<int32_t> u_texture = {"u_texture", *this};
Uniform<int32_t> u_fadetexture = {"u_fadetexture", *this};
gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
gl::Uniform<std::array<float, 2>> u_extrude_scale = {"u_extrude_scale", *this};
gl::Uniform<Color> u_color = {"u_color", *this};
gl::Uniform<float> u_opacity = {"u_opacity", *this};
gl::Uniform<std::array<float, 2>> u_texsize = {"u_texsize", *this};
gl::Uniform<float> u_buffer = {"u_buffer", *this};
gl::Uniform<float> u_gamma = {"u_gamma", *this};
gl::Uniform<float> u_zoom = {"u_zoom", *this};
gl::Uniform<float> u_pitch = {"u_pitch", *this};
gl::Uniform<float> u_bearing = {"u_bearing", *this};
gl::Uniform<float> u_aspect_ratio = {"u_aspect_ratio", *this};
gl::Uniform<int32_t> u_rotate_with_map = {"u_rotate_with_map", *this};
gl::Uniform<int32_t> u_pitch_with_map = {"u_pitch_with_map", *this};
gl::Uniform<int32_t> u_texture = {"u_texture", *this};
gl::Uniform<int32_t> u_fadetexture = {"u_fadetexture", *this};
};
} // namespace mbgl

View File

@@ -1,52 +0,0 @@
#pragma once
#include <mbgl/gl/types.hpp>
#include <mbgl/gl/object.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/optional.hpp>
namespace mbgl {
namespace gl {
class Context;
} // namespace gl
class Shader : private util::noncopyable {
public:
~Shader();
const char* name;
gl::ProgramID getID() const {
return program.get();
}
gl::UniformLocation getUniformLocation(const char* uniform) const;
enum Defines : bool {
None = false,
Overdraw = true,
};
protected:
Shader(const char* name_,
const char* vertex,
const char* fragment,
gl::Context&,
Defines defines = Defines::None);
public:
static constexpr gl::AttributeLocation a_pos = 0;
static constexpr gl::AttributeLocation a_extrude = 1;
static constexpr gl::AttributeLocation a_offset = 2;
static constexpr gl::AttributeLocation a_data = 3;
static constexpr gl::AttributeLocation a_texture_pos = 4;
private:
bool compileShader(gl::UniqueShader&, const char *source);
gl::UniqueProgram program;
gl::UniqueShader vertexShader;
gl::UniqueShader fragmentShader;
};
} // namespace mbgl

View File

@@ -17,7 +17,7 @@ namespace mbgl {
class Shaders {
public:
Shaders(gl::Context& context, Shader::Defines defines = Shader::None)
Shaders(gl::Context& context, gl::Shader::Defines defines = gl::Shader::None)
: plain(context, defines),
outline(context, defines),
outlinePattern(context, defines),

View File

@@ -1,5 +1,5 @@
#include <mbgl/shader/texture_rect_vertex.hpp>
#include <mbgl/shader/shader.hpp>
#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {