当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_VideoDevice::UnlockHWSurface方法代码示例

本文整理汇总了C++中SDL_VideoDevice::UnlockHWSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ SDL_VideoDevice::UnlockHWSurface方法的具体用法?C++ SDL_VideoDevice::UnlockHWSurface怎么用?C++ SDL_VideoDevice::UnlockHWSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SDL_VideoDevice的用法示例。


在下文中一共展示了SDL_VideoDevice::UnlockHWSurface方法的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);
}
开发者ID:ashmew2,项目名称:kolibriosSVN,代码行数:88,代码来源:SDL_blit.c


注:本文中的SDL_VideoDevice::UnlockHWSurface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。