i am just start Computer grahics. that is my first program please help me
#include <GL/glut.h>
void DrawPixels();
void OurPixelsDrawingFunction();
void SetView();
void SetView(int w, int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
}
void DrawPixels()
{
glClearColor(1.0,1.0,1.0,0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
gluOrtho2D (0.0,600.0,0.0,600.0);
OurPixelsDrawingFunction();
void OurPixelsDrawingFuntion()
{
glColor3f(0,1,0);
/*Set current pixels drwaing color to green*/
glPointSize(10);
/* Sets the pixel size to 10 units*/
glBegin(GL_POINTS);
/* Tells the Open GL that we want to draw points, similarly we can tell OpenGL
that we want to draw lines using GL_LINES and then we will use line drawing
functons.*/
/*====================================================================*/
/* Drawing one horizental line covering full window (0 to 600) */
/* at Y = 100 and x from 0 to 600 */
/*====================================================================*/
for(int i = 0; i <= 600; i++)
glVertex2i(i,100);
/*=========================================================================*/
/*=========================================================================*/
/* Drawing only one pixel of blue color form zero
/*=========================================================================*/
glColor3f(0,0,1);
glVertex2i(140,120);
/*=========================================================================*/
/*=========================================================================*/
/* Drawing one Vertical line of four pixels for fourd */
/*=========================================================================*/
glColor3f(0,1,0);
glVertex2i(160,120);
glVertex2i(160,140);
glVertex2i(160,160);
glVertex2i(160,180);
/*=========================================================================*/
/*=========================================================================*/
/* Draewing only one pixel of blue color for Zero */
/*=========================================================================*/
glColor3f(0,0,1);
glVertex2i(180,120);
/*=========================================================================*/
/*=========================================================================*/
/* Drawing one Vertical line of Two pixels for two */
/*=========================================================================*/
glColor3f(0,1,0);
glVertex2i(200,120);
glVertex2i(200,140);
/*=========================================================================*/
/*=========================================================================*/
/* Drawing only one Pixel of blue color for zero */
/*=========================================================================*/
glColor3f(0,0,1);
glVertex2i(220,120);
/*=========================================================================*/
/*=========================================================================*/
/* Drawing only one pexel of blue color for zero */
/*=========================================================================*/
glColor3f(0,0,1);
glVertex2i(240,120);
/*=========================================================================*/
/*=========================================================================*/
/* Drawing one Vertical line of two pexels for two */
/*=========================================================================*/
glColor3f(0,1,0);
glVertex2i(260,120);
glVertex2i(260,140);
/*=========================================================================*/
/*=========================================================================*/
/* drawing one Vertical line of five pixels for five */
/*=========================================================================*/
glColor3f(0,1,0);
glVertex2i(280,120);
glVertex2i(280,140);
glVertex2i(280,160);
glVertex2i(280,180);
glVertex2i(280,200);
/*=========================================================================*/
/*=========================================================================*/
/* Drawing only one pexel of blue color for zero
/*=========================================================================*/
glColor3f(0,0,1);
glVertex2i(300,120);
/*=========================================================================*/
/*=========================================================================*/
/* We can use loops if we want to for this purpose as well.*/
/*=========================================================================*/
glEnd();
/* tells Open GL that we have finished drawing pixels*/
/*=========================================================================*/
/* Writng Text */
/*=========================================================================*/
/*===========Write your Id=================================================*/
glRasterPos2i(140,80);
/* this pixels are wrtien using raster mod see the handouts of Lecture no. 3
for more details. In this mode we have fexed no. of horizontal and vertical
lines we can't draw pexels using this mode
*/
char id[12] = "bc040200250";
int id_count = (int)strlen (id);
for (int i=0; i < id_count; i++)
{
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, id[i]);
}
glFlush();
/* this command out put pexels on the screen without this commmand the pixels
will not be displayed to the screen*/
}
/*/////////////////////////////////////////////////////////////////////////////
//
This is reshape function mean that this function is called whenever we resizw//
our window and in this fuction we are adjusting the contents of our window //
according to its new size. This function can be used in any graphics program //
and you don't need to understand it thoroughly at this moment,*/ //
/////////////////////////////////////////////////////////////////////////////*/
/*/////////////////////////////////////////////////////////////////////////*/
int main (int argc ,char ** argv)
{
glutInit(&argc,argv);
glutInitWindowSize(800,600);
glutCreateWindow ("-----bc040200250.........Your Name------");
glutDisplayFunc(DrawPixels);
glutReshapeFunc(SetView);
glutMainLoop ();
return 0;
}