Java Code Examples for net.minecraft.client.renderer.GlStateManager#matrixMode()

The following examples show how to use net.minecraft.client.renderer.GlStateManager#matrixMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuiItemIconDumper.java    From NotEnoughItems with MIT License 6 votes vote down vote up
private void drawItems() {
    Dimension d = GuiDraw.getDisplayRes();

    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.loadIdentity();
    GlStateManager.ortho(0, d.width * 16D / iconSize, d.height * 16D / iconSize, 0, 1000, 3000);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.clearColor(0, 0, 0, 0);
    GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    int rows = d.height / boxSize;
    int cols = d.width / boxSize;
    int fit = rows * cols;

    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableRescaleNormal();
    GlStateManager.color(1, 1, 1, 1);

    for (int i = 0; drawIndex < ItemPanel.items.size() && i < fit; drawIndex++, i++) {
        int x = i % cols * 18;
        int y = i / cols * 18;
        GuiHelper.drawItem(x + 1, y + 1, ItemPanel.items.get(drawIndex));
    }

    GL11.glFlush();
}
 
Example 2
Source File: GuiItemIconDumper.java    From NotEnoughItems with MIT License 6 votes vote down vote up
private void drawItems() {
    Dimension d = GuiDraw.displayRes();

    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.loadIdentity();
    GlStateManager.ortho(0, d.width*16D/iconSize, d.height*16D/iconSize, 0, 1000, 3000);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.clearColor(0, 0, 0, 0);
    GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    int rows = d.height / boxSize;
    int cols = d.width / boxSize;
    int fit = rows*cols;

    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableRescaleNormal();
    GlStateManager.color(1, 1, 1, 1);

    for(int i = 0; drawIndex < ItemPanel.items.size() && i < fit; drawIndex++, i++) {
        int x = i%cols * 18;
        int y = i/cols * 18;
        GuiContainerManager.drawItem(x+1, y+1, ItemPanel.items.get(drawIndex));
    }

    GL11.glFlush();
}
 
Example 3
Source File: RenderItemHook.java    From SkyblockAddons with MIT License 5 votes vote down vote up
public static void renderToxicArrowPoisonEffect(IBakedModel model, ItemStack stack) {
    SkyblockAddons main = SkyblockAddons.getInstance();

    if (main.getUtils().isOnSkyblock() && main.getConfigValues().isEnabled(Feature.TURN_BOW_GREEN_WHEN_USING_TOXIC_ARROW_POISON)
            && main.getInventoryUtils().isUsingToxicArrowPoison() && Items.bow.equals(stack.getItem()) && main.getUtils().itemIsInHotbar(stack)) {
        TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();

        GlStateManager.depthMask(false);
        GlStateManager.depthFunc(514);
        GlStateManager.disableLighting();
        GlStateManager.blendFunc(768, 1);
        textureManager.bindTexture(BLANK);
        GlStateManager.matrixMode(5890);

        GlStateManager.pushMatrix();

        Minecraft.getMinecraft().getRenderItem().renderModel(model, 0x201cba41);
        GlStateManager.popMatrix();

        GlStateManager.matrixMode(5888);
        GlStateManager.blendFunc(770, 771);
        GlStateManager.enableLighting();
        GlStateManager.depthFunc(515);
        GlStateManager.depthMask(true);
        textureManager.bindTexture(TextureMap.locationBlocksTexture);
    }
}
 
Example 4
Source File: HyperiumRenderItem.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Basically the same as renderEffect, but does not include the depth code and uses custom color
 *
 * @param model the model
 */
private void renderPot(IBakedModel model, int color) {
    GlStateManager.depthMask(false);
    GlStateManager.disableLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_COLOR, 1);
    ((IMixinRenderItem) parent).getTextureManager().bindTexture(RES_ITEM_GLINT);
    GlStateManager.matrixMode(GL11.GL_TEXTURE);
    GlStateManager.pushMatrix();
    GlStateManager.scale(8.0F, 8.0F, 8.0F);
    float f = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
    GlStateManager.translate(f, 0.0F, 0.0F);
    GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
    ((IMixinRenderItem2) parent).callRenderModel(model, color);
    GlStateManager.popMatrix();
    GlStateManager.pushMatrix();
    GlStateManager.scale(8.0F, 8.0F, 8.0F);
    float f1 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
    GlStateManager.translate(-f1, 0.0F, 0.0F);
    GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
    ((IMixinRenderItem2) parent).callRenderModel(model, color);
    GlStateManager.popMatrix();
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableLighting();
    GlStateManager.depthMask(true);

    ((IMixinRenderItem) parent).getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
}
 
Example 5
Source File: EntryValueEffectOpacity.java    From WearableBackpacks with MIT License 5 votes vote down vote up
private static void renderEffect(int x, int y, int width, int height, float opacity) {
	if (opacity <= 0) return;
	Minecraft mc = Minecraft.getMinecraft();
	float animProgress = Minecraft.getSystemTime() / 400.0F;
	
	int color = 0xFF8040CC;
	float r = (color >> 16 & 0xFF) / 255.0F;
	float g = (color >> 8 & 0xFF) / 255.0F;
	float b = (color & 0xFF) / 255.0F;
	GlStateManager.color(r, g, b, opacity * 0.6F);
	
	mc.getTextureManager().bindTexture(ENCHANTED_ITEM_GLINT);
	
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
	GlStateManager.enableAlpha();
	GlStateManager.alphaFunc(GL11.GL_ALWAYS, 0.0F);
	
	for (int i = 0; i < 2; ++i) {
		GlStateManager.matrixMode(GL11.GL_TEXTURE);
		GlStateManager.loadIdentity();
		GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F);
		GlStateManager.translate(0.0F, animProgress * (0.001F + i * 0.003F) * 20.0F, 0.0F);
		GlStateManager.matrixMode(GL11.GL_MODELVIEW);
		GuiUtils.drawTexturedModalRect(x, y, 0, 0, width, height, 0);
	}
	
	GlStateManager.matrixMode(GL11.GL_TEXTURE);
	GlStateManager.loadIdentity();
	GlStateManager.matrixMode(GL11.GL_MODELVIEW);
	
	GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
	GlStateManager.disableAlpha();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
	GlStateManager.disableBlend();
}
 
Example 6
Source File: GuiDownloadTofuTerrain.java    From TofuCraftReload with MIT License 4 votes vote down vote up
private void drawPanorama(float ticks) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.pushMatrix();
    GlStateManager.loadIdentity();
    Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.pushMatrix();
    GlStateManager.loadIdentity();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.disableCull();
    GlStateManager.depthMask(false);
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    byte b0 = 8;

    for (int k = 0; k < b0 * b0; ++k) {
        GlStateManager.pushMatrix();
        float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F;
        float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F;
        float f3 = 0.0F;
        GlStateManager.translate(f1, f2, f3);
        GlStateManager.rotate(MathHelper.sin((panoramaTimer + ticks) / 400.0F) * 15.0F + 10.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(-(panoramaTimer + ticks) * 0.08F, 0.0F, 1.0F, 0.0F);

        for (int l = 0; l < 6; ++l) {
            GlStateManager.pushMatrix();

            switch (l) {
                case 1:
                    GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
                    break;
                case 2:
                    GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
                    break;
                case 3:
                    GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
                    break;
                case 4:
                    GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
                    break;
                case 5:
                    GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
                    break;
            }

            mc.getTextureManager().bindTexture(getPanoramaPaths().getPath(l));
            buffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
            int i = 255 / (k + 1);
            buffer.pos(-1.0D, -1.0D, 1.0D).tex(0.0D, 0.0D).color(255, 255, 255, i).endVertex();
            buffer.pos(1.0D, -1.0D, 1.0D).tex(1.0D, 0.0D).color(255, 255, 255, i).endVertex();
            buffer.pos(1.0D, 1.0D, 1.0D).tex(1.0D, 1.0D).color(255, 255, 255, i).endVertex();
            buffer.pos(-1.0D, 1.0D, 1.0D).tex(0.0D, 1.0D).color(255, 255, 255, i).endVertex();
            tessellator.draw();
            GlStateManager.popMatrix();
        }

        GlStateManager.popMatrix();
        GlStateManager.colorMask(true, true, true, false);
    }

    buffer.setTranslation(0.0D, 0.0D, 0.0D);
    GlStateManager.colorMask(true, true, true, true);
    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.popMatrix();
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.popMatrix();
    GlStateManager.depthMask(true);
    GlStateManager.enableCull();
    GlStateManager.enableDepth();
}
 
