aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2021-06-03 20:23:54 +0200
committerAndre Weissflog <floooh@gmail.com>2021-06-03 20:23:54 +0200
commit3c2fa0bafb38928c44dfb2643d05e0ec240e57b5 (patch)
tree8f32e3c1beda7e4c39168c7e28e6d1ed73cb1f4d
parent5a1ff5b6a4cac8fd1fe76e63f1c9df01d3ae4a9e (diff)
sokol_app.h metal: fix MTKView internal texture resize
-rw-r--r--sokol_app.h37
1 files changed, 18 insertions, 19 deletions
diff --git a/sokol_app.h b/sokol_app.h
index 5fbadf64..a74ae9b5 100644
--- a/sokol_app.h
+++ b/sokol_app.h
@@ -4184,26 +4184,34 @@ _SOKOL_PRIVATE CVReturn _sapp_macos_displaylink_callback(
_sapp_window_t* win = _sapp_lookup_window(_sapp.main_window_id);
_sapp_macos_activate_window_context(win);
#endif
- _sapp_frame();
+ /* NOTE: the MTKView drawables MUST be resized right before the dummy draw
+ invocation, *NOT* from within the event loop, this is because
+ MTKView lazily resizes some "secondary" surfaces at the start
+ of the draw method before drawRect callback is called. Setting
+ the drawableSize in the event loop causes currentRenderPassDescriptor
+ to return a render pass descriptor with different surfaces sizes
+ */
for (int i = 0; i < _sapp.window_pool.pool.size; i++) {
const uint32_t win_id = _sapp.window_pool.windows[i].slot.id;
_sapp_window_t* win = _sapp_lookup_window(win_id);
if (win) {
- /* NOTE: the MTKView drawables MUST be resized right before the dummy draw
- invocation, *NOT* from within the event loop, this is because
- MTKView lazily resizes some "secondary" surfaces at the start
- of the draw method before drawRect callback is called. Setting
- the drawableSize in the event loop causes currentRenderPassDescriptor
- to return a render pass descriptor with different surfaces sizes
- */
_sapp_macos_update_dimensions(win);
+ // let MTKView lazily resize its framebuffer textures
#if defined(SOKOL_METAL)
[win->macos.view draw];
- #else
- [[win->macos.view openGLContext] flushBuffer];
#endif
}
}
+ _sapp_frame();
+ #if defined(SOKOL_GLCORE33)
+ for (int i = 0; i < _sapp.window_pool.pool.size; i++) {
+ const uint32_t win_id = _sapp.window_pool.windows[i].slot.id;
+ _sapp_window_t* win = _sapp_lookup_window(win_id);
+ if (win) {
+ [[win->macos.view openGLContext] flushBuffer];
+ }
+ }
+ #endif
if (_sapp.quit_requested && !_sapp.quit_ordered) {
_sapp_window_t* win = _sapp_lookup_window(_sapp.main_window_id);
_sapp_macos_close_window(win);
@@ -4434,15 +4442,6 @@ _SOKOL_PRIVATE CVReturn _sapp_macos_displaylink_callback(
- (void)drawRect:(NSRect)rect {
_SOKOL_UNUSED(rect);
- // FIXME?
- /*
- #if !defined(SOKOL_METAL)
- _sapp_window_t* win = _sapp_lookup_window(self.win_id);
- if (win) {
- [[win->macos.view openGLContext] flushBuffer];
- }
- #endif
- */
}
- (BOOL)isOpaque {