From 0383f0db1b1c00886e28052a0383b19133c55323 Mon Sep 17 00:00:00 2001 From: "Colin J. Brigato" Date: Tue, 24 Sep 2024 11:46:52 +0200 Subject: [PATCH] setsurfacesn --- ReflectiveBoundTexture.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ReflectiveBoundTexture.go b/ReflectiveBoundTexture.go index 4bc90273..f4ee5ff1 100644 --- a/ReflectiveBoundTexture.go +++ b/ReflectiveBoundTexture.go @@ -54,6 +54,11 @@ func (i *ReflectiveBoundTexture) commit() (*ReflectiveBoundTexture, bool) { return i, has_changed } +func (i *ReflectiveBoundTexture) SetSurfaceFn(fn func() *image.RGBA, commit bool) error { + img := fn() + return i.SetSurfaceFromRGBA(img, commit) +} + func (i *ReflectiveBoundTexture) SetSurfaceFromFillRect(width int, height int, c color.Color, commit bool) error { img := newImage(width, height, c) return i.SetSurfaceFromRGBA(img, commit) @@ -98,6 +103,22 @@ func (i *ReflectiveBoundTexture) GetImGuiImageVDefaultOptionsStruct() ImguiImage Border_col: imgui.Vec4{0, 0, 0, 0}, } } +func (i *ReflectiveBoundTexture) ImguiImage(width float32, height float32, options ImguiImageVOptionStruct) { + size := imgui.Vec2{X: width, Y: height} + + if size.X == -1 { + rect := imgui.ContentRegionAvail() + size.X = rect.X + } + + if size.Y == -1 { + rect := imgui.ContentRegionAvail() + size.Y = rect.Y + } + + imgui.Image(i.Texture().ID(), size) +} + func (i *ReflectiveBoundTexture) ImguiImageV(width float32, height float32, options ImguiImageVOptionStruct) { size := imgui.Vec2{X: width, Y: height}