Hi there!
Any chance we could get the ability to programmatically set the screen resolution?
I'd like to be able to somehow query screen modes/resolutions that are supported by the system, and set one of those programmatically.
A use case for such a feature would be an in-game options menu, for example. At the moment resolution options are very limited and it would be nice to have more control over such things.
Thank you for considering!
Programmatically changing screen resolution
Moderator: Moderators
Re: Programmatically changing screen resolution
Hi,
What is easy to do and we should do first is adding more built-in resolution options because those listed are old. Can you recommend a list of resolution options? Then we'll see if I can add code to be able to change between them at runtime.
What is easy to do and we should do first is adding more built-in resolution options because those listed are old. Can you recommend a list of resolution options? Then we'll see if I can add code to be able to change between them at runtime.
Re: Programmatically changing screen resolution
I wouldn't really recommend any hard-coded list because nowadays there are too many different screen sizes and aspect ratios. If my resolution happens to not be on that list, then I'm stuck with using windowed mode, or having black borders around the screen, or even with a scaled screen with a wrong aspect ratio or something.
For example the laptop I'm using right now uses 1600x900 resolution which is already a bit rare (although 16:9 aspect ratio). But my desktop uses 1280x1024 (5:4), and I have another laptop that has this weird 1366x768 (683:384!!!) resolution.
So most convenient would be if I could just query the available screen modes from the system, and pick one of those. A bit like how libraries like SDL let you do.
For example the laptop I'm using right now uses 1600x900 resolution which is already a bit rare (although 16:9 aspect ratio). But my desktop uses 1280x1024 (5:4), and I have another laptop that has this weird 1366x768 (683:384!!!) resolution.
So most convenient would be if I could just query the available screen modes from the system, and pick one of those. A bit like how libraries like SDL let you do.
Re: Programmatically changing screen resolution
Hi jmp,
I don't see why anyone would want to use a resolution that isn't the native resolution of their monitor, but below is a example on how to get all supported resolutions ( on Windows ).
+ Attached is a simple demo, use left / right arrow to select a resolution and press spacebar to switch to it.
K
I don't see why anyone would want to use a resolution that isn't the native resolution of their monitor, but below is a example on how to get all supported resolutions ( on Windows ).
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<OnLoaded>
<ZExternalLibrary ModuleName="user32" Source="byte EnumDisplaySettingsA(string lpszDeviceName, int iModeNum, xptr lpDevMode){}"/>
<ZExpression>
<Expression>
<![CDATA[int index;
int[39] dm;
string resolution = "";
while(EnumDisplaySettingsA(null, index++, dm))
{
string r = intToStr(dm[27])+"x"+intToStr(dm[28]);
if(r != resolution)
{
resolution = r;
trace(resolution);
}
}]]>
</Expression>
</ZExpression>
</OnLoaded>
</ZApplication>
K
- Attachments
-
- Resolution.zgeproj
- (8.1 KiB) Downloaded 1041 times
Re: Programmatically changing screen resolution
Woah, that's pretty sweet!! I actually completely missed the fact that I can call external libraries from within ZGE.
Of course a cross-platform solution would be optimal, but this is already great. Thanks Kjell!
Of course a cross-platform solution would be optimal, but this is already great. Thanks Kjell!
Re: Programmatically changing screen resolution
This far I have been using 1024x576, 1360x768, 1366x768, so those are the ones I'd like most on the list. 1920x1080 would be useful to have too.Can you recommend a list of resolution options? Then we'll see if I can add code to be able to change between them at runtime.
Re: Programmatically changing screen resolution
Real nice example Kjell!
I can agree with this. When is it really relevant to change resolutions, in practice? In the older days you would try setting lower resolution if the game didn't run at full frame rate but these days I'd expect any game to run in full frame rate on the default native monitor resolution.Kjell wrote:I don't see why anyone would want to use a resolution that isn't the native resolution of their monitor
Re: Programmatically changing screen resolution
I use windowed mode of ZGE application with small resolution (e.g., 400x320) for OpenGL debugging purposes. For instance, gDebugger does not run well for full-screen applications and I want to see both windows, ZGE and gDebugger, on my screen side-by-side. But this is quite an exception for usual ZGE users, I agree...Kjell wrote:I don't see why anyone would want to use a resolution that isn't the native resolution of their monitor
Re: Programmatically changing screen resolution
Hi Rado1,
K
Windowed mode is something else entirely. I do appreciate it when PC games that allow windowed mode offer a slew of resolutions .. but in that case the desktop / video-out resolution doesn't have to change, nor do they have to be supported by the GPU & monitor ( obviously ).Rado1 wrote:I use windowed mode of ZGE application with small resolution (e.g., 400x320) for OpenGL debugging purposes.
K