|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
marco0999 Cheater Reputation: 0
Joined: 28 Jun 2020 Posts: 29 Location: Italy
|
Posted: Sat Jan 30, 2021 2:49 am Post subject: How change resolution and update window without flickering |
|
|
Hi,
I have created a dll for hooking a game (becouse I don't have the source code) to solve a bug.
In short in this game the videos play in wrong resolutions.
To correct this bug I have inserted in the right place this code:
Code: | bool SetDiplayResolution(int Width, int Height, int Refresh = 0)
{
LONG Outout;
DEVMODE desiredMode;
memset(&desiredMode, 0, sizeof(desiredMode));
desiredMode.dmSize = sizeof(desiredMode);
if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &desiredMode) != 0)
{
desiredMode.dmSize = sizeof(DEVMODE);
desiredMode.dmPelsWidth = Width;
desiredMode.dmPelsHeight = Height;
if (Refresh > 0)
{
desiredMode.dmDisplayFrequency = Refresh;
desiredMode.dmFields = DM_PELSHEIGHT | DM_PELSWIDTH | DM_DISPLAYFREQUENCY;
}
else
{
desiredMode.dmFields = DM_PELSHEIGHT | DM_PELSWIDTH;
}
Outout = ChangeDisplaySettings(&desiredMode, 0);
}
return Outout;
}
void myfunction
{
HWND hWnd = GetActiveWindow();
SetDiplayResolution(1920, 1080);
SetWindowPos(hWnd, 0, 0, 0, 1920, 1080, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
UpdateWindow(hWnd);
} |
This code work fine but unfortunatenly the transaction beetween the old and new resolution produce some very short, but visble annoyng effects:
1. Temporary presence of the windows bar.
2. The screen flash for one instant.
I have also tried to create a secondary “cover” window topmost without success.
I ask if there is a way to solve these problem using DirectDraw, OpenGL , or other way.
Thanks !
|
|
Back to top |
|
|
atom0s Moderator Reputation: 202
Joined: 25 Jan 2006 Posts: 8548 Location: 127.0.0.1
|
Posted: Sat Jan 30, 2021 4:14 am Post subject: |
|
|
Changing the actual display resolution is always going to have side effects like flickering and potential window task/tray bar anomalies. That isn't really the best way to go about what you're doing.
You would need to figure out a few things:
1. What does the game render with/in? (Direct3D, OpenGL, etc. and what version of said API.)
2. What does the game render videos with? (There are a lot of ways to draw/render a video, and it does not have to be done within the same graphics API. They can just pause rendering Direct3D for example, and render the video using a different library to the same window etc.)
3. Does the game alter the window when playing the video? (In some cases, the window itself is resized to fit the exact size of the video file (generally if its a smaller compressed video. Such as the Resident Evil series that compress and downscale videos to shit resolutions.)
With that in mind, it'll be easier to suggest what to do next if that info was available to us.
_________________
- Retired. |
|
Back to top |
|
|
marco0999 Cheater Reputation: 0
Joined: 28 Jun 2020 Posts: 29 Location: Italy
|
Posted: Sat Jan 30, 2021 5:20 am Post subject: |
|
|
Hi Atom0s,
Many thanks for your fast response.
The game is very old "1997" and was modded to another users some year ago to add support for high Resolution videos 1920x1080 (I don't have the source code) and with other affects (Antialiasing, anisotropic filter, etc..)
But this mod have 2 bugs:
1) If the game run at 1920x1080, the aspect ratio is 4:3 but the videos play fine.
2) If the game run at 1280x960, my monitor interpolate perfectly the resolution to full hd and the game work fine, but the videos are cutted to "1280" and add top and down black bar.
I like to play at full hd and the second point is the best compromise.
My hooked DLL force 1920x1080 when the vidoes start and restore 1280x960 when the video finish and work fine apart these very short artefacts.
When I change the resolution (small to high) from:
1280x960 to 1920x1080 (when the video start). I see these very short artifacts.
When I change the resolution (high to small) from:
1920x1080 to 1280x960 (when the video finish). I don't see any artifacts.
The game use OpenGL I don't known what version, however If I chance the resolution to 1920x1080 and I don't write this code:
Code: | SetWindowPos(hWnd, 0, 0, 0, 1920, 1080, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
UpdateWindow(hWnd); |
The video is cutted to "1280x960" with black bar on the right and on the top.
So the window need to update after change the resolution.
Theoretically to see the game in full HD (not in 4:3) I can try a different approch, but probably can be more complicated.
I have used IDA to hook the game with code that I have posted.
How I can find the informations usufull in this situation ?
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|