Mercurial > sdl-ios-xcode
diff src/video/windx5/SDL_dx5video.c @ 338:518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 11 Apr 2002 15:23:07 +0000 |
parents | f65715bd8ad8 |
children | 3fc4e71f7714 |
line wrap: on
line diff
--- a/src/video/windx5/SDL_dx5video.c Thu Apr 11 14:35:16 2002 +0000 +++ b/src/video/windx5/SDL_dx5video.c Thu Apr 11 15:23:07 2002 +0000 @@ -404,11 +404,8 @@ static SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); static int DX5_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); -static void DX5_SwapGamma(_THIS); -#ifdef IDirectDrawGammaControl_SetGammaRamp static int DX5_SetGammaRamp(_THIS, Uint16 *ramp); static int DX5_GetGammaRamp(_THIS, Uint16 *ramp); -#endif static void DX5_VideoQuit(_THIS); /* Hardware surface functions */ @@ -430,6 +427,11 @@ static void DX5_PaletteChanged(_THIS, HWND window); static void DX5_WinPAINT(_THIS, HDC hdc); +/* WinDIB driver functions for manipulating gamma ramps */ +extern int DIB_SetGammaRamp(_THIS, Uint16 *ramp); +extern int DIB_GetGammaRamp(_THIS, Uint16 *ramp); +extern void DIB_QuitGamma(_THIS); + /* DX5 driver bootstrap functions */ static int DX5_Available(void) @@ -591,10 +593,8 @@ device->UnlockHWSurface = DX5_UnlockHWSurface; device->FlipHWSurface = DX5_FlipHWSurface; device->FreeHWSurface = DX5_FreeHWSurface; -#ifdef IDirectDrawGammaControl_SetGammaRamp device->SetGammaRamp = DX5_SetGammaRamp; device->GetGammaRamp = DX5_GetGammaRamp; -#endif #ifdef HAVE_OPENGL device->GL_LoadLibrary = WIN_GL_LoadLibrary; device->GL_GetProcAddress = WIN_GL_GetProcAddress; @@ -618,7 +618,6 @@ /* Set up the windows message handling functions */ WIN_RealizePalette = DX5_RealizePalette; WIN_PaletteChanged = DX5_PaletteChanged; - WIN_SwapGamma = DX5_SwapGamma; WIN_WinPAINT = DX5_WinPAINT; HandleMessage = DX5_HandleMessage; @@ -2112,20 +2111,24 @@ return(alloct_all); } -static void DX5_SwapGamma(_THIS) -{ - return; -} - /* Gamma code is only available on DirectX 7 and newer */ -#ifdef IDirectDrawGammaControl_SetGammaRamp - static int DX5_SetGammaRamp(_THIS, Uint16 *ramp) { +#ifdef IDirectDrawGammaControl_SetGammaRamp LPDIRECTDRAWGAMMACONTROL gamma; DDGAMMARAMP gamma_ramp; HRESULT result; +#endif + /* In windowed or OpenGL mode, use windib gamma code */ + if ( ! DDRAW_FULLSCREEN() ) { + return DIB_SetGammaRamp(this, ramp); + } + +#ifndef IDirectDrawGammaControl_SetGammaRamp + SDL_SetError("SDL compiled without DirectX gamma ramp support"); + return -1; +#else /* Check for a video mode! */ if ( ! SDL_primary ) { SDL_SetError("A video mode must be set for gamma correction"); @@ -2152,14 +2155,26 @@ /* Release the interface and return */ IDirectDrawGammaControl_Release(gamma); return (result == DD_OK) ? 0 : -1; +#endif /* !IDirectDrawGammaControl_SetGammaRamp */ } static int DX5_GetGammaRamp(_THIS, Uint16 *ramp) { +#ifdef IDirectDrawGammaControl_SetGammaRamp LPDIRECTDRAWGAMMACONTROL gamma; DDGAMMARAMP gamma_ramp; HRESULT result; +#endif + /* In windowed or OpenGL mode, use windib gamma code */ + if ( ! DDRAW_FULLSCREEN() ) { + return DIB_GetGammaRamp(this, ramp); + } + +#ifndef IDirectDrawGammaControl_SetGammaRamp + SDL_SetError("SDL compiled without DirectX gamma ramp support"); + return -1; +#else /* Check for a video mode! */ if ( ! SDL_primary ) { SDL_SetError("A video mode must be set for gamma correction"); @@ -2187,10 +2202,9 @@ /* Release the interface and return */ IDirectDrawGammaControl_Release(gamma); return (result == DD_OK) ? 0 : -1; +#endif /* !IDirectDrawGammaControl_SetGammaRamp */ } -#endif /* IDirectDrawGammaControl_SetGammaRamp */ - void DX5_VideoQuit(_THIS) { int i, j; @@ -2228,6 +2242,7 @@ } /* Free the window */ + DIB_QuitGamma(this); if ( SDL_Window ) { DX5_DestroyWindow(this); }