From: David Gow Date: Mon, 30 Jun 2014 04:26:52 +0000 (+0800) Subject: Maybe don't use all of the lines. Or maybe do. X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=54798ed9050d0742c6cdab067fad0cc364b1d6b2;p=ipdf%2Fcode.git Maybe don't use all of the lines. Or maybe do. --- diff --git a/bin/ipdf b/bin/ipdf index 4739d21..03e79d7 100755 Binary files a/bin/ipdf and b/bin/ipdf differ diff --git a/src/shaders/bezier_texbuf_geom.glsl b/src/shaders/bezier_texbuf_geom.glsl index caf7a10..56dddbe 100644 --- a/src/shaders/bezier_texbuf_geom.glsl +++ b/src/shaders/bezier_texbuf_geom.glsl @@ -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; diff --git a/src/shaders/rect_vert.glsl b/src/shaders/rect_vert.glsl index a9f258a..bdfd3ea 100644 --- a/src/shaders/rect_vert.glsl +++ b/src/shaders/rect_vert.glsl @@ -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; } diff --git a/src/view.cpp b/src/view.cpp index 4bba591..af1980a 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -147,13 +147,15 @@ void View::Render(int width, int height) if (m_use_gpu_transform) { - GLfloat glbounds[] = {static_cast(Float(m_bounds.x)), static_cast(Float(m_bounds.y)), static_cast(Float(m_bounds.w)), static_cast(Float(m_bounds.h))}; - m_bounds_ubo.Upload(sizeof(float)*4, glbounds); + GLfloat glbounds[] = {static_cast(Float(m_bounds.x)), static_cast(Float(m_bounds.y)), static_cast(Float(m_bounds.w)), static_cast(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;