SDL_UpdateRect函数
用这个函数来在指定屏幕区域进行更新。在更新之前,需要对表面进行解除锁定。
#include "SDL.h"
void SDL_UpdateRect
(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h);
例子:
if (lpRect != NULL) { dstrect.x = (SHORT)((INT)(lpRect->x) * gpScreenReal->w / gpScreen->w); dstrect.y = (SHORT)((INT)(screenRealY + lpRect->y) * screenRealHeight / gpScreen->h); dstrect.w = (WORD)((DWORD)(lpRect->w) * gpScreenReal->w / gpScreen->w); dstrect.h = (WORD)((DWORD)(lpRect->h) * screenRealHeight / gpScreen->h); SDL_SoftStretch(gpScreen, (SDL_Rect *)lpRect, gpScreenReal, &dstrect); if (SDL_MUSTLOCK(gpScreenReal)) { SDL_UnlockSurface(gpScreenReal); } SDL_UpdateRect(gpScreenReal, dstrect.x, dstrect.y, dstrect.w, dstrect.h); }