func init_() { //pos := []float64{5.0, 5.0, 10.0, 0.0} colors := map[string][]float32{ "0": {0.7, 0.7, 0.7, 1.0}, "1": {1.0, 0.0, 0.0, 1.0}, "2": {1.0, 0.6, 0.0, 1.0}, "3": {1.0, 1.0, 0.0, 1.0}, "4": {0.0, 1.0, 0.0, 1.0}, "5": {0.0, 0.0, 1.0, 1.0}, "6": {0.0, 0.6, 1.0, 1.0}, "7": {1.0, 0.0, 1.0, 1.0}, "8": {1.0, 1.0, 1.0, 1.0}, "9": {0.3, 0.3, 0.3, 1.0}, } fetchChunks(2, 2) gl.ShadeModel(gl.SMOOTH) gl.ClearColor(0.2, 0.2, 0.6, 0.0) gl.ClearDepth(1.0) gl.Enable(gl.DEPTH_TEST) gl.DepthFunc(gl.LEQUAL) gl.Enable(gl.COLOR_MATERIAL) gl.Enable(gl.CULL_FACE) gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST) gl.Hint(gl.LINE_SMOOTH_HINT, gl.NICEST) gl.Lightfv(gl.LIGHT0, gl.AMBIENT, lightAmbient) gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, lightDiffuse) gl.Lightfv(gl.LIGHT0, gl.POSITION, lightPosition) gl.Enable(gl.LIGHT0) gl.Enable(gl.LIGHTING) for name, color := range colors { /* make a cube */ cubes[name] = gl.GenLists(1) gl.NewList(cubes[name], gl.COMPILE) cube(color) gl.EndList() } 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") } }
// general OpenGL initialization func initGL() { gl.Enable(gl.TEXTURE_2D) gl.ShadeModel(gl.SMOOTH) gl.ClearColor(0.0, 0.0, 0.0, 0.5) gl.ClearDepth(1.0) gl.Enable(gl.DEPTH_TEST) gl.DepthFunc(gl.LEQUAL) gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST) // Setup the light gl.Lightfv(gl.LIGHT1, gl.AMBIENT, lightAmbient[:]) // ambient lighting gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, lightDiffuse[:]) // make it diffuse gl.Lightfv(gl.LIGHT1, gl.POSITION, lightPosition[:]) // and place it gl.Enable(gl.LIGHT1) // and finally turn it on. gl.Color4f(1.0, 1.0, 1.0, 0.5) // Full Brightness, 50% Alpha ( NEW ) gl.BlendFunc(gl.SRC_ALPHA, gl.ONE) // Blending Function For Translucency Based On Source Alpha Value ( NEW ) }
// general OpenGL initialization func initGL() { LoadGLTextures("data/mud.bmp") gl.Enable(gl.TEXTURE_2D) gl.ShadeModel(gl.SMOOTH) gl.ClearColor(0.0, 0.0, 0.0, 0.0) gl.ClearDepth(1.0) gl.Enable(gl.DEPTH_TEST) gl.DepthFunc(gl.LEQUAL) gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST) gl.Lightfv(gl.LIGHT1, gl.AMBIENT, lightAmbient[:]) gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, lightDiffuse[:]) gl.Lightfv(gl.LIGHT1, gl.POSITION, lightPosition[:]) gl.Enable(gl.LIGHT1) gl.Color4f(1.0, 1.0, 1.0, 0.5) gl.BlendFunc(gl.SRC_ALPHA, gl.ONE) }
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") } }
// general OpenGL initialization func initGL() { gl.Enable(gl.TEXTURE_2D) gl.ShadeModel(gl.SMOOTH) gl.ClearColor(0.0, 0.0, 0.0, 0.5) gl.ClearDepth(1.0) gl.Enable(gl.DEPTH_TEST) gl.DepthFunc(gl.LEQUAL) gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST) // Setup the light gl.Lightfv(gl.LIGHT1, gl.AMBIENT, lightAmbient1[:]) // ambient lighting gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, lightDiffuse1[:]) // make it diffuse gl.Lightfv(gl.LIGHT1, gl.POSITION, lightPosition1[:]) // and place it gl.Enable(gl.LIGHT1) // and finally turn it on. gl.Lightfv(gl.LIGHT2, gl.AMBIENT, lightAmbient2[:]) // ambient lighting gl.Lightfv(gl.LIGHT2, gl.DIFFUSE, lightDiffuse2[:]) // make it diffuse gl.Lightfv(gl.LIGHT2, gl.POSITION, lightPosition2[:]) // and place it gl.Enable(gl.LIGHT2) // and finally turn it on. }