comparison src/video/windib/SDL_dibvideo.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 ec53caed9fb2
children 3fc4e71f7714
comparison
equal deleted inserted replaced
337:9154ec9ca3d2 338:518ffd98a8f6
59 static SDL_Rect **DIB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); 59 static SDL_Rect **DIB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
60 SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); 60 SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
61 static int DIB_SetColors(_THIS, int firstcolor, int ncolors, 61 static int DIB_SetColors(_THIS, int firstcolor, int ncolors,
62 SDL_Color *colors); 62 SDL_Color *colors);
63 static void DIB_CheckGamma(_THIS); 63 static void DIB_CheckGamma(_THIS);
64 static void DIB_SwapGamma(_THIS); 64 void DIB_SwapGamma(_THIS);
65 static void DIB_QuitGamma(_THIS); 65 void DIB_QuitGamma(_THIS);
66 #ifndef NO_GAMMA_SUPPORT 66 int DIB_SetGammaRamp(_THIS, Uint16 *ramp);
67 static int DIB_SetGammaRamp(_THIS, Uint16 *ramp); 67 int DIB_GetGammaRamp(_THIS, Uint16 *ramp);
68 static int DIB_GetGammaRamp(_THIS, Uint16 *ramp);
69 #endif
70 static void DIB_VideoQuit(_THIS); 68 static void DIB_VideoQuit(_THIS);
71 69
72 /* Hardware surface functions */ 70 /* Hardware surface functions */
73 static int DIB_AllocHWSurface(_THIS, SDL_Surface *surface); 71 static int DIB_AllocHWSurface(_THIS, SDL_Surface *surface);
74 static int DIB_LockHWSurface(_THIS, SDL_Surface *surface); 72 static int DIB_LockHWSurface(_THIS, SDL_Surface *surface);
140 device->SetHWAlpha = NULL; 138 device->SetHWAlpha = NULL;
141 device->LockHWSurface = DIB_LockHWSurface; 139 device->LockHWSurface = DIB_LockHWSurface;
142 device->UnlockHWSurface = DIB_UnlockHWSurface; 140 device->UnlockHWSurface = DIB_UnlockHWSurface;
143 device->FlipHWSurface = NULL; 141 device->FlipHWSurface = NULL;
144 device->FreeHWSurface = DIB_FreeHWSurface; 142 device->FreeHWSurface = DIB_FreeHWSurface;
145 #ifndef NO_GAMMA_SUPPORT
146 device->SetGammaRamp = DIB_SetGammaRamp; 143 device->SetGammaRamp = DIB_SetGammaRamp;
147 device->GetGammaRamp = DIB_GetGammaRamp; 144 device->GetGammaRamp = DIB_GetGammaRamp;
148 #endif
149 #ifdef HAVE_OPENGL 145 #ifdef HAVE_OPENGL
150 device->GL_LoadLibrary = WIN_GL_LoadLibrary; 146 device->GL_LoadLibrary = WIN_GL_LoadLibrary;
151 device->GL_GetProcAddress = WIN_GL_GetProcAddress; 147 device->GL_GetProcAddress = WIN_GL_GetProcAddress;
152 device->GL_GetAttribute = WIN_GL_GetAttribute; 148 device->GL_GetAttribute = WIN_GL_GetAttribute;
153 device->GL_MakeCurrent = WIN_GL_MakeCurrent; 149 device->GL_MakeCurrent = WIN_GL_MakeCurrent;
167 device->PumpEvents = DIB_PumpEvents; 163 device->PumpEvents = DIB_PumpEvents;
168 164
169 /* Set up the windows message handling functions */ 165 /* Set up the windows message handling functions */
170 WIN_RealizePalette = DIB_RealizePalette; 166 WIN_RealizePalette = DIB_RealizePalette;
171 WIN_PaletteChanged = DIB_PaletteChanged; 167 WIN_PaletteChanged = DIB_PaletteChanged;
172 WIN_SwapGamma = DIB_SwapGamma;
173 WIN_WinPAINT = DIB_WinPAINT; 168 WIN_WinPAINT = DIB_WinPAINT;
174 HandleMessage = DIB_HandleMessage; 169 HandleMessage = DIB_HandleMessage;
175 170
176 device->free = DIB_DeleteDevice; 171 device->free = DIB_DeleteDevice;
177 172
805 this->SetGammaRamp = NULL; 800 this->SetGammaRamp = NULL;
806 } 801 }
807 ReleaseDC(SDL_Window, hdc); 802 ReleaseDC(SDL_Window, hdc);
808 #endif /* !NO_GAMMA_SUPPORT */ 803 #endif /* !NO_GAMMA_SUPPORT */
809 } 804 }
810 static void DIB_SwapGamma(_THIS) 805 void DIB_SwapGamma(_THIS)
811 { 806 {
812 #ifndef NO_GAMMA_SUPPORT 807 #ifndef NO_GAMMA_SUPPORT
813 HDC hdc; 808 HDC hdc;
814 809
815 if ( gamma_saved ) { 810 if ( gamma_saved ) {
824 } 819 }
825 ReleaseDC(SDL_Window, hdc); 820 ReleaseDC(SDL_Window, hdc);
826 } 821 }
827 #endif /* !NO_GAMMA_SUPPORT */ 822 #endif /* !NO_GAMMA_SUPPORT */
828 } 823 }
829 static void DIB_QuitGamma(_THIS) 824 void DIB_QuitGamma(_THIS)
830 { 825 {
831 #ifndef NO_GAMMA_SUPPORT 826 #ifndef NO_GAMMA_SUPPORT
832 if ( gamma_saved ) { 827 if ( gamma_saved ) {
833 /* Restore the original gamma if necessary */ 828 /* Restore the original gamma if necessary */
834 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { 829 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
844 gamma_saved = 0; 839 gamma_saved = 0;
845 } 840 }
846 #endif /* !NO_GAMMA_SUPPORT */ 841 #endif /* !NO_GAMMA_SUPPORT */
847 } 842 }
848 843
849 #ifndef NO_GAMMA_SUPPORT 844 int DIB_SetGammaRamp(_THIS, Uint16 *ramp)
850 845 {
851 static int DIB_SetGammaRamp(_THIS, Uint16 *ramp) 846 #ifdef NO_GAMMA_SUPPORT
852 { 847 SDL_SetError("SDL compiled without gamma ramp support");
848 return -1;
849 #else
853 HDC hdc; 850 HDC hdc;
854 BOOL succeeded; 851 BOOL succeeded;
855 852
856 /* Set the ramp for the display */ 853 /* Set the ramp for the display */
857 if ( ! gamma_saved ) { 854 if ( ! gamma_saved ) {
870 ReleaseDC(SDL_Window, hdc); 867 ReleaseDC(SDL_Window, hdc);
871 } else { 868 } else {
872 succeeded = TRUE; 869 succeeded = TRUE;
873 } 870 }
874 return succeeded ? 0 : -1; 871 return succeeded ? 0 : -1;
875 } 872 #endif /* !NO_GAMMA_SUPPORT */
876 873 }
877 static int DIB_GetGammaRamp(_THIS, Uint16 *ramp) 874
878 { 875 int DIB_GetGammaRamp(_THIS, Uint16 *ramp)
876 {
877 #ifdef NO_GAMMA_SUPPORT
878 SDL_SetError("SDL compiled without gamma ramp support");
879 return -1;
880 #else
879 HDC hdc; 881 HDC hdc;
880 BOOL succeeded; 882 BOOL succeeded;
881 883
882 /* Get the ramp from the display */ 884 /* Get the ramp from the display */
883 hdc = GetDC(SDL_Window); 885 hdc = GetDC(SDL_Window);
884 succeeded = GetDeviceGammaRamp(hdc, ramp); 886 succeeded = GetDeviceGammaRamp(hdc, ramp);
885 ReleaseDC(SDL_Window, hdc); 887 ReleaseDC(SDL_Window, hdc);
886 return succeeded ? 0 : -1; 888 return succeeded ? 0 : -1;
887 }
888
889 #endif /* !NO_GAMMA_SUPPORT */ 889 #endif /* !NO_GAMMA_SUPPORT */
890 }
890 891
891 void DIB_VideoQuit(_THIS) 892 void DIB_VideoQuit(_THIS)
892 { 893 {
893 /* Destroy the window and everything associated with it */ 894 /* Destroy the window and everything associated with it */
894 if ( SDL_Window ) { 895 if ( SDL_Window ) {