Example usage for org.lwjgl.opengl GL11 glEnable

List of usage examples for org.lwjgl.opengl GL11 glEnable

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glEnable.

Prototype

public static void glEnable(@NativeType("GLenum") int target) 

Source Link

Document

Enables the specified OpenGL state.

Usage

From source file:com.mtbs3d.minecrift.render.FBOParams.java

License:LGPL

public FBOParams(String fboName, int textureType, int internalFormat, int baseFormat, int bufferType,
        int fboWidth, int fboHeight) throws Exception {
    Minecraft mc = Minecraft.getMinecraft();
    _textureType = textureType;//w  ww . ja va  2 s.  c o  m

    if (fboSupport == FBO_SUPPORT.USE_EXT_UNKNOWN) {
        // The framebuffer, which regroups 0, 1, or more textures, and 0 or 1 depth buffer.
        try {
            _frameBufferId = GL30.glGenFramebuffers();
            fboSupport = FBO_SUPPORT.USE_GL30;
        } catch (IllegalStateException ex) {
            System.out.println(
                    "[Minecrift] FBO creation: GL30.glGenFramebuffers not supported. Attempting to use EXTFramebufferObject.glGenFramebuffersEXT");
            fboSupport = FBO_SUPPORT.USE_EXT;

            try {
                _frameBufferId = EXTFramebufferObject.glGenFramebuffersEXT();
            } catch (IllegalStateException ex1) {
                System.out.println(
                        "[Minecrift] FBO creation: EXTFramebufferObject.glGenFramebuffersEXT not supported, FBO creation failed.");
                throw ex1;
            }
        }
    } else if (fboSupport == FBO_SUPPORT.USE_GL30) {
        _frameBufferId = GL30.glGenFramebuffers();
    } else {
        _frameBufferId = EXTFramebufferObject.glGenFramebuffersEXT();
    }

    if (fboSupport == FBO_SUPPORT.USE_GL30) {
        _colorTextureId = GL11.glGenTextures();
        _depthRenderBufferId = GL30.glGenRenderbuffers();

        GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, _frameBufferId);
        mc.checkGLError("FBO bind framebuffer");

        GL11.glBindTexture(textureType, _colorTextureId);
        mc.checkGLError("FBO bind texture");

        GL11.glEnable(textureType);
        GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexImage2D(textureType, 0, internalFormat, fboWidth, fboHeight, 0, baseFormat, bufferType,
                (java.nio.ByteBuffer) null);

        //System.out.println("[Minecrift] FBO '" + fboName + "': w: " + fboWidth + ", h: " + fboHeight);

        GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, textureType,
                _colorTextureId, 0);

        mc.checkGLError("FBO bind texture framebuffer");

        GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, _depthRenderBufferId); // bind the depth renderbuffer
        GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL14.GL_DEPTH_COMPONENT24, fboWidth, fboHeight); // get the data space for it
        GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER,
                _depthRenderBufferId);
        mc.checkGLError("FBO bind depth framebuffer");
    } else {
        _colorTextureId = GL11.glGenTextures();
        _depthRenderBufferId = EXTFramebufferObject.glGenRenderbuffersEXT();

        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _frameBufferId);
        mc.checkGLError("FBO bind framebuffer");

        GL11.glBindTexture(textureType, _colorTextureId);
        mc.checkGLError("FBO bind texture");

        GL11.glEnable(textureType);
        GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexImage2D(textureType, 0, internalFormat, fboWidth, fboHeight, 0, baseFormat, bufferType,
                (java.nio.ByteBuffer) null);
        //System.out.println("[Minecrift] FBO '" + fboName + "': w: " + fboWidth + ", h: " + fboHeight);

        EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
                EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, textureType, _colorTextureId, 0);

        mc.checkGLError("FBO bind texture framebuffer");

        EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                _depthRenderBufferId); // bind the depth renderbuffer
        EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                GL14.GL_DEPTH_COMPONENT24, fboWidth, fboHeight); // get the data space for it
        EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
                EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT,
                _depthRenderBufferId);
        mc.checkGLError("FBO bind depth framebuffer");
    }

    if (!checkFramebufferStatus()) {
        // OK, if we have an error here - then throw an exception
        System.out.println("[Minecrift] FAILED to create framebuffer!!");
        throw new Exception("Failed to create framebuffer");
    }
}

From source file:com.mtbs3d.minecrift.VRRenderer.java

License:LGPL

