Beispiel #1
0
// Internal function to generate a framebuffer/renderbuffer of the correct
// dimensions exactly once per execution
func getFBORBO(t *Texture) *fborbo {
	p := image.Point{t.W, t.H}
	result, ok := framebuffers[p]
	if ok {
		return result
	}

	result = &fborbo{}

	result.rbo = gl.GenRenderbuffer()
	OpenGLSentinel()
	result.fbo = gl.GenFramebuffer()
	OpenGLSentinel()

	result.fbo.Bind()

	result.rbo.Bind()
	gl.RenderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT, t.W, t.H)
	result.rbo.Unbind()

	result.rbo.FramebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT,
		gl.RENDERBUFFER)

	result.fbo.Unbind()

	framebuffers[image.Point{t.W, t.H}] = result
	return result
}
Beispiel #2
0
// Internal function to generate a framebuffer/renderbuffer of the correct
// dimensions exactly once per execution
func getFBORBO(width, height int) *fborbo {
	p := image.Point{width, height}
	result, ok := framebuffers[p]
	if ok {
		return result
	}

	result = &fborbo{}

	result.rbo = gl.GenRenderbuffer()
	result.fbo = gl.GenFramebuffer()

	result.fbo.Bind()

	result.rbo.Bind()
	gl.RenderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT, p.X, p.Y)
	result.rbo.Unbind()

	result.rbo.FramebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT,
		gl.RENDERBUFFER)

	result.fbo.Unbind()

	framebuffers[p] = result
	return result
}