Graphics: Making circles

This is a discussion on Graphics: Making circles within the C++ Programming forums, part of the General Programming Boards category; I am a beginner in C++ and I know so far, the basics of: cout, cin,if,loops,functions, basic formatting such as ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    36

    Graphics: Making circles

    I am a beginner in C++ and I know so far, the basics of: cout, cin,if,loops,functions, basic formatting such as cout.precision,cout.width, and i know how to use the string class.

    Ever since starting C++, I have always wanted to make graphics. Just simple ones. Like making a circle, square, lines, points and stuff like that. I have searched over 50-100 sites on the web in order to find this information but i was pretty unsuccessful.

    Here is one piece of code that my book says about this.

    Code:
    #include <lvp\gui_top.h>
    
    class GuiClass 
    {
          public:
                 GuiClass();
                 void GuiMouseClick(int x, int y);
                 void GuiPaint();
                 string Title();
          private:
                  
                  };
    
    GuiClass::GuiClass()
    {
                        }
    string GuiClass::Title()
    {
           return "Olympic Symbol!";
           }
    void GuiClass::GuiMouseClick(int x, int y)
    {
     }
    void GuiClass::GuiPaint()
    {
         Circle(180,200,50);
         }
    
    #include <lvp\gui_bot.h>
    The above code, I tried to compile using DEV C++ latest compiler but i get like 6 errors. They are:
    -------------------------------------------------------------------------------
    gui_top: No such file or directory.

    syntax error before `)' token

    syntax error before `::' token

    In member function `void GuiClass::GuiPaint()':

    `Circle' undeclared (first use this function)

    gui_bot: No such file or directory.

    ------------------------------------------------------------------------------



    So can anybody please tell me a very simpe, program that allows me to make a freakin' circle. PLEASE!

  2. #2
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    There are no graphics in standard C++. You will need to use something like the Win32 API. From there you can learn OpenGL or DirectX. An alternative is to just learn Allegro or SDL (and not Win32). I believe the Borland compiler has a circle() or some such function, but I wouldn't use those as they are far from standard. There you go!

    - SirCrono6

    P.S. Make sure to learn more standard C++ before attempting graphics. If you decide on Win32 later when you are ready, I would suggest using theForger's tutorial.
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    36
    What the heck does all that mean?

    U cant make one circle without that? I am surprised!

  4. #4
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    You can still make circles in the console with nice text art

  5. #5
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    I always seems to surprise people who are new to C++ It wouldn't be portable to have the circle function in standard C++; that is, it wouldn't run on other operating systems. Don't worry about all that yet, just continue learning basic C++. When your feeling pretty comfortable with standard C++ (without Win32, circle, etc.), pick one of those things above and start learning it. Here are some orders to learn things in:
    • Standard C++
    • Win32 API
    • DirectX

    -------------------------------
    • Standard C++
    • Win32 API
    • OpenGL

    -------------------------------
    • Standard C++
    • SDL

    -------------------------------
    • Standard C++
    • Allegro


    Note they all start with standard C++

    - SirCrono6
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  6. #6
    Super Moderater.
    Join Date
    Jan 2005
    Posts
    374
    Perhaps you should consider using a more graphically orientated language such as java to achieve your needs.

    If not, the win32app looks good.

  7. #7
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Ever since starting C++, I have always wanted to make graphics. Just simple ones. Like making a circle, square, lines, points and stuff like that. I have searched over 50-100 sites on the web in order to find this information but i was pretty unsuccessful.
    Next time you are in a bookstore, check out the book "Ivor Horton's Beginning Visual C++". It's red. The first half of the book is on C++, and the second half of the book is on "windows programming", e.g. using windows to display your output. When you use windows to display output, you can do all the circle drawing you want. The windows programming part of the book has you construct a sample program called Sketcher, which is a program that presents a window to the user, and provides the user with all kinds of shapes they can draw. Just a warning: trying to learn windows programming without a solid understanding of pointers, classes, and inheritance is going to be very frustrating.

    Any book with Visual C++ in the title will teach you how to do windows programming using the MS Visual C++ compiler and the MFC(Microsoft Foundation Classes). MFC provides you with hundreds of classes to help you do windows programming, but learning how to use those classes is not easy. The MFC was created to remove a lot of the complex drudgery of creating windows programs using the win32 API. So, another course of action is:

    standard C++
    visual C++

    However, that requires a serious time commitment, and instead you may just want to learn something easy like Visual Basic 6, which is known as a RAD language for "rapid application development".
    Last edited by 7stud; 04-09-2005 at 02:22 AM.

  8. #8
    Chief Code Coloniser!
    Join Date
    Apr 2005
    Posts
    121
    The quickest way of drawing a circle:

    Code:
    cout << "O"<< endl;


    Sorry... couldn't resist

  9. #9
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    I win
    Code:
    #include <iostream>
    
    void drawCircle();
    
    int main()
    {
        drawCircle();
        std::cin.get();    
        return 0;
    }
    
    void drawCircle()
    {
        std::cout<<"    *****      "<<std::endl;
        std::cout<<"   *     *     "<<std::endl;
        std::cout<<"   *     *     "<<std::endl;
        std::cout<<"   *     *     "<<std::endl;
        std::cout<<"    *****      "<<std::endl;
    }
    Woop?

  10. #10
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    If you want to implement a circle drawer yourself check out bresenham and the mid point algorithm.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  11. #11
    Let's do some coding! Welshy's Avatar
    Join Date
    Mar 2005
    Location
    Staffordshire University, UK
    Posts
    168
    By reading all of this i assume that there is no simple way to colour text in standard C++? or is there a simple function i could use if i include <windows.h>??

    I'd really like to colour the characters in my textbased RTS game :P

  12. #12
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    or is there a simple function i could use if i include <windows.h>
    Ya,
    http://www.adrianxw.dk/SoftwareSite/...Consoles4.html

  13. #13
    Let's do some coding! Welshy's Avatar
    Join Date
    Mar 2005
    Location
    Staffordshire University, UK
    Posts
    168
    ah i thank you very much kind sir

  14. #14
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Quote Originally Posted by Magos
    If you want to implement a circle drawer yourself check out bresenham and the mid point algorithm.
    and if you want an example check out my clock demo which uses Bresenhams line and circle algorithms to display an analog clock.
    Line/Circle algos (clock demo)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Turtle Graphics, how does it work?
    By freddyvorhees in forum C++ Programming
    Replies: 15
    Last Post: 08-28-2009, 09:57 AM
  2. Difficulty choosing graphics library
    By jdiperla in forum Game Programming
    Replies: 11
    Last Post: 02-27-2008, 05:35 PM
  3. Making control...
    By Finchie_88 in forum C++ Programming
    Replies: 2
    Last Post: 09-07-2004, 01:42 PM
  4. Graphics in the console (for real)
    By harryP in forum C++ Programming
    Replies: 11
    Last Post: 10-16-2003, 04:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21