本文整理汇总了C++中SDL_VideoDevice::LockHWSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ SDL_VideoDevice::LockHWSurface方法的具体用法?C++ SDL_VideoDevice::LockHWSurface怎么用?C++ SDL_VideoDevice::LockHWSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SDL_VideoDevice
的用法示例。
在下文中一共展示了SDL_VideoDevice::LockHWSurface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_SoftBlit
/* The general purpose software blit routine */
static int SDL_SoftBlit(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect)
{
int okay;
int src_locked;
int dst_locked;
/* Everything is okay at the beginning... */
okay = 1;
/* Lock the destination if it's in hardware */
dst_locked = 0;
if ( dst->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;
if ( video->LockHWSurface(this, dst) < 0 ) {
okay = 0;
} else {
dst_locked = 1;
}
}
/* Lock the source if it's in hardware */
src_locked = 0;
if ( src->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;
if ( video->LockHWSurface(this, src) < 0 ) {
okay = 0;
} else {
src_locked = 1;
}
}
/* Unencode the destination if it's RLE encoded */
if ( dst->flags & SDL_RLEACCEL ) {
SDL_UnRLESurface(dst, 1);
dst->flags |= SDL_RLEACCEL; /* save accel'd state */
}
/* Set up source and destination buffer pointers, and BLIT! */
if ( okay && srcrect->w && srcrect->h ) {
SDL_BlitInfo info;
SDL_loblit RunBlit;
/* Set up the blit information */
info.s_pixels = (Uint8 *)src->pixels + src->offset +
(Uint16)srcrect->y*src->pitch +
(Uint16)srcrect->x*src->format->BytesPerPixel;
info.s_width = srcrect->w;
info.s_height = srcrect->h;
info.s_skip=src->pitch-info.s_width*src->format->BytesPerPixel;
info.d_pixels = (Uint8 *)dst->pixels + dst->offset +
(Uint16)dstrect->y*dst->pitch +
(Uint16)dstrect->x*dst->format->BytesPerPixel;
info.d_width = dstrect->w;
info.d_height = dstrect->h;
info.d_skip=dst->pitch-info.d_width*dst->format->BytesPerPixel;
info.aux_data = src->map->sw_data->aux_data;
info.src = src->format;
info.table = src->map->table;
info.dst = dst->format;
RunBlit = src->map->sw_data->blit;
/* Run the actual software blit */
RunBlit(&info);
}
/* Re-encode the destination if it's RLE encoded */
if ( dst->flags & SDL_RLEACCEL ) {
dst->flags &= ~SDL_RLEACCEL; /* stop lying */
SDL_RLESurface(dst);
}
/* We need to unlock the surfaces if they're locked */
if ( dst_locked ) {
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;
video->UnlockHWSurface(this, dst);
} else
if ( src_locked ) {
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;
video->UnlockHWSurface(this, src);
}
/* Blit is done! */
return(okay ? 0 : -1);
}