func drawChunk(chunkX, chunkY int64) { chunk := terrain.GetChunkAt(chunkX, chunkY) if chunk.DisplayList == 0 { chunk.DisplayList = gl.GenLists(1) gl.NewList(chunk.DisplayList, gl.COMPILE) for x := 0; x < config.ChunkArraySize()-1; x++ { for y := 0; y < config.ChunkArraySize()-1; y++ { gl.Normal3d(chunk.Normals.Get(x, y)) gl.Vertex3d(chunk.Vertices.Get(x, y)) x++ gl.Normal3d(chunk.Normals.Get(x, y)) gl.Vertex3d(chunk.Vertices.Get(x, y)) y++ gl.Normal3d(chunk.Normals.Get(x, y)) gl.Vertex3d(chunk.Vertices.Get(x, y)) x-- gl.Normal3d(chunk.Normals.Get(x, y)) gl.Vertex3d(chunk.Vertices.Get(x, y)) y-- } } gl.EndList() } gl.CallList(chunk.DisplayList) }
func init_() { pos := []float32{5.0, 5.0, 10.0, 0.0} red := []float32{0.8, 0.1, 0.0, 1.0} green := []float32{0.0, 0.8, 0.2, 1.0} blue := []float32{0.2, 0.2, 1.0, 1.0} gl.Lightfv(gl.LIGHT0, gl.POSITION, pos) gl.Enable(gl.CULL_FACE) gl.Enable(gl.LIGHTING) gl.Enable(gl.LIGHT0) gl.Enable(gl.DEPTH_TEST) /* make the gears */ gear1 = gl.GenLists(1) gl.NewList(gear1, gl.COMPILE) gl.Materialfv(gl.FRONT, gl.AMBIENT_AND_DIFFUSE, red) gear(1.0, 4.0, 1.0, 20, 0.7) gl.EndList() gear2 = gl.GenLists(1) gl.NewList(gear2, gl.COMPILE) gl.Materialfv(gl.FRONT, gl.AMBIENT_AND_DIFFUSE, green) gear(0.5, 2.0, 2.0, 10, 0.7) gl.EndList() gear3 = gl.GenLists(1) gl.NewList(gear3, gl.COMPILE) gl.Materialfv(gl.FRONT, gl.AMBIENT_AND_DIFFUSE, blue) gear(1.3, 2.0, 0.5, 10, 0.7) gl.EndList() gl.Enable(gl.NORMALIZE) if *printInfo { print("GL_RENDERER = ", gl.GetString(gl.RENDERER), "\n") print("GL_VERSION = ", gl.GetString(gl.VERSION), "\n") print("GL_VENDOR = ", gl.GetString(gl.VENDOR), "\n") print("GL_EXTENSIONS = ", gl.GetString(gl.EXTENSIONS), "\n") } }