Update options

This commit is contained in:
Kneelawk 2024-03-04 14:58:58 -08:00
parent aae98c06f4
commit ce1d7dc44b
No known key found for this signature in database
GPG Key ID: DB4E28870D6D260A
3 changed files with 34 additions and 1 deletions

View File

@ -29,6 +29,7 @@ public class Uniforms {
private static @Nullable UniformBuffer<OptionsUniforms> options;
private static @Nullable UniformBuffer<PlayerUniforms> player;
private static @Nullable UniformBuffer<LevelUniforms> level;
private static boolean optionsRequiresUpdate = false;
public static UniformBuffer<FrameUniforms> frame() {
if (frame == null) {
@ -109,12 +110,20 @@ public class Uniforms {
}
}
public static void onOptionsUpdate() {
// this is sometimes called too early to do an actual update
optionsRequiresUpdate = true;
}
public static void updateContext(RenderContext ctx) {
var ubo = frame();
ubo.provider.setContext(ctx);
ubo.update();
options();
if (optionsRequiresUpdate) {
options().update();
optionsRequiresUpdate = false;
}
var player = player();
player.provider.setContext(ctx);

View File

@ -0,0 +1,23 @@
package com.jozufozu.flywheel.backend.mixin;
import com.jozufozu.flywheel.backend.engine.uniform.Uniforms;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.Options;
@Mixin(Options.class)
public class OptionsMixin {
@Inject(method = "load()V", at = @At("RETURN"))
private void onLoad(CallbackInfo ci) {
Uniforms.onOptionsUpdate();
}
@Inject(method = "save", at = @At("HEAD"))
private void onSave(CallbackInfo ci) {
Uniforms.onOptionsUpdate();
}
}

View File

@ -9,6 +9,7 @@
"GameRendererAccessor",
"GlStateManagerMixin",
"LightTextureAccessor",
"OptionsMixin",
"OverlayTextureAccessor",
"RenderSystemMixin"
],