Baldur’s Gate II widescreen scaling bug

Here is a unique issue for you… with an odd workaround solution. To sum it up its a script that “works around” improper scaling resulting in black bars when you have dual graphics cards and nothing else appears to work.

Problem description – black bars in fullscreen

When running Baldur’s Gate II in fullscreen with the widescreen mod installed and set to 1280×720 you see black bars surrounding the game window.

Before trying the hacky script make sure that you have explored all your control panel graphics options. If you see black bars on your desktop check these Intel options first before proceeding.

bg2wrongscale

Background

My laptop has two graphics cards. One integrated Intel HD and an NVidia 840M. This is quite an ingenious solution to minimize power consumption. The Intel HD works as a low power accelerator for desktop and minor applications with the Nvidia card kicking in as a “turbo” when 3D applications like games are launched.

Unfortunately this rather unique solution can cause driver compatibility issues, as someone searching the internet will find out. One reason being that the drivers supplied by Nvidia are trimmed and lacking the much needed display options.

The fact that Intel doesn’t supply regular updates to their drivers doesn’t help much. They point toward the laptop manufacturer which only supply old drivers.

intel graphics darn

 The solution that should work, try this first

With regular graphics card configurations the NVidia control panel should have the following scaling options available. Unfortunately for me these options are not there. If you have them, then you’re lucky. Change the scaling to full-screen and the borders should be gone.

nvidiascaling

At first glance one might think that Intel lacks these scaling options completely, however this is not true. The scaling options are hidden inside Intel HD graphics control panel.

To show the options you cannot have your desktop resolution set to your monitor native (max) resolution. (which is usually 1920 x 1080 for most monitors) As soon as you change this to something lower, say something like 1024 x 768 temporarily. The option will magically appear at the screen below.

Again, unfortunately for me, this did not fix my issue with Baldur’s Gate.

intel graphics custom aspect scaling

That didn’t work, what now?

The workaround to this problem is a somewhat clumsy AutoHotkey script that switches the desktop resolution temporarily and forcefully stretches the game window to fit the size of your desktop resolution.

Considering the limitations of this workaround it will not work if you’re already seeing black bars when lowering your resolution in desktop. If that is your case, sorry. You’re situation is even more complicated than mine 🙂

This of course assumes that when you installed the Baldurs Gate II widescreen patch you set the resolution to 1280 x 720. While installing it should have looked like this:

widescreenmod_resolution

If you have any more graphics related mods installed the situation may be different.

Instructions for the workaround

Optional Pre compiled script

This will only work if you have configured the widescreen patch to run at resolution 1280×720!

1. Download the compiled script from here (mirror)
MD5 checksum: 998df07f0078cadc684dcf0484e17c6e

Please note!
You probably have set this program to run as an administrator in the compatibility tab!

2. Place it in the directory where you have installed Baldurs Gate

3. Run BGMainNoBorders.exe and it will attempt to launch the game without borders.

Run the script manually

If you’ve set the widescreen resolution patch to anything other than 1280×720 you need to edit the script and run it manually.

1. Download and install Autohotkey

2. Copy and paste the following script below into notepad or any other plain text editor like notepad2 or notepad++.

3. Save the file as BGmainNoBorders.ahk or any other name you prefer as long as you end with the file extension .ahk and save it into your BG2 install folder.

You can also download it directly from here (mirror) (right click and select save as)
(GitHub)

4. Edit the script where it says ChangeResolution(1280,720) to whichever is the resolution you’ve set the widescreen patch to run in.

For example if you have set the widescreen patch to run at 1600×900 you need to change this to ChangeResolution(1600,900)

5. Double click BGmainNoBorders.ahk to start the game!

Script to copy and paste

#singleinstance force ; prevent multiple instances

; increase this if you have a very slow computer to 1500 or 2000
sleepdelay := 1000

; Check and remember current resolution
x = %A_ScreenWidth%
y = %A_ScreenHeight%

run bgmain.exe ; start baldurs gate

sleep %sleepdelay% ; wait milliseconds

; old method of changing resolution
;run qres /x 1280 /y 720 

; change resolution temporarily
ChangeResolution(1280,720)

sleep %sleepdelay% ; wait milliseconds

WinActivate ahk_class ChitinClass ; focus on baldurs gate

sleep %sleepdelay% ; wait milliseconds

SetFakeFullscreen()

WinWaitClose ahk_class ChitinClass ; wait for baldurs gate to close

; old method of changing resolution
;run qres /x %x% /y %y%

; change back resolution
ChangeResolution(x,y)

sleep %sleepdelay%

ExitApp
return

;---Remapped keys 

; Swap arrow keys with WASD for panning
#IfWinActive ahk_class ChitinClass
a::left
left::a

; Swap arrow keys with WASD for panning
#IfWinActive ahk_class ChitinClass
d::right
right::d

; Swap arrow keys with WASD for panning
#IfWinActive ahk_class ChitinClass
w::up
up::w

; Swap arrow keys with WASD for panning
#IfWinActive ahk_class ChitinClass
s::down
down::s

; Select all party members using tilde
#IfWinActive ahk_class ChitinClass
SC029::SC00c
SC00c::SC029

;---Functions

SetFakeFullscreen()
{
	WinGet Style, Style, ahk_class ChitinClass ; retrieve window data
	WinSet Style, -0xC40000, ahk_class ChitinClass ; hide thickframe/sizebox
	WinSet Style, -0xC00000, ahk_class ChitinClass ; hide title bar
	WinSet Style, -0x800000, ahk_class ChitinClass ; hide thin-line border
	WinSet Style, -0x400000, ahk_class ChitinClass ; hide dialog frame
	WinMove, ahk_class ChitinClass, , 0, 0, A_ScreenWidth, A_ScreenHeight
}

ChangeResolution(w,h)
{
	VarSetCapacity(dM,156,0)
	NumPut(156,dM,36)
	NumPut(0x5c0000,dM,40)
	NumPut(w,dM,108)
	NumPut(h,dM,112)
	DllCall( "ChangeDisplaySettingsA", UInt,&dM, UInt,0 )
}

Troubleshooting

If it doesn’t work try to change Baldur’s Gate to run in windowed mode in bgconfig. This should solve it but can cause issues when panning the overview map.

If it still doesn’t work try increasing sleepdelay from 1000 to 1500 or 2000. Also make sure not to click on anything when you’ve launched the script. Have patience and wait for the game to start.

If you’re using any resolutions other than 1280×720 in the widescreen mod you must edit the script manually at ChangeResolution(1280,720) to the resolution of choice.

Extra features

WASD are remapped and swapped with the arrow keys left, up, down and right and tilde for selecting the whole party. This is more of a convenience for me. If you dislike these keybindings delete all the lines from the text file from remapped keys down to functions.

If you’re only looking for the remapped WASD keybindings you can download it directly here (mirror) (right click and select save as) or the pre compiled script executable here (mirror)
MD5: f26caa20a3fbdaec26fe17abf0a6f514
(GitHub)

If you figure out any better solutions or have anything else to add that might help, please don’t hesitate to leave a comment!