Hello everyone,
Currently I wanted to display random points on openGL window to get more real time effect (same as data from sensor)
So basically it should continuously display new points which will be there in glVertex2i(n,n1) function.
I am not able to see any thing on OpenGL window after writing below code.
Could you please suggest me any function for this task.
#include<stdio.h>
#include <cstring>
#include <stdlib.h>
#include <GL/freeglut.h>
#include <GL/gl.h>
#include <time.h>
int main(int argc, char** argv)
{
void renderFunction(void);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(100,100);
glutCreateWindow("OpenGL - First window demo");
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glClearColor(1,1,1,1);
gluOrtho2D(0,500,0,500);
glutDisplayFunc(renderFunction);
glutMainLoop();
return 0;
}
void renderFunction()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glPointSize(5);
glBegin(GL_POINTS);
int n,n1;
while(1)
{
n = rand() % (500 + 1-100)+100;
n1= rand() % (500 + 1-100)+100;
//printf("%d
", n);
printf("a=%d b=%d
",n,n1);
glVertex2i(n,n1);
glEnd();
}
glFlush();
}