views:

685

answers:

3

I guess I'll illustrate with an example: In this game you are able to draw 2D shapes using the mouse and what you draw is rendered to the screen in real-time. I want to know what the best ways are to render this type of drawing using hardware acceleration (OpenGL). I had two ideas:

  • Create a screen-size texture when drawing is started, update this when drawing, and blit this to the screen
  • Create a series of line segments to represent the drawing, and render these using either lines or thin polygons

Are there any other ideas? Which of these methods is likely to be best/most efficient/easiest? Any suggestions are welcome.

A: 

I'm pretty sure the second idea is the way to go.

Jim Crafton
A: 

First option if the player draws pure freehand (rather than lines), and what they draw doesn't need to be animated.

Second option if it is animated or is primarily lines. If you do choose this, it seems like you'd need to draw thin polygons rather than regular lines to get any kind of interesting look (as in the crayon example).

+2  A: 

I love crayon physics (music gets me every time). Great game!

But back to the point... He has created brush sprites that follow your mouse position. He's created a few brushes that account for a little variation. Once the mouse goes down, I imagine he is adding these sprites to a data structure and sending that structure through his drawing and collision functions to loop through. Thus popping out the real-time effect. He is using Simple DirectMedia Layer library, which I give two thumbs up.

David McGraw