mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-15 06:54:21 +01:00
Update options
This commit is contained in:
parent
aae98c06f4
commit
ce1d7dc44b
@ -29,6 +29,7 @@ public class Uniforms {
|
|||||||
private static @Nullable UniformBuffer<OptionsUniforms> options;
|
private static @Nullable UniformBuffer<OptionsUniforms> options;
|
||||||
private static @Nullable UniformBuffer<PlayerUniforms> player;
|
private static @Nullable UniformBuffer<PlayerUniforms> player;
|
||||||
private static @Nullable UniformBuffer<LevelUniforms> level;
|
private static @Nullable UniformBuffer<LevelUniforms> level;
|
||||||
|
private static boolean optionsRequiresUpdate = false;
|
||||||
|
|
||||||
public static UniformBuffer<FrameUniforms> frame() {
|
public static UniformBuffer<FrameUniforms> frame() {
|
||||||
if (frame == null) {
|
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) {
|
public static void updateContext(RenderContext ctx) {
|
||||||
var ubo = frame();
|
var ubo = frame();
|
||||||
ubo.provider.setContext(ctx);
|
ubo.provider.setContext(ctx);
|
||||||
ubo.update();
|
ubo.update();
|
||||||
|
|
||||||
options();
|
if (optionsRequiresUpdate) {
|
||||||
|
options().update();
|
||||||
|
optionsRequiresUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
var player = player();
|
var player = player();
|
||||||
player.provider.setContext(ctx);
|
player.provider.setContext(ctx);
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@
|
|||||||
"GameRendererAccessor",
|
"GameRendererAccessor",
|
||||||
"GlStateManagerMixin",
|
"GlStateManagerMixin",
|
||||||
"LightTextureAccessor",
|
"LightTextureAccessor",
|
||||||
|
"OptionsMixin",
|
||||||
"OverlayTextureAccessor",
|
"OverlayTextureAccessor",
|
||||||
"RenderSystemMixin"
|
"RenderSystemMixin"
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user