Sign in to follow this  
littlekid

OpenGL Pen Tool With Thickness

Recommended Posts

Hi I am trying to create a "pen tool" like simulation with opengl. I am rendering each point as a circle with a certain radius. It look decent when the user is drawing with a slow speed.

However when the user move the mouse really fast, there would be gaps in between each drawn circle. Is there way to avoid this problem??

Off the top my head, I would think of joining up adjacent points with a line. However I was wondering if this would lead to blocky lines??

regards

Share this post


Link to post
Share on other sites
Think about it as lines to begin with. The mouse moves from A to B in a single frame, and you want to draw this line, as it represents where the mouse just moved.
Now, normalize a "stepping/direction" unit vector from the line between A and B, and multiply it by a suitable step size.
Then plot a new circle every step along that vector from A, and stop stepping when B has been passed (when distance AB has been travelled).
If the step size is small, the line will appear as just that; a line with rounded edges (while taking longer to draw). Higher step sizes give the line a more jagged look.
It's faster to draw a rectangle (two triangles ;) )connecting the circles at A and B, -and it will always look nice.

Share this post


Link to post
Share on other sites
[quote name='szecs' timestamp='1310490577' post='4834390']
a line segment = rectangle + circles at the end
[/quote]
-Or semicircles if you really intend to save overdraw! [img]http://public.gamedev.net/public/style_emoticons/default/tongue.gif[/img]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this