@@ -44,7 +44,9 @@ static SDL_Texture *pg_texture = NULL;
4444typedef struct _display_state_s {
4545 char * title ;
4646 PyObject * icon ;
47+ #if !SDL_VERSION_ATLEAST (3 , 0 , 0 )
4748 Uint16 * gamma_ramp ;
49+ #endif
4850 SDL_GLContext gl_context ;
4951 int toggle_windowed_w ;
5052 int toggle_windowed_h ;
@@ -87,10 +89,12 @@ _display_state_cleanup(_DisplayState *state)
8789 SDL_GL_DeleteContext (state -> gl_context );
8890 state -> gl_context = NULL ;
8991 }
92+ #if !SDL_VERSION_ATLEAST (3 , 0 , 0 )
9093 if (state -> gamma_ramp ) {
9194 free (state -> gamma_ramp );
9295 state -> gamma_ramp = NULL ;
9396 }
97+ #endif
9498}
9599
96100// prevent this code block from being linked twice
@@ -1342,6 +1346,8 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
13421346 surf = SDL_GetWindowSurface (win );
13431347 }
13441348 }
1349+
1350+ #if !SDL_VERSION_ATLEAST (3 , 0 , 0 )
13451351 if (state -> gamma_ramp ) {
13461352 int result = SDL_SetWindowGammaRamp (win , state -> gamma_ramp ,
13471353 state -> gamma_ramp + 256 ,
@@ -1356,6 +1362,7 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
13561362 goto DESTROY_WINDOW ;
13571363 }
13581364 }
1365+ #endif
13591366
13601367 if (state -> using_gl && pg_renderer != NULL ) {
13611368 _display_state_cleanup (state );
@@ -2011,6 +2018,24 @@ pg_set_palette(PyObject *self, PyObject *args)
20112018 Py_RETURN_NONE ;
20122019}
20132020
2021+ #if SDL_VERSION_ATLEAST (3 , 0 , 0 )
2022+ static PyObject *
2023+ pg_set_gamma (PyObject * self , PyObject * arg )
2024+ {
2025+ return RAISE (pgExc_SDLError ,
2026+ "set_gamma not supported with SDL3, this functionality has "
2027+ "been removed." );
2028+ }
2029+
2030+ static PyObject *
2031+ pg_set_gamma_ramp (PyObject * self , PyObject * arg )
2032+ {
2033+ return RAISE (
2034+ pgExc_SDLError ,
2035+ "pg_set_gamma_ramp not supported with SDL3, this functionality has "
2036+ "been removed." );
2037+ }
2038+ #else
20142039static PyObject *
20152040pg_set_gamma (PyObject * self , PyObject * arg )
20162041{
@@ -2150,6 +2175,7 @@ pg_set_gamma_ramp(PyObject *self, PyObject *arg)
21502175 }
21512176 return PyBool_FromLong (result == 0 );
21522177}
2178+ #endif
21532179
21542180static PyObject *
21552181pg_set_caption (PyObject * self , PyObject * arg )
@@ -3207,7 +3233,9 @@ MODINIT_DEFINE(display)
32073233 state = DISPLAY_MOD_STATE (module );
32083234 state -> title = NULL ;
32093235 state -> icon = NULL ;
3236+ #if !SDL_VERSION_ATLEAST (3 , 0 , 0 )
32103237 state -> gamma_ramp = NULL ;
3238+ #endif
32113239 state -> using_gl = 0 ;
32123240 state -> auto_resize = SDL_TRUE ;
32133241
0 commit comments