public void renderGUIandWorld(float renderPartialTicks) {
    this.farPlaneDistance = (float) this.mc.gameSettings.ofRenderDistanceFine;

    if (Config.isFogFancy()) {
        this.farPlaneDistance *= 0.95F;
    }//from   w  w  w  . j a va 2s . c  o  m

    if (Config.isFogFast()) {
        this.farPlaneDistance *= 0.83F;
    }

    if (this.prevFarPlaneDistance != this.farPlaneDistance) {
        _FBOInitialised = false;
        this.prevFarPlaneDistance = this.farPlaneDistance;
    }

    //Ensure FBO are in place and initialized
    if (!setupFBOs())
        return;

    boolean guiShowingThisFrame = false;
    int mouseX = 0;
    int mouseY = 0;
    ScaledResolution var15 = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth,
            this.mc.displayHeight);
    int var16 = var15.getScaledWidth();
    int var17 = var15.getScaledHeight();

    if ((this.mc.theWorld != null && !this.mc.gameSettings.hideGUI && this.mc.thePlayer.getSleepTimer() == 0)
            || this.mc.currentScreen != null || this.mc.loadingScreen.isEnabled()) {
        //Render all UI elements into guiFBO
        mouseX = Mouse.getX() * var16 / this.mc.displayWidth;
        mouseY = var17 - Mouse.getY() * var17 / this.mc.displayHeight - 1;

        guiFBO.bindRenderTarget();

        GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
        GL11.glClearColor(0, 0, 0, 0);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glLoadIdentity();
        GL11.glOrtho(0.0D, var15.getScaledWidth_double(), var15.getScaledHeight_double(), 0.0D, 1000.0D,
                3000.0D);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glLoadIdentity();
        GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
        guiShowingThisFrame = true;
    }

    // Display loading / progress window if necessary
    if (this.mc.loadingScreen.isEnabled()) {
        this.mc.loadingScreen.vrRender(var16, var17);
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    } else if (this.mc.theWorld != null && !this.mc.gameSettings.hideGUI && !this.blankGUIUntilWorldValid) {
        //Disable any forge gui crosshairs and helmet overlay (pumkinblur)
        if (Reflector.ForgeGuiIngame_renderCrosshairs.exists()) {
            Reflector.ForgeGuiIngame_renderCrosshairs.setValue(false);
            Reflector.ForgeGuiIngame_renderHelmet.setValue(false);
        }
        //Draw in game GUI
        this.mc.ingameGUI.renderGameOverlay(renderPartialTicks, this.mc.currentScreen != null, mouseX, mouseY);
        guiAchievement.updateAchievementWindow();
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    }

    if (this.blankGUIUntilWorldValid) {
        if (this.mc.theWorld != null)
            this.blankGUIUntilWorldValid = false;
    }

    if (this.mc.loadingScreen.isEnabled() == false && this.mc.currentScreen != null
            && !this.blankGUIUntilWorldValid) {
        try {
            this.mc.currentScreen.drawScreen(mouseX, mouseY, renderPartialTicks);
        } catch (Throwable var13) {
            CrashReport var11 = CrashReport.makeCrashReport(var13, "Rendering screen");
            throw new ReportedException(var11);
        }

        GL11.glDisable(GL11.GL_LIGHTING); //inventory messes up fog color sometimes... This fixes
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        drawMouseQuad(mouseX, mouseY);
    }

    //Setup render target
    if (mc.vrSettings.useDistortion) {
        preDistortionFBO.bindRenderTarget();
    } else if (this.mc.vrSettings.useSupersample) {
        postDistortionFBO.bindRenderTarget();
        eyeRenderParams._renderScale = 1.0f;
    } else {
        unbindFBORenderTarget();
        eyeRenderParams._renderScale = 1.0f;
    }

    GL11.glClearColor(0, 0, 0, 1);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);

    if (this.mc.theWorld != null) {
        //If we're in-game, render in-game stuff
        this.mc.mcProfiler.startSection("level");

        if (this.mc.renderViewEntity == null) {
            this.mc.renderViewEntity = this.mc.thePlayer;
        }

        EntityLivingBase renderViewEntity = this.mc.renderViewEntity;
        this.mc.mcProfiler.endStartSection("center");

        //Used by fog comparison, 3rd person camera/block collision detection
        renderOriginX = renderViewEntity.lastTickPosX
                + (renderViewEntity.posX - renderViewEntity.lastTickPosX) * (double) renderPartialTicks;
        renderOriginY = renderViewEntity.lastTickPosY
                + (renderViewEntity.posY - renderViewEntity.lastTickPosY) * (double) renderPartialTicks;
        renderOriginZ = renderViewEntity.lastTickPosZ
                + (renderViewEntity.posZ - renderViewEntity.lastTickPosZ) * (double) renderPartialTicks;

        if (this.mc.currentScreen == null) {
            this.mc.mcProfiler.endStartSection("pick");
            getPointedBlock(renderPartialTicks);
        }

        // Update sound engine
        setSoundListenerOrientation();

    }

    //Update gui Yaw
    if (guiShowingThisFrame && !guiShowingLastFrame) {
        guiHeadYaw = this.cameraYaw - this.mc.lookaimController.getBodyYawDegrees();
    }
    guiShowingLastFrame = guiShowingThisFrame;

    //Now, actually render world
    for (int renderSceneNumber = 0; renderSceneNumber < 2; ++renderSceneNumber) {
        setupEyeViewport(renderSceneNumber);

        this.mc.mcProfiler.endStartSection("camera");
        //transform camera with pitch,yaw,roll + neck model + game effects 
        setupCameraTransform(renderPartialTicks, renderSceneNumber);

        if (this.mc.theWorld != null) {
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glPushMatrix();

            this.renderWorld(renderPartialTicks, 0L, renderSceneNumber);
            this.disableLightmap(renderPartialTicks);

            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glPopMatrix();
        } else {
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer on the framebuffer to black
            GL11.glDisable(GL11.GL_BLEND);
        }

        if (guiShowingThisFrame) {
            GL11.glPushMatrix();
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            guiFBO.bindTexture();

            // Prevent black border at top / bottom of GUI
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);

            if (this.mc.theWorld != null && this.mc.vrSettings.hudLockToHead) {
                GL11.glLoadIdentity();

                if (renderSceneNumber == 0)
                    GL11.glMultMatrix(eyeRenderParams.gl_getLeftViewportTransform());
                else
                    GL11.glMultMatrix(eyeRenderParams.gl_getRightViewportTransform());

                GL11.glRotatef(180f - this.mc.vrSettings.hudYawOffset, 0f, 1f, 0f);
                GL11.glRotatef(-this.mc.vrSettings.hudPitchOffset, 1f, 0f, 0f);
                //                    GL11.glRotatef(cameraRoll, 0f, 0f, 1f);

                GL11.glTranslatef(0.0f, 0.0f,
                        this.mc.vrSettings.hudDistance - this.mc.vrSettings.eyeProtrusion);
                GL11.glRotatef(180f, 0f, 1f, 0f);//Not sure why this is necessary... normals/backface culling maybe?
            } else {
                float guiYaw = 0f;
                if (this.mc.theWorld != null) {
                    if (this.mc.vrSettings.lookMoveDecoupled)
                        guiYaw = this.mc.lookaimController.getBodyYawDegrees();
                    else
                        guiYaw = guiHeadYaw + this.mc.lookaimController.getBodyYawDegrees();

                    guiYaw -= this.mc.vrSettings.hudYawOffset;
                } else
                    guiYaw = guiHeadYaw + this.mc.lookaimController.getBodyYawDegrees();
                GL11.glRotatef(-guiYaw, 0f, 1f, 0f);

                float guiPitch = 0f;

                if (this.mc.theWorld != null)
                    guiPitch = -this.mc.vrSettings.hudPitchOffset;

                //                    if( this.mc.vrSettings.allowMousePitchInput)
                //                        guiPitch += this.mc.lookaimController.getBodyPitchDegrees();

                GL11.glRotatef(guiPitch, 1f, 0f, 0f);

                GL11.glTranslatef(0.0f, 0.0f, this.mc.vrSettings.hudDistance);
                GL11.glRotatef(180f, 0f, 1f, 0f);//Not sure why this is necessary... normals/backface culling maybe?
            }

            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            if (this.mc.theWorld != null)
                GL11.glColor4f(1, 1, 1, this.mc.vrSettings.hudOpacity);
            else
                GL11.glColor4f(1, 1, 1, 1);
            if (!this.mc.vrSettings.hudOcclusion)
                GL11.glDisable(GL11.GL_DEPTH_TEST);

            drawQuad2(this.mc.displayWidth, this.mc.displayHeight,
                    this.mc.vrSettings.hudScale * this.mc.vrSettings.hudDistance);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_DEPTH_TEST);

            GL11.glPopMatrix();

            unbindTexture();
            //mc.checkGLError("GUI");
        }

        if (calibrationHelper != null) {
            float x = lookX * mc.vrSettings.hudDistance;
            float y = lookY * mc.vrSettings.hudDistance;
            float z = lookZ * mc.vrSettings.hudDistance;

            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glPushMatrix();
            GL11.glTranslatef(x, y, z);
            GL11.glRotatef(-this.cameraYaw, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(this.cameraPitch, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(this.cameraRoll, 0.0F, 0.0F, 1.0F);
            float textScale = (float) Math.sqrt((x * x + y * y + z * z));
            GL11.glScalef(-INITIAL_CALIBRATION_TEXT_SCALE * textScale,
                    -INITIAL_CALIBRATION_TEXT_SCALE * textScale, -INITIAL_CALIBRATION_TEXT_SCALE * textScale);
            String calibrating = "Calibrating " + calibrationHelper.currentPlugin.getName() + "...";
            mc.fontRenderer.drawStringWithShadow(calibrating, -mc.fontRenderer.getStringWidth(calibrating) / 2,
                    -8, /*white*/16777215);
            String calibrationStep = calibrationHelper.calibrationStep;
            //                mc.fontRenderer.drawStringWithShadow(calibrationStep, -mc.fontRenderer.getStringWidth(calibrationStep)/2, 8, /*white*/16777215);

            int column = 8;
            ArrayList<String> wrapped = new ArrayList<String>();
            Utils.wordWrap(calibrationStep, CALIBRATION_TEXT_WORDWRAP_LEN, wrapped);
            for (String line : wrapped) {
                mc.fontRenderer.drawStringWithShadow(line, -mc.fontRenderer.getStringWidth(line) / 2, column,
                        /*white*/16777215);
                column += 16;
            }

            GL11.glPopMatrix();
            GL11.glEnable(GL11.GL_DEPTH_TEST);
        }
    }
    GL11.glDisable(GL11.GL_SCISSOR_TEST);

    doDistortionAndSuperSample();
    checkLatencyTester();

    // Finish frame
    GL11.glFinish();

    // Get end frame timings
    endFrameTimeNanos = startVSyncPeriodNanos = System.nanoTime();
    long frameTime = endFrameTimeNanos - startFrameRenderNanos;
    addRenderFrameTimeNanos(frameTime);

    mc.checkGLError("After render world and GUI");
}

From source file:com.mtbs3d.minecrift.VRRenderer.java

License:LGPL

public void renderWorld(float renderPartialTicks, long nextFrameTime, int renderSceneNumber) {
    RenderGlobal renderGlobal = this.mc.renderGlobal;
    EffectRenderer effectRenderer = this.mc.effectRenderer;
    EntityLivingBase renderViewEntity = this.mc.renderViewEntity;

    //TODO: fog color isn't quite right yet when eyes split water/air
    this.updateFogColor(renderPartialTicks);
    GL11.glClearColor(fogColorRed, fogColorGreen, fogColorBlue, 0.5f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_DEPTH_TEST);/* w ww . ja v a 2 s .c  om*/
    //mc.checkGLError("FBO init");

    this.mc.mcProfiler.startSection("lightTex");
    if (this.lightmapUpdateNeeded) {
        this.updateLightmap(renderPartialTicks);
    }

    ActiveRenderInfo.updateRenderInfo(this.mc.thePlayer, this.mc.gameSettings.thirdPersonView == 2);
    this.mc.mcProfiler.endStartSection("frustrum");
    ClippingHelperImpl.getInstance(); // setup clip, using current modelview / projection matrices

    if (!Config.isSkyEnabled() && !Config.isSunMoonEnabled() && !Config.isStarsEnabled()) {
        GL11.glDisable(GL11.GL_BLEND);
    } else {
        this.setupFog(-1, renderPartialTicks);
        this.mc.mcProfiler.endStartSection("sky");
        renderGlobal.renderSky(renderPartialTicks);
    }

    GL11.glEnable(GL11.GL_FOG);
    this.setupFog(1, renderPartialTicks);

    if (this.mc.gameSettings.ambientOcclusion != 0) {
        GL11.glShadeModel(GL11.GL_SMOOTH);
    }

    this.mc.mcProfiler.endStartSection("culling");
    Frustrum frustrum = new Frustrum();
    frustrum.setPosition(renderOriginX, renderOriginY, renderOriginZ);

    this.mc.renderGlobal.clipRenderersByFrustum(frustrum, renderPartialTicks);

    if (renderSceneNumber == 0) {
        this.mc.mcProfiler.endStartSection("updatechunks");

        while (!this.mc.renderGlobal.updateRenderers(renderViewEntity, false) && nextFrameTime != 0L) {
            long var15 = nextFrameTime - System.nanoTime();

            if (var15 < 0L || var15 > 1000000000L) {
                break;
            }
        }
    }

    if (renderViewEntity.posY < 128.0D) {
        this.renderCloudsCheck(renderGlobal, renderPartialTicks);
    }

    this.mc.mcProfiler.endStartSection("prepareterrain");
    this.setupFog(0, renderPartialTicks);
    GL11.glEnable(GL11.GL_FOG);
    this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
    RenderHelper.disableStandardItemLighting();
    this.mc.mcProfiler.endStartSection("terrain");
    renderGlobal.sortAndRender(renderViewEntity, 0, (double) renderPartialTicks);
    GL11.glShadeModel(GL11.GL_FLAT);
    boolean var16 = Reflector.ForgeHooksClient.exists();
    EntityPlayer var18;

    if (this.debugViewDirection == 0) {
        RenderHelper.enableStandardItemLighting();
        this.mc.mcProfiler.endStartSection("entities");

        if (var16) {
            Reflector.callVoid(Reflector.ForgeHooksClient_setRenderPass, new Object[] { Integer.valueOf(0) });
        }

        //TODO: multiple render passes for entities?
        renderGlobal.renderEntities(renderViewEntity.getPosition(renderPartialTicks), frustrum,
                renderPartialTicks);

        if (var16) {
            Reflector.callVoid(Reflector.ForgeHooksClient_setRenderPass, new Object[] { Integer.valueOf(-1) });
        }

        RenderHelper.disableStandardItemLighting();

    }

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDepthMask(true);
    this.setupFog(0, renderPartialTicks);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_CULL_FACE);

    this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
    WrUpdates.resumeBackgroundUpdates();

    if (Config.isWaterFancy()) {
        this.mc.mcProfiler.endStartSection("water");

        if (this.mc.gameSettings.ambientOcclusion != 0) {
            GL11.glShadeModel(GL11.GL_SMOOTH);
        }

        GL11.glColorMask(false, false, false, false);
        int var17 = renderGlobal.renderAllSortedRenderers(1, (double) renderPartialTicks);

        if (this.mc.gameSettings.anaglyph) {
            if (anaglyphField == 0) {
                GL11.glColorMask(false, true, true, true);
            } else {
                GL11.glColorMask(true, false, false, true);
            }
        } else {
            GL11.glColorMask(true, true, true, true);
        }

        if (var17 > 0) {
            renderGlobal.renderAllSortedRenderers(1, (double) renderPartialTicks);
        }

        GL11.glShadeModel(GL11.GL_FLAT);
    } else {
        this.mc.mcProfiler.endStartSection("water");
        renderGlobal.renderAllSortedRenderers(1, (double) renderPartialTicks);
    }

    WrUpdates.pauseBackgroundUpdates();

    if (var16 && this.debugViewDirection == 0) {
        RenderHelper.enableStandardItemLighting();
        this.mc.mcProfiler.endStartSection("entities");
        Reflector.callVoid(Reflector.ForgeHooksClient_setRenderPass, new Object[] { Integer.valueOf(1) });
        this.mc.renderGlobal.renderEntities(renderViewEntity.getPosition(renderPartialTicks), frustrum,
                renderPartialTicks);
        Reflector.callVoid(Reflector.ForgeHooksClient_setRenderPass, new Object[] { Integer.valueOf(-1) });
        RenderHelper.disableStandardItemLighting();
    }

    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_BLEND);

    boolean renderOutline = this.mc.vrSettings.alwaysRenderBlockOutline || !this.mc.gameSettings.hideGUI;
    if (this.mc.currentScreen == null && this.cameraZoom == 1.0D && renderViewEntity instanceof EntityPlayer
            && this.mc.objectMouseOver != null && !renderViewEntity.isInsideOfMaterial(Material.water)
            && renderOutline) {
        var18 = (EntityPlayer) renderViewEntity;
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        this.mc.mcProfiler.endStartSection("outline");

        if (!var16 || !Reflector.callBoolean(Reflector.ForgeHooksClient_onDrawBlockHighlight,
                new Object[] { renderGlobal, var18, this.mc.objectMouseOver, Integer.valueOf(0),
                        var18.inventory.getCurrentItem(), Float.valueOf(renderPartialTicks) })) {
            renderGlobal.drawSelectionBox(var18, this.mc.objectMouseOver, 0, renderPartialTicks);
        }
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }

    if (this.mc.currentScreen == null && this.cameraZoom == 1.0D && renderViewEntity instanceof EntityPlayer
            && !renderViewEntity.isInsideOfMaterial(Material.water) && renderOutline
            && this.mc.vrSettings.showEntityOutline) {
        var18 = (EntityPlayer) renderViewEntity;
        if (var18 != null) {
            GL11.glDisable(GL11.GL_ALPHA_TEST);
            this.mc.mcProfiler.endStartSection("entityOutline");

            if (this.bb != null)
                drawBoundingBox(var18, this.bb, renderPartialTicks);

            GL11.glEnable(GL11.GL_ALPHA_TEST);
        }
    }

    this.mc.mcProfiler.endStartSection("destroyProgress");
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    renderGlobal.drawBlockDamageTexture(Tessellator.instance, renderViewEntity, renderPartialTicks);
    GL11.glDisable(GL11.GL_BLEND);
    this.mc.mcProfiler.endStartSection("weather");
    this.renderRainSnow(renderPartialTicks);

    GL11.glDisable(GL11.GL_FOG);

    if (renderViewEntity.posY >= 128.0D) {
        this.renderCloudsCheck(renderGlobal, renderPartialTicks);
    }

    this.enableLightmap((double) renderPartialTicks);
    this.mc.mcProfiler.endStartSection("litParticles");
    RenderHelper.enableStandardItemLighting();
    effectRenderer.renderLitParticles(renderViewEntity, renderPartialTicks);
    RenderHelper.disableStandardItemLighting();
    this.setupFog(0, renderPartialTicks);
    this.mc.mcProfiler.endStartSection("particles");
    effectRenderer.renderParticles(renderViewEntity, renderPartialTicks);
    this.disableLightmap((double) renderPartialTicks);

    if (var16) {
        this.mc.mcProfiler.endStartSection("FRenderLast");
        Reflector.callVoid(Reflector.ForgeHooksClient_dispatchRenderLast,
                new Object[] { renderGlobal, Float.valueOf(renderPartialTicks) });
    }

    if (this.mc.vrSettings.renderFullFirstPersonModel == false) {
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        this.renderHand(renderPartialTicks, renderSceneNumber);
    }

    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); //white crosshair, with blending
    //Draw crosshair
    boolean renderCrosshair = this.mc.vrSettings.alwaysRenderInGameCrosshair || !this.mc.gameSettings.hideGUI;

    if (this.mc.currentScreen == null && this.mc.gameSettings.thirdPersonView == 0 && renderCrosshair) {
        this.mc.mcProfiler.endStartSection("crosshair");
        float crossDepth = (float) Math.sqrt((crossX * crossX + crossY * crossY + crossZ * crossZ));
        float scale = 0.025f * crossDepth * this.mc.vrSettings.crosshairScale;

        GL11.glPushMatrix();
        GL11.glTranslatef(crossX, crossY, crossZ);
        GL11.glRotatef(-this.aimYaw, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(this.aimPitch, 1.0F, 0.0F, 0.0F);
        if (this.mc.vrSettings.crosshairRollsWithHead)
            GL11.glRotatef(this.cameraRoll, 0.0F, 0.0F, 1.0F);
        GL11.glScalef(-scale, -scale, scale);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR);
        this.mc.getTextureManager().bindTexture(Gui.icons);

        float var7 = 0.00390625F;
        float var8 = 0.00390625F;
        Tessellator.instance.startDrawingQuads();
        Tessellator.instance.addVertexWithUV(-1, +1, 0, 0, 16 * var8);
        Tessellator.instance.addVertexWithUV(+1, +1, 0, 16 * var7, 16 * var8);
        Tessellator.instance.addVertexWithUV(+1, -1, 0, 16 * var7, 0);
        Tessellator.instance.addVertexWithUV(-1, -1, 0, 0, 0);
        Tessellator.instance.draw();
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glPopMatrix();
        //mc.checkGLError("crosshair");
    }

    this.mc.mcProfiler.endSection();
}

From source file:com.mtbs3d.minecrift.VRRenderer.java

License:LGPL

public void drawLatencyTesterColoredQuad(float r, float g, float b, float a) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from ww w .j a v a2  s  . c  om*/
    GL11.glEnable(GL11.GL_BLEND);

    // Setup ortho projection
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    GL11.glTranslatef(0.0f, 0.0f, -0.7f);

    // Cover the appropriate areas of the screen with the colored quad
    GL11.glBegin(GL11.GL_QUADS);

    GL11.glColor4f(r, g, b, a);

    GL11.glVertex3f(-0.6f, -0.6f, 0.0f); // Bottom Left Of The Texture and Quad
    GL11.glVertex3f(0.6f, -0.6f, 0.0f); // Bottom Right Of The Texture and Quad
    GL11.glVertex3f(0.6f, 0.6f, 0.0f); // Top Right Of The Texture and Quad
    GL11.glVertex3f(-0.6f, 0.6f, 0.0f); // Top Left Of The Texture and Quad

    GL11.glEnd();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:com.mtbs3d.minecrift.VRRenderer.java

License:LGPL

private void drawMouseQuad(int mouseX, int mouseY) {
    GL11.glDisable(GL11.GL_BLEND);//from w ww . ja v a  2 s .  c  om
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glColor3f(1, 1, 1);
    this.mc.mcProfiler.endStartSection("mouse pointer");
    this.mc.getTextureManager().bindTexture(Gui.icons);
    this.mc.ingameGUI.drawTexturedModalRect(mouseX - 7, mouseY - 7, 0, 0, 16, 16);

    GL11.glEnable(GL11.GL_BLEND);
}

From source file:com.mtbs3d.minecrift.VRRenderer.java

License:LGPL

public void drawBoundingBox(EntityPlayer par1EntityPlayer, AxisAlignedBB bb, float par4) {
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
    GL11.glLineWidth(2.0F);//from w w  w.  j a v  a  2  s . c o  m
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDepthMask(false);
    float var5 = 0.002F;
    double var7 = par1EntityPlayer.lastTickPosX
            + (par1EntityPlayer.posX - par1EntityPlayer.lastTickPosX) * (double) par4;
    double var9 = par1EntityPlayer.lastTickPosY
            + (par1EntityPlayer.posY - par1EntityPlayer.lastTickPosY) * (double) par4;
    double var11 = par1EntityPlayer.lastTickPosZ
            + (par1EntityPlayer.posZ - par1EntityPlayer.lastTickPosZ) * (double) par4;
    drawOutlinedBoundingBox(
            bb.expand((double) var5, (double) var5, (double) var5).getOffsetBoundingBox(-var7, -var9, -var11));

    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:com.mtbs3d.minecrift.VRRenderer.java

License:LGPL

public void drawLine(EntityPlayer par1EntityPlayer, Vec3 start, Vec3 end, float par4) {
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
    GL11.glLineWidth(2.0F);/*from   w w w .  j  a v a  2s  .  com*/
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDepthMask(false);
    float var5 = 0.002F;
    double var7 = par1EntityPlayer.lastTickPosX
            + (par1EntityPlayer.posX - par1EntityPlayer.lastTickPosX) * (double) par4;
    double var9 = par1EntityPlayer.lastTickPosY
            + (par1EntityPlayer.posY - par1EntityPlayer.lastTickPosY) * (double) par4;
    double var11 = par1EntityPlayer.lastTickPosZ
            + (par1EntityPlayer.posZ - par1EntityPlayer.lastTickPosZ) * (double) par4;

    Tessellator var2 = Tessellator.instance;
    var2.startDrawing(GL11.GL_LINE_STRIP);
    var2.addVertex(start.xCoord, start.yCoord, start.zCoord);
    var2.addVertex(end.xCoord, end.yCoord, end.zCoord);
    var2.draw();

    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:com.n8lm.zener.nifty.NiftyGUISystem.java

License:Open Source License

@Override
protected void processSystem() {

    glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();//from  w  ww . j av  a  2s.c  om
    GL11.glOrtho(0, game.getContainer().getWidth(), game.getContainer().getHeight(), 0, -9999, 9999);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    glPushAttrib(GL_ENABLE_BIT);

    GL11.glDisable(GL11.GL_DEPTH_TEST);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_NOTEQUAL, 0);

    GL11.glDisable(GL11.GL_LIGHTING);

    // Back to GL Texture 0 Unit
    glActiveTexture(GL_TEXTURE0);
    glEnable(GL_TEXTURE_2D);
    //glBindTexture();

    nifty.update();
    nifty.render(false);

    glPopAttrib();

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
}

From source file:com.oneofthesevenbillion.ziah.ZiahsClient.gui.GuiModList.java

License:Open Source License

@Override
public void drawScreen(int mouseX, int mouseY, float tick) {
    if (this.modList == null)
        return;//from ww w  .  j  av a2  s .  c o  m
    this.modList.drawScreen(mouseX, mouseY, tick);
    this.drawCenteredString(this.fontRenderer, this.title, this.width / 2, 16, 0xFFFFFF);
    int offsetX = this.listWidth + 20;
    if (this.selectedMod != null) {
        GL11.glEnable(GL11.GL_BLEND);
        String requires = "";
        String[] requiresOrig = this.selectedMod.requiredModules().split(",");
        int i = 0;
        for (String modId : requiresOrig) {
            if (modId.trim().length() <= 0 || modId == null)
                continue;
            Module mod = ModuleManager.getInstance().getModule(modId);
            if (mod != null) {
                requires += mod.name();
            } else {
                requires += modId;
            }
            if (i < requiresOrig.length - 1)
                requires += ", ";
            i++;
        }
        if (requires.trim().length() == 0)
            requires = "Nothing";

        String recommends = "";
        String[] recommendsOrig = this.selectedMod.recommendedModules().split(",");
        i = 0;
        for (String modId : recommendsOrig) {
            if (modId.trim().length() <= 0 || modId == null)
                continue;
            Module mod = ModuleManager.getInstance().getModule(modId);
            if (mod != null) {
                recommends += mod.name();
            } else {
                recommends += modId;
            }
            if (i < recommendsOrig.length - 1)
                recommends += ", ";
            i++;
        }
        if (recommends.trim().length() == 0)
            recommends = "Nothing";

        String incompatibles = "";
        String[] incompatiblesOrig = this.selectedMod.incompatibleModules().split(",");
        i = 0;
        for (String modId : incompatiblesOrig) {
            if (modId.trim().length() <= 0 || modId == null)
                continue;
            Module mod = ModuleManager.getInstance().getModule(modId);
            if (mod != null) {
                incompatibles += mod.name();
            } else {
                incompatibles += modId;
            }
            if (i < incompatiblesOrig.length - 1)
                incompatibles += ", ";
            i++;
        }
        if (incompatibles.trim().length() == 0)
            incompatibles = "Nothing";

        int offsetY = 0;

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        TextureManager tm = this.mc.func_110434_K();
        String logoBase64 = ModuleManager.getInstance().getModuleLogo(this.selectedMod);
        if (logoBase64 != null) {
            InputStream logoIn = new ByteArrayInputStream(DatatypeConverter.parseBase64Binary(logoBase64));

            if (logoIn != null) {
                try {
                    BufferedImage logo = ImageIO.read(logoIn);
                    ResourceLocation rl = tm.func_110578_a(this.selectedMod.moduleId() + "-logo",
                            new DynamicTexture(logo));
                    tm.func_110577_a(rl);

                    Dimension dim = new Dimension(logo.getWidth(), logo.getHeight());
                    double scaleX = dim.width / 200.0;
                    double scaleY = dim.height / 65.0;
                    double scale = 1.0;
                    if (scaleX > 1 || scaleY > 1) {
                        scale = 1.0 / Math.max(scaleX, scaleY);
                    }
                    dim.width *= scale;
                    dim.height *= scale;
                    int top = 32;
                    Tessellator tess = Tessellator.instance;
                    tess.startDrawingQuads();
                    tess.addVertexWithUV(offsetX, top + dim.height, this.zLevel, 0, 1);
                    tess.addVertexWithUV(offsetX + dim.width, top + dim.height, this.zLevel, 1, 1);
                    tess.addVertexWithUV(offsetX + dim.width, top, this.zLevel, 1, 0);
                    tess.addVertexWithUV(offsetX, top, this.zLevel, 0, 0);
                    tess.draw();
                    offsetY += dim.height + 2;
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        offsetY += 35;
        this.drawString(this.fontRenderer, this.selectedMod.name(), offsetX, offsetY, 0xFFFFFF);
        offsetY += 9;
        this.drawString(this.fontRenderer, "Version: "
                + (ModuleManager.getInstance().isModuleUpToDate(this.selectedMod.moduleId(),
                        ModuleManager.getInstance().getModuleVersion(this.selectedMod.moduleId())) ? "2"
                                : "4")
                + ModuleManager.getInstance().getModuleVersion(this.selectedMod.moduleId()) + "r", offsetX,
                offsetY, 0xDDDDDD);
        offsetY += 9;
        this.drawString(this.fontRenderer,
                "State: "
                        + (ModuleManager.getInstance().getLoadedModules().containsKey(this.selectedMod)
                                ? "Loaded"
                                : (ModuleManager.getInstance().getDisabledModules().containsValue(
                                        this.selectedMod) ? "4Disabledr" : "4Not loadedr")),
                offsetX, offsetY, 0xDDDDDD);
        offsetY += 9;
        this.drawString(this.fontRenderer,
                "Required Minecraft Version: " + this.selectedMod.compatibleMCVersion(), offsetX, offsetY,
                0xDDDDDD);
        offsetY += 9;
        this.drawString(this.fontRenderer,
                "Required Ziah_'s Client Version: " + this.selectedMod.compatibleZCVersion(), offsetX, offsetY,
                0xDDDDDD);
        offsetY += 9;
        offsetY += 9;

        i = 0;
        for (String curStr : ((List<String>) this.fontRenderer.listFormattedStringToWidth(
                "Description: " + this.selectedMod.description(), (this.width - 5) - offsetX))) {
            this.drawString(this.fontRenderer, curStr, offsetX, offsetY, 0xDDDDDD);
            offsetY += 9;
            i++;
        }
        offsetY += 9;
        this.drawString(this.fontRenderer, "Required Modules: " + requires, offsetX, offsetY, 0xDDDDDD);
        offsetY += 9;
        this.drawString(this.fontRenderer, "Recommended Modules: " + recommends, offsetX, offsetY, 0xDDDDDD);
        offsetY += 9;
        this.drawString(this.fontRenderer, "Incompatible with: " + incompatibles, offsetX, offsetY, 0xDDDDDD);
        offsetY += 9;
        GL11.glDisable(GL11.GL_BLEND);
    }
    super.drawScreen(mouseX, mouseY, tick);
}

From source file:com.oneofthesevenbillion.ziah.ZiahsClient.gui.GuiRepoModList.java

License:Open Source License

@Override
public void drawScreen(int mouseX, int mouseY, float tick) {
    if (this.modList == null)
        return;/*w  ww . ja va  2 s  .  c om*/
    this.modList.drawScreen(mouseX, mouseY, tick);
    this.drawCenteredString(this.fontRenderer, this.title, this.width / 2, 16, 0xFFFFFF);
    int offsetX = this.listWidth + 20;
    if (this.selectedMod != null) {
        Module modAnnot = ModuleManager.getInstance().getModule(this.selectedMod.getId());
        GL11.glEnable(GL11.GL_BLEND);
        int offsetY = 35;
        this.drawString(this.fontRenderer, this.selectedMod.getName(), offsetX, offsetY, 0xFFFFFF);
        offsetY += 9;
        this.drawString(this.fontRenderer, modAnnot != null ? "2Installedr" : "cNot Installedr",
                offsetX, offsetY, 0xDDDDDD);
        offsetY += 9;
        this.drawString(this.fontRenderer, "Release Version: " + this.selectedMod.getVersion(), offsetX,
                offsetY, 0xDDDDDD);
        offsetY += 9;
        if (modAnnot != null) {
            this.drawString(this.fontRenderer,
                    "Installed Version: " + ModuleManager.getInstance().getModuleVersion(modAnnot.moduleId()),
                    offsetX, offsetY, 0xDDDDDD);
            offsetY += 9;
            if (!ModuleManager.getInstance().isModuleUpToDate(this.selectedMod.getId(),
                    ModuleManager.getInstance().getModuleVersion(modAnnot.moduleId()))) {
                this.drawString(
                        this.fontRenderer, "cA new version of " + this.selectedMod.getName()
                                + " is available: " + this.selectedMod.getVersion() + "r",
                        offsetX, offsetY, 0xDDDDDD);
                offsetY += 9;
            }
        }
        offsetY += 9;

        int i = 0;
        for (String curStr : this.descriptionLines) {
            this.drawString(this.fontRenderer, curStr, offsetX, offsetY, 0xDDDDDD);
            offsetY += 9;
            i++;
        }
        offsetY += 9;
        this.drawString(this.fontRenderer, "Required Modules: " + this.requires, offsetX, offsetY, 0xDDDDDD);
        offsetY += 9;
        this.drawString(this.fontRenderer, "Recommended Modules: " + this.recommends, offsetX, offsetY,
                0xDDDDDD);
        offsetY += 9;
        this.drawString(this.fontRenderer, "Incompatible with: " + this.incompatible, offsetX, offsetY,
                0xDDDDDD);
        offsetY += 9;
        GL11.glDisable(GL11.GL_BLEND);
    }
    super.drawScreen(mouseX, mouseY, tick);
}