How do I write to the texture returned by SDL_LockTexture? I’m using something like:
void* pixels;
int pitch;
Uint32* dst;
SDL_Texture* buffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888,SDL_TEXTUREACCESS_STREAMING, WIDTH, HEIGHT);
SDL_LockTexture(text,NULL, &pixels, &pitch)
dst = (Uint32 *) pixels;
for(int i=0;i<WIDTH;i++){
for(int j=0;j<HEIGHT;j++){
dst[ j*pitch + i ] = 0xFF00FF00; // or any other color
}
}
SDL_UnlockTexture(text)
and I always get a blacck screen or a segmentation fault, that shows me that I’m accessing memory that I shouldn’t, but I can’t see where.
What I’m missing? I’m creating the texture wrong? I’m locking it wrong?