bayaraa / d2gl

Diablo 2 LoD Glide/DDraw to OpenGL Wrapper
GNU General Public License v3.0
175 stars 30 forks source link

Multiple screenshots taken when Print Screen pressed #148

Open fearedbliss opened 6 months ago

fearedbliss commented 6 months ago

Hello,

It seems there is a bug with D2GL 1.3.3 where if I press Print Screen, two screenshots will be taken. My theory is that D2GL is taking a screenshot, and also the in-game Diablo II functionality may also be getting triggered (and re-directed to D2GL). It may be good to have an option to allow disabling the "direct D2GL screenshot" code path, and only take a screenshot when Diablo II requests for a screenshot to be taken (After D2 receives the Print Screen signal). That should eliminate the issue without requiring people to unset their Print Screen, which will affect other Cactus Platforms.

Thank you, Jonathan (fearedbliss)

fearedbliss commented 6 months ago

Small update, single screenshots are taken in the main menu, but two screenshots are taken once in game. I wonder if there is some sort of race condition with the signal capturing logic.

bayaraa commented 6 months ago

It's actually D2's screenshot function is signaling to D2GL (no direct screenshot). Don't know why multiple screenshot taken. Is it framerate uncapped? Without any mods still taken multiple screenshots?

fearedbliss commented 6 months ago

Thanks for the reply @bayaraa. I've done some testing between different versions (in vanilla state), and mods from 1.09b, 1.10, and 1.13c, and these are the results. I'll combine the cursor/screenshots results into this one but we can discuss discuss specifics if anything in separate issues:

Tested on D2GL 1.3.3 with default settings. Only glide3x.dll is used (via -3dfx). I didn't use the ddraw.dll at all (since I'm using cnc-ddraw for this). This means my D2 Directory has D2GL's glide3x.dll and cnc-ddraw's ddraw.dll in the same directory. Hopefully this is ok and D2GL isn't calling into ddraw.dll if I specify -3dfx code path.

All of the below mods work with cnc-ddraw via DirectDraw for both screenshots in Main Menu/In Game, and and also cursor lock/unlock.

I also tried taking a screenshot in the main menu in admin mode, and it didn't work.


Vanilla (1.10 Base)

Main Menu: Doesn't work (No screenshots at all). IG: Good (Only 1 screenshot). Cursor: Good (Locks/Unlocks properly - Cursor is only always unlocked when Ctrl + O window is opened).

Singling (1.10 Base - Includes my own FPS unlock fix)

Main Menu: Doesn't work (No screenshots at all). IG: Good (Only 1 screenshot). Cursor: Good (Locks/Unlocks properly - Cursor is only always unlocked when Ctrl + O window is opened).

Le Royaume des Ombres (6.00 Beta) (1.10 Base)

However, screenshots don't trigger in main menu (same as the other 1.10 versions).

Boss Hunter (1.13c Base w/ BaseMod)

SlashGaming-Diablo-II-Free_Resolution ... src/helper/file_version.cc ...
not being able to map the 1.3.3.0 file verson to a known glide3x.

Succulent (1.09b Base)

Valhalla 5.03 (1.10 Base)

Median XL (2012, v005) (1.10 Base)

Main Menu: Doesn't work (No screenshots at all). IG: Good (Only 1 screenshot). Cursor: Good (Locks/Unlocks properly - Cursor is only always unlocked when Ctrl + O window is opened).

Median XL (Ultimative XVI) (1.13c Base, Doesn't use BaseMod)

Main Menu: Good (Only 1 screenshot). IG: Bad (Takes 2 screenshots). Cursor: Good (Locks/Unlocks properly - Cursor is only always unlocked when Ctrl + O window is opened).

Diablo II Extended (1.08b) (1.13c Base, Uses BaseMod)

Main Menu: Good (Only 1 screenshot). IG: Bad (Takes 2 screenshots). Cursor: Good (Locks/Unlocks properly - Cursor is only always unlocked when Ctrl + O window is opened).

bayaraa commented 6 months ago

I think D2's default screenshot function only works in ingame. Those 2 screenshot images are same size/format? and sequential filename?

fearedbliss commented 6 months ago

Hey @bayaraa, Default functionality works in main menu and in game (You can test this with -w).

That's correct. Here's a screenshot (first is in main menu for Median XL Ultimative XVI, which took 1 proper screenshot in png format, Screenshot 2 and 4 are two separate print screen presses in game, and you can see the subsequent identically sized pngs):

Capture

By the way, don't worry about mods that are not compatible due to some weird "glide specific check" they are using. I only listed those so you can get a better sense of the landscape.

bayaraa commented 6 months ago

Default functionality works in main menu and in game (You can test this with -w).

I see. didn't know that.

Capture It seems your right. Default key Print Screen It takes 2 screenshots. But when i press J (Key/Button Two) it take only 1 screenshot. There is something that calls screenshot twice when i press Print Screen. Will look later.

Necrolis commented 5 months ago

The original D2Win function sets a delay of ~1000ms between screenshots, this is due to the fact that the command handler for keydown doesn't check for the key down repeat flag, and the input message isn't passed to the handler so it cannot check this for itself.