Friday, 20 March 2020

Implement Cohen Sutherland Hodgman algorithm to clip any given polygon. Provide the vertices of the polygon to be clipped and pattern of clipping interactively

//#include <windows.h>
#include <GL/glut.h>

struct Point
{

    float x,y;
} w[4],oVer[4];
int Nout;   

void drawPoly(Point p[],int n)
{
    glBegin(GL_POLYGON);           
    for(int i=0;i<n;i++)
        glVertex2f(p[i].x,p[i].y);   
    glEnd();
}

bool insideVer(Point p)
{   
        if((p.x>=w[0].x)&&(p.x<=w[2].x))       
        if((p.y>=w[0].y)&&(p.y<=w[2].y))
        return true;               
        return false;       
}

void addVer(Point p){       
    oVer[Nout]=p;       
    Nout=Nout+1;
}

Point getInterSect(Point s,Point p,int edge)
{
    Point in;           
    float m;
    if(w[edge].x==w[(edge+1)%4].x)
      {
//Vertical Line       
        m=(p.y-s.y)/(p.x-s.x);   
        in.x=w[edge].x;               
        in.y=in.x*m+s.y;
    }
    else
{
//Horizontal Line           
        m=(p.y-s.y)/(p.x-s.x);   
        in.y=w[edge].y;
        in.x=(in.y-s.y)/m;       
    }   
    return in;
}

void clipAndDraw(Point inVer[],int Nin){
    Point s,p,interSec;   
    for(int i=0;i<4;i++)
    {
        Nout=0;
        s=inVer[Nin-1];
        for(int j=0;j<Nin;j++)
        {           
            p=inVer[j];
            if(insideVer(p)==true)
               {               
                if(insideVer(s)==true){
                    addVer(p);                                   
                }
                else
                 {
                    interSec=getInterSect(s,p,i);
                    addVer(interSec);                   
                    addVer(p);                   
                }
            }
            else
               {       
                if(insideVer(s)==true){
                    interSec=getInterSect(s,p,i);               
                    addVer(interSec);                                                   
                }
            }
            s=p;           
        }       
        inVer=oVer;       
        Nin=Nout;   
    }   
    drawPoly(oVer,4);
}

void init(){
    glClearColor(0.0f,0.0f,0.0f,0.0f);
    glMatrixMode(GL_PROJECTION);       
    glLoadIdentity();   
    glOrtho(0.0,100.0,0.0,100.0,0.0,100.0);
    glClear(GL_COLOR_BUFFER_BIT);   
    w[0].x =20,w[0].y=10;
    w[1].x =20,w[1].y=80;
    w[2].x =80,w[2].y=80;
    w[3].x =80,w[3].y=10;
}
void display(void){   
    Point inVer[4];
    init();
    // As Window for Clipping
    glColor3f(1.0f,0.0f,0.0f);       
    drawPoly(w,4);
    // As Rect
    glColor3f(0.0f,1.0f,0.0f);
    inVer[0].x =10, inVer[0].y=40;
    inVer[1].x =10, inVer[1].y=60;
    inVer[2].x =60, inVer[2].y=60;
    inVer[3].x =60, inVer[3].y=40;
    drawPoly(inVer,4);
    // As Rect
    glColor3f(0.0f,0.0f,1.0f);
    clipAndDraw(inVer,4);       
    // Print
    glFlush();
}

int main(int argc,char *argv[]){
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(400,400);
    glutInitWindowPosition(100,100);
    glutCreateWindow("Polygon Clipping!");
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}

Draw a 4X4 chessboard rotated 45˚ with the horizontal axis. Use Bresenham algorithm to draw all the lines. Use seed fill algorithm to fill black squares of the rotated chessboard

#include <GL/glut.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<stdio.h>
#define PI 3.14159265/180
using namespace std;
float rtri=0.0f;
int ww=660,wh=660; 
int xi,yi,xf,yf,xx,yy;
float fillcol[3]={0.9,0.0,0.2};
float bordercol[3]={0.0,0.0,0.0};
void setpixel(int pointx,int pointy,float f[3])
{
glBegin(GL_POINTS);
glColor3f(f[0],f[1],f[2]);
glVertex2d(pointx,pointy);
glEnd();
glFlush();
}
void getpixel(int x,int y,float pixels[3])
{
glReadPixels(x,y,1.0,1.0,GL_RGB,GL_FLOAT,pixels);
}
int sign(float arg)
{
if(arg<0)
return -1;
else if(arg==0)
return 0;
else
return 1;
}
double calx(double xold,double yold,double angle)
{
double xnew;
xnew=xold*cos(PI*angle)-yold*sin(PI*angle);
return xnew;
}
double caly(double xold,double yold,double angle)
{
double ynew;
ynew=xold*sin(PI*angle)+yold*cos(PI*angle) ;
return ynew;
}
void Bre(int X1,int Y1,int X2,int Y2,double angle)
{
 double xold=0,yold=0;
 double xnew=0,ynew=0;
xold=X1;
yold=Y1;
xnew=calx(xold,yold,angle);
ynew=caly(xold,yold,angle);
X1=(int)xnew;
   Y1=(int)ynew;
xold=X2;
yold=Y2;
xnew=xold*cos(PI*angle)-yold*sin(PI*angle) ;
ynew=xold*sin(PI*angle)+yold*cos(PI*angle) ;
X2=(int)xnew;
Y2=(int)ynew;
  float dx=abs(X2-X1);
 float dy=abs(Y2-Y1);
 int s1,s2,exc,y,x,i;
  float g,temp;
x=X1;
y=Y1;
s1=sign(X2-X1);
s2=sign(Y2-Y1);
glBegin(GL_POINTS); // Plot the points
//rotate 45 on x axis
if(dy>dx)
{
temp=dx;
dx=dy;
dy=temp;
exc=1;
}
else
{
exc=0;
}
g=2*dy-dx;
i=1;
while(i<=dx)
{
glVertex2d(x,y);
while(g>=0)
{
if(exc==1)
x=x+s1;
else
y=y+s2;
g=g-2*dx;
}
if(exc==1)
y=y+s2;
else
x=x+s1;
g=g+2*dy;
i++;
}
 glEnd();
glFlush();
}
void display() 
  { 
double angle=45;
glClearColor(1.0,1.0,1.0,0); // Set Background color to white
glColor3f(0.0,0.0,0.0);
glViewport(0,0,1360,760);
glLoadIdentity();
gluOrtho2D(0 , 1360 , 0 , 760);       
glClear(GL_COLOR_BUFFER_BIT);
Bre(300,00,500,00,angle);
Bre(300,00,300,200,angle);
Bre(500,200,300,200,angle);
Bre(500,200,500,00,angle);//outer
Bre(300,50,500,50,angle);
Bre(300,100,500,100,angle);
Bre(300,150,500,150,angle);//outer
Bre(350,00,350,200,angle);
Bre(400,00,400,200,angle);
Bre(450,00,450,200,angle);//outer
angle=0;
Bre(300,00,500,00, angle);
Bre(300,00,300,200, angle);
Bre(500,200,300,200, angle);
Bre(500,200,500,00, angle);
Bre(300,50,500,50, angle);
Bre(300,100,500,100,angle);
Bre(300,150,500,150,angle);//outer
Bre(350,00,350,200, angle);
Bre(400,00,400,200, angle);
Bre(450,00,450,200, angle);//outer
}
void bfill(int x,int y,float fillcolor[3],float bordercolor[3])
{
float inter_color[3];
getpixel(x,y,inter_color);
if((inter_color[0]!=bordercolor[0]&&inter_color[1]!=bordercolor[1]&&inter_color[2]!=bordercolor[2])&&(inter_color[0]!=fillcolor[0]&&inter_color[1]!=fillcolor[1]&&inter_color[2]!=fillcolor[2]))
{
setpixel(x,y,fillcolor);
bfill(x+1,y,fillcolor,bordercolor);
bfill(x-1,y,fillcolor,bordercolor);
bfill(x,y+1,fillcolor,bordercolor);
bfill(x,y-1,fillcolor,bordercolor);
}
}
 void mouse(int btn,int state,int x,int y) 
  { 
     if(btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN) 
     { 
              xi=x; 
               yi=wh-y;
printf("\nPoints collected are:%d and %d",xi,yi);
bfill(xi,yi,fillcol,bordercol);   
     }
  }

 int main(int argc,char** argv) 
 {
glutInit(&argc,argv); 
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); 
glutInitWindowSize(ww,wh);
glutInitWindowPosition(0,0);
glutCreateWindow("CheckBox(Click on any box to fill color)"); 
glutDisplayFunc(display); 
glutMouseFunc(mouse); 
glutMainLoop(); 
return 0;
  } 

Draw the polygons by using the mouse. Choose colors by clicking on the designed color pane

#include<iostream>
#include<GL/glut.h>
#include<math.h>
#define w 500
#define h 500

using namespace std;
float a[30][2];
int k=0;

void myMouse(GLint button,GLint state,GLint x,GLint y)
{

if(state==GLUT_DOWN)
{
if(button==GLUT_LEFT_BUTTON)
{
a[k][0]=(float)(x-250);
a[k][1]=(float)(250-y);

glBegin(GL_POINTS);
glVertex2f(a[k][0],a[k][1]);
glEnd();
k++;
glFlush();
}
if(button==GLUT_RIGHT_BUTTON)
{
glBegin(GL_LINE_LOOP);
for(int i=0;i<k;i++)
{
glVertex2f(a[i][0],a[i][1]);
}
glEnd();
k=0;
glFlush();

}
}
}
void menu(GLint item)
{
if(item==1)
{
       glColor3f(1.0,0.0,0.0);
       glutMouseFunc(myMouse);
}
if(item==2)
{
glColor3f(0.0,1.0,0.0);
glutMouseFunc(myMouse);
}
if(item==3)
{
glColor3f(0.0,0.0,1.0);
glutMouseFunc(myMouse);
}
if(item==4)
{
glColor3f(0.0,1.0,1.0);
glutMouseFunc(myMouse);
}

}


void myInit()
{
glClearColor(1.0,1.0,1.0,0.0);
glColor3f(0.0f,0.0f,0.0f);
glMatrixMode(GL_PROJECTION);
glPointSize(5);
glLoadIdentity();
gluOrtho2D(-w/2,w/2,-h/2,h/2);
glClear(GL_COLOR_BUFFER_BIT);

}
int main(int argc,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(500,500);
glutCreateWindow("POLYGON(First Middle Click->Then LEft Clicks->Then Right Clicks)");
myInit();

    glutCreateMenu(menu);
    glutAddMenuEntry("RED",1);
    glutAddMenuEntry("GREEN",2);
    glutAddMenuEntry("BLUE",3);
    glutAddMenuEntry("CYAN",4);
    glutAttachMenu(GLUT_MIDDLE_BUTTON);
    glutMainLoop();

}

Wednesday, 11 January 2017

Draw inscribed and Circumscribed circles in the triangle by using Bresenham circle and bresenham Line Alorithm

Program:


  #include<stdio.h> 
  #include<GL/glut.h> 
  #include<math.h> 
  int ww=1200,wh=800; 
  int xi,yi,xf,yf,r;
  float theta=2.0933;

 void putpixel(int x,int y) 
  { 
       glBegin(GL_POINTS); 
       glVertex2i(x,y); 
       glEnd(); 
       glFlush(); 
  } 
  double round(double n) 
  { 
       return (n>=0)?(int)(n+0.5):(int)(n-0.5); 
  } 
  void Bresenham_circle(int xc, int yc, int xr) 
  { 
        int x=0,y=xr;
        int d=3-2*y;
        while(x<=y){ 
        putpixel(x+xc, y+yc); 
        putpixel(xc+y, yc+x); 
        putpixel(xc-x, yc+y); 
        putpixel(xc-x, yc-y); 
        putpixel(xc-y, yc+x); 
        putpixel(xc-y, yc-x); 
        putpixel(xc+y, yc-x); 
        putpixel(xc+x, yc-y); 
            if(d<0) 
                 d=d+(4*x)+6; 
            else{ 
                 d=d+(4*(x-y))+10; 
                 y--; 
            } 
            x++; 
       } 
  } 

 void bresenhamAlg (int x0, int y0, int x1, int y1) 
  { 
  int dx = abs (x1 - x0); 
  int dy = abs (y1 - y0); 
  int x, y; 
  if (dx >= dy) 
  { 
   int d = 2*dy-dx; 
   int ds = 2*dy; 
   int dt = 2*(dy-dx); 
       if (x0 < x1)  
       { 
            x = x0; 
            y = y0; 
       } 
        else 
        {  
             x = x1; 
             y = y1; 
             x1 = x0; 
             y1 = y0; 
        } 
       putpixel (x, y); 
   while (x < x1) 
   { 
        if (d < 0) 
        d += ds; 
        else { 
             if (y < y1) { 
              y++; 
              d += dt; 
             }  
             else { 
              y--; 
              d += dt; 
             } 
            } 
   x++; 
        putpixel (x, y); 
       }  }
       else {  
             int d = 2*dx-dy; 
             int ds = 2*dx; 
             int dt = 2*(dx-dy); 
             if (y0 < y1) { 
             x = x0; 
             y = y0; 
             } 
             else {  
             x = x1; 
             y = y1; 
             y1 = y0; 
             x1 = x0; 
             } 
            putpixel (x, y);  
        while (y < y1) 
        { 
              if (d < 0) 
                 d += ds; 
              else { 
                      if (x > x1){ 
                      x--; 
                      d += dt; 
                 } else { 
                      x++; 
                      d += dt; 
                   } 
              } 
              y++;
              putpixel (x, y); 
        } 
       } 
  } 
 void triangle (int ix , int iy)
 {
    int x=ix, y=iy,x1,x2,y1,y2;
    x1=xi+(x-xi)*cos(theta)-(y-yi)*sin(theta);
    y1=yi-r/2;
    x2=xi+(x-xi)*cos(theta)+(y-yi)*sin(theta);
    y2=yi-r/2;;
    bresenhamAlg (x, y, x1, y1);
    bresenhamAlg (x, y, x2, y2);
    bresenhamAlg (x1, y1, x2, y2);
 }
 void display() 
  { 
        glClearColor(0.4,0.7,0.2,1.0); 
        glColor3f(0.5,0.3,0.0); 
        glClear(GL_COLOR_BUFFER_BIT); 
        glutSwapBuffers();
        Bresenham_circle(xi,yi,r);
        Bresenham_circle(xi,yi,r/2);
        triangle(xi,(yi+r));
        glFlush(); 
  } 
 

  void myinit() 
  { 
        glViewport(0,0,ww,wh); 
        glMatrixMode(GL_PROJECTION); 
        glLoadIdentity(); 
        gluOrtho2D(0.0,(GLdouble)ww,0.0,(GLdouble)wh); 
        glMatrixMode(GL_MODELVIEW); 
  } 
  int main(int argc,char** argv) 
  { 
    printf("enter centre of the circle");
    scanf("%d%d",&xi,&yi);
    printf("\nenter radius of circle");
    scanf("%d",&r);      
    glutInit(&argc,argv); 
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); 
    glutInitWindowSize(ww,wh); 
    glutCreateWindow("Bresenham-Circle"); 
    myinit();
    glutDisplayFunc(display); 
    glutMainLoop(); 
    return 0; 
  } 



Output:

Draw the pattern using BRESENHAM Line drawing algorithms using MOUSE in OpenGL


 Program:

#include <GL/glut.h> 
#include <math.h> 
int ww = 600, wh = 400; 
int first = 0; 
int xi, yi, xf, yf; 
void putPixel (int x, int y) 

   glBegin (GL_POINTS); 
   glVertex2i (x, y); 
   glEnd (); 
   glFlush ();
  } 
  void display() 
  { 
   glClearColor(0.4, 0.7, 0.5, 1.0); 
   glClear(GL_COLOR_BUFFER_BIT); 
   glFlush(); 
  } 
  void bresenhamAlg (int x0, int y0, int x1, int y1) 
  { 
  int dx = abs (x1 - x0); 
  int dy = abs (y1 - y0); 
  int x, y; 
  if (dx >= dy) 
  { 
   int d = 2*dy-dx; 
   int ds = 2*dy; 
   int dt = 2*(dy-dx); 
       if (x0 < x1)  
       { 
            x = x0; 
            y = y0; 
       } 
        else 
        {  
             x = x1; 
             y = y1; 
             x1 = x0; 
             y1 = y0; 
        } 
       putPixel (x, y); 
   while (x < x1) 
   { 
        if (d < 0) 
        d += ds; 
        else { 
             if (y < y1) { 
              y++; 
              d += dt; 
             }  
             else { 
              y--; 
              d += dt; 
             } 
            } 
   x++; 
        putPixel (x, y); 
       }  }
       else {  
             int d = 2*dx-dy; 
             int ds = 2*dx; 
             int dt = 2*(dx-dy); 
             if (y0 < y1) { 
             x = x0; 
             y = y0; 
             } 
             else {  
             x = x1; 
             y = y1; 
             y1 = y0; 
             x1 = x0; 
             } 
            putPixel (x, y);  
        while (y < y1) 
        { 
              if (d < 0) 
                 d += ds; 
              else { 
                      if (x > x1){ 
                      x--; 
                      d += dt; 
                 } else { 
                      x++; 
                      d += dt; 
                   } 
              } 
              y++; 
              putPixel (x, y); 
        } 
       } 
  } 
       void mouse(int btn, int state, int x, int y) 
       { 
        if(btn==GLUT_LEFT_BUTTON && state == GLUT_DOWN) 
        { 
        switch(first) 
        { 
        case 0: 
         xi = x; 
         yi = (wh-y); 
         first = 1; 
         break; 
        case 1: 
         xf = x; 
         yf = (wh-y); 
        
glColor3f(1.0,0.0,0.0);
    bresenhamAlg(xi,yi,xi,yf);
    bresenhamAlg(xi,yf,xf,yf);
    bresenhamAlg(xf,yf,xf,yi);
    bresenhamAlg(xf,yi,xi,yi);
 glColor3f(0.0,1.0,0.0);
    bresenhamAlg(xi,(yi+yf)/2,(xi+xf)/2,yf);
    bresenhamAlg((xi+xf)/2,yf,xf,(yi+yf)/2);
    bresenhamAlg(xf,(yi+yf)/2,(xi+xf)/2,yi);
    bresenhamAlg((xi+xf)/2,yi,xi,(yi+yf)/2);   
 glColor3f(0.0,0.0,1.0);
    bresenhamAlg((xi+(xi+xf)/2)/2,(yf+(yi+yf)/2)/2,(xf+(xi+xf)/2)/2,(yf+(yi+yf)/2)/2);
    bresenhamAlg((xf+(xi+xf)/2)/2,(yf+(yi+yf)/2)/2,(xf+(xi+xf)/2)/2,(yi+(yi+yf)/2)/2);
    bresenhamAlg((xf+(xi+xf)/2)/2,(yi+(yi+yf)/2)/2,(xi+(xi+xf)/2)/2, (yi+(yi+yf)/2)/2);
    bresenhamAlg((xi+(xi+xf)/2)/2, (yi+(yi+yf)/2)/2,(xi+(xi+xf)/2)/2,(yf+(yi+yf)/2)/2); 
         first = 0; 
         break;  
        } 
        } 
       } 
  void myinit() 
  {       
     glViewport(0,0,ww,wh); 
     glMatrixMode(GL_PROJECTION); 
     glLoadIdentity(); 
     gluOrtho2D(0.0,(GLdouble)ww,0.0,(GLdouble)wh); 
     glMatrixMode(GL_MODELVIEW); 
  } 
  int main(int argc, char** argv) 
  { 
     glutInit(&argc,argv); 
     glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); 
     glutInitWindowSize(ww,wh); 
     glutCreateWindow("Bresenham Line Algorithm With Mouse"); 
     glutDisplayFunc(display); 
     myinit(); 
     glutMouseFunc(mouse); 
     glutMainLoop(); 
     return 0; 
  } 

Output:

Tuesday, 10 January 2017

Draw the pattern using DDA Line drawing algorithm with KeyBoard in OpenGL

Program:
#include<stdio.h>
#include<GL/glut.h>
#include<math.h>
int xx1,xx2,yy1,yy2;
int sign(int x)
{
    if(x > 0) return 1;
    if(x < 0) return -1;
    return 0;
}
void drawline(int X1,int Y1, int X2,int Y2)  
{
    float x,y,dx,dy,length;
    int i;
    dx=abs(X2-X1);
    dy=abs(Y2-Y1);
    if(dx>=dy)
        length=dx;
    else
        length=dy;
    dx=(X2-X1)/length;
    dy=(Y2-Y1)/length;
    x=X1 + 0.5*sign(X1);
    y=Y1 + 0.5*sign(Y1);
    i=1;
    while(i<=length)
    {
   
                 glBegin(GL_POINTS);
             glVertex2i(x,y);
             glEnd();
                 glFlush();
        x=x+dx;
        y=y+dy;
        i=i+1;
    }
    glFlush();
}
  
void display(void)                            
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0,0.0,0.0);
    drawline(xx1,yy1,xx1,yy2);
    drawline(xx1,yy2,xx2,yy2);
    drawline(xx2,yy2,xx2,yy1);
    drawline(xx2,yy1,xx1,yy1);
     glColor3f(0.0,1.0,0.0);
    drawline(xx1,(yy1+yy2)/2,(xx1+xx2)/2,yy2);
    drawline((xx1+xx2)/2,yy2,xx2,(yy1+yy2)/2);
    drawline(xx2,(yy1+yy2)/2,(xx1+xx2)/2,yy1);
    drawline((xx1+xx2)/2,yy1,xx1,(yy1+yy2)/2);  
     glColor3f(0.0,0.0,1.0);
    drawline((xx1+(xx1+xx2)/2)/2,(yy2+(yy1+yy2)/2)/2,(xx2+(xx1+xx2)/2)/2,(yy2+(yy1+yy2)/2)/2);
    drawline((xx2+(xx1+xx2)/2)/2,(yy2+(yy1+yy2)/2)/2,(xx2+(xx1+xx2)/2)/2,(yy1+(yy1+yy2)/2)/2);
    drawline((xx2+(xx1+xx2)/2)/2,(yy1+(yy1+yy2)/2)/2,(xx1+(xx1+xx2)/2)/2, (yy1+(yy1+yy2)/2)/2);
    drawline((xx1+(xx1+xx2)/2)/2, (yy1+(yy1+yy2)/2)/2,(xx1+(xx1+xx2)/2)/2,(yy2+(yy1+yy2)/2)/2);  

}
void init(void)
{
       glViewport(0,0,640,480); 
       glMatrixMode(GL_PROJECTION); 
       glLoadIdentity(); 
       gluOrtho2D(0.0,640.0,0.0,480.0); 
       glMatrixMode(GL_MODELVIEW);    
}
int main(int argc,char** argv)
{
    printf("\n Enter vertex x1 ");
        scanf("%d",&xx1);
        printf("\n Enter vertex y1 ");
        scanf("%d",&yy1);
        printf("\n Enter vertex x2 ");
        scanf("%d",&xx2);
        printf("\n Enter vertex y2 ");
        scanf("%d",&yy2);
        glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(640,480);
    glutInitWindowPosition(0,0);
    glutCreateWindow("DDA Line");
    init();
    glClear(GL_COLOR_BUFFER_BIT);
    glutDisplayFunc(display);
    glFlush();
    glutMainLoop();
    return 0;
}

Output:

 

How to Install OpenGL in Ubuntu

Prerequisite : Internet Connection

To install OpenGL on system you need to install some basic packages. Open terminal and execute the following commands on terminal.
Step 1: sudo apt-get update 
             To update your basic packages
Step 2: sudo apt-get install build-essential
              For installing essential packages.
Step 3: sudo apt-get install freeglut3 freeglut3-dev
Step 4: sudo apt-get install binutils-gold
Step 5: sudo apt-get install g++ cmake
Step 6: sudo apt-get install mesa-common-dev mesa-utils
Step 7: sudo apt-get install libglew-dev libglew1.5-dev libglm-dev
Step 8: glxinfo | grep OpenGL


Now you are ready to compile your program!
● Write your program using any editor and save.
● Open the terminal for the specified folder and then run with:
gcc MyProg.c -lGL -lGLU -lglut (for C program)
g++ MyProg.cpp -lGL -lGLU -lglut (for C++ program)
./a.out

● Once all this installation process is done, you don't need to follow this process again and again. Just
compile and execute the program.