New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/exp/shiny: windows: win.Copy coordinates scaled unexpectedly #19902
Comments
@as thank you for the issue. But I cannot see what the problem is - I am slow. Is it possible to make your example simpler to make it obvious for me? Alex |
Sorry, I was in a hurry so didn't have time to make a lucid example. Hopefully this one is easier to understand: https://play.golang.org/p/wZx8QWcWwJ The example attempts to paint rectangles at the location (200,200)-(400-400) in a shiny window. The green rectangle paints at expected location (200,200)-(400-400). It uses a buf (screen.Buffer) and win (screen.Window). The red rectangle paints at (0,0)-(200,200) instead. It uploads the buf to tx (screen.Texture) before copying to win. Something I find confusing happens in the call to win.Copy(dp, src, sr). It works when the entire texture is copied to the window and aligned to image.ZP. Otherwise dp needs to be multiplied x 2 to make things align correctly. |
@as Alex |
CL https://golang.org/cl/40891 mentions this issue. |
Yes, thank you. The cl fixes the issue and the example now works as expected. The issue can be closed at this time. |
Thank you for checking.
Lets leave it open for the moment. The issue will get closed automatically once CL https://golang.org/cl/40891 is submitted. Alex |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8rc3 windows/amd64
What operating system and processor architecture are you using (
go env
)?Microsoft Windows [Version 10.0.14393]
(The "Change the size of apps on the screen" option is set to 100%)
set GOARCH=amd64
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\g
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CGO_CFLAGS=-g -O2
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
What did you do?
Copying a texture to a window doesn't work as expected when a partial copy
of the texture is desired instead of the entire texture. The coordinates of pt
are scaled by a factor of two.
The call to below win.Copy doesn't align pt with r if r != winSize
winSize := image.Pt(1920, 1080)
win, _ := src.NewWindow(&screen.NewWindowOptions{winSize.X, winSize.Y})
tx, _ := src.NewTexture(winSize)
r := image.Rect(10, 10, 20, 20) // only recopy this part to the window
// r := winSize // works if you copy the whole texture
sp := r.Min
// Uncomment the following two statements and it works
// pt.X *= 2
// pt.Y *= 2
win.Copy(pt, tx, r, screen.Src, nil)
What did you expect to see?
Rectangle updated
What did you see instead?
Some other area updated
Full example program (needs exp/shiny)
Draws on mouse click
https://play.golang.org/p/lut2R9xBMW
The text was updated successfully, but these errors were encountered: