Пример #1
0
func Render(w, h int, srt *image.RGBA) {
	var cc, wait = 0, 0
	var tx, ty, tw, th int
	var rt *renderTile
	tw, th = tileWidth, tileHeight
	for ty = 0; ty < NumTiles; ty++ {
		for tx = 0; tx < NumTiles; tx++ {
			if len(renderTiles) <= wait {
				rt = &renderTile{}
				// rt.rmat = make([][]float64, 3)
				// rt.rmat[0] = make([]float64, 3)
				// rt.rmat[1] = make([]float64, 3)
				// rt.rmat[2] = make([]float64, 3)
				renderTiles = append(renderTiles, rt)
			}
			go RenderTile(tx*tw, num.Mini((tx+1)*tw, w), ty*th, num.Mini((ty+1)*th, h), renderTiles[wait], srt)
			wait++
		}
	}
	for cc < wait {
		cc += (<-Chan)
	}
}
Пример #2
0
func Render() {
	rcc, rwait = 0, 0
	if RootOctree != nil {
		if OctreeMaxLevel > RootOctree.MaxLevel {
			OctreeMaxLevel = RootOctree.MaxLevel
		} else if OctreeMaxLevel < 0 {
			OctreeMaxLevel = 0
		}
	}
	for rty = 0; rty < NumThreads; rty++ {
		for rtx = 0; rtx < NumThreads; rtx++ {
			curThread = threads[rwait]
			curThread.maxSteps, curThread.xmin, curThread.xmax, curThread.ymin, curThread.ymax = MaxSteps, rtx*tileWidth, num.Mini((rtx+1)*tileWidth, width), rty*tileHeight, num.Mini((rty+1)*tileHeight, height)
			go curThread.RenderTile()
			rwait++
		}
	}
	for rcc < rwait {
		rcc += (<-threadChan)
	}
}