Example 7
Source File: RenderTileEntityStoneMortar.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public void render(TileEntityStoneMortar te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    GlStateManager.enableDepth();
    GlStateManager.depthFunc(515);
    GlStateManager.depthMask(true);
    GlStateManager.disableCull();

    if (destroyStage >= 0) {
        this.bindTexture(DESTROY_STAGES[destroyStage]);
        GlStateManager.matrixMode(5890);
        GlStateManager.pushMatrix();
        GlStateManager.scale(4.0F, 4.0F, 1.0F);
        GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
        GlStateManager.matrixMode(5888);
    } else {
        this.bindTexture(TEXTURES);
    }

    GlStateManager.pushMatrix();
    GlStateManager.enableRescaleNormal();

    if (destroyStage < 0) {
        GlStateManager.color(1.0F, 1.0F, 1.0F, alpha);
    }

    GlStateManager.translate((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
    GlStateManager.scale(1.0F, -1.0F, -1.0F);
    GlStateManager.translate(0.0F, 1.0F, 0.0F);
    GlStateManager.scale(0.9995F, 0.9995F, 0.9995F);
    GlStateManager.translate(0.0F, -1.0F, 0.0F);

    this.model.block1.render(0.0625F);

    if(te.getUpdateTag().getInteger("processTimer")!=0){
        float rot = te.getWorld().getTotalWorldTime() % 360;
        rot = rot * 2;
        GlStateManager.rotate(rot, 0.0F, 1.0F, 0.0F);
    }

    this.model.block2.render(0.0625F);
    this.model.handle.render(0.0625F);
    GlStateManager.enableCull();
    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    if (destroyStage >= 0) {
        GlStateManager.matrixMode(5890);
        GlStateManager.popMatrix();
        GlStateManager.matrixMode(5888);
    }
}
 
Example 8
Source File: WrapperGlStateManager.java    From ClientBase with MIT License 4 votes vote down vote up
public static void matrixMode(int var0) {
    GlStateManager.matrixMode(var0);
}
 
Example 9
Source File: MixinLoadingScreenRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @author ConorTheDev
 * @reason Custom screen when loading to a new world
 */
@Inject(method = "setLoadingProgress", at = @At("HEAD"), cancellable = true)
private void setLoadingProgress(CallbackInfo ci) {
    if (Settings.HYPERIUM_LOADING_SCREEN) {
        long nanoTime = Minecraft.getSystemTime();

        if (nanoTime - systemTime >= 100L) {
            systemTime = nanoTime;
            ScaledResolution scaledresolution = new ScaledResolution(mc);
            int scaleFactor = scaledresolution.getScaleFactor();
            int scaledWidth = scaledresolution.getScaledWidth();
            int scaledHeight = scaledresolution.getScaledHeight();

            if (OpenGlHelper.isFramebufferEnabled()) {
                framebuffer.framebufferClear();
            } else {
                GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT);
            }

            framebuffer.bindFramebuffer(false);
            GlStateManager.matrixMode(GL11.GL_PROJECTION);
            GlStateManager.loadIdentity();
            GlStateManager.ortho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 100.0D, 300.0D);
            GlStateManager.matrixMode(GL11.GL_MODELVIEW);
            GlStateManager.loadIdentity();
            GlStateManager.translate(0.0F, 0.0F, -200.0F);

            if (!OpenGlHelper.isFramebufferEnabled()) GlStateManager.clear(16640);

            Tessellator tessellator = Tessellator.getInstance();
            WorldRenderer worldrenderer = tessellator.getWorldRenderer();
            mc.getTextureManager().bindTexture(new ResourceLocation("textures/world-loading.png"));

            Gui.drawModalRectWithCustomSizedTexture(0, 0, 0.0f, 0.0f, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight());

            int progress;
            if ("Loading world".equals(currentlyDisplayedText)) {
                if (message.isEmpty()) {
                    progress = 33;
                } else if (message.equals("Converting world")) {
                    progress = 66;
                } else if (message.equals("Building terrain")) {
                    progress = 90;
                } else {
                    progress = 100;
                }
            } else {
                progress = -1;
            }

            if (progress >= 0) {
                int maxProgress = 100;
                int barTop = 2;
                int barHeight = scaledResolution.getScaledHeight() - 15;
                GlStateManager.disableTexture2D();
                worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
                worldrenderer.pos(maxProgress, barHeight, 0.0D).color(128, 128, 128, 255).endVertex();
                worldrenderer.pos(maxProgress, barHeight + barTop, 0.0D).color(128, 128, 128, 255).endVertex();
                worldrenderer.pos(maxProgress + maxProgress, barHeight + barTop, 0.0D).color(128, 128, 128, 255).endVertex();
                worldrenderer.pos(maxProgress + maxProgress, barHeight, 0.0D).color(128, 128, 128, 255).endVertex();
                worldrenderer.pos(maxProgress, barHeight, 0.0D).color(128, 255, 128, 255).endVertex();
                worldrenderer.pos(maxProgress, barHeight + barTop, 0.0D).color(128, 255, 128, 255).endVertex();
                worldrenderer.pos(maxProgress + progress, barHeight + barTop, 0.0D).color(128, 255, 128, 255).endVertex();
                worldrenderer.pos(maxProgress + progress, barHeight, 0.0D).color(128, 255, 128, 255).endVertex();
                tessellator.draw();
                GlStateManager.enableAlpha();
                GlStateManager.enableBlend();
                Gui.drawRect(0, scaledResolution.getScaledHeight() - 35, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(),
                    new Color(0, 0, 0, 50).getRGB());
                GlStateManager.disableAlpha();
                GlStateManager.disableBlend();
                GlStateManager.enableTexture2D();
            }

            GlStateManager.enableBlend();
            GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
            mc.fontRendererObj.drawString(currentlyDisplayedText, 5, scaledResolution.getScaledHeight() - 30, -1);
            mc.fontRendererObj.drawString(message, 5, scaledResolution.getScaledHeight() - 15, -1);
            framebuffer.unbindFramebuffer();

            if (OpenGlHelper.isFramebufferEnabled()) {
                framebuffer.framebufferRender(scaledWidth * scaleFactor, scaledHeight * scaleFactor);
            }

            mc.updateDisplay();

            try {
                Thread.yield();
            } catch (Exception ignored) {
            }
        }

        ci.cancel();
    }
}
 
