Esempio n. 1
0
func (buf *TextureFramebuffer) StartSample(ctx gl.Context) {
	buf.fbo.Bind(ctx, buf.withtex)
	ctx.GetIntegerv(int32v4, gl.VIEWPORT)
	ctx.Viewport(0, 0, buf.w, buf.h)
	ctx.ClearColor(0, 0, 0, 0)
	ctx.Clear(gl.COLOR_BUFFER_BIT)
}
Esempio n. 2
0
func unproject(glctx gl.Context, x, y float32) (mgl32.Vec3, mgl32.Vec3) {
	var wx, wy float32
	var viewport [4]int32
	glctx.GetIntegerv(viewport[:], gl.VIEWPORT)

	wx = x
	wy = float32(viewport[3]) - y

	posStart, err := mgl32.UnProject(mgl32.Vec3{wx, wy, 0}, arcball.getMtx(), projectionMtx, int(viewport[0]), int(viewport[1]), int(viewport[2]), int(viewport[3]))
	posEnd, err := mgl32.UnProject(mgl32.Vec3{wx, wy, 1}, arcball.getMtx(), projectionMtx, int(viewport[0]), int(viewport[1]), int(viewport[2]), int(viewport[3]))

	if err != nil {
		log.Printf("unable to unproject: %+v", err)
	}

	return posStart, posEnd
}