本文整理汇总了C++中SDL_VideoDevice::FillHWRect方法的典型用法代码示例。如果您正苦于以下问题:C++ SDL_VideoDevice::FillHWRect方法的具体用法?C++ SDL_VideoDevice::FillHWRect怎么用?C++ SDL_VideoDevice::FillHWRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SDL_VideoDevice
的用法示例。
在下文中一共展示了SDL_VideoDevice::FillHWRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_FillRect
/*
* This function performs a fast fill of the given rectangle with 'color'
*/
int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
{
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;
int x, y;
Uint8 *row;
/* If 'dstrect' == NULL, then fill the whole surface */
if ( dstrect ) {
/* Perform clipping */
if ( !SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect) ) {
return(0);
}
} else {
dstrect = &dst->clip_rect;
}
/* Check for hardware acceleration */
if ( ((dst->flags & SDL_HWSURFACE) == SDL_HWSURFACE) &&
video->info.blit_fill ) {
return(video->FillHWRect(this, dst, dstrect, color));
}
/* Perform software fill */
if ( SDL_LockSurface(dst) != 0 ) {
return(-1);
}
row = (Uint8 *)dst->pixels+dstrect->y*dst->pitch+
dstrect->x*dst->format->BytesPerPixel;
if ( dst->format->palette || (color == 0) ) {
x = dstrect->w*dst->format->BytesPerPixel;
if ( !color && !((long)row&3) && !(x&3) && !(dst->pitch&3) ) {
int n = x >> 2;
for ( y=dstrect->h; y; --y ) {
SDL_memset4(row, 0, n);
row += dst->pitch;
}
} else {
示例2: SDL_FillRect
/*
* This function performs a fast fill of the given rectangle with 'color'
*/
int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
{
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;
int x, y;
Uint8 *row;
/* This function doesn't work on surfaces < 8 bpp */
if ( dst->format->BitsPerPixel < 8 ) {
switch(dst->format->BitsPerPixel) {
case 1:
return SDL_FillRect1(dst, dstrect, color);
break;
case 4:
return SDL_FillRect4(dst, dstrect, color);
break;
default:
SDL_SetError("Fill rect on unsupported surface format");
return(-1);
break;
}
}
/* If 'dstrect' == NULL, then fill the whole surface */
if ( dstrect ) {
/* Perform clipping */
if ( !SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect) ) {
return(0);
}
} else {
dstrect = &dst->clip_rect;
}
/* Check for hardware acceleration */
if ( ((dst->flags & SDL_HWSURFACE) == SDL_HWSURFACE) &&
video->info.blit_fill ) {
SDL_Rect hw_rect;
if ( dst == SDL_VideoSurface ) {
hw_rect = *dstrect;
hw_rect.x += current_video->offset_x;
hw_rect.y += current_video->offset_y;
dstrect = &hw_rect;
}
return(video->FillHWRect(this, dst, dstrect, color));
}
/* Perform software fill */
if ( SDL_LockSurface(dst) != 0 ) {
return(-1);
}
row = (Uint8 *)dst->pixels+dstrect->y*dst->pitch+
dstrect->x*dst->format->BytesPerPixel;
if ( dst->format->palette || (color == 0) ) {
x = dstrect->w*dst->format->BytesPerPixel;
if ( !color && !((int)row&3) && !(x&3) && !(dst->pitch&3) ) {
int n = x >> 2;
for ( y=dstrect->h; y; --y ) {
SDL_memset4(row, 0, n);
row += dst->pitch;
}
} else {