Maybe don't use all of the lines. Or maybe do.
authorDavid Gow <[email protected]>
Mon, 30 Jun 2014 04:26:52 +0000 (12:26 +0800)
committerDavid Gow <[email protected]>
Mon, 30 Jun 2014 04:26:52 +0000 (12:26 +0800)
bin/ipdf
src/shaders/bezier_texbuf_geom.glsl
src/shaders/rect_vert.glsl
src/view.cpp

index 4739d21..03e79d7 100755 (executable)
Binary files a/bin/ipdf and b/bin/ipdf differ
index caf7a10..56dddbe 100644 (file)
@@ -7,6 +7,13 @@ layout(lines) in;
 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()
 {
@@ -15,9 +22,12 @@ 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;
index a9f258a..bdfd3ea 100644 (file)
@@ -8,11 +8,16 @@ layout(std140, binding=0) uniform ViewBounds
        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()
 {
@@ -24,6 +29,6 @@ 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;
 }
index 4bba591..af1980a 100644 (file)
@@ -147,13 +147,15 @@ void View::Render(int width, int height)
 
        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;
 

UCC git Repository :: git.ucc.asn.au