Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Need Help. Graphics in C

  1. #1
    Julia008 is offline Newbie
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    Need Help. Graphics in C

    Good day everyone,

    We're having a subject by the name "Computer Graphics" in university and our teacher wrote 3 programs regarding drawing a line using "DDA algorithm", using "Bresenham's line algorithm" as well as a program for drawing a circle using "Mid-Point Circle Generating Algorithm".

    He gave those codes to us. But we need to add graphics mode (initialize the program to graphics mode...) in order to get them working.

    I am pretty weak in programming and have no idea how it is done.

    Please, if you're expert in graphics for C programming, leave me a message in private message so that I can contact you either in private message or yahoo/MSN. I have many questions that I want to ask.

    Best regards,
    Julia.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,489
    Blog Entries
    75
    Rep Power
    143

    Re: Need Help. Graphics in C

    The first question anyone will ask: Which operating system? Graphic programming is inherently system depending.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Julia008 is offline Newbie
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    Re: Need Help. Graphics in C

    Sorry I may get your question wrong (I am a rookie). I think the answer will be console application. Graphics using Turbo C++.

    I am able to understand the program logic that teacher given to us. And I am aware of how to initialize the graphics in C. What I don't know is where to initialize the graphics and how to solve the errors generated uring compiling. I tried the whole day but still have one error.

    Shall I send you the codes WingedPanther?

    Regards,
    Julia

  5. #4
    Join Date
    Jul 2006
    Posts
    16,489
    Blog Entries
    75
    Rep Power
    143

    Re: Need Help. Graphics in C

    I'm guessing that means Windows.

    If you post what you have here, you are more likely to get assistance.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  6. #5
    Steve.L's Avatar
    Steve.L is offline Programming Expert
    Join Date
    Sep 2008
    Location
    Ottawa,ON
    Posts
    445
    Rep Power
    15

    Re: Need Help. Graphics in C

    The first question anyone will ask: Which operating system? Graphic programming is inherently system depending.
    Sorry I may get your question wrong (I am a rookie). I think the answer will be console application. Graphics using Turbo C++.
    Epic FAIL.

  7. #6
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Need Help. Graphics in C

    It also highly depends on what graphics library your teacher is using. What #includes do they have?

  8. #7
    Julia008 is offline Newbie
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    Re: Need Help. Graphics in C

    Thanks for replies so far.

    You're right WingedPanther, it is for windows.
    Here is the code for first program that teacher wrote:
    Code:
    void lineDDA(int x1,int y1,int x2,int y2)
    { int dx = x2 – x1;
      int dy = y2 – y1;
      int steps, k;
      float xIncrmnt, yIncrmnt,
        x = x1, y = y1;
       if (abs (dx) > abs (dy))
           steps = abs (dx);
      else 
           steps = abs (dy);
      xIncrmnt = dx / (float) steps;
      yIncrmnt = dy / (float) steps;
      putPixel (ROUND(x), ROUND(y));
      for (k=0; k<steps; k++) {
        x += xIncrmnt;
        y += yIncrmnt;
        putPixel (ROUND(x), ROUND(y));
      }
    }
    (As you can see, it is just the logic for generating a line, there is no graphics added to this code. I don't know where to add the code to make it work.)

    for #incluedes, I guess it will be:
    #include <math.h>
    #include <graphics.h>
    #include <conio.h>
    #include <stdio.h>
    Last edited by WingedPanther; 10-31-2008 at 05:55 AM. Reason: add code tages (the # button)

  9. #8
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Need Help. Graphics in C

    Whooo, boy. That's an old library. The code to draw the lines is there ( see the putPixel() call?) but the library is so old it doesn't--or at least shouldn't--work anymore. Unless you're running an old version of Windows.

  10. #9
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Need Help. Graphics in C

    I found this somewhere:

    Code:
     /* request auto detection */
       int gdriver = DETECT, gmode, errorcode;
       int midx, midy, i;
       /* initialize graphics and local
          variables */A
       initgraph(&gdriver, &gmode, "");
       /* read result of initialization */
       errorcode = graphresult();
       if (errorcode != grOk)  /* an error
           occurred */
    
        //do your thing here
    
        //clean up
        closegraph();
    Borland C - graphics.h

  11. #10
    Steve.L's Avatar
    Steve.L is offline Programming Expert
    Join Date
    Sep 2008
    Location
    Ottawa,ON
    Posts
    445
    Rep Power
    15

    Re: Need Help. Graphics in C

    graphics.h isn't standard, so make sure you have it...

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. graphics in c++
    By thapchi in forum C and C++
    Replies: 6
    Last Post: 03-08-2010, 06:15 PM
  2. Graphics in VB.NET Part 2 - Graphics
    By Vswe in forum Visual Basic Tutorials
    Replies: 4
    Last Post: 11-07-2009, 06:03 PM
  3. Need some graphics help
    By HowdyDoody in forum General Programming
    Replies: 1
    Last Post: 09-28-2009, 06:20 PM
  4. Graphics?
    By Andrew.G in forum Python
    Replies: 7
    Last Post: 07-03-2009, 10:23 AM
  5. Graphics in C++
    By Kaabi in forum General Programming
    Replies: 3
    Last Post: 11-12-2007, 02:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts