title: OpenGL particle system
body: <p>I'm trying to simulate a particle system using OpenGl but I can't get it to work, this is what I have so far:</p>
  
  <pre><code>#include &lt;GL/glut.h&gt;
  int main (int argc, char **argv){
  
    // data allocation, various non opengl stuff
    ............
    glutInit(&amp;argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE );
    glutInitWindowPosition(100,100);
    glutInitWindowSize(size, size);
    glPointSize (4);
    glutCreateWindow("test gl");
    ............
    // initial state, not opengl
    ............
    glViewport(0,0,size,size);
    glutDisplayFunc(display);
    glutIdleFunc(compute);
    glutMainLoop();
  
  
  }
  
  void compute (void) {
  
   // change state not opengl
  
    glutPostRedisplay();
  
  }
  
  void display (void) {
  
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POINTS);
  
    for(i = 0; i&lt;nparticles; i++) {
  
      // two types of particles
      if (TYPE(particle[i]) == 1) glColor3f(1,0,0);
        else glColor3f(0,0,1);
  
      glVertex2f(X(particle[i]),Y(particle[i]));
  
    }
  
    glEnd();
    glFlush();
    glutSwapBuffers();
  
  }
  </code></pre>
  
  <p>I get a black window after a couple of seconds (the window has just the title bar before that). Where do I go wrong?</p>
  
  <p><strong>LE:</strong> the x and y coordinates of each particle are within the interval (0,size)</p>