layout(line_strip, max_vertices = 101) out;
in int objectid[];
+in vec2 pixsize[];
+
+//TODO: I thought this might be useful, maybe not.
+float areatriangle(vec2 a, vec2 b, vec2 c)
+{
+ return (c.y-a.y)*(b.y-a.y) - (b.x - a.x)*(c.x-a.x);
+}
void main()
{
vec2 coeff0 = texelFetch(bezier_buffer_texture, bezierid*3).rg + gl_in[0].gl_Position.xy ;
vec2 coeff1 = texelFetch(bezier_buffer_texture, bezierid*3+1).rg * boundssize + gl_in[0].gl_Position.xy;
vec2 coeff2 = texelFetch(bezier_buffer_texture, bezierid*3+2).rg * boundssize + gl_in[0].gl_Position.xy;
- for (int i = 0; i <= 100; ++i)
+ vec2 boundspxsize = pixsize[0];
+ int blen = clamp(int(abs(boundspxsize.x)),2,100);
+ float invblen = 1.0f/float(blen);
+ for (int i = 0; i <= blen; ++i)
{
- float t = i * 0.01f;
+ float t = i * invblen;
float oneminust = 1.0f - t;
float bernstein0 = t*t;
float bernstein1 = 2*t*oneminust;
float bounds_y;
float bounds_w;
float bounds_h;
+ float pixel_x;
+ float pixel_y;
+ float pixel_w;
+ float pixel_h;
};
layout(location = 0) in vec2 position;
out int objectid;
+out vec2 pixsize;
void main()
{
gl_Position.y = 1 - (transformed_position.y*2);
gl_Position.z = 0.0;
gl_Position.w = 1.0;
-
+ pixsize = vec2(pixel_w/bounds_w, 100*pixel_h/bounds_h);
objectid = gl_VertexID / 2;
}
if (m_use_gpu_transform)
{
- GLfloat glbounds[] = {static_cast<GLfloat>(Float(m_bounds.x)), static_cast<GLfloat>(Float(m_bounds.y)), static_cast<GLfloat>(Float(m_bounds.w)), static_cast<GLfloat>(Float(m_bounds.h))};
- m_bounds_ubo.Upload(sizeof(float)*4, glbounds);
+ GLfloat glbounds[] = {static_cast<GLfloat>(Float(m_bounds.x)), static_cast<GLfloat>(Float(m_bounds.y)), static_cast<GLfloat>(Float(m_bounds.w)), static_cast<GLfloat>(Float(m_bounds.h)),
+ 0.0, 0.0, 640.0, 480.0};
+ m_bounds_ubo.Upload(sizeof(float)*8, glbounds);
}
else
{
- GLfloat glbounds[] = {0.0f, 0.0f, 1.0f, 1.0f};
- m_bounds_ubo.Upload(sizeof(float)*4, glbounds);
+ GLfloat glbounds[] = {0.0f, 0.0f, 1.0f, 1.0f,
+ 0.0f, 0.0f, 640.0f, 480.0f};
+ m_bounds_ubo.Upload(sizeof(float)*8, glbounds);
}
m_bounds_dirty = false;