func (r Region) setClipPlanes() { eqs[0][0], eqs[0][1], eqs[0][2], eqs[0][3] = 1, 0, 0, -gl.Double(r.X) eqs[1][0], eqs[1][1], eqs[1][2], eqs[1][3] = -1, 0, 0, gl.Double(r.X+r.Dx) eqs[2][0], eqs[2][1], eqs[2][2], eqs[2][3] = 0, 1, 0, -gl.Double(r.Y) eqs[3][0], eqs[3][1], eqs[3][2], eqs[3][3] = 0, -1, 0, gl.Double(r.Y+r.Dy) gl.ClipPlane(gl.CLIP_PLANE0, &eqs[0][0]) gl.ClipPlane(gl.CLIP_PLANE1, &eqs[1][0]) gl.ClipPlane(gl.CLIP_PLANE2, &eqs[2][0]) gl.ClipPlane(gl.CLIP_PLANE3, &eqs[3][0]) }
func (tm *ThunderMenu) Draw(region Region, style StyleStack) { // Set clip planes gl.PushAttrib(gl.TRANSFORM_BIT) defer gl.PopAttrib() var eqs [4][4]gl.Double eqs[0][0], eqs[0][1], eqs[0][2], eqs[0][3] = 1, 0, 0, -gl.Double(region.X) eqs[1][0], eqs[1][1], eqs[1][2], eqs[1][3] = -1, 0, 0, gl.Double(region.X+region.Dx) eqs[2][0], eqs[2][1], eqs[2][2], eqs[2][3] = 0, 1, 0, -gl.Double(region.Y) eqs[3][0], eqs[3][1], eqs[3][2], eqs[3][3] = 0, -1, 0, gl.Double(region.Y+region.Dy) gl.Enable(gl.CLIP_PLANE0) gl.Enable(gl.CLIP_PLANE1) gl.Enable(gl.CLIP_PLANE2) gl.Enable(gl.CLIP_PLANE3) gl.ClipPlane(gl.CLIP_PLANE0, &eqs[0][0]) gl.ClipPlane(gl.CLIP_PLANE1, &eqs[1][0]) gl.ClipPlane(gl.CLIP_PLANE2, &eqs[2][0]) gl.ClipPlane(gl.CLIP_PLANE3, &eqs[3][0]) var start, end int if tm.delta <= 0 { start = tm.current + int(math.Floor(tm.delta)) end = tm.current region.X += int(float64(region.Dx) * (float64(start-tm.current) - tm.delta)) } else { start = tm.current end = tm.current + int(math.Ceil(tm.delta)) region.X += int(float64(region.Dx) * (float64(end-tm.current) - tm.delta - math.Floor(tm.delta) - 1)) } var offset linear.Vec2 offset.X = (float64(tm.current) + tm.delta) * float64(region.Dx) for i := start; i <= end; i++ { style.PushStyle(map[string]interface{}{"offset": offset}) tm.Subs[tm.menuStack[i]].Draw(region, style) style.Pop() region.X += region.Dx } }