void Init() { //bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height); Title = "Enviro 3D"; WindowState = WindowState.Fullscreen; GL.ClearColor(Color.FromArgb(0xC0D9FA)); lightPos = new float[]{ 10f, 10.0f, 10.0f, 1.0f }; GL.Enable(EnableCap.Light0); GL.Enable(EnableCap.Lighting); GL.Enable(EnableCap.CullFace); GL.Enable(EnableCap.DepthTest); //GL.Enable(EnableCap.Blend); //GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.ShadeModel(ShadingModel.Smooth); //make terain from composed random noise List<NoiseWrapper> noisy = new List<NoiseWrapper> { new NoiseWrapper(2f, 0.011f, ADD), //new NoiseWrapper(2f, 0.004f, ADD), new NoiseWrapper(1.5f, 0.009f, MUL), new NoiseWrapper(2f, 0.04f, ADD), //new NoiseWrapper(2f, 0.004f, ADD), new NoiseWrapper(0.2f, 0.71f, ADD), // new NoiseWrapper(2f, 0.004f, ADD), // new NoiseWrapper(2f, 0.004f, ADD), new NoiseWrapper(0.5f, 0.15f, ADD), new NoiseWrapper(1.5f, 0.009f, MUL) }; t = new Terrain(100,100, 1f, noisy); t.GenerateTerrainFromNoise(); }
void Draw(Terrain terrain) { //enable light float diffuseLight = 0.8f; float ambientLight = 0.6f; float specularLight = 0.6f; float[] lightKa = { ambientLight, ambientLight, ambientLight, 1.0f }; float[] lightKd = { diffuseLight, diffuseLight, diffuseLight, 1.0f }; float[] lightKs = { specularLight, specularLight, specularLight, 0.06f }; GL.Light(LightName.Light0, LightParameter.Ambient, lightKa); GL.Light(LightName.Light0, LightParameter.Diffuse, lightKd); GL.Light(LightName.Light0, LightParameter.Specular, lightKs); GL.Light(LightName.Light0, LightParameter.Position, lightPos); terrain.Draw(flat, downhills); }