staticvoid UpdateTexture(SDL_Texture *texture, int frame)
+{
+ SDL_Color *color;
+ Uint8 *src;
+ Uint32 *dst;
+ int row, col;
+ void *pixels;
+ int pitch;
+
//ok we are locking the texture and taking the values of pixels
+ if (SDL_LockTexture(texture, NULL, &pixels, &pitch) < 0) {
+ fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError());
+ quit(5);
+ }
+ src = MooseFrames[frame];
// the rest is not important but here we try to reach pixels one by one
+ for (row = 0; row < MOOSEPIC_H; ++row) {
+ dst = (Uint32*)((Uint8*)pixels + row * pitch);
+ for (col = 0; col < MOOSEPIC_W; ++col) {
+ color = &MooseColors[*src++];
+ *dst++ = (0xFF000000|(color->r<<16)|(color->g<<8)|color->b);
+ }
+ }
//but how the pixel values are stored and how can i reach it
+ SDL_UnlockTexture(texture);
+}
i m having hard times on understanding the usage of sdl_locktexture
i dont get how the value is stored at pixels and how can i reach it and use it.