Skip to content

Commit

Permalink
sdl/texture: Add helper function for updating texture with []uint32 i…
Browse files Browse the repository at this point in the history
…nstead of []byte
  • Loading branch information
xyproto authored and veeableful committed Aug 14, 2018
1 parent 2176f28 commit adc8a1e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sdl/render.go
Expand Up @@ -272,6 +272,17 @@ func (texture *Texture) Update(rect *Rect, pixels []byte, pitch int) error {
C.int(pitch))))
}

// UpdateRGBA updates the given texture rectangle with new uint32 pixel data.
// (https://wiki.libsdl.org/SDL_UpdateTexture)
func (texture *Texture) UpdateRGBA(rect *Rect, pixels []uint32, pitch int) error {
return errorFromInt(int(
C.SDL_UpdateTexture(
texture.cptr(),
rect.cptr(),
unsafe.Pointer(&pixels[0]),
C.int(4*pitch)))) // 4 bytes in one uint32
}

// UpdateYUV updates a rectangle within a planar YV12 or IYUV texture with new pixel data.
// (https://wiki.libsdl.org/SDL_UpdateYUVTexture)
func (texture *Texture) UpdateYUV(rect *Rect, yPlane []byte, yPitch int, uPlane []byte, uPitch int, vPlane []byte, vPitch int) error {
Expand Down

0 comments on commit adc8a1e

Please sign in to comment.