/* new window size or exposure */ func reshape(width int32, height int32) { h := float64(height) / float64(width) gl.Viewport(0, 0, width, height) gl.MatrixMode(gl.PROJECTION) gl.LoadIdentity() gl.Frustum(-1.0, 1.0, -h, h, 5.0, 600.0) gl.MatrixMode(gl.MODELVIEW) gl.LoadIdentity() gl.Translatef(0.0, 0.0, -100) }
func (c *Camera) Update() { // This has to be called in the GL thread vx := math.Cos(c.alpha)*10 + c.Pos.X vy := math.Sin(c.alpha)*10 + c.Pos.Y vz := math.Sin(c.theta)*10 + c.Pos.Z c.lookAt(vector.V3{vx, vy, vz}) gl.MatrixMode(gl.PROJECTION) gl.LoadIdentity() gl.Frustum(-c.frustum.nearW, c.frustum.nearW, -c.frustum.nearH, c.frustum.nearH, c.frustum.zNear, c.frustum.zFar) }
func setupScene() { gl.Enable(gl.DEPTH_TEST) gl.Enable(gl.LIGHTING) gl.ClearColor(0.5, 0.5, 0.5, 0.0) gl.ClearDepth(1) gl.DepthFunc(gl.LEQUAL) ambient := []float32{0.5, 0.5, 0.5, 1} diffuse := []float32{1, 1, 1, 1} lightPosition := []float32{-5, 5, 10, 0} gl.Lightfv(gl.LIGHT0, gl.AMBIENT, &ambient[0]) gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, &diffuse[0]) gl.Lightfv(gl.LIGHT0, gl.POSITION, &lightPosition[0]) gl.Enable(gl.LIGHT0) gl.MatrixMode(gl.PROJECTION) gl.LoadIdentity() gl.Frustum(-1, 1, -1, 1, 1.0, 10.0) gl.MatrixMode(gl.MODELVIEW) gl.LoadIdentity() }
func (c *Context) Frustum(left, right, bottom, top, zNear, zFar float64) { gl.Frustum(left, right, bottom, top, zNear, zFar) }