mirror of
https://github.com/4sval/FModel.git
synced 2026-03-21 17:24:26 -05:00
better fps limiter
This commit is contained in:
parent
aca754a517
commit
0343ee3577
|
|
@ -88,7 +88,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
return Application.Current.Dispatcher.Invoke(delegate
|
||||
{
|
||||
return _snooper ??= new Snooper(
|
||||
new GameWindowSettings { RenderFrequency = 240 },
|
||||
new GameWindowSettings { RenderFrequency = Snooper.GetMaxRefreshFrequency() },
|
||||
new NativeWindowSettings
|
||||
{
|
||||
Size = new OpenTK.Mathematics.Vector2i(
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ using System;
|
|||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using CUE4Parse.UE4.Assets.Exports;
|
||||
using FModel.Views.Snooper.Buffers;
|
||||
using ImGuiNET;
|
||||
|
|
@ -13,6 +13,8 @@ using OpenTK.Windowing.Desktop;
|
|||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
using SixLabors.ImageSharp.Advanced;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using Application = System.Windows.Application;
|
||||
using Keys = OpenTK.Windowing.GraphicsLibraryFramework.Keys;
|
||||
|
||||
namespace FModel.Views.Snooper;
|
||||
|
||||
|
|
@ -183,4 +185,62 @@ public class Snooper : GameWindow
|
|||
base.OnClosing(e);
|
||||
WindowShouldClose(true, true);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool EnumDisplaySettings(
|
||||
string deviceName, int modeNum, ref DEVMODE devMode);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct DEVMODE
|
||||
{
|
||||
private const int CCHDEVICENAME = 0x20;
|
||||
private const int CCHFORMNAME = 0x20;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
|
||||
public string dmDeviceName;
|
||||
public short dmSpecVersion;
|
||||
public short dmDriverVersion;
|
||||
public short dmSize;
|
||||
public short dmDriverExtra;
|
||||
public int dmFields;
|
||||
public int dmPositionX;
|
||||
public int dmPositionY;
|
||||
public ScreenOrientation dmDisplayOrientation;
|
||||
public int dmDisplayFixedOutput;
|
||||
public short dmColor;
|
||||
public short dmDuplex;
|
||||
public short dmYResolution;
|
||||
public short dmTTOption;
|
||||
public short dmCollate;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
|
||||
public string dmFormName;
|
||||
public short dmLogPixels;
|
||||
public int dmBitsPerPel;
|
||||
public int dmPelsWidth;
|
||||
public int dmPelsHeight;
|
||||
public int dmDisplayFlags;
|
||||
public int dmDisplayFrequency;
|
||||
public int dmICMMethod;
|
||||
public int dmICMIntent;
|
||||
public int dmMediaType;
|
||||
public int dmDitherType;
|
||||
public int dmReserved1;
|
||||
public int dmReserved2;
|
||||
public int dmPanningWidth;
|
||||
public int dmPanningHeight;
|
||||
|
||||
}
|
||||
|
||||
public static int GetMaxRefreshFrequency()
|
||||
{
|
||||
var rf = 60;
|
||||
DEVMODE vDevMode = new DEVMODE();
|
||||
var i = 0;
|
||||
while (EnumDisplaySettings(null, i, ref vDevMode))
|
||||
{
|
||||
i++;
|
||||
rf = Math.Max(rf, vDevMode.dmDisplayFrequency);
|
||||
}
|
||||
|
||||
return rf;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user