You are on page 1of 1

//Point drawing on openGL

#include <GL/glut.h>//openGL header files


#include <stdlib.h>//standard library header files
void myInit(void)
{
glClearColor(0.9,2,0.28,0);//Use to spacify the color for the window(RGB)

glPointSize(10.0); //specify the size of the point in pixel


glMatrixMode(GL_PROJECTION);//start drawing the graphics
glLoadIdentity();//used to start to clear previous back_ground objects
gluOrtho2D(-30.0,400.0,-300.0,400.0);//change the position of points(Right,
Left, Bottom, Top
}
void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT);//Used to clear previous back_ground
color and change the color of the window
glBegin(GL_QUADS );//Used to specify the object to be create
//Its posible to change the value in the bracket to one of the
following
//GL_POINTS, GL_LINES, GL_POLYGON, GL_LINE_STRIP, GL_LINE_LOOP,
GL_TRIANGLES, GL_QUADS
glColor3f(1.0,0.0,0.0);//specify the color of the points
glVertex2i(300,100);//x and y cordinate
glColor3f(0.15,2,28);//specify the color of the points
glVertex2i(100,300);
glColor3f(0.0,1.0,0.0);//specify the color of the points
glVertex2i(-30,100);
glColor3f(20.0,1.0,1.0);//specify the color of the points
glVertex2i(50,0);
glEnd();
glFlush();
}
int main(int argc, char** argv)
{ glutInit(&argc, argv);
glutInitWindowSize(500,500);//Used to specify the size of the
window
glutInitWindowPosition(100,200);//Used to change the position of
the window
glutCreateWindow("Point In lab");//Used to create window with
title
glutDisplayFunc(Display);
myInit();//calls the function void myInit
glutMainLoop();//put the OpenGL graphics system to wait for
events (such as re-paint), and trigger respective event handlers (such as
display()).

return 0;
}

You might also like