Skip to content

Commit e2ff109

Browse files
eliasSiegeLord
authored andcommitted
fix resize on macos
1 parent e8ac980 commit e2ff109

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/macosx/osxgl.m

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ -(void) viewDidChangeBackingProperties
504504
event.display.width = NSWidth(content);
505505
event.display.height = NSHeight(content);
506506
_al_event_source_emit_event(es, &event);
507-
ALLEGRO_INFO("Window finished resizing");
507+
ALLEGRO_INFO("Window finished resizing %d x %d\n", event.display.width, event.display.height);
508508
}
509509
_al_event_source_unlock(es);
510510
}
@@ -532,7 +532,7 @@ -(void) viewDidEndLiveResize
532532
event.display.width = NSWidth(content);
533533
event.display.height = NSHeight(content);
534534
_al_event_source_emit_event(es, &event);
535-
ALLEGRO_INFO("Window finished resizing");
535+
ALLEGRO_INFO("Window finished resizing %d x %d\n", event.display.width, event.display.height);
536536
}
537537
_al_event_source_unlock(es);
538538
}
@@ -585,7 +585,6 @@ -(void) windowDidResize:(NSNotification*) notification
585585
scale_factor = [window backingScaleFactor];
586586
}
587587
#endif
588-
589588
NSSize max_size;
590589
max_size.width = (dpy_ptr->max_w > 0) ? dpy_ptr->max_w / scale_factor : FLT_MAX;
591590
max_size.height = (dpy_ptr->max_h > 0) ? dpy_ptr->max_h / scale_factor : FLT_MAX;
@@ -600,7 +599,7 @@ -(void) windowDidResize:(NSNotification*) notification
600599
event.display.width = NSWidth(content);
601600
event.display.height = NSHeight(content);
602601
_al_event_source_emit_event(es, &event);
603-
ALLEGRO_INFO("Window was resized\n");
602+
ALLEGRO_INFO("Window was resized %d x %d\n", event.display.width, event.display.height);
604603
}
605604
_al_event_source_unlock(es);
606605
}
@@ -720,10 +719,9 @@ static bool set_current_display(ALLEGRO_DISPLAY* d) {
720719
/* Helper to set up GL state as we want it. */
721720
static void setup_gl(ALLEGRO_DISPLAY *d)
722721
{
723-
_al_ogl_setup_gl(d);
724-
725722
ALLEGRO_DISPLAY_OSX_WIN* dpy = (ALLEGRO_DISPLAY_OSX_WIN*) d;
726723
[dpy->ctx performSelectorOnMainThread:@selector(update) withObject:nil waitUntilDone:YES];
724+
_al_ogl_setup_gl(d);
727725
}
728726

729727

@@ -2031,19 +2029,17 @@ static bool acknowledge_resize_display_win_main_thread(ALLEGRO_DISPLAY *d)
20312029
d->w = NSWidth(content);
20322030
d->h = NSHeight(content);
20332031

2034-
if (d->ogl_extras->backbuffer) {
2035-
_al_ogl_resize_backbuffer(d->ogl_extras->backbuffer, d->w, d->h);
2036-
}
2037-
setup_gl(d);
2038-
20392032
return true;
20402033
}
2034+
20412035
/* Call from user thread */
20422036
static bool acknowledge_resize_display_win(ALLEGRO_DISPLAY *d) {
20432037
ASSERT_USER_THREAD();
20442038
dispatch_sync(dispatch_get_main_queue(), ^{
20452039
acknowledge_resize_display_win_main_thread(d);
20462040
});
2041+
// must be done on the thread the user calls it from, not the main thread
2042+
setup_gl(d);
20472043
return true;
20482044
}
20492045

@@ -2062,6 +2058,8 @@ static bool resize_display_win(ALLEGRO_DISPLAY *d, int w, int h)
20622058
dispatch_sync(dispatch_get_main_queue(), ^{
20632059
rc = resize_display_win_main_thread(d, w, h);
20642060
});
2061+
// must be done on the thread the user calls it from, not the main thread
2062+
setup_gl(d);
20652063
return rc;
20662064
}
20672065

0 commit comments

Comments
 (0)