`_DESKTOPWIDTH`, `_DESKTOPHEIGHT` do not work in `$CONSOLE` programs
Closed this issue · 6 comments
A few strange behaviours when a program uses $CONSOLE
-
$CONSOLE:ONLY
causes_DESKTOPWIDTH
/_DESKTOPHEIGHT
to always return 0 -
This code causes the program to soft-lock
$CONSOLE $SCREENHIDE _ECHO STR$(_DESKTOPWIDTH)
Using
$CONSOLE:ONLY
instead prevents the soft-lock but still returns 0 for_DESKTOPWIDTH
I need this work correctly so that I can send the desktop resolution to various DOOM engines from a command-line program.
Even before investigation: $CONSOLE:ONLY disables all dependencies, so _DESKTOPWIDTH and _DESKTOPHEIGHT are rendered powerless in a sort of expected way. My suggestion would be exactly what you reported in item 2, so I'll have a look what is going on there.
I am intending to use a GUI eventually, so yes, item.2 will be my typical usage.
Just checked:
We use glutGet(GLUT_SCREEN_WIDTH) and glutGet(GLUT_SCREEN_HEIGHT) to return _DESKTOPWIDTH and _DESKTOPHEIGHT, so you won't be able to read those settings without having the main window created (which is why it hangs; libqb.cpp is waiting for the window to show to return the requested value).
Are you using Windows?
DECLARE LIBRARY
FUNCTION GetSystemMetrics& (BYVAL WhichMetric&)
END DECLARE
$CONSOLE:ONLY
_ECHO STR$(DesktopWidth)
_ECHO STR$(DesktopHeight)
FUNCTION DesktopWidth&
DesktopWidth& = GetSystemMetrics&(0)
END FUNCTION
FUNCTION DesktopHeight&
DesktopHeight& = GetSystemMetrics&(1)
END FUNCTION
Yes, that sample code worked for me 👍
Patch pushed.