Example 10
Source File: CustomCrosshair.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void drawCrosshair() {
    int screenWidth = ResolutionUtil.current().getScaledWidth() / 2;
    int screenHeight = ResolutionUtil.current().getScaledHeight() / 2;
    if (!enabled && !mc.gameSettings.hideGUI) {
        if (mc.gameSettings.showDebugInfo) {
            drawDebugAxisCrosshair(screenWidth, screenHeight);
        }
    }
    if (enabled && (mc.gameSettings.thirdPersonView <= 0 || visibleThirdPerson) && (!mc.gameSettings.hideGUI || visibleHiddenGui) && (
        !mc.thePlayer
            .isSpectator() || visibleSpectator)) {
        if (!visibleDefault) {
            return;
        }
        if (mc.gameSettings.hideGUI) {
            GlStateManager.clear(GL11.GL_ACCUM);
            GlStateManager.matrixMode(GL11.GL_PROJECTION);
            GlStateManager.loadIdentity();
            GlStateManager.ortho(0.0, ResolutionUtil.current().getScaledWidth_double(),
                ResolutionUtil.current().getScaledHeight_double(), 0.0, 1000.0, 3000.0);
            GlStateManager.matrixMode(GL11.GL_MODELVIEW);
            GlStateManager.loadIdentity();
            GlStateManager.translate(0.0f, 0.0f, -2000.0f);
        }
        ++rainbowColourTick;
        Color renderColour = colour;
        int renderGap = gap;
        if (rainbowCrosshair) {
            int red = (int) (
                Math.sin(rainbowSpeed / 100000.0f * rainbowColourTick + 0.0f) * 127.0
                    + 128.0);
            int green = (int) (
                Math.sin(rainbowSpeed / 100000.0f * rainbowColourTick + 2.0f) * 127.0
                    + 128.0);
            int blue = (int) (
                Math.sin(rainbowSpeed / 100000.0f * rainbowColourTick + 4.0f) * 127.0
                    + 128.0);
            renderColour = new Color(red, green, blue, 255);
        }

        if (!mc.thePlayer.isSpectator() && dynamicBow
            && mc.thePlayer.getHeldItem() != null) {
            ItemStack item = mc.thePlayer.getHeldItem();
            int useCount = mc.thePlayer.getItemInUseCount();
            if (dynamicBow
                && mc.thePlayer.getHeldItem().getItem() == Items.bow) {
                float bowExtension =
                    (item.getItem().getMaxItemUseDuration(item) - useCount) / 20.0f;
                if (useCount == 0 || bowExtension > 1.0f) {
                    bowExtension = 1.0f;
                }
                renderGap =
                    gap + (int) ((1.0f - bowExtension) * (gap + 5) * 2.0f);
            }
        }

        if (!mc.gameSettings.showDebugInfo || visibleDebug) {
            switch (crosshairType) {
                case CIRCLE:
                    drawCircleCrosshair(screenWidth, screenHeight, renderGap,
                        renderColour);
                    break;
                case SQUARE:
                    drawSquareCrosshair(screenWidth, screenHeight, renderGap,
                        renderColour);
                    break;
                case ARROW:
                    drawArrowCrosshair(screenWidth, screenHeight, renderGap, renderColour);
                    break;
                case X:
                    drawXCrosshair(screenWidth, screenHeight, renderGap, renderColour);
                    break;
                default:
                    drawCrossCrosshair(screenWidth, screenHeight, renderGap, renderColour);
                    break;
            }

            if (dot) {
                CustomCrosshairGraphics
                    .drawFilledRectangle(screenWidth, screenHeight, screenWidth + 1,
                        screenHeight + 1, colourDot);
            }
        } else {
            drawDebugAxisCrosshair(screenWidth, screenHeight);
        }
    }
    GlStateManager.resetColor();
}
 
Example 11
Source File: MixinMinecraft.java    From VanillaFix with MIT License 4 votes vote down vote up
private void runGUILoop(GuiScreen screen) throws IOException {
    displayGuiScreen(screen);
    while (running && currentScreen != null && !(currentScreen instanceof GuiMainMenu) && !(Loader.isModLoaded("custommainmenu") && currentScreen instanceof GuiCustom)) {
        if (Display.isCreated() && Display.isCloseRequested()) System.exit(0);
        leftClickCounter = 10000;
        currentScreen.handleInput();
        currentScreen.updateScreen();

        GlStateManager.pushMatrix();
        GlStateManager.clear(16640);
        framebuffer.bindFramebuffer(true);
        GlStateManager.enableTexture2D();

        GlStateManager.viewport(0, 0, displayWidth, displayHeight);

        // EntityRenderer.setupOverlayRendering
        ScaledResolution scaledResolution = new ScaledResolution((Minecraft) (Object) this);
        GlStateManager.clear(256);
        GlStateManager.matrixMode(5889);
        GlStateManager.loadIdentity();
        GlStateManager.ortho(0.0D, scaledResolution.getScaledWidth_double(), scaledResolution.getScaledHeight_double(), 0, 1000, 3000);
        GlStateManager.matrixMode(5888);
        GlStateManager.loadIdentity();
        GlStateManager.translate(0, 0, -2000);
        GlStateManager.clear(256);

        int width = scaledResolution.getScaledWidth();
        int height = scaledResolution.getScaledHeight();
        int mouseX = Mouse.getX() * width / displayWidth;
        int mouseY = height - Mouse.getY() * height / displayHeight - 1;
        currentScreen.drawScreen(mouseX, mouseY, 0);

        framebuffer.unbindFramebuffer();
        GlStateManager.popMatrix();

        GlStateManager.pushMatrix();
        framebuffer.framebufferRender(displayWidth, displayHeight);
        GlStateManager.popMatrix();

        updateDisplay();
        Thread.yield();
        Display.sync(60);
        checkGLError("VanillaFix GUI Loop");
    }
}
 
Example 12
Source File: GuiCustom.java    From Custom-Main-Menu with MIT License 4 votes vote down vote up
private void drawPanorama(int p_73970_1_, int p_73970_2_, float p_73970_3_)
{
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder vertexBuffer = tessellator.getBuffer();
	GlStateManager.matrixMode(5889);
	GlStateManager.pushMatrix();
	GlStateManager.loadIdentity();
	Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
	GlStateManager.matrixMode(5888);
	GlStateManager.pushMatrix();
	GlStateManager.loadIdentity();
	GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
	GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.enableBlend();
	GlStateManager.disableAlpha();
	GlStateManager.disableCull();
	GlStateManager.depthMask(false);
	GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
	int i = 8;

	for (int j = 0; j < 64; ++j)
	{
		GlStateManager.pushMatrix();
		float f = ((float) (j % i) / (float) i - 0.5F) / 64.0F;
		float f1 = ((float) (j / i) / (float) i - 0.5F) / 64.0F;
		float f2 = 0.0F;
		GlStateManager.translate(f, f1, 0.0F);
		GlStateManager.rotate(MathHelper.sin(this.panoramaTimer / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F, 0.0F);
		GlStateManager.rotate(-this.panoramaTimer * 0.1F, 0.0F, 1.0F, 0.0F);

		for (int k = 0; k < 6; ++k)
		{
			GlStateManager.pushMatrix();

			if (k == 1)
			{
				GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
			}

			if (k == 2)
			{
				GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
			}

			if (k == 3)
			{
				GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
			}

			if (k == 4)
			{
				GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
			}

			if (k == 5)
			{
				GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
			}

			titlePanoramaPaths[k].bind();
			vertexBuffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
			int l = 255 / (j + 1);
			float f3 = 0.0F;
			vertexBuffer.pos(-1.0D, -1.0D, 1.0D).tex(0.0D, 0.0D).color(255, 255, 255, l).endVertex();
			vertexBuffer.pos(1.0D, -1.0D, 1.0D).tex(1.0D, 0.0D).color(255, 255, 255, l).endVertex();
			vertexBuffer.pos(1.0D, 1.0D, 1.0D).tex(1.0D, 1.0D).color(255, 255, 255, l).endVertex();
			vertexBuffer.pos(-1.0D, 1.0D, 1.0D).tex(0.0D, 1.0D).color(255, 255, 255, l).endVertex();
			tessellator.draw();
			GlStateManager.popMatrix();
		}

		GlStateManager.popMatrix();
		GlStateManager.colorMask(true, true, true, false);
	}

	vertexBuffer.setTranslation(0.0D, 0.0D, 0.0D);
	GlStateManager.colorMask(true, true, true, true);
	GlStateManager.matrixMode(5889);
	GlStateManager.popMatrix();
	GlStateManager.matrixMode(5888);
	GlStateManager.popMatrix();
	GlStateManager.depthMask(true);
	GlStateManager.enableCull();
	GlStateManager.enableDepth();
}
 
Example 13
Source File: RendererBackpack.java    From WearableBackpacks with MIT License 4 votes vote down vote up
private static void renderEnchanted(IBackpack backpack, BlockModelRenderer renderer,
                                    float ticks, boolean renderStraps) {
	
	Minecraft mc = Minecraft.getMinecraft();
	float glintStrength = WearableBackpacks.CONFIG.cosmetic.enchantEffectOpacity.get().floatValue();
	if (glintStrength <= 0) return;
	float glintScale   = 1.5F;
	float animProgress = ticks / 10;
	
	int color = IntermodUtils.getRuneColor(backpack.getStack());
	float r = (color >> 16 & 0xFF) / 255.0F * glintStrength;
	float g = (color >>  8 & 0xFF) / 255.0F * glintStrength;
	float b = (color       & 0xFF) / 255.0F * glintStrength;
	
	mc.getTextureManager().bindTexture(ENCHANTED_ITEM_GLINT);
	mc.entityRenderer.setupFogColor(true);
	
	GlStateManager.disableLighting();
	GlStateManager.depthMask(false);
	GlStateManager.depthFunc(GL11.GL_EQUAL);
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE);
	
	for (int i = 0; i < 2; ++i) {
		GlStateManager.matrixMode(GL11.GL_TEXTURE);
		GlStateManager.loadIdentity();
		GlStateManager.scale(glintScale, glintScale, glintScale);
		GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F);
		GlStateManager.translate(0.0F, animProgress * (0.001F + i * 0.003F) * 20.0F, 0.0F);
		GlStateManager.matrixMode(GL11.GL_MODELVIEW);
		renderModel(backpack, renderer, ticks, renderStraps, r, g, b, true);
	}
	
	GlStateManager.matrixMode(GL11.GL_TEXTURE);
	GlStateManager.loadIdentity();
	GlStateManager.matrixMode(GL11.GL_MODELVIEW);
	
	GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
	GlStateManager.disableBlend();
	GlStateManager.depthFunc(GL11.GL_LEQUAL);
	GlStateManager.depthMask(true);
	GlStateManager.enableLighting();
	
	mc.entityRenderer.setupFogColor(false);
	
}