lwjgl icon indicating copy to clipboard operation
lwjgl copied to clipboard

Interlaced display modes aren't supported on lwjgl for linux

Open ScoreUnder opened this issue 9 years ago • 4 comments
trafficstars

This is the output of xrandr -q

Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
HDMI-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 16mm x 9mm
   1920x1080i    60.00*+  50.00    59.94  
   1920x1080     24.00    23.98  
   1280x720      60.00    50.00    59.94  
   1024x768      75.08    70.07    60.00  
   1440x480i     59.94  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   720x576       50.00  
   720x576i      50.00  
   720x480       60.00    59.94  
   720x480i      60.00    59.94  
   640x480       75.00    72.81    66.67    60.00    59.94  
DVI-0 disconnected (normal left inverted right x axis y axis)
VGA-0 disconnected (normal left inverted right x axis y axis)

The error encountered was an ArrayIndexOutOfBoundsException in XRandR.findPrimary.

This is a second-hand error report because my own monitors don't support interlaced display modes, but the person who I'm helping is testing this with Minecraft, which is notoriously hard to replace libraries in nowadays (due to integrity checks and automatic re-downloading). For that reason I can't really test a solution to this, but I suspect it may be as simple as:

diff --git a/src/java/org/lwjgl/opengl/XRandR.java b/src/java/org/lwjgl/opengl/XRandR.java
index 6630f97..586b611 100644
--- a/src/java/org/lwjgl/opengl/XRandR.java
+++ b/src/java/org/lwjgl/opengl/XRandR.java
@@ -259,7 +259,7 @@ public class XRandR {
        }

        private static final Pattern SCREEN_HEADER_PATTERN   = Pattern.compile("^(\\d+)x(\\d+)[+](\\d+)[+](\\d+)$");
-       private static final Pattern SCREEN_MODELINE_PATTERN = Pattern.compile("^(\\d+)x(\\d+)$");
+       private static final Pattern SCREEN_MODELINE_PATTERN = Pattern.compile("^(\\d+)x(\\d+)i?$");
        private static final Pattern FREQ_PATTERN            = Pattern.compile("^(\\d+)[.](\\d+)(?:\\s*[*])?(?:\\s*[+])?$");

        /**

I gave my friend an entirely different workaround, and one which is laughably hacky. I sent a tar.gz file containing a directory with these two scripts inside, then instructed them to run ./stupid-hack minecraft in that directory. It worked.

Probably related to:

  • https://github.com/dnschneid/crouton/issues/1334
  • https://askubuntu.com/questions/695498/cant-run-minecraft-on-crouton
  • https://bugs.mojang.com/browse/MC-68732 (It is highly infuriating that even the moderators in that bug report point to the red herring error ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread., which is caused by Display.<clinit> failing and contains no useful information of its own.)
  • http://www.minecraftforum.net/forums/support/unmodified-minecraft-client/2581456-minecraft-will-not-start

ScoreUnder avatar Feb 27 '16 20:02 ScoreUnder

This should be fixed by the proposed change in: https://github.com/LWJGL/lwjgl/issues/112#issuecomment-174032449

tfg13 avatar Feb 27 '16 22:02 tfg13

Sounds good.

On an almost-related note, does Java support non-capturing groups in regexes? It's been a long, long time since I used Java's particular flavour of regex, but in many dialects you could write it like this: "^(?:\\S*\\D)?(\\d+)x(\\d+)(?:\\D\\S*)?$" This would remove the need for switching the group numbers around.

ScoreUnder avatar Feb 27 '16 22:02 ScoreUnder

Has this issue been fixed in LWJGL yet? This issue is still occuring in programs such as Minecraft. https://bugs.mojang.com/browse/MC-79573 (main bug page, there are also 11 duplicates).

aaronfranke avatar Jun 25 '17 18:06 aaronfranke

Custom resolution such as 1680x1050_60.00 aren't supported, either:

  • https://askubuntu.com/questions/377937/how-to-set-a-custom-resolution

@ScoreUnder Yes they are supported:

  • http://docs.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html

nodakai avatar Jul 29 '17 11:07 nodakai