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.
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++.
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
I'm guessing that means Windows.
If you post what you have here, you are more likely to get assistance.
The first question anyone will ask: Which operating system? Graphic programming is inherently system depending.Epic FAIL.Sorry I may get your question wrong (I am a rookie). I think the answer will be console application. Graphics using Turbo C++.
It also highly depends on what graphics library your teacher is using. What #includes do they have?
Thanks for replies so far.
You're right WingedPanther, it is for windows.
Here is the code for first program that teacher wrote:
(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.)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)); } }
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)
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.
I found this somewhere:
Borland C - graphics.hCode:/* 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();
graphics.h isn't standard, so make sure you have it...
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks