Files
darling-lol/tools/riot-display-modes-check.c
T
ztancrellandClaude Opus 5.5 7af99c85db Return a real physical size from CGDisplayScreenSize; never return NULL display modes
CGDisplayScreenSize returned 0x0 for any display with EDID (upstream left
that branch unimplemented). League divides by it for its camera aspect
ratio, so the view-projection x row became NaN: every 3D vertex was
discarded, the scene showed only its blue clear colour, and world clicks
were ignored. Read the size from the EDID detailed timing (mm) or basic
parameters (cm), fall back to 96 dpi, and use the main display for an
unknown id.

CGDisplayCopyAllDisplayModes returned NULL for display 0 (a window off
every screen), which League passes straight to CFArrayGetCount. Fall back
to the main display, then to an empty array.

Add riot-display-modes-check covering both for the main display,
display 0 and an unknown id.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-16 10:44:04 -04:00

35 lines
1.3 KiB
C

#include <CoreGraphics/CoreGraphics.h>
#include <stdio.h>
/* Exported by Darling's CoreGraphics but missing from its CGDirectDisplay.h. */
CFArrayRef CGDisplayCopyAllDisplayModes(CGDirectDisplayID display, CFDictionaryRef options);
/* League passes CGDisplayCopyAllDisplayModes' result straight to
* CFArrayGetCount; display id 0 comes from an off-screen window. */
static int check(CGDirectDisplayID display) {
CFArrayRef modes = CGDisplayCopyAllDisplayModes(display, NULL);
if (!modes) {
printf("DISPLAY_MODES display=%u result=NULL pass=0\n", display);
return 0;
}
printf("DISPLAY_MODES display=%u count=%ld\n", display, (long)CFArrayGetCount(modes));
CFRelease(modes);
return 1;
}
/* League divides by the physical size for its camera aspect ratio; {0,0}
* made every 3D vertex NaN. */
static int checkSize(CGDirectDisplayID display) {
CGSize size = CGDisplayScreenSize(display);
int ok = size.width > 0 && size.height > 0;
printf("SCREEN_SIZE display=%u size=%.0fx%.0fmm pass=%d\n", display, size.width, size.height, ok);
return ok;
}
int main(void) {
int pass = check(CGMainDisplayID()) & check(0) & check(0xffff);
pass &= checkSize(CGMainDisplayID()) & checkSize(0) & checkSize(0xffff);
printf("DISPLAY_MODES_CHECK pass=%d\n", pass);
return !pass;
}