added offscreen rendering to test cases
This commit is contained in:
parent
7297427a70
commit
4327bd938a
1 changed files with 13 additions and 3 deletions
|
@ -15,20 +15,26 @@ import (
|
|||
)
|
||||
|
||||
func run(t *testing.T, fn func(cv *canvas.Canvas)) {
|
||||
wnd, cv, err := sdlcanvas.CreateWindow(100, 100, "test")
|
||||
wnd, cv2, err := sdlcanvas.CreateWindow(100, 100, "test")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to crete window: %v", err)
|
||||
return
|
||||
}
|
||||
defer wnd.Destroy()
|
||||
|
||||
cv := canvas.NewOffscreen(100, 100)
|
||||
|
||||
gl.Disable(gl.MULTISAMPLE)
|
||||
|
||||
wnd.StartFrame()
|
||||
|
||||
cv.ClearRect(0, 0, 100, 100)
|
||||
fn(cv)
|
||||
img := cv.GetImageData(0, 0, 100, 100)
|
||||
|
||||
cv2.DrawImage(cv)
|
||||
img2 := cv2.GetImageData(0, 0, 100, 100)
|
||||
|
||||
caller, _, _, ok := runtime.Caller(1)
|
||||
if !ok {
|
||||
t.Fatal("Failed to get caller")
|
||||
|
@ -85,8 +91,12 @@ func run(t *testing.T, fn func(cv *canvas.Canvas)) {
|
|||
for y := 0; y < 100; y++ {
|
||||
for x := 0; x < 100; x++ {
|
||||
r1, g1, b1, a1 := img.At(x, y).RGBA()
|
||||
r2, g2, b2, a2 := refImg.At(x, y).RGBA()
|
||||
if r1 != r2 || g1 != g2 || b1 != b2 || a1 != a2 {
|
||||
r2, g2, b2, a2 := img2.At(x, y).RGBA()
|
||||
r3, g3, b3, a3 := refImg.At(x, y).RGBA()
|
||||
if r1 != r3 || g1 != g3 || b1 != b3 || a1 != a3 {
|
||||
t.FailNow()
|
||||
}
|
||||
if r2 != r3 || g2 != g3 || b2 != b3 || a2 != a3 {
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue