gpu: add uncap fps option

This commit is contained in:
Adam
2021-10-22 20:49:48 -04:00
parent 6ad7ba1799
commit 6cad150f3a
3 changed files with 39 additions and 2 deletions

View File

@@ -1951,4 +1951,6 @@ public interface Client extends GameEngine
*/
@Nullable
ClanSettings getClanSettings(int clanId);
void setUnlockedFps(boolean unlock);
}

View File

@@ -78,6 +78,7 @@ import net.runelite.api.hooks.DrawCallbacks;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginInstantiationException;
@@ -387,7 +388,10 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
}
this.gl = glContext.getGL().getGL4();
gl.setSwapInterval(0);
final boolean unlockFps = this.config.unlockFps();
client.setUnlockedFps(unlockFps);
gl.setSwapInterval(unlockFps ? 1 : 0);
if (log.isDebugEnabled())
{
@@ -459,6 +463,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
{
client.setGpu(false);
client.setDrawCallbacks(null);
client.setUnlockedFps(false);
invokeOnMainThread(() ->
{
@@ -529,6 +534,23 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
return configManager.getConfig(GpuPluginConfig.class);
}
@Subscribe
public void onConfigChanged(ConfigChanged configChanged)
{
if (configChanged.getGroup().equals(GpuPluginConfig.GROUP))
{
if (configChanged.getKey().equals("unlockFps"))
{
boolean unlockFps = Boolean.parseBoolean(configChanged.getNewValue());
clientThread.invokeLater(() ->
{
client.setUnlockedFps(unlockFps);
invokeOnMainThread(() -> gl.setSwapInterval(unlockFps ? 1 : 0));
});
}
}
}
private void initProgram() throws ShaderException
{
String versionHeader = OSType.getOSType() == OSType.Linux ? LINUX_VERSION_HEADER : WINDOWS_VERSION_HEADER;

View File

@@ -34,9 +34,11 @@ import net.runelite.client.plugins.gpu.config.AntiAliasingMode;
import net.runelite.client.plugins.gpu.config.ColorBlindMode;
import net.runelite.client.plugins.gpu.config.UIScalingMode;
@ConfigGroup("gpu")
@ConfigGroup(GpuPluginConfig.GROUP)
public interface GpuPluginConfig extends Config
{
String GROUP = "gpu";
@Range(
max = MAX_DISTANCE
)
@@ -146,4 +148,15 @@ public interface GpuPluginConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "unlockFps",
name = "Unlock FPS",
description = "Removes the 50 FPS cap for camera movement",
position = 10
)
default boolean unlockFps()
{
return false;
}
}