mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-14 06:24:12 +01:00
avoid 'glGet's at all costs
This commit is contained in:
parent
951a0c4769
commit
11616a0b16
@ -0,0 +1,20 @@
|
||||
package com.simibubi.create.foundation.mixin;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.simibubi.create.foundation.render.backend.gl.GlFog;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
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;
|
||||
|
||||
@Mixin(GlStateManager.class)
|
||||
public class FogColorTrackerMixin {
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "fog")
|
||||
private static void copyFogColor(int pname, float[] params, CallbackInfo ci) {
|
||||
if (pname == GL11.GL_FOG_COLOR) {
|
||||
GlFog.FOG_COLOR = params;
|
||||
}
|
||||
}
|
||||
}
|
@ -47,8 +47,7 @@ public class BasicProgram extends GlProgram {
|
||||
GL20.glUniform3f(uCameraPos, camX, camY, camZ);
|
||||
|
||||
GL20.glUniform2f(uFogRange, GlFog.getFogStart(), GlFog.getFogEnd());
|
||||
GL20.glGetFloatv(GL20.GL_FOG_COLOR, Backend.VEC4_BUFFER);
|
||||
GL20.glUniform4fv(uFogColor, Backend.VEC4_BUFFER);
|
||||
GL20.glUniform4fv(uFogColor, GlFog.FOG_COLOR);
|
||||
}
|
||||
|
||||
protected static void uploadMatrixUniform(int uniform, Matrix4f mat) {
|
||||
|
@ -1,13 +1,29 @@
|
||||
package com.simibubi.create.foundation.render.backend.gl;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
public class GlFog {
|
||||
public static float[] FOG_COLOR = new float[] {0, 0, 0, 0};
|
||||
|
||||
public static boolean fogEnabled() {
|
||||
return GlStateManager.FOG.field_179049_a.field_179201_b;
|
||||
}
|
||||
|
||||
public static int getFogMode() {
|
||||
return GlStateManager.FOG.field_179047_b;
|
||||
}
|
||||
|
||||
public static float getFogDensity() {
|
||||
return GlStateManager.FOG.field_179048_c;
|
||||
}
|
||||
|
||||
public static float getFogEnd() {
|
||||
return GL20.glGetFloat(GL20.GL_FOG_END);
|
||||
return GlStateManager.FOG.field_179046_e;
|
||||
}
|
||||
|
||||
public static float getFogStart() {
|
||||
return GL20.glGetFloat(GL20.GL_FOG_START);
|
||||
return GlStateManager.FOG.field_179045_d;
|
||||
}
|
||||
}
|
||||
|
@ -33,3 +33,9 @@ public net.minecraft.client.Minecraft field_193996_ah #renderPartialTicksPaused
|
||||
public net.minecraft.client.renderer.GameRenderer field_78529_t #rendererUpdateCount
|
||||
public net.minecraft.client.renderer.GameRenderer func_228380_a_(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V #bobViewWhenHurt
|
||||
public net.minecraft.client.renderer.GameRenderer func_228383_b_(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V #bobView
|
||||
|
||||
# Expose fog state to the public
|
||||
public com.mojang.blaze3d.platform.GlStateManager$FogState
|
||||
public com.mojang.blaze3d.platform.GlStateManager field_225663_h_ #FOG
|
||||
public com.mojang.blaze3d.platform.GlStateManager$BooleanState
|
||||
public com.mojang.blaze3d.platform.GlStateManager$BooleanState field_179201_b #field_179201_b
|
@ -3,7 +3,14 @@
|
||||
"package": "com.simibubi.create.foundation.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"refmap": "create.refmap.json",
|
||||
"client": ["OnRemoveTileMixin", "ShaderCloseMixin", "CancelTileEntityRenderMixin", "LightUpdateMixin", "RenderHooksMixin"],
|
||||
"client": [
|
||||
"OnRemoveTileMixin",
|
||||
"ShaderCloseMixin",
|
||||
"CancelTileEntityRenderMixin",
|
||||
"LightUpdateMixin",
|
||||
"RenderHooksMixin",
|
||||
"FogColorTrackerMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user