The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
What am I doing wrong with SDL_LockTexture()
AYOTECH14413


Joined: 18 Apr 2015
Posts: 1
I'm trying to use SDL_LockTexture and SDL_UnlockTexture for direct access to pixels in SDL 2.0. When I try to set pixels, I never see anything happen. Here's my code:

Code:
void *pixels;
int pitch;

SDL_LockTexture(mytexture, NULL, &pixels, &pitch);

// Set pixel 100,100 to blue
((uint32_t *)pixels)[100 * 100] = 255;

SDL_UnlockTexture(mytexture);

It doesn't make the pixel blue. Can anyone help?