Skip to content

Commit

Permalink
sokol_app.h win32: draw during window sizing and moving
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Oct 2, 2020
1 parent af9ba80 commit d5e6190
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Simple
[STB-style](https://github.com/nothings/stb/blob/master/docs/stb_howto.txt)
cross-platform libraries for C and C++, written in C.

[See what's new](#updates) (**30-Sep-2020** UWP support for sokol_audio.h)
[See what's new](#updates) (**02-Oct-2020** sokol_app.h win32: draw during resizing and moving the window)

[Live Samples](https://floooh.github.io/sokol-html5/index.html) via WASM.

Expand Down Expand Up @@ -432,6 +432,14 @@ Emulators](https://floooh.github.io/tiny8bit/) for more interesting usage exampl
# Updates
- **02-Oct-2020**:
The sokol_app.h Win32 backend can now render while moving and resizing
the window. NOTE that resizing the swapchain buffers (and receiving
SAPP_EVENTTYPE_RESIZED events) is deferred until the resizing finished.
Resizing the swapchain buffers each frame created a substantial temporary
memory spike of up to several hundred MBytes. I need to figure out a better
swapchain resizing strategy.
- **30-Sep-2020**:
sokol_audio.h now works on UWP, thanks again to Alberto Fustinoni
(@albertofustinoni) for the PR!
Expand Down
26 changes: 25 additions & 1 deletion sokol_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -5273,7 +5273,6 @@ _SOKOL_PRIVATE void _sapp_win32_char_event(uint32_t c, bool repeat) {
}

_SOKOL_PRIVATE LRESULT CALLBACK _sapp_win32_wndproc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
/* FIXME: refresh rendering during resize with a WM_TIMER event */
if (!_sapp.win32.in_create_window) {
switch (uMsg) {
case WM_CLOSE:
Expand Down Expand Up @@ -5438,6 +5437,31 @@ _SOKOL_PRIVATE LRESULT CALLBACK _sapp_win32_wndproc(HWND hWnd, UINT uMsg, WPARAM
case WM_SYSKEYUP:
_sapp_win32_key_event(SAPP_EVENTTYPE_KEY_UP, (int)(HIWORD(lParam)&0x1FF), false);
break;
case WM_ENTERSIZEMOVE:
SetTimer(_sapp.win32.hwnd, 1, USER_TIMER_MINIMUM, NULL);
break;
case WM_EXITSIZEMOVE:
KillTimer(_sapp.win32.hwnd, 1);
break;
case WM_TIMER:
_sapp_frame();
#if defined(SOKOL_D3D11)
_sapp_dxgi_Present(_sapp.d3d11.swap_chain, _sapp.swap_interval, 0);
#endif
#if defined(SOKOL_GLCORE33)
_sapp_wgl_swap_buffers();
#endif
/* NOTE: resizing the swap-chain during resize leads to a substantial
memory spike (hundreds of megabytes for a few seconds).
if (_sapp_win32_update_dimensions()) {
#if defined(SOKOL_D3D11)
_sapp_d3d11_resize_default_render_target();
#endif
_sapp_win32_uwp_app_event(SAPP_EVENTTYPE_RESIZED);
}
*/
break;
default:
break;
}
Expand Down

0 comments on commit d5e6190

Please sign in to comment.