Example #1
0
func (self *Window) Draw(ctx vg.Context) {
	now := time.Now()
	_, _, w, h := self.Bounds()
	fbw, fbh := self.FramebufferSize()

	// Calculate pixel ration for hi-dpi devices.
	bg := color.Gray13

	gl.ClearColor(gl.Float(bg.R), gl.Float(bg.G), gl.Float(bg.B), gl.Float(bg.A))
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT)

	//Do OpenGL stuff
	// Iterate over scene, rendering what can be rendered
	if self.renderer != nil {
		self.renderer.Render()
	}

	// 2D Display
	// r := float64(fbw) / float64(w)
	gl.Viewport(0, 0, gl.Sizei(fbw), gl.Sizei(fbh))

	if self.child != nil {
		ctx.BeginFrame(int(w), int(h), 1.0)
		self.child.SetBounds(0.0, 0.0, float64(w), float64(h))
		self.child.Draw(ctx)
		ctx.EndFrame()
	}
	if debug {
		fmt.Println(time.Since(now))
	}
}