src/video/windx5/SDL_dx5video.c
changeset 338 518ffd98a8f6
parent 334 f65715bd8ad8
child 374 3fc4e71f7714
     1.1 --- a/src/video/windx5/SDL_dx5video.c	Thu Apr 11 14:35:16 2002 +0000
     1.2 +++ b/src/video/windx5/SDL_dx5video.c	Thu Apr 11 15:23:07 2002 +0000
     1.3 @@ -404,11 +404,8 @@
     1.4  static SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
     1.5  static int DX5_SetColors(_THIS, int firstcolor, int ncolors,
     1.6  			 SDL_Color *colors);
     1.7 -static void DX5_SwapGamma(_THIS);
     1.8 -#ifdef IDirectDrawGammaControl_SetGammaRamp
     1.9  static int DX5_SetGammaRamp(_THIS, Uint16 *ramp);
    1.10  static int DX5_GetGammaRamp(_THIS, Uint16 *ramp);
    1.11 -#endif
    1.12  static void DX5_VideoQuit(_THIS);
    1.13  
    1.14  /* Hardware surface functions */
    1.15 @@ -430,6 +427,11 @@
    1.16  static void DX5_PaletteChanged(_THIS, HWND window);
    1.17  static void DX5_WinPAINT(_THIS, HDC hdc);
    1.18  
    1.19 +/* WinDIB driver functions for manipulating gamma ramps */
    1.20 +extern int DIB_SetGammaRamp(_THIS, Uint16 *ramp);
    1.21 +extern int DIB_GetGammaRamp(_THIS, Uint16 *ramp);
    1.22 +extern void DIB_QuitGamma(_THIS);
    1.23 +
    1.24  /* DX5 driver bootstrap functions */
    1.25  
    1.26  static int DX5_Available(void)
    1.27 @@ -591,10 +593,8 @@
    1.28  	device->UnlockHWSurface = DX5_UnlockHWSurface;
    1.29  	device->FlipHWSurface = DX5_FlipHWSurface;
    1.30  	device->FreeHWSurface = DX5_FreeHWSurface;
    1.31 -#ifdef IDirectDrawGammaControl_SetGammaRamp
    1.32  	device->SetGammaRamp = DX5_SetGammaRamp;
    1.33  	device->GetGammaRamp = DX5_GetGammaRamp;
    1.34 -#endif
    1.35  #ifdef HAVE_OPENGL
    1.36          device->GL_LoadLibrary = WIN_GL_LoadLibrary;
    1.37          device->GL_GetProcAddress = WIN_GL_GetProcAddress;
    1.38 @@ -618,7 +618,6 @@
    1.39  	/* Set up the windows message handling functions */
    1.40  	WIN_RealizePalette = DX5_RealizePalette;
    1.41  	WIN_PaletteChanged = DX5_PaletteChanged;
    1.42 -	WIN_SwapGamma = DX5_SwapGamma;
    1.43  	WIN_WinPAINT = DX5_WinPAINT;
    1.44  	HandleMessage = DX5_HandleMessage;
    1.45  
    1.46 @@ -2112,20 +2111,24 @@
    1.47  	return(alloct_all);
    1.48  }
    1.49  
    1.50 -static void DX5_SwapGamma(_THIS)
    1.51 -{
    1.52 -	return;
    1.53 -}
    1.54 -
    1.55  /* Gamma code is only available on DirectX 7 and newer */
    1.56 -#ifdef IDirectDrawGammaControl_SetGammaRamp
    1.57 -
    1.58  static int DX5_SetGammaRamp(_THIS, Uint16 *ramp)
    1.59  {
    1.60 +#ifdef IDirectDrawGammaControl_SetGammaRamp
    1.61  	LPDIRECTDRAWGAMMACONTROL gamma;
    1.62  	DDGAMMARAMP gamma_ramp;
    1.63  	HRESULT result;
    1.64 +#endif
    1.65  
    1.66 +	/* In windowed or OpenGL mode, use windib gamma code */
    1.67 +	if ( ! DDRAW_FULLSCREEN() ) {
    1.68 +		return DIB_SetGammaRamp(this, ramp);
    1.69 +	}
    1.70 +
    1.71 +#ifndef IDirectDrawGammaControl_SetGammaRamp
    1.72 +	SDL_SetError("SDL compiled without DirectX gamma ramp support");
    1.73 +	return -1;
    1.74 +#else
    1.75  	/* Check for a video mode! */
    1.76  	if ( ! SDL_primary ) {
    1.77  		SDL_SetError("A video mode must be set for gamma correction");
    1.78 @@ -2152,14 +2155,26 @@
    1.79  	/* Release the interface and return */
    1.80  	IDirectDrawGammaControl_Release(gamma);
    1.81  	return (result == DD_OK) ? 0 : -1;
    1.82 +#endif /* !IDirectDrawGammaControl_SetGammaRamp */
    1.83  }
    1.84  
    1.85  static int DX5_GetGammaRamp(_THIS, Uint16 *ramp)
    1.86  {
    1.87 +#ifdef IDirectDrawGammaControl_SetGammaRamp
    1.88  	LPDIRECTDRAWGAMMACONTROL gamma;
    1.89  	DDGAMMARAMP gamma_ramp;
    1.90  	HRESULT result;
    1.91 +#endif
    1.92  
    1.93 +	/* In windowed or OpenGL mode, use windib gamma code */
    1.94 +	if ( ! DDRAW_FULLSCREEN() ) {
    1.95 +		return DIB_GetGammaRamp(this, ramp);
    1.96 +	}
    1.97 +
    1.98 +#ifndef IDirectDrawGammaControl_SetGammaRamp
    1.99 +	SDL_SetError("SDL compiled without DirectX gamma ramp support");
   1.100 +	return -1;
   1.101 +#else
   1.102  	/* Check for a video mode! */
   1.103  	if ( ! SDL_primary ) {
   1.104  		SDL_SetError("A video mode must be set for gamma correction");
   1.105 @@ -2187,10 +2202,9 @@
   1.106  	/* Release the interface and return */
   1.107  	IDirectDrawGammaControl_Release(gamma);
   1.108  	return (result == DD_OK) ? 0 : -1;
   1.109 +#endif /* !IDirectDrawGammaControl_SetGammaRamp */
   1.110  }
   1.111  
   1.112 -#endif /* IDirectDrawGammaControl_SetGammaRamp */
   1.113 -
   1.114  void DX5_VideoQuit(_THIS)
   1.115  {
   1.116  	int i, j;
   1.117 @@ -2228,6 +2242,7 @@
   1.118  	}
   1.119  
   1.120  	/* Free the window */
   1.121 +	DIB_QuitGamma(this);
   1.122  	if ( SDL_Window ) {
   1.123  		DX5_DestroyWindow(this);
   1.124  	}