检查 SDL_LockSurface 函数的实现时,我偶然发现了这一点:
/* This needs to be done here in case pixels changes value */
surface->pixels = (Uint8 *)surface->pixels + surface->offset;
为什么会pixels
改变它的价值?是不是,实际像素阵列的位置也发生了变化?
特别是,考虑到这一点:
SDL_LockSurface(sur);
Uint8* my_pixels = reinterpret_cast<Uint8*>sur->pixels;
SDL_UnlockSurface(sur);
现在,假设my_pixels
它将始终指向sur
当前指向的表面的像素阵列是否安全,除非我释放它?(我几乎可以肯定,因为移动那些巨大的阵列似乎有点愚蠢,但仍然......也许我很愚蠢......)