mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 18:09:46 +00:00
Fix black frames of the simple window and rename its setting
Without the shadow and the resize border composeFrame() only forced the alpha channel, so the buffer the driver reallocated after a size change was presented as it is, which showed up as a black frame on every resize step. The content is now always painted from the cache and only the shadow itself is skipped when there are no margins. The setting is named simple-window and means the opposite of the previous shadow-and-border: it is off by default, so the window keeps its shadow and the outer border for resizing.
This commit is contained in:
parent
ab7f542d61
commit
27a58b584e
6 changed files with 19 additions and 18 deletions
|
|
@ -56,7 +56,7 @@ SettingsHandler::SettingsHandler(EngineSettings& settings) {
|
|||
builder.add("window-mode", &settings.display.windowMode);
|
||||
builder.add("adaptive-menu-fps", &settings.display.adaptiveFpsInMenu);
|
||||
builder.add("compact-window-bar", &settings.display.compactWindowBar);
|
||||
builder.add("window-shadow", &settings.display.windowShadow);
|
||||
builder.add("simple-window", &settings.display.simpleWindow);
|
||||
builder.add("live-resize", &settings.display.liveResize);
|
||||
|
||||
builder.addSection("camera");
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ struct DisplaySettings {
|
|||
FlagSetting adaptiveFpsInMenu {false};
|
||||
/// @brief Draw the narrow (24px) window bar instead of the 48px one
|
||||
FlagSetting compactWindowBar {false};
|
||||
/// @brief Draw the window shadow and keep the outer area for resizing
|
||||
FlagSetting windowShadow {true};
|
||||
/// @brief Draw the window without the shadow and the resize border
|
||||
FlagSetting simpleWindow {false};
|
||||
/// @brief Render the window content every frame while it is resized
|
||||
FlagSetting liveResize {true};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ void WaylandWindow::setMaximized(bool enabled) {
|
|||
|
||||
int WaylandWindow::marginSize() const {
|
||||
if (!barEnabled || !shadowEnabled ||
|
||||
(settings != nullptr && !settings->windowShadow.get())) {
|
||||
(settings != nullptr && settings->simpleWindow.get())) {
|
||||
return 0;
|
||||
}
|
||||
if (fullscreen || maximized || Window::mode != WindowMode::WINDOWED) {
|
||||
|
|
@ -307,9 +307,9 @@ void WaylandWindow::updateSettings() {
|
|||
if (settings == nullptr) {
|
||||
return;
|
||||
}
|
||||
const bool shadow = settings->windowShadow.get();
|
||||
if (shadow != shadowSetting) {
|
||||
shadowSetting = shadow;
|
||||
const bool simple = settings->simpleWindow.get();
|
||||
if (simple != simpleWindowSetting) {
|
||||
simpleWindowSetting = simple;
|
||||
// The surface size depends on whether the frame around the content is
|
||||
// drawn at all, so the egl window and the toplevel geometry change.
|
||||
resize(size.x, size.y);
|
||||
|
|
@ -610,18 +610,19 @@ void WaylandWindow::composeFrame() {
|
|||
const int margin = marginSize();
|
||||
GlStateGuard state;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
if (margin <= 0) {
|
||||
makeContentOpaque(0, 0, size.x, size.y);
|
||||
return;
|
||||
}
|
||||
const auto surface = surfaceSize();
|
||||
glViewport(0, 0, surface.x, surface.y);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
// Without the shadow the surface is exactly the content, but it still has
|
||||
// to be painted from the cache: a buffer the driver reallocated after a
|
||||
// resize holds nothing until something is drawn into it.
|
||||
glClearColor(0.0f, 0.0f, 0.0f, margin > 0 ? 0.0f : 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
drawShadow();
|
||||
if (margin > 0) {
|
||||
drawShadow();
|
||||
}
|
||||
if (stretchProgram == 0 || cacheWidth == 0) {
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(margin, margin, size.x, size.y);
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ class WaylandWindow : public Window {
|
|||
static constexpr int SHADOW_MARGIN = 10;
|
||||
static constexpr int RESIZE_GRAB_EXTRA = 2;
|
||||
bool shadowEnabled = false;
|
||||
bool shadowSetting = true;
|
||||
bool simpleWindowSetting = false;
|
||||
bool compactBarSetting = false;
|
||||
GLuint shadowProgram = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue