Search in sources :

Example 1 with IEOFWorldRenderer

use of com.qouteall.immersive_portals.IEOFWorldRenderer in project ImmersivePortalsMod by qouteall.

the class OFInterfaceInitializer method init.

public static void init() {
    Validate.isTrue(OFInterface.isOptifinePresent);
    OFInterface.isShaders = Config::isShaders;
    OFInterface.isShadowPass = () -> Config.isShaders() && Shaders.isShadowPass;
    OFInterface.bindToShaderFrameBuffer = () -> {
        EXTFramebufferObject.glBindFramebufferEXT(36160, OFGlobal.getDfb.get());
        GlStateManager.viewport(0, 0, Shaders.renderWidth, Shaders.renderHeight);
    };
    OFInterface.beforeRenderCenter = (partialTicks) -> {
        if (Config.isShaders()) {
            MinecraftClient mc = MinecraftClient.getInstance();
            Shaders.activeProgram = Shaders.ProgramNone;
            Shaders.beginRender(mc, mc.gameRenderer.getCamera(), partialTicks, 0);
        }
    };
    OFInterface.afterRenderCenter = () -> Shaders.activeProgram = Shaders.ProgramNone;
    OFInterface.resetViewport = () -> {
        if (OFInterface.isShaders.getAsBoolean()) {
            GlStateManager.viewport(0, 0, Shaders.renderWidth, Shaders.renderHeight);
        }
    };
    OFInterface.onPlayerTraveled = (fromDimension1, toDimension1) -> {
        if (OFInterface.isShaders.getAsBoolean()) {
            OFGlobal.shaderContextManager.onPlayerTraveled(fromDimension1, toDimension1);
        }
    };
    OFInterface.shouldDisableFog = () -> {
        GameRenderer gameRenderer = MinecraftClient.getInstance().gameRenderer;
        if (gameRenderer_fogStandard == null) {
            try {
                gameRenderer_fogStandard = GameRenderer.class.getDeclaredField("fogStandard");
            } catch (NoSuchFieldException e) {
                throw new IllegalStateException(e);
            }
        }
        try {
            boolean fogStandard = gameRenderer_fogStandard.getBoolean(gameRenderer);
            return Config.isFogOff() && fogStandard;
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e);
        }
    };
    OFInterface.createNewRenderInfosNormal = newWorldRenderer1 -> {
        /**
         *{@link WorldRenderer#chunkInfos}
         */
        // in vanilla it will create new chunkInfos object every frame
        // but with optifine it will always use one object
        // we need to switch chunkInfos correctly
        // if we do not put it a new object, it will clear the original chunkInfos
        ((IEOFWorldRenderer) newWorldRenderer1).createNewRenderInfosNormal();
    };
    OFInterface.initShaderCullingManager = ShaderCullingManager::init;
}
Also used : Config(net.optifine.Config) IEOFWorldRenderer(com.qouteall.immersive_portals.IEOFWorldRenderer) MinecraftClient(net.minecraft.client.MinecraftClient) GameRenderer(net.minecraft.client.render.GameRenderer)

Aggregations

IEOFWorldRenderer (com.qouteall.immersive_portals.IEOFWorldRenderer)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 GameRenderer (net.minecraft.client.render.GameRenderer)1 Config (net.optifine.Config)1