Files
MapLibreParticleLab/src/mbgl/programs/circle_program.hpp
John Firebaugh 1db2ffbc1b [core] Use gl::Program to resolve some rough edges in the GL binding types
* Extract `ignore` util to separate header.
* `Segment` now tracks offset and length of indices, rather than primitives. This is more natural.
* Introduce `VertexVector` and `IndexVector` types. These types carry information about the intended draw mode (`Triangles`, `LineStrip`, etc.), and ensure that elements are always appended in a group size appropriate for that draw mode, for both indexed and unindexed rendering.
* `Program`, rather than `Drawable`, is now the unifying object for draw calls. `Program` is the best place to type check the draw call, because it is typed to carry information about the intended primitive, vertex type, attributes, and uniforms.
* Use the debug shaders for debug tile rendering, like gl-js.
* Fix the draw mode for background. It was drawing triangle strips with a triangles array. Surprised this didn’t cause issues. Now it’s type checked.
2016-11-08 08:09:29 -08:00

54 lines
1.3 KiB
C++

#pragma once
#include <mbgl/programs/program.hpp>
#include <mbgl/programs/attributes.hpp>
#include <mbgl/programs/uniforms.hpp>
#include <mbgl/shader/circle.hpp>
#include <mbgl/util/geometry.hpp>
namespace mbgl {
namespace uniforms {
MBGL_DEFINE_UNIFORM_SCALAR(float, u_radius);
MBGL_DEFINE_UNIFORM_SCALAR(bool, u_scale_with_map);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_devicepixelratio);
} // namespace uniforms
class CircleProgram : public Program<
shaders::circle,
gl::Triangle,
gl::Attributes<
attributes::a_pos>,
gl::Uniforms<
uniforms::u_matrix,
uniforms::u_opacity,
uniforms::u_color,
uniforms::u_radius,
uniforms::u_blur,
uniforms::u_scale_with_map,
uniforms::u_extrude_scale,
uniforms::u_devicepixelratio>>
{
public:
using Program::Program;
/*
* @param {number} x vertex position
* @param {number} y vertex position
* @param {number} ex extrude normal
* @param {number} ey extrude normal
*/
static Vertex vertex(Point<int16_t> p, float ex, float ey) {
return Vertex {
{
static_cast<int16_t>((p.x * 2) + ((ex + 1) / 2)),
static_cast<int16_t>((p.y * 2) + ((ey + 1) / 2))
}
};
}
};
using CircleVertex = CircleProgram::Vertex;
} // namespace mbgl