SDL_LockTexture

hi guys

i m ashamed to ask you such a favor but i couldnt get it and need help. so i m here.

this is the example code i work on at http://lists.libsdl.org/pipermail/commits-libsdl.org/2011-February/003829.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
static void 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.
Last edited on
Topic archived. No new replies allowed.