function init()
{
	this.angle = 0;
}

function update(dt)
{
	this.angle+=80.0*dt;
	if (this.angle >= 360.0)
		this.angle -= 360.0;
}

function render()
{
//	gl.Scale(3.0,3.0,3.0);

	gl.DisableDepthTest();
	gl.EnableBlend();

	gl.Translate(-1,-1,0);
	gl.Rotate(15,0,1,0);
	gl.Rotate(-45,1,0,0);

	var x=-2;
	var y=-2;
	var z=0;
	var nbx = 6;
	var nby = 6;
	var grey=0;
	var rndx,rndy;

	var i,j;
	for (i=0;i<nbx;i++)
	{
		y = -2;
		for (j=0;j<nby;j++)
		{
			z = 0.4+2*((Math.cos((this.angle+i*5+j*8)*Math.PI/180.0)+1)*0.5);
			grey = z/2;
			rndx = Math.random()*0.03;
			rndy = Math.random()*0.03;
			
			gl.Color4(0.8,0.8,0.8,0.6);	
			gl.Line3D(x,y,0,x+rndx,y+rndy,z);

			gl.PushMatrix();
			gl.Translate(x+rndx,y+rndy,z);
			gl.Scale(0.04,0.04,0.1);
			this.petales(0.6,0.05,0.4,z/2);
			gl.PopMatrix();
			y+=4/nby;
		}
		x += 4/nbx;
	}

	gl.DisableBlend();
}


function petales(r,g,b,a)
{
	nb = 8;
	gl.Color4(r,g,b, a);
	
	gl.PushMatrix();
	var step = 360/nb;
	for (var i=0;i<nb;i++)
	{
		gl.Rotate(step,0,0,1);
		gl.PushMatrix();
		gl.Translate(3.0,0,0);
		gl.Rotate(-6,0,1,0);
		gl.Ellipse(0,0,4.6,0.7);			
		gl.PopMatrix();
	}
	gl.PopMatrix();

}



