Example #1
0
func (w *World) Resize(width, height int) {
	w.Width, w.Height = width, height
	gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
	w.projection = mathgl.Perspective(60, float32(width)/float32(height), 1, 20)
	w.projectionView = w.projection
	w.projectionView.Mul4(w.view)
	for _, obj := range w.objects {
		obj.projectionView = w.projectionView
	}
}
Example #2
0
func NewWorld(width, height int) *World {
	gl.Enable(gl.DEPTH_TEST)
	gl.ClearColor(0.0, 0.0, 0.0, 0.0)
	gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))

	return &World{
		Width:      width,
		Height:     height,
		objects:    make([]*Cube, 0),
		projection: mathgl.Perspective(60, float32(width)/float32(height), 1, 20),
		view:       mathgl.Ident4f(),
	}
}