mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
gpu: add Framebuffer.ReadPixels
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -127,6 +127,7 @@ type Framebuffer interface {
|
||||
Bind()
|
||||
Invalidate()
|
||||
Release()
|
||||
ReadPixels(src image.Rectangle, pixels []byte) error
|
||||
}
|
||||
|
||||
type Timer interface {
|
||||
|
||||
@@ -589,6 +589,16 @@ func (b *gpuBuffer) BindIndex() {
|
||||
b.backend.funcs.BindBuffer(ELEMENT_ARRAY_BUFFER, b.obj)
|
||||
}
|
||||
|
||||
func (f *gpuFramebuffer) ReadPixels(src image.Rectangle, pixels []byte) error {
|
||||
glErr(f.funcs)
|
||||
f.Bind()
|
||||
if len(pixels) < src.Dx()*src.Dy() {
|
||||
return errors.New("unexpected RGBA size")
|
||||
}
|
||||
f.funcs.ReadPixels(src.Min.X, src.Min.Y, src.Dx(), src.Dy(), RGBA, UNSIGNED_BYTE, pixels)
|
||||
return glErr(f.funcs)
|
||||
}
|
||||
|
||||
func (f *gpuFramebuffer) Bind() {
|
||||
f.funcs.BindFramebuffer(FRAMEBUFFER, f.obj)
|
||||
}
|
||||
|
||||
@@ -139,6 +139,7 @@ type Functions interface {
|
||||
GetUniformLocation(p Program, name string) Uniform
|
||||
InvalidateFramebuffer(target, attachment Enum)
|
||||
LinkProgram(p Program)
|
||||
ReadPixels(x, y, width, height int, format, ty Enum, data []byte)
|
||||
RenderbufferStorage(target, internalformat Enum, width, height int)
|
||||
ShaderSource(s Shader, src string)
|
||||
TexImage2D(target Enum, level int, internalFormat int, width, height int, format, ty Enum, data []byte)
|
||||
|
||||
Reference in New Issue
Block a user