How to use nGlide environment variables

General discussion about nGlide.
User avatar
Zeus
Site Admin
Posts: 1712
Joined: Sun Sep 21, 2008 2:51 pm
Contact:

How to use nGlide environment variables

Post by Zeus »

nGlide 1.04 adds the support for nGlide environment variables. Below, you can find a tutorial how to use them.

WHAT IS THIS THING?
nGlide environment variables is just another way to control nGlide settings (next to nGlide configurator). With them you can override not only default wrapper settings but also settings stored by nGlide configurator in windows registry.

DO I NEED IT?
If you need to use individual nGlide settings per game or you like to keep nGlide settings in a portable format, then environment variables are definitely for you. By using them you can not only have separate nGlide configurations per game. You can also have as many nGlide configuration sets per game as you want.

HOW TO USE IT?
The easiest way is to create a batch file (text file with extension renamed to *.bat or *.cmd) and use "set" command.
For example, if you want to change nGlide gamma setting to 0.9, create a batch file with:

Code: Select all

set NGLIDE_GAMMA=4
start game.exe
.. and instead of launching game.exe directly, launch the game with batch file you created.

Settings not defined in a batch file will be taken from nGlide configurator. If they won't be defined even there, nGlide will use its default settings. The settings chain looks like this:
Environment variables (highest priority) -> nGlide configurator (medium priority) -> default settings (lowest priority)

This means if you want to be fully portable, you need to define all 7 nGlide settings in batch file.

For example, to run a game with:
Backend=Vulkan,1920x1080@60Hz,Aspect=correction,Vsync=enabled,Gamma=1.0,Splash=enabled you will need this:

Code: Select all

set NGLIDE_BACKEND=2
set NGLIDE_RESOLUTION=21
set NGLIDE_ASPECT=1
set NGLIDE_REFRESH=1
set NGLIDE_VSYNC=1
set NGLIDE_GAMMA=5
set NGLIDE_SPLASH=1
start game.exe
And to run a game with default nGlide settings, this:

Code: Select all

set NGLIDE_BACKEND=0
set NGLIDE_RESOLUTION=0
set NGLIDE_ASPECT=0
set NGLIDE_REFRESH=0
set NGLIDE_VSYNC=1
set NGLIDE_GAMMA=5
set NGLIDE_SPLASH=1
start game.exe
Note: game.exe should be replaced with game executable name, e.g. to run Need For Speed 2 SE replace last line to
start nfs2sea.exe.

VARIABLE VALUES LEGEND
Values are identical to settings stored in windows registry by nGlide configurator.

Code: Select all

NGLIDE_BACKEND:

0 - "Automatic (Default)"
1 - "DirectX"
2 - "Vulkan"

Code: Select all

NGLIDE_RESOLUTION:

0 - "By app (Default)"
1 - "By desktop"
2 - "640 x 480"
3 - "800 x 600"
4 - "1024 x 600"
5 - "1024 x 768"
6 - "1152 x 864"
7 - "1280 x 720"
8 - "1280 x 768"
9 - "1280 x 800"
10 - "1280 x 960"
11 - "1280 x 1024"
12 - "1360 x 768"
13 - "1366 x 768"
14 - "1400 x 1050"
15 - "1440 x 900"
16 - "1440 x 1080"
17 - "1536 x 864"
18 - "1600 x 900"
19 - "1600 x 1200"
20 - "1680 x 1050"
21 - "1920 x 1080"
22 - "1920 x 1200"
23 - "1920 x 1440"
24 - "2048 x 1536"
25 - "2560 x 1440"
26 - "2560 x 1600"
27 - "3840 x 2160"
28 - "7680 x 4320"

Code: Select all

NGLIDE_ASPECT:

0 - "Entire screen (Default)"
1 - "Aspect correction"
2 - "Integer rendering"
3 - "Integer scaling"

Code: Select all

NGLIDE_REFRESH:

0 - "By app (Default)"
1 - "By desktop"
2 - "60 Hz"
3 - "70 Hz"
4 - "72 Hz"
5 - "75 Hz"
6 - "85 Hz"
7 - "90 Hz"
8 - "100 Hz"
9 - "120 Hz"
10 - "144 Hz"

Code: Select all

NGLIDE_VSYNC:

0 - "Off"
1 - "On (Default)"

Code: Select all

NGLIDE_GAMMA:

0 - "0.5"
1 - "0.6"
2 - "0.7"
3 - "0.8"
4 - "0.9"
5 - "1.0 (Default)"
6 - "1.1"
7 - "1.2"
8 - "1.3"
9 - "1.4"
10 - "1.5"

Code: Select all

NGLIDE_SPLASH:

0 - "Off"
1 - "On (Default)"
On Linux use "export" or "env" command:

Code: Select all

#!/bin/bash
export NGLIDE_BACKEND=0
export NGLIDE_RESOLUTION=0
export NGLIDE_ASPECT=0
export NGLIDE_REFRESH=0
export NGLIDE_VSYNC=1
export NGLIDE_GAMMA=5
export NGLIDE_SPLASH=1
wine game.exe
Here you can download the examples.
Attachments
nGlide_env_examples.zip
(758 Bytes) Downloaded 981 times
Stiletto
Posts: 49
Joined: Sat Apr 10, 2010 6:55 pm

Re: How to use nGlide environment variables

Post by Stiletto »

It'd be kinda neat if you supported the original Glide environment variables, although many would not apply and I'm not sure what purpose it would serve.

Anyhow, cool addition. :D
User avatar
NicoDE
Posts: 67
Joined: Fri Aug 24, 2012 9:09 am
Location: Germany
Contact:

Re: How to use nGlide environment variables

Post by NicoDE »

Many thanks for the feature, it really helps with testing different configurations.

ps: If one does not want to set the variables permanently (export), one could use env.
VEG
Posts: 64
Joined: Mon Apr 13, 2015 4:05 pm
Location: Belarus, Minsk
Contact:

Re: How to use nGlide environment variables

Post by VEG »

I propose to change format of NGLIDE_RESOLUTION to exact setting of needed resolution.

Using:

Code: Select all

By app:
NGLIDE_RESOLUTION=0 or NGLIDE_RESOLUTION= or NGLIDE_RESOLUTION=byapp or NGLIDE_RESOLUTION=app

By desktop:
NGLIDE_RESOLUTION=1 or NGLIDE_RESOLUTION=bydesktop or NGLIDE_RESOLUTION=desktop

Exact resolution:
NGLIDE_RESOLUTION=640x480
Motivation: currently you can't set many usable resolutions. For example, 5120 x 2880 (http://accessories.us.dell.com/sna/prod ... ku=UP275K3). And it's more vivid: user don't have to use table of resolutions to choose one needed.

Also I propose to change format of NGLIDE_ASPECT setting:

Code: Select all

Fit to screen (Default):
NGLIDE_ASPECT= or NGLIDE_ASPECT=0 or NGLIDE_ASPECT=fitscreen or NGLIDE_ASPECT=screen
By app (always square pixels):
NGLIDE_ASPECT=1 or NGLIDE_ASPECT=byapp or NGLIDE_ASPECT=app
4:3 exactly:
NGLIDE_ASPECT=4:3
Motivation: default glide library supports not only 4:3 resolutions. There is also 5:4, for example 1280×1024. And it's also more vivid and flexible.
User avatar
Zeus
Site Admin
Posts: 1712
Joined: Sun Sep 21, 2008 2:51 pm
Contact:

Re: How to use nGlide environment variables

Post by Zeus »

I don't plan any changes in this regard.

nGlide settings are indexed, so it's natural (and simpler) to have them represented as numbers.
Changing integers to strings would cause more damage than good because it would be easier to make a mistake.

Ex1:
NGLIDE_RESOLUTION=640x488
NGLIDE_GAMMA=0.55 (or 0,55)
NGLIDE_VSYNC=Enabled (instead of "On")

Ex2:
NGLIDE_RESOLUTION=by app (default)
NGLIDE_RESOLUTION=by app
NGLIDE_RESOLUTION=byapp
NGLIDE_RESOLUTION=app
VEG wrote:Motivation: currently you can't set many usable resolutions. For example, 5120 x 2880 (http://accessories.us.dell.com/sna/prod ... ku=UP275K3).
All popular resolutions are indexed as separate settings. For those that are not popular you can use Resolution=By desktop, so it's not a problem.
VEG wrote:And it's more vivid: user don't have to use table of resolutions to choose one needed.
Not at all. Users would still need to use the tables. How else would they know if they use defined (supported) values?
VEG
Posts: 64
Joined: Mon Apr 13, 2015 4:05 pm
Location: Belarus, Minsk
Contact:

Re: How to use nGlide environment variables

Post by VEG »

Zeus wrote:NGLIDE_RESOLUTION=640x488
But it is easier to set any supported by system resolution without table in this format. Simply open system screen settings and choose any resolution, and after it write it into environment variable. Hardcoded list isn't flexible (you can't set resolution not from list) and in this case user have to open this website to view this list. You could use any symbol (which is not a digit) or group of symbols (e.g. “, ” or “ x ”, with spaces) as a separator. In this case user will be able to set this value not only in format 640x480, but also “640,480”, “640 480” etc. For meanings “by app” and “by desktop” you can still use 0 (or empty value) and 1 if you think that it is more understandable :)
Zeus wrote:NGLIDE_GAMMA=0.55 (or 0,55)
In this case you could always treat “,” as “.” and round value to supported precision. It isn't hard to implement but it is really user-friendly. Also it is more understandable and self-describing enough. For example, if I see bath file with set NGLIDE_GAMMA=0.55, I will understand what does it mean without any tables. And I have to see external tables if magic numbers is used for this setting.
Zeus wrote:NGLIDE_VSYNC=Enabled (instead of "On")
Usually 0 or 1 are used for booleans. There is no problems at all. Of course you can treat also “on”, “true” and “enabled” as “1” for users convenience, but 0 and 1 are easy enough for using and they are understandable.
Zeus wrote:Ex2:
NGLIDE_RESOLUTION=by app (default)
NGLIDE_RESOLUTION=by app
NGLIDE_RESOLUTION=byapp
NGLIDE_RESOLUTION=app
User still can use “table of possible strings of setting X”. String constants much easier to remember (in comparison to magic numbers) and they are self-descriptive.

Even without supporting variety of formats natural values with strict format like 640x480 and 0.55 will be more convenient than magic numbers “5” and “1” which do not carry any sense without tables. If user have written value in format that nGlide doesn't support you may simply ignore this value like you are ignoring invalid integers like “666” (not from tables) now.
glidenewbie
Posts: 7
Joined: Sun Oct 11, 2015 11:15 am

Re: How to use nGlide environment variables

Post by glidenewbie »

This important thread should be stickied! Also a link to this from the FAQ on the download page would be nice, don't you think? :)
VEG
Posts: 64
Joined: Mon Apr 13, 2015 4:05 pm
Location: Belarus, Minsk
Contact:

Re: How to use nGlide environment variables

Post by VEG »

Are there some changes in the nGlide 1.05?
User avatar
Zeus
Site Admin
Posts: 1712
Joined: Sun Sep 21, 2008 2:51 pm
Contact:

Re: How to use nGlide environment variables

Post by Zeus »

Nope.
User avatar
Toshiba-3
Posts: 23
Joined: Mon Mar 22, 2010 12:47 am
Location: Belgium/France
Contact:

Re: How to use nGlide environment variables

Post by Toshiba-3 »

Very handy!

Too bad they don't work from within Dosbox (I know, they can be set before Dosbox is run via the batch file, but that's not what I wanted to do :mrgreen: )
Image / carmageddon add-ons at road reaction
Post Reply