本文整理汇总了C++中SDL_VideoDevice::SetGammaRamp方法的典型用法代码示例。如果您正苦于以下问题:C++ SDL_VideoDevice::SetGammaRamp方法的具体用法?C++ SDL_VideoDevice::SetGammaRamp怎么用?C++ SDL_VideoDevice::SetGammaRamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SDL_VideoDevice
的用法示例。
在下文中一共展示了SDL_VideoDevice::SetGammaRamp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_SetGammaRamp
int SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue)
{
int succeeded;
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;
SDL_Surface *screen = SDL_PublicSurface;
/* Verify the screen parameter */
if ( !screen ) {
SDL_SetError("No video mode has been set");
return -1;
}
/* Lazily allocate the gamma tables */
if ( ! video->gamma ) {
SDL_GetGammaRamp(0, 0, 0);
}
/* Fill the gamma table with the new values */
if ( red ) {
SDL_memcpy(&video->gamma[0*256], red, 256*sizeof(*video->gamma));
}
if ( green ) {
SDL_memcpy(&video->gamma[1*256], green, 256*sizeof(*video->gamma));
}
if ( blue ) {
SDL_memcpy(&video->gamma[2*256], blue, 256*sizeof(*video->gamma));
}
/* Gamma correction always possible on split palettes */
if ( (screen->flags & SDL_HWPALETTE) == SDL_HWPALETTE ) {
SDL_Palette *pal = screen->format->palette;
/* If physical palette has been set independently, use it */
if(video->physpal)
pal = video->physpal;
SDL_SetPalette(screen, SDL_PHYSPAL,
pal->colors, 0, pal->ncolors);
return 0;
}
/* Try to set the gamma ramp in the driver */
succeeded = -1;
if ( video->SetGammaRamp ) {
succeeded = video->SetGammaRamp(this, video->gamma);
} else {
SDL_SetError("Gamma ramp manipulation not supported");
}
return succeeded;
}