[reactive] crayon - a 2D opengl curve renderer, with Reactive animations

Peter Verswyvelen bugfact at gmail.com
Wed Mar 25 19:21:31 EDT 2009


Excellent work! I have been looking into curve rendering myself lately, and
found some links that you might find interesting (besides the Loop/Blinn
article Bob already forwarded to you)
Maxim Shemanarev, the author of the open source anti-grain 2D rendering
engine, seems to have tackled the curve stroking (dealing with cusps etc)
pragmatically: <http://www.antigrain.com/mcseem/index.html>
  <http://www.antigrain.com/mcseem/index.html>
http://www.antigrain.com/research/adaptive_bezier/index.html#PAGE_ADAPTIVE_BEZIER

I also came across a kind of curve that I didn't know about yet, named
"Pythagorean
hodograph curves <http://www.research.ibm.com/journal/rd/345/ibmrd3405J.pdf> ".
These are subsets of Bezier polynomials for which arclength is expressible
as a polynomial, and for which offset curves (aka parallel curves) are
rational polynomials again (for regular curves arclength and offsets must be
approximated numerically). Offset curves could be used to avoid generating
all those line segments to stroke a curve, even rendering them directly on
the GPU, but I haven't found a fast way for doing this. There's even a full
book about PH curves from his inventor:
http://www.amazon.com/Pythagorean-Hodograph-Curves-Geometry-Inseparable-Computing/dp/3540733973

Personally I'm trying to do stroking by approximating cubic Bezier curves
and their offset curves with simple quadratic polynomial curves, performing
Delaunay triangulation, converting the quadratic curve segments to implicit
form, and directly rendering the triangles that form the control points of
the quadratics on the GPU. This is more for fun since it is most likely more
computationally expensive than just doing very fine subdivision and
rendering stroked line segments (although the implicits on the GPU is fully
resolution independent of course)

On Wed, Mar 25, 2009 at 10:56 PM, Jules Bean <jules at jellybean.co.uk> wrote:

> Tom Poliquin wrote:
>
>> Jules, thanks for uploading the code!
>>
>
> You're most welcome.
>
>
>> As a reactive newbie, examples are a gigantic help ..
>>
>> It works great .. about 40FPS  on my
>> ATI Technologies Inc RV515GL [FireGL V3350] using about 3% of my  AMD
>> Athlon(tm) 64 X2 Dual Core Processor 6000+
>> CPU.
>>
>
> Yes, capped to 40fps by the "25" (25 milliseconds = 1/40 seconds) in line
> 115 inside the idle callback.
>
> If you change that to "0" then it will take up more or less 100% of your
> CPU and framerates will be much higher. On my machine (nvidia m 8xxx) it
> does 1000fps (!) for Pong, 400fps for the charts and 100fps for the flowers.
>
>
>> I had to make a small change to get it to work on my
>> system (perhaps I'm down rev somewhere) .. but I thought I'd share in case
>> other newbies have the same
>> issue ..
>>
>> crayon.hs:689:57:
>>    Constructor `WeightedProperties' should have 4 arguments, but has been
>> given 1
>> crayon.hs:699:8:
>>    Constructor `WeightedProperties' should have 4 arguments, but has been
>> given 1
>>
>> I just changed the WeightedProperties args in each case to,
>>  (WeightedProperties (_,p) _ _ _)
>> from
>>  (WeightedProperties ((_, p) : _))
>>
>
> D'OH
>
> That is the correct fix, yes.
>
> I forgot that my HOpenGL bugfix actually changed the API.
>
>
> Jules
>
> _______________________________________________
> Reactive mailing list
> Reactive at haskell.org
> http://www.haskell.org/mailman/listinfo/reactive
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/reactive/attachments/20090326/6d452ef6/attachment-0001.htm


More information about the Reactive mailing list