How exactly can one get to the RGBA pixel arrays of SDL 2.0 textures? Does the texture need to be specially initialized and locked down?
byte * bytes= nullptr; int pitch = 0; SDL_LockTexture(texturePointer, nullptr, reinterpret_cast<void **>(&bytes), &pitch); // ...read data... SDL_UnlockTexture(texturePointer);
Both methods have return codes you should check for errors, obviously.
bytes pointer will refer to the locked bits of the texture, and the
pitch variable will contain the number of bytes between successive rows of a texture (to account for padding).
Note that the texture must have been created with the streaming access flag (
Also note that you get the raw bytes of the texture data, which may not always be RGBA (for example, the texture may not have alpha).