3. Course Content
• Introduction to Graphics Programming in C
• Points, Lines and Polygons
• Line Drawing Algorithms
• Circle Drawing Algorithms
• Area Filling Algorithms
• Geometric Transformations in 2D
• Geometric Transformations in 3D
• Line Clipping Algorithms in 2D
• Line Clipping Algorithms in 3D
5. Graphics Header File
• Go to File New
• Type initgraph in the new window and right click on it
• There you will find a program and using it lets try to create a
header file to initialize and exit graphics mode
• Open another file and save it as grap.h
9. The First Program
• Open a new file and save it as first.c
• There you have to include the grap.h header file that had been
created earlier
• Then your first program should look like as follows and
running it will give a black and empty screen
#include<stdio.h>
#include<conio.h>
#include"D:/GP/header/grap.h"
void main()
{
ginit();
getch();
gexit();
}
10. The Output Screen
• Execute following code to get the maximum x and maximum y
values of the output screen
#include<stdio.h>
#include<conio.h>
#include"D:/GP/header/grap.h"
void main()
{
ginit();
printf("%d %d",getmaxx(),getmaxy());
getch();
gexit();
}
14. Approximating x and y Coordinates
int dpx(double x)
{
int p;
p=(int)(x+0.5);
return p;
}
int dpy(double y)
{
int p;
p=(int)(y+0.5);
p=getmaxy()-p;
return p;
}
15. Displaying a Point
void main()
{
ginit();
putpixel(dpx(50.2),dpy(70.7),15);
getch();
gexit();
}