Skip to content

Commit 85967e2

Browse files
authored
Merge pull request #2925 from pygame-community/ankith26-display-setmode
Fix scaled-after-non-scaled usage
2 parents dbc6622 + 61ed0ec commit 85967e2

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
@@ -1205,6 +1205,15 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
12051205
SDL_SetHintWithPriority(SDL_HINT_RENDER_SCALE_QUALITY,
12061206
"nearest", SDL_HINT_DEFAULT);
12071207

1208+
#if SDL_VERSION_ATLEAST(2, 28, 0)
1209+
/* If the window has a surface associated with it already,
1210+
* we need to destroy it (if possible) because now we are
1211+
* associating a renderer with it. */
1212+
if (SDL_HasWindowSurface(win)) {
1213+
SDL_DestroyWindowSurface(win);
1214+
}
1215+
#endif
1216+
12081217
if (vsync) {
12091218
pg_renderer = SDL_CreateRenderer(
12101219
win, -1, SDL_RENDERER_PRESENTVSYNC);
@@ -1214,8 +1223,7 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
12141223
}
12151224

12161225
if (pg_renderer == NULL) {
1217-
return RAISE(pgExc_SDLError,
1218-
"failed to create renderer");
1226+
return RAISE(pgExc_SDLError, SDL_GetError());
12191227
}
12201228

12211229
if (flags & PGS_SCALED) {

0 commit comments

Comments
 (0)