Jump to content
  • Advertisement
Sign in to follow this  
littlekid

OpenGL Pen Tool With Thickness

This topic is 2562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

a line segment = rectangle + circles at the end

-Or semicircles if you really intend to save overdraw! tongue.gif

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!