Wednesday 18 September 2013

BASIC OPENGL PROGRAM

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

const int screenWidth=640;
const int screenHeight=480;


void myInit()
{
     glClearColor(1.0,1.0,1.0,0.0);
     glColor3f(1.0,0.0,0.0);
     glPointSize(3.0);
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     gluOrtho2D(0.0,(GLdouble)screenWidth,0.0,(GLdouble)screenHeight);

    
     }
    
     void myDisplay()
     {
          glClear(GL_COLOR_BUFFER_BIT);
         // glColor3f(0.0,0.0,1.0);
          glRecti(10,10,100,100);
          glFlush();
          }
                            

    
     int main(int argc, char **argv)
     {
         glutInit(&argc,argv);
         glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
         glutInitWindowSize(screenWidth,screenHeight);
         glutCreateWindow("drawing rectangles");
         glutDisplayFunc(myDisplay);
      
         myInit();
        
         glutMainLoop();
         }

No comments:

Post a Comment