PDA

View Full Version : line drawing program in c?



rozan
December 29th, 2008, 02:26 PM
can some one write a simple program in c that draws a line.
thnx.

slavik
December 29th, 2008, 02:28 PM
can some one write a simple program in c that draws a line.
thnx.
Yes, you can. I can suggest using OpenGL/GLUT for this.

rozan
December 29th, 2008, 02:33 PM
Yes, you can. I can suggest using OpenGL/GLUT for this.

can you write a code for drawing line?

slavik
December 29th, 2008, 02:34 PM
No. Neither will anyone else that reads the forum. Why do you need this? Is this a homework assignment?

rozan
December 29th, 2008, 02:40 PM
No. Neither will anyone else that reads the forum. Why do you need this? Is this a homework assignment?

Its not an assignment. I just want to learn to use graphic in c.
I tried using #include<graphic.h> but error message says no such file or directory.
??

slavik
December 29th, 2008, 02:42 PM
Have you tried looking for a tutorial?

This is a good tutorial if you would like to learn some OpenGL (drawing lines in OpenGL is not difficult).
http://nehe.gamedev.net/

mike_g
December 29th, 2008, 04:03 PM
I put some code for line drawing (bresenham algo) here (http://grundez.net/snippet.php?id=31). Its api independent, but requires you to pass a drawing buffer to the function.

Edit: for a lib to draw 2D stuff, you could check out sdl as its a bit simpler than openGL. The development files can be downloaded via the repos.

mmix
December 29th, 2008, 05:53 PM
http://zetcode.com/tutorials/cairographicstutorial/basicdrawing/