comparison 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
comparison
equal deleted inserted replaced
337:9154ec9ca3d2 338:518ffd98a8f6
402 static int DX5_VideoInit(_THIS, SDL_PixelFormat *vformat); 402 static int DX5_VideoInit(_THIS, SDL_PixelFormat *vformat);
403 static SDL_Rect **DX5_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); 403 static SDL_Rect **DX5_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
404 static SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); 404 static SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
405 static int DX5_SetColors(_THIS, int firstcolor, int ncolors, 405 static int DX5_SetColors(_THIS, int firstcolor, int ncolors,
406 SDL_Color *colors); 406 SDL_Color *colors);
407 static void DX5_SwapGamma(_THIS);
408 #ifdef IDirectDrawGammaControl_SetGammaRamp
409 static int DX5_SetGammaRamp(_THIS, Uint16 *ramp); 407 static int DX5_SetGammaRamp(_THIS, Uint16 *ramp);
410 static int DX5_GetGammaRamp(_THIS, Uint16 *ramp); 408 static int DX5_GetGammaRamp(_THIS, Uint16 *ramp);
411 #endif
412 static void DX5_VideoQuit(_THIS); 409 static void DX5_VideoQuit(_THIS);
413 410
414 /* Hardware surface functions */ 411 /* Hardware surface functions */
415 static int DX5_AllocHWSurface(_THIS, SDL_Surface *surface); 412 static int DX5_AllocHWSurface(_THIS, SDL_Surface *surface);
416 static int DX5_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst); 413 static int DX5_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst);
427 424
428 /* Windows message handling functions */ 425 /* Windows message handling functions */
429 static void DX5_RealizePalette(_THIS); 426 static void DX5_RealizePalette(_THIS);
430 static void DX5_PaletteChanged(_THIS, HWND window); 427 static void DX5_PaletteChanged(_THIS, HWND window);
431 static void DX5_WinPAINT(_THIS, HDC hdc); 428 static void DX5_WinPAINT(_THIS, HDC hdc);
429
430 /* WinDIB driver functions for manipulating gamma ramps */
431 extern int DIB_SetGammaRamp(_THIS, Uint16 *ramp);
432 extern int DIB_GetGammaRamp(_THIS, Uint16 *ramp);
433 extern void DIB_QuitGamma(_THIS);
432 434
433 /* DX5 driver bootstrap functions */ 435 /* DX5 driver bootstrap functions */
434 436
435 static int DX5_Available(void) 437 static int DX5_Available(void)
436 { 438 {
589 device->SetHWAlpha = DX5_SetHWAlpha; 591 device->SetHWAlpha = DX5_SetHWAlpha;
590 device->LockHWSurface = DX5_LockHWSurface; 592 device->LockHWSurface = DX5_LockHWSurface;
591 device->UnlockHWSurface = DX5_UnlockHWSurface; 593 device->UnlockHWSurface = DX5_UnlockHWSurface;
592 device->FlipHWSurface = DX5_FlipHWSurface; 594 device->FlipHWSurface = DX5_FlipHWSurface;
593 device->FreeHWSurface = DX5_FreeHWSurface; 595 device->FreeHWSurface = DX5_FreeHWSurface;
594 #ifdef IDirectDrawGammaControl_SetGammaRamp
595 device->SetGammaRamp = DX5_SetGammaRamp; 596 device->SetGammaRamp = DX5_SetGammaRamp;
596 device->GetGammaRamp = DX5_GetGammaRamp; 597 device->GetGammaRamp = DX5_GetGammaRamp;
597 #endif
598 #ifdef HAVE_OPENGL 598 #ifdef HAVE_OPENGL
599 device->GL_LoadLibrary = WIN_GL_LoadLibrary; 599 device->GL_LoadLibrary = WIN_GL_LoadLibrary;
600 device->GL_GetProcAddress = WIN_GL_GetProcAddress; 600 device->GL_GetProcAddress = WIN_GL_GetProcAddress;
601 device->GL_GetAttribute = WIN_GL_GetAttribute; 601 device->GL_GetAttribute = WIN_GL_GetAttribute;
602 device->GL_MakeCurrent = WIN_GL_MakeCurrent; 602 device->GL_MakeCurrent = WIN_GL_MakeCurrent;
616 device->PumpEvents = DX5_PumpEvents; 616 device->PumpEvents = DX5_PumpEvents;
617 617
618 /* Set up the windows message handling functions */ 618 /* Set up the windows message handling functions */
619 WIN_RealizePalette = DX5_RealizePalette; 619 WIN_RealizePalette = DX5_RealizePalette;
620 WIN_PaletteChanged = DX5_PaletteChanged; 620 WIN_PaletteChanged = DX5_PaletteChanged;
621 WIN_SwapGamma = DX5_SwapGamma;
622 WIN_WinPAINT = DX5_WinPAINT; 621 WIN_WinPAINT = DX5_WinPAINT;
623 HandleMessage = DX5_HandleMessage; 622 HandleMessage = DX5_HandleMessage;
624 623
625 device->free = DX5_DeleteDevice; 624 device->free = DX5_DeleteDevice;
626 625
2110 } 2109 }
2111 } 2110 }
2112 return(alloct_all); 2111 return(alloct_all);
2113 } 2112 }
2114 2113
2115 static void DX5_SwapGamma(_THIS)
2116 {
2117 return;
2118 }
2119
2120 /* Gamma code is only available on DirectX 7 and newer */ 2114 /* Gamma code is only available on DirectX 7 and newer */
2115 static int DX5_SetGammaRamp(_THIS, Uint16 *ramp)
2116 {
2121 #ifdef IDirectDrawGammaControl_SetGammaRamp 2117 #ifdef IDirectDrawGammaControl_SetGammaRamp
2122
2123 static int DX5_SetGammaRamp(_THIS, Uint16 *ramp)
2124 {
2125 LPDIRECTDRAWGAMMACONTROL gamma; 2118 LPDIRECTDRAWGAMMACONTROL gamma;
2126 DDGAMMARAMP gamma_ramp; 2119 DDGAMMARAMP gamma_ramp;
2127 HRESULT result; 2120 HRESULT result;
2128 2121 #endif
2122
2123 /* In windowed or OpenGL mode, use windib gamma code */
2124 if ( ! DDRAW_FULLSCREEN() ) {
2125 return DIB_SetGammaRamp(this, ramp);
2126 }
2127
2128 #ifndef IDirectDrawGammaControl_SetGammaRamp
2129 SDL_SetError("SDL compiled without DirectX gamma ramp support");
2130 return -1;
2131 #else
2129 /* Check for a video mode! */ 2132 /* Check for a video mode! */
2130 if ( ! SDL_primary ) { 2133 if ( ! SDL_primary ) {
2131 SDL_SetError("A video mode must be set for gamma correction"); 2134 SDL_SetError("A video mode must be set for gamma correction");
2132 return(-1); 2135 return(-1);
2133 } 2136 }
2150 } 2153 }
2151 2154
2152 /* Release the interface and return */ 2155 /* Release the interface and return */
2153 IDirectDrawGammaControl_Release(gamma); 2156 IDirectDrawGammaControl_Release(gamma);
2154 return (result == DD_OK) ? 0 : -1; 2157 return (result == DD_OK) ? 0 : -1;
2158 #endif /* !IDirectDrawGammaControl_SetGammaRamp */
2155 } 2159 }
2156 2160
2157 static int DX5_GetGammaRamp(_THIS, Uint16 *ramp) 2161 static int DX5_GetGammaRamp(_THIS, Uint16 *ramp)
2158 { 2162 {
2163 #ifdef IDirectDrawGammaControl_SetGammaRamp
2159 LPDIRECTDRAWGAMMACONTROL gamma; 2164 LPDIRECTDRAWGAMMACONTROL gamma;
2160 DDGAMMARAMP gamma_ramp; 2165 DDGAMMARAMP gamma_ramp;
2161 HRESULT result; 2166 HRESULT result;
2162 2167 #endif
2168
2169 /* In windowed or OpenGL mode, use windib gamma code */
2170 if ( ! DDRAW_FULLSCREEN() ) {
2171 return DIB_GetGammaRamp(this, ramp);
2172 }
2173
2174 #ifndef IDirectDrawGammaControl_SetGammaRamp
2175 SDL_SetError("SDL compiled without DirectX gamma ramp support");
2176 return -1;
2177 #else
2163 /* Check for a video mode! */ 2178 /* Check for a video mode! */
2164 if ( ! SDL_primary ) { 2179 if ( ! SDL_primary ) {
2165 SDL_SetError("A video mode must be set for gamma correction"); 2180 SDL_SetError("A video mode must be set for gamma correction");
2166 return(-1); 2181 return(-1);
2167 } 2182 }
2185 } 2200 }
2186 2201
2187 /* Release the interface and return */ 2202 /* Release the interface and return */
2188 IDirectDrawGammaControl_Release(gamma); 2203 IDirectDrawGammaControl_Release(gamma);
2189 return (result == DD_OK) ? 0 : -1; 2204 return (result == DD_OK) ? 0 : -1;
2190 } 2205 #endif /* !IDirectDrawGammaControl_SetGammaRamp */
2191 2206 }
2192 #endif /* IDirectDrawGammaControl_SetGammaRamp */
2193 2207
2194 void DX5_VideoQuit(_THIS) 2208 void DX5_VideoQuit(_THIS)
2195 { 2209 {
2196 int i, j; 2210 int i, j;
2197 2211
2226 SDL_modelist[i] = NULL; 2240 SDL_modelist[i] = NULL;
2227 } 2241 }
2228 } 2242 }
2229 2243
2230 /* Free the window */ 2244 /* Free the window */
2245 DIB_QuitGamma(this);
2231 if ( SDL_Window ) { 2246 if ( SDL_Window ) {
2232 DX5_DestroyWindow(this); 2247 DX5_DestroyWindow(this);
2233 } 2248 }
2234 2249
2235 /* Free our window icon */ 2250 /* Free our window icon */