rcore_desktop_glfw.c : flags to control texture font linear filtering - part 3

When in `FLAT_RESCALE_CONTENT` mode, the default "nearest pixel" filter of the texture font is ugly sometimes. So this change adds `FLAG_RESCALE_CONTENT_LINEAR` and `FLAG_TEXT_LINEAR_FILTER` to offer more control. `FLAG_TEXT_LINEAR_FILTER` can also be used to disable the linear filtering of `FLAG_WINDOW_HIGHDPI`.
This commit is contained in:
SuperUserNameMan 2024-07-23 17:57:58 +02:00 committed by GitHub
parent 4ae3e555ed
commit 9228338b39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -418,6 +418,14 @@ void SetWindowState(unsigned int flags)
glfwGetFramebufferSize(platform.handle, &fbWidth, &fbHeight); glfwGetFramebufferSize(platform.handle, &fbWidth, &fbHeight);
WindowSizeCallback(platform.handle, fbWidth, fbHeight); WindowSizeCallback(platform.handle, fbWidth, fbHeight);
} }
// State change: FLAG_TEXT_LINEAR_FILTER
if (((CORE.Window.flags & FLAG_TEXT_LINEAR_FILTER) != (flags & FLAG_TEXT_LINEAR_FILTER)) && ((flags & FLAG_TEXT_LINEAR_FILTER) > 0))
{
CORE.Window.flags |= FLAG_TEXT_LINEAR_FILTER;
rlTextureParameters(GetFontDefault().texture.id, RL_TEXTURE_MIN_FILTER, RL_TEXTURE_FILTER_LINEAR);
rlTextureParameters(GetFontDefault().texture.id, RL_TEXTURE_MAG_FILTER, RL_TEXTURE_FILTER_LINEAR);
}
} }
// Clear window configuration state flags // Clear window configuration state flags
@ -541,6 +549,14 @@ void ClearWindowState(unsigned int flags)
glfwGetFramebufferSize(platform.handle, &fbWidth, &fbHeight); glfwGetFramebufferSize(platform.handle, &fbWidth, &fbHeight);
WindowSizeCallback(platform.handle, fbWidth, fbHeight); WindowSizeCallback(platform.handle, fbWidth, fbHeight);
} }
// State change: FLAG_TEXT_LINEAR_FILTER
if (((CORE.Window.flags & FLAG_TEXT_LINEAR_FILTER) > 0) && ((flags & FLAG_TEXT_LINEAR_FILTER) > 0))
{
CORE.Window.flags &= ~FLAG_TEXT_LINEAR_FILTER;
rlTextureParameters(GetFontDefault().texture.id, RL_TEXTURE_MIN_FILTER, RL_TEXTURE_FILTER_NEAREST);
rlTextureParameters(GetFontDefault().texture.id, RL_TEXTURE_MAG_FILTER, RL_TEXTURE_FILTER_NEAREST);
}
} }
// Set icon for window // Set icon for window