瀏覽代碼

[core] Complement implementations for `SDL` (3) (#3450)

* Fix SetWindowMinSize and SetWindowMaxSize

* Fix window resizes to update the viewport

* Fix window resizes to update the viewport 2
pull/3452/head
ubkp 1 年之前
committed by GitHub
父節點
當前提交
8cda4273ec
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 1 個檔案被更改,包括 18 行新增0 行删除
  1. +18
    -0
      src/platforms/rcore_desktop_sdl.c

+ 18
- 0
src/platforms/rcore_desktop_sdl.c 查看文件

@ -618,6 +618,8 @@ void SetWindowMonitor(int monitor)
// Set window minimum dimensions (FLAG_WINDOW_RESIZABLE) // Set window minimum dimensions (FLAG_WINDOW_RESIZABLE)
void SetWindowMinSize(int width, int height) void SetWindowMinSize(int width, int height)
{ {
SDL_SetWindowMinimumSize(platform.window, width, height);
CORE.Window.screenMin.width = width; CORE.Window.screenMin.width = width;
CORE.Window.screenMin.height = height; CORE.Window.screenMin.height = height;
} }
@ -625,6 +627,8 @@ void SetWindowMinSize(int width, int height)
// Set window maximum dimensions (FLAG_WINDOW_RESIZABLE) // Set window maximum dimensions (FLAG_WINDOW_RESIZABLE)
void SetWindowMaxSize(int width, int height) void SetWindowMaxSize(int width, int height)
{ {
SDL_SetWindowMaximumSize(platform.window, width, height);
CORE.Window.screenMax.width = width; CORE.Window.screenMax.width = width;
CORE.Window.screenMax.height = height; CORE.Window.screenMax.height = height;
} }
@ -979,6 +983,8 @@ void PollInputEvents(void)
} }
*/ */
CORE.Window.resizedLastFrame = false;
SDL_Event event = { 0 }; SDL_Event event = { 0 };
while (SDL_PollEvent(&event) != 0) while (SDL_PollEvent(&event) != 0)
{ {
@ -992,6 +998,18 @@ void PollInputEvents(void)
{ {
switch (event.window.event) switch (event.window.event)
{ {
case SDL_WINDOWEVENT_RESIZED:
case SDL_WINDOWEVENT_SIZE_CHANGED:
{
const int width = event.window.data1;
const int height = event.window.data2;
SetupViewport(width, height);
CORE.Window.screen.width = width;
CORE.Window.screen.height = height;
CORE.Window.currentFbo.width = width;
CORE.Window.currentFbo.height = height;
CORE.Window.resizedLastFrame = true;
} break;
case SDL_WINDOWEVENT_LEAVE: case SDL_WINDOWEVENT_LEAVE:
case SDL_WINDOWEVENT_HIDDEN: case SDL_WINDOWEVENT_HIDDEN:
case SDL_WINDOWEVENT_MINIMIZED: case SDL_WINDOWEVENT_MINIMIZED:

Loading…
取消
儲存