Skip to content

Commit 61ed0ec

Browse files
committed
display.c: fix scaled-after-non-scaled usage
1 parent 6cdd9ff commit 61ed0ec

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src_c/display.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,15 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
12151215
SDL_SetHintWithPriority(SDL_HINT_RENDER_SCALE_QUALITY,
12161216
"nearest", SDL_HINT_DEFAULT);
12171217

1218+
#if SDL_VERSION_ATLEAST(2, 28, 0)
1219+
/* If the window has a surface associated with it already,
1220+
* we need to destroy it (if possible) because now we are
1221+
* associating a renderer with it. */
1222+
if (SDL_HasWindowSurface(win)) {
1223+
SDL_DestroyWindowSurface(win);
1224+
}
1225+
#endif
1226+
12181227
if (vsync) {
12191228
pg_renderer = SDL_CreateRenderer(
12201229
win, -1, SDL_RENDERER_PRESENTVSYNC);
@@ -1224,8 +1233,7 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
12241233
}
12251234

12261235
if (pg_renderer == NULL) {
1227-
return RAISE(pgExc_SDLError,
1228-
"failed to create renderer");
1236+
return RAISE(pgExc_SDLError, SDL_GetError());
12291237
}
12301238

12311239
if (flags & PGS_SCALED) {

0 commit comments

Comments
 (0)