Program:
#include<GL/glut.h> void MyInit() { glClearColor(1,1,1,1); // Seting Background Color White with full trasparent glColor3f(1,0,0); // Changing Drawing Color to Red } void draw() { glClear(GL_COLOR_BUFFER_BIT); //To Clear the frame buffer glOrtho(0,500,500,0,0,1); // Produces an Oblique Projection // glOrtho(left,windowwidth,windowheight,top,near,far) glPointSize(5); // to set the point size glBegin(GL_LINES); // To group the points glVertex2f(50,50); // To draw x and y Points glVertex2f(450,450); glEnd(); glFlush(); // To Put Changed Pixel in Frame Buffer } int main(int argc,char **argv) // argc -> argument counter { // argv -> argument vector glutInit(&argc,argv); // Initialization glutInitWindowSize(500,500); // Specifying Windows Size glutInitWindowPosition(100,50); // Chaning Window Position glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE); // Work in RGB color mode and Single Index Color glutCreateWindow("Basic Program"); // Create a Window to Diplay Graphics MyInit(); glutDisplayFunc(draw); // To display an object calling a function glutMainLoop(); // To Make Our Window Active Continously return 0; }
Output:
To Run the Program: $ g++ main.c -lglut -lGL -lGLEW -lGLU -o OpenGLExample