How to draw a line, a rectangle and a circle with C?
I would like to have some codes to know how to draw a line, a rectangle (or square) and a circle with C. Or maybe you have other stuff like that to show me? Most of books don''t teach these things.
Thank you!!!
Eric Chambers
www.cinnamonmagazine.com
Yes, most general programming books wouldn''t teach those concepts and most graphics library packages provide prebuilt functions that will do the work for you - GDI, DX, OGL, SDL and so on.
The subject isn''t as simple as drawing a line or circle on paper
Check out the tutorials here. Also check out flipcode and gametutorials.com. Also Google on "Breshenham" - hhh.
The subject isn''t as simple as drawing a line or circle on paper
Check out the tutorials here. Also check out flipcode and gametutorials.com. Also Google on "Breshenham" - hhh.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
DX has built in line support ????? Sure ?
[edited by - granat on September 13, 2002 1:04:26 AM]
[edited by - granat on September 13, 2002 1:04:26 AM]
-------------Ban KalvinB !
September 13, 2002 12:21 AM
Displaying graphics in C is not as simple as it is in other languages that may have built-in functions to draw lines, circles, etc. C has no concept of a "line" or a "circle" or even a video card. All you can do in C is read and write values to memory locations. If you write some value to a memory location that happens to be on the video card (in a special area called the frame buffer) then what you get is a pixel on the screen. Putting one pixel on the screen is simple enough, drawing lines and circles requires a little math. You could write your own pixel plotting functions, but there are libraries already written that give you access to the display. LessBread mentioned a few. DirectX is a good one if you are developing on a Windows machine. Since you posted this in the Beginners forum, please give us some indication of your confort level with C, that way people will know whether to tell you to look into a graphics API or to get more familiar with the language before moving on to graphics. Good luck and don''t get discouraged!
quote: Original post by granat
DX has built in line support ????? Sure ?
Not explicitly - but it does provide for other primatives - box, cynlinder, sphere, torus. I was speaking generally - The AP explained it better than I did.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
I''m really a beginner. I started programmation 3 days ago, but I learned it for about more than 10 hours by days. So, I have around 30 hrs of experiences. But I think I''m learning fast. Things are getting clearer now.
I did a lot of Basic 7 years ago, and I did a little battle scene like Final Fantasy with a lot of cool effect. I''m tring to do the same thing with C now.
If C is not compatible with graphical stuff, how did they make games like Final Fantasy on the Super Nintendo?
I did a lot of Basic 7 years ago, and I did a little battle scene like Final Fantasy with a lot of cool effect. I''m tring to do the same thing with C now.
If C is not compatible with graphical stuff, how did they make games like Final Fantasy on the Super Nintendo?
quote: Original post by Cinnamon
If C is not compatible with graphical stuff, how did they make games like Final Fantasy on the Super Nintendo?
Don''t forget Quake and Quake II - It''s not a matter of "compatibility" - it''s that the language itself doesn''t specify any requirements regarding a large range of familiar computer hardware components. That makes the language very flexible. Instead what you get is a buffer of memory - that could mean a file, an array, or a video buffer. What you do with that buffer is up to you. Like the AP said - "All you can do in C is read and write values to memory locations." That might sound limited - but really that''s all you can do in any programming language - it''s just that most other languages do all that for you "underneath the hood" so to speak. All the math and such is preprogrammed and what you''re left with is calling a function that does the work - like DrawCircle or what have you. The libraries I mentioned do that too. As you continue forward with your studies this will become more clear to you.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
I will do plenty of search and try to improve my learning with C. Anyway, it will be a good thing to be part of this forum.
once you feel comfortable writing simple non graphics programs in C, try SDL/DX or OpenGL (which ever you find easier) and then you can draw stuff and write simple games.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement