Skip to content

Commit e322b42

Browse files
thomas-holmesveeableful
authored andcommitted
sdl: render.go: Fix computation of slice returned by LockTexture
1 parent 50d371f commit e322b42

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sdl/render.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ func (texture *Texture) Lock(rect *Rect) ([]byte, int, error) {
307307

308308
pitch := int32(_pitch)
309309
if rect != nil {
310-
length = int((pitch / w) * rect.W * rect.H)
310+
bytesPerPixel := pitch / w
311+
length = int(bytesPerPixel * (w*rect.H - rect.X - (w - rect.X - rect.W)))
311312
} else {
312313
length = int(pitch * h)
313314
}

0 commit comments

Comments
 (0)