Skip to content

Commit a8b89f8

Browse files
authored
fix crash when default framebuffer sizes are too small (#2619)
* fix crash when default framebuffer sizes are below 2 * bump min default framebuffer size to 16x16
1 parent 48ce41b commit a8b89f8

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,8 @@ private void updateSizes() {
482482
// framebuffer size (resolution) may differ from window size (e.g. HiDPI)
483483

484484
glfwGetWindowSize(window, width, height);
485-
int windowWidth = width[0] < 1 ? 1 : width[0];
486-
int windowHeight = height[0] < 1 ? 1 : height[0];
485+
int windowWidth = width[0] < 16 ? 16 : width[0];
486+
int windowHeight = height[0] < 16 ? 16 : height[0];
487487
if (settings.getWindowWidth() != windowWidth || settings.getWindowHeight() != windowHeight) {
488488
settings.setWindowSize(windowWidth, windowHeight);
489489
for (WindowSizeListener wsListener : windowSizeListeners.getArray()) {
@@ -492,8 +492,8 @@ private void updateSizes() {
492492
}
493493

494494
glfwGetFramebufferSize(window, width, height);
495-
int framebufferWidth = width[0];
496-
int framebufferHeight = height[0];
495+
int framebufferWidth = width[0] < 16 ? 16 : width[0];
496+
int framebufferHeight = height[0] < 16 ? 16 : height[0];
497497
if (framebufferWidth != oldFramebufferWidth || framebufferHeight != oldFramebufferHeight) {
498498
settings.setResolution(framebufferWidth, framebufferHeight);
499499
listener.reshape(framebufferWidth, framebufferHeight);
@@ -502,8 +502,8 @@ private void updateSizes() {
502502
oldFramebufferHeight = framebufferHeight;
503503
}
504504

505-
float xScale = framebufferWidth / windowWidth;
506-
float yScale = framebufferHeight / windowHeight;
505+
float xScale = (float) framebufferWidth / windowWidth;
506+
float yScale = (float) framebufferHeight / windowHeight;
507507
if (oldScale.x != xScale || oldScale.y != yScale) {
508508
listener.rescale(xScale, yScale);
509509

0 commit comments

Comments
 (0)