Wednesday 18 September 2013

OPENGL PROGRAM TO PLOT AND MEASURE RAND FUNCTION

#include<GL/glut.h>
#include<stdlib.h>
#include<math.h>
#define NUM 480

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(2.0);
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     gluOrtho2D(0.0,640.0,0.0,480.0);
     }
    


    void myDisplay()
    {
         glClear(GL_COLOR_BUFFER_BIT);
         GLint i=0;
         glBegin(GL_POINTS);
         for(i=0;i<5000;i++)
         glVertex2i((rand()+rand())%NUM,(rand()+rand())%NUM);
         glEnd();
         glFlush();
         }
          
         
          int main(int argc ,char **argv)
          {
               glutInit(&argc,argv);
               glutInitDisplayMode(GLUT_SINGLE| GLUT_RGB );
               glutInitWindowSize(640,480);
               //glutInitWindowPosition(200,200);
               glutCreateWindow("plot showing corelation of consecutive random values");
               glutDisplayFunc(myDisplay);
               myInit();
               glutMainLoop();
               }

No comments:

Post a Comment