#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;
#include <GL/glu.h>
#include <GL/glut.h>
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;
#define PARTICLE_SIZE 2000
void grid(){
int i = 0, j = 0;
glColor3f(0.89,0.99,0.79);
glBegin(GL_LINES);
//hoz line
for(i=0; i<= 10; i++){
glVertex2f(-0.1, i/10.0);
glVertex2f(1.0, i/10.0);
}
//verical line
for(j=0; j<=10; j++){
glVertex2f(j/10.0, -0.1);
glVertex2f(j/10.0, 1.0);
}
// coordinate line
glColor3f(0.0,1.0,0.0);
//hoz line
glVertex2f(-0.1, 0.0);
glVertex2f(1.0, 0.0);
// vertical line
glVertex2f(0.0, -0.1);
glVertex2f(0.0, 1.0);
glEnd();
}
void particle(){
glPointSize(1.0);
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_POINTS);
srand((unsigned) time(NULL));
int i=0;
for(i;i<PARTICLE_SIZE;i++){
float x = rand()*4.0/100000.00;
float y = rand()*5.0/100000.00;
glVertex2f(x, y);
//cout << x << " " << y << endl;
}
glEnd();
}
void init(){
glClearColor(1.0,1.0,1.0,1.0);
gluOrtho2D(-0.1,1,-0.1,1.0);
}
void display(){
glClear(GL_COLOR_BUFFER_BIT);
particle();
grid();
glFlush();
}
int main(int argc, char *argv[]){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowSize(400,300);
glutInitWindowPosition(200,100);
glutCreateWindow("Simulation App");
init();
glutDisplayFunc(display);
glutIdleFunc(display);
glutMainLoop();
return 0;
}
No comments:
Post a Comment