Wiki Page Content

Differences between revisions 13 and 14
Revision 13 as of 2014-11-29 19:19:30
Size: 1295
Editor: Sam Lantinga
Comment: Improved the pitch variable description
Revision 14 as of 2015-01-07 02:48:27
Size: 1476
Comment: EDITING ON IPAD, PLS REVIEW, Added comments on streaming textures
Deletions are marked like this. Additions are marked like this.
Line 32: Line 32:
This is a fairly slow function, intended for use with static textures. This is a fairly slow function, intended for use with static textures that do not change often.
Line 34: Line 34:
This function will work with streaming textures, but for optimization reasons you may not get the pixels back if you lock the texture afterward. If the texture is intended to be updated often, it is preferred to create the texture as streaming and use the lockout ng functions referenced below. While this function will work with streaming textures, but for optimization reasons you may not get the pixels back if you lock the texture afterward.

SDL_UpdateTexture

Use this function to update the given texture rectangle with new pixel data.

Syntax

int SDL_UpdateTexture(SDL_Texture*    texture,
                      const SDL_Rect* rect,
                      const void*     pixels,
                      int             pitch)

Function Parameters

texture

the texture to update

rect

an SDL_Rect structure representing the area to update, or NULL to update the entire texture

pixels

the raw pixel data

pitch

the number of bytes in a row of pixel data, including padding between lines

Return Value

Returns 0 on success or a negative error code on failure; call SDL_GetError() for more information.

Code Examples

You can add your code example here

Remarks

This is a fairly slow function, intended for use with static textures that do not change often.

If the texture is intended to be updated often, it is preferred to create the texture as streaming and use the lockout ng functions referenced below. While this function will work with streaming textures, but for optimization reasons you may not get the pixels back if you lock the texture afterward.


CategoryAPI, CategoryRender

None: SDL_UpdateTexture (last edited 2017-08-11 23:41:29 by ChliHug)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit