本文整理汇总了C++中SDL_VideoDevice::SetHWColorKey方法的典型用法代码示例。如果您正苦于以下问题:C++ SDL_VideoDevice::SetHWColorKey方法的具体用法?C++ SDL_VideoDevice::SetHWColorKey怎么用?C++ SDL_VideoDevice::SetHWColorKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SDL_VideoDevice
的用法示例。
在下文中一共展示了SDL_VideoDevice::SetHWColorKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_SetColorKey
/*
* Set the color key in a blittable surface
*/
int SDL_SetColorKey (SDL_Surface *surface, Uint32 flag, Uint32 key)
{
/* Sanity check the flag as it gets passed in */
if ( flag & SDL_SRCCOLORKEY ) {
if ( flag & (SDL_RLEACCEL|SDL_RLEACCELOK) ) {
flag = (SDL_SRCCOLORKEY | SDL_RLEACCELOK);
} else {
flag = SDL_SRCCOLORKEY;
}
} else {
flag = 0;
}
/* Optimize away operations that don't change anything */
if ( (flag == (surface->flags & (SDL_SRCCOLORKEY|SDL_RLEACCELOK))) &&
(key == surface->format->colorkey) ) {
return(0);
}
/* UnRLE surfaces before we change the colorkey */
if ( surface->flags & SDL_RLEACCEL ) {
SDL_UnRLESurface(surface, 1);
}
if ( flag ) {
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;
surface->flags |= SDL_SRCCOLORKEY;
surface->format->colorkey = key;
if ( (surface->flags & SDL_HWACCEL) == SDL_HWACCEL ) {
if ( (video->SetHWColorKey == NULL) ||
(video->SetHWColorKey(this, surface, key) < 0) ) {
surface->flags &= ~SDL_HWACCEL;
}
}
if ( flag & SDL_RLEACCELOK ) {
surface->flags |= SDL_RLEACCELOK;
} else {
surface->flags &= ~SDL_RLEACCELOK;
}
} else {
surface->flags &= ~(SDL_SRCCOLORKEY|SDL_RLEACCELOK);
surface->format->colorkey = 0;
}
SDL_InvalidateMap(surface->map);
return(0);
}