SDL2's "texture" rendering API is designed for accelerated graphics in mind; this is where you upload textures to your graphics hardware beforehand, and then render that texture by referring to it.
This is why textures are write-only, and can only be written to if:
- the texture was created with the
- you lock the texture before writing using
So if you want to do pixel manipulation, you should do it in-memory, using a plain pixel buffer (or sometimes an
SDL_Surface). Then when you're done, create a texture out of the buffer. If you do this repeatedly with the same texture, use a texture with the aforementioned
SDL_TEXTUREACCESS_STREAMING flag. This is still very slow though because it's unaccelerated.
For efficient pixel manipulation, the standard practice is to write shader code.