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

The following examples show how to use net.minecraft.client.renderer.GlStateManager#ortho() . 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: WrapperGlStateManager.java    From ClientBase with MIT License 4 votes vote down vote up
public static void ortho(double param0, double param2, double param4, double param6, double param8, double param10) {
    GlStateManager.ortho(param0, param2, param4, param6, param8, param10);
}
 
Example 4
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 5
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 6
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");
    }
}