mirror of
https://github.com/lucannez64/darling-lol.git
synced 2026-10-26 19:47:42 +00:00
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]>
This commit is contained in:
1 parent
7f0e57fb5e
commit
7af99c85db
4 files changed
+123
-4
No files matched your search
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build the CGDisplayCopyAllDisplayModes NULL-result probe against Darling's SDK."""
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
import subprocess
|
||||
|
||||
root = Path(__file__).resolve().parent.parent
|
||||
folder = root / 'build/darling-src/build/src/external/cocotron/CoreGraphics'
|
||||
flags = {}
|
||||
for line in (folder / 'CMakeFiles/CoreGraphics.dir/flags.make').read_text().splitlines():
|
||||
if line.startswith('C_') and ' = ' in line:
|
||||
key, value = line.split(' = ', 1)
|
||||
flags[key] = shlex.split(value)
|
||||
obj = root / 'build/riot-display-modes-check.o'
|
||||
subprocess.run(['clang', *flags['C_DEFINES'], *flags['C_INCLUDES'], *flags['C_FLAGS'],
|
||||
'-Wno-macro-redefined', '-c', str(root / 'tools/riot-display-modes-check.c'),
|
||||
'-o', str(obj)], check=True)
|
||||
subprocess.run(['clang', '-target', 'x86_64-apple-macosx11.0', '-fuse-ld=lld', '-nostdlib',
|
||||
'-isysroot', '@DARLING_SDK@', str(obj), '-lSystem',
|
||||
'-framework', 'CoreGraphics', '-framework', 'CoreFoundation',
|
||||
'-o', str(root / 'build/riot-display-modes-check')], check=True)
|
||||
@@ -0,0 +1,34 @@
|
||||
#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;
|
||||
}
|
||||
Reference in new issue
Block a user