SetGoImage sets Texture image data from an *image.RGBA standard Go image, at given layer, and sets the Mod flag, so it will be sync'd by Memory or if TextureOwns is set for the var, it allocates Host memory. This is most efficiently done using an image.RGBA, but other formats will be converted as ne
(img image.Image, layer int, flipY bool)
| 214 | // the image data (requires row-by-row copy) -- can avoid this |
| 215 | // by configuring texture coordinates to compensate. |
| 216 | func (vl *Value) SetGoImage(img image.Image, layer int, flipY bool) error { |
| 217 | if vl.HasFlag(ValueTextureOwns) { |
| 218 | if layer == 0 && vl.Texture.Format.Layers <= 1 { |
| 219 | vl.Texture.ConfigGoImage(img.Bounds().Size(), layer+1) |
| 220 | } |
| 221 | vl.Texture.AllocHost() |
| 222 | } |
| 223 | err := vl.Texture.SetGoImage(img, layer, flipY) |
| 224 | if err != nil { |
| 225 | fmt.Println(err) |
| 226 | } else { |
| 227 | vl.SetMod() |
| 228 | } |
| 229 | if vl.HasFlag(ValueTextureOwns) { |
| 230 | vl.Texture.AllocTexture() |
| 231 | // svimg, _ := vl.Texture.GoImage() |
| 232 | // images.Save(svimg, fmt.Sprintf("dimg_%d.png", vl.Index)) |
| 233 | } |
| 234 | return err |
| 235 | } |
| 236 | |
| 237 | // MemReg returns the memory region for this value |
| 238 | func (vl *Value) MemReg(vr *Var) MemReg { |
nothing calls this directly
no test coverage detected