/* 
   Copyright (C) 1999 E. H. Haley

   draws a slightly random dirichlet domain mosaic, using the
   z-buffered-cones GL hack.
   
   (Apparently there's a stencil buffer version that screams.  That'll
   be in the next rev.)
*/

#include <GL/glut.h>
#include <X11/Xlib.h>
#include <stdlib.h> //for random
#include <stdio.h>

void display(void)
{
  int i,j;

  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
  glPushMatrix();

  for(i=-5; i<5; i++)
    for(j=-5; j<5; j++)
      {
	glLoadIdentity();
	glTranslatef(((float)i+(float)random()/(float)RAND_MAX)/5.0,
		     ((float)j+(float)random()/(float)RAND_MAX)/5.0,
		     0.0);
	glColor3f((float)random()/(float)RAND_MAX,
		  (float)random()/(float)RAND_MAX,
		  (float)random()/(float)RAND_MAX);
	glutSolidCone(0.3,-0.1,20,1);
      }
  glPopMatrix();
  glFlush();
}

void mouse(int button, int state, int x, int y)
{
  exit(0);
}

int main(int aardc, char **aardv)
{
  glutInit(&aardc, aardv);

  glutInitDisplayMode( GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH );
  glutInitWindowSize(200,200);
  glutCreateWindow("DC");
  glutDisplayFunc(display);
  glutMouseFunc(mouse);

  glEnable(GL_DEPTH_TEST);
  glShadeModel(GL_FLAT);

  glutMainLoop();
  exit(0);
}

