narzoul / DDrawCompat

DirectDraw and Direct3D 1-7 compatibility, performance and visual enhancements for Windows Vista, 7, 8, 10 and 11
BSD Zero Clause License
888 stars 67 forks source link

Force the game to run stretch fullscreen #21

Closed LumineBot closed 1 year ago

LumineBot commented 6 years ago

Hi there! I'm running 800x600 game on 1920x1080 with DDrawCompat. Everything works fine except the black border appear on the right and left side.

I want to the game to run forced into stretched fullscreen without modifying my graphic card settings. Because I've tried to modify my graphic card setting scaling into "Scale Fullscreen" option and the game performance drastically went down.

I've zero knowledge about ddraw and dx but I'm not really bad at cpp and I wish to contribute if possible.

Looking forward for the solution Thanks for your awesome works, keep it up!

OS: Windows 10 Pro Graphic Card: Intel HD Graphic 530 / Nvdia GeForce GTX 950M

EDIT: Seems the lag is not caused by stretching game with my graphic card settings, but it's seems come from latest DDrawCompat, (I use it from the source, I compile the source directly in order to remove the logs).

I tried v0.21, the game run smoothly even with "Scaling Fullscreen" option turned on in within my graphic card settings. But still..

If you have pointer which code I should edit in v0.21 to stretch the game! Or even better, make the latest one work proper as v0.21 do, because the game really stutter

Any both of them would be highly appreciated. Thanks in advance.

narzoul commented 6 years ago

I've been a bit inactive on this project lately, but I can certainly give you a few pointers.

Implementing manual stretching to native resolution is something I have been planning to do for the next major version (if I ever get to v0.3.0 first), but it's a lot more effort than it might first appear.

You'd have to override the resolution setting in DisplayMode.cpp (maybe it was still in DirectDraw.cpp in v0.2.1) and convince the game it's running at the correct resolution (IDirectDraw::GetDisplayMode, EnumDisplaySettings(Ex), maybe even SystemParametersInfo and others) without confusing the original ddraw module about the same (most likely with some extra IAT hooks for that). If you lie to ddraw about the resolution it will most likely end up in the primary surface creation/usage failing (resolution not matching the display mode).

Then you'd have to use some kind of scaling when presenting the internal primary surface to the real one in RealPrimarySurface.cpp compatBlt function. If you're fine with the builtin bilinear/nearest pixel scaling offered by DirectDraw then this is pretty simple, just use the Blt method of IDirectDrawSurface. Unfortunately the actual scaling method (bilinear vs nearest) is up to your GPU driver, but you can possibly influence it by changing the flags in the driver's Blt callback, which is now hooked in DeviceFuncs.cpp (though it wasn't in v0.2.1).

If you only need upscaling, the mouse would need to be restricted to the original resolution rectangle via the ClipCursor win32 function, to preserve the original mouse movement speed and to avoid having to convert mouse input coordinates. Then if hardware cursor is used, you'd have to hide it and draw the cursor yourself before presentation, somewhere during compatBlt in RealPrimarySurface.cpp I guess, and make sure the primary is updated frequently enough (at least whenever the mouse is moving) via some timer.

Possibly alt-tabbing may need some fixes after all that in ActiveAppHandler.cpp to reset everything correctly when switching back and forth between other applications.

As for fixing the performance issue, I can possibly help with that if you let me know which game you're having problems with (assuming I have the game and can reproduce the issue). You can also try to debug it yourself, or at least narrow down the problem to a single commit using git bisect.

LumineBot commented 6 years ago

Hi! Thanks for your reply! To be honest, after I open both sources, I would prefer to use latest source instead v0.21 lolol Well, I'm not good at c++ and ddraw / dx in the first place tho.

Anyway, the game what I was running is O2Jam. I don't know whether you ever heard this game but this is an online multiplayer rhythm music game which heavily depends on stable performance.

There are several version out there you can try, such as O2V3, O2INT and O2PF, all of them are fanmade servers . This game originally made between Windows 2000 and Windows XP era.

Let me know if you are interested for the performance fix. Meanwhile, I will check all the hints you told me on my free time.

Once again, Thanks in advance!

elishacloud commented 6 years ago

Hello @LumineBot, you might want to look at this thread here: #9. That thread is about O2Jam also. In addition, DxWnd has the ability to stretch a program to fill the screen. I posted a download here compatibility on o2jam that should allow O2Jam to work with DxWnd.

LumineBot commented 6 years ago

@elishacloud Hi! thanks for the reply. First of all, the issue that you referenced seems has nothing to do with my issue. Embedded WebControl ingame seems run perfectly starting with 0.21, none of my friends facing such issue.

Also I prefer to use DDrawCompat over DxWnd as it provide minimalist solution (only single binary, ddraw.dll without config files and it's open source!). This allow me to distribute easily among my friends, it also appear easier to maintain as it does not contains large codebase.

narzoul commented 6 years ago

Yeah, I've worked on O2Jam issues before, but I'm not having any performance issues with the latest experimental release, either using my dedicated AMD or integrated Intel HD GPUs.

Do you know if the issue is specific to your Nvidia GPU? Can you try switching to Intel HD? Since you seem to have a mobile GPU I guess you have some kind of Optimus setup, so that may complicate things, but I guess it's possible to configure it to run on Intel only?

narzoul commented 1 year ago

Display scaling has been added in v0.4.0. As for O2Jam, it went on my no-support list, along with all other online games.