Example usage for org.lwjgl.opengl GL11 glClear

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

Introduction

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

Prototype

public static void glClear(@NativeType("GLbitfield") int mask) 

Source Link

Document

Sets portions of every pixel in a particular buffer to the same value.

Usage

From source file:com.kauridev.lunarfever.Lunar.java

License:Open Source License

@Override
public void render(double elapsed) {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glLoadIdentity();/*from w w w .j  av a 2 s.  co m*/

    viewManager.render(elapsed);

    Display.update();
}

From source file:com.lukke100.sbdi.Sbdi.java

License:Open Source License

public static void main(String[] args) {
    System.out.println("Beginning Main Method");
    JyInjector jyInjector = new JyInjector();
    jyInjector.main();/*from   www .j a  v a 2 s.com*/
    try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.create();
        Display.setVSyncEnabled(true);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(0);
    }
    GL11.glOrtho(0, 640, 0, 480, 0, 1);
    GL11.glTranslated(.5d, .5d, 0f);
    RenderBuffer.init();

    setActiveMap(new DebugMap(1024, 1024));
    final DebugEntity player = new DebugEntity(128, 128);
    DebugEntity temp = new DebugEntity(130, 128);
    activeCamera = new Camera(0, 0, 16, 12);
    activeCamera.center(player);
    player.queueRender(RenderLayer.ENTITY0);
    temp.queueRender(RenderLayer.ENTITY0);

    Input.addKeyTotal(Keyboard.KEY_RIGHT, Keyboard.KEY_LEFT, new Execute() {
        @Override
        public void exec() {
            player.goRight();

        }
    }, new Execute() {
        @Override
        public void exec() {
            player.idleX();

        }
    }, new Execute() {

        @Override
        public void exec() {
            player.goLeft();

        }
    });

    Input.addKeyTotal(Keyboard.KEY_UP, Keyboard.KEY_DOWN, new Execute() {

        @Override
        public void exec() {
            player.goUp();

        }
    }, new Execute() {

        @Override
        public void exec() {
            player.idleY();

        }
    }, new Execute() {

        @Override
        public void exec() {
            player.goDown();

        }
    });

    System.gc();
    while (!Display.isCloseRequested()) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
        Input.parseHotkeys();
        activeMap.markMoving(player);
        activeMap.markMoving(temp);
        activeMap.moveAll(true);
        activeCamera.center(player);
        Display.setTitle("COORDS: " + player.getxCoord() + " (" + player.getxTile() + "), " + player.getyCoord()
                + " (" + player.getyTile() + "), " + " - MEM: " + memUsage('m'));
        RenderBuffer.process();
        activeCamera.debugTiles();
        FPSCounter.update();
        Display.sync(240);
        Display.update();
    }
    Display.destroy();
    //jyInjector.exit();
}

From source file:com.mbrlabs.mundus.editor.tools.RotateTool.java

License:Apache License

@Override
public void render() {
    super.render();
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);

    ProjectContext projectContext = getProjectManager().current();
    if (state == TransformState.IDLE && projectContext.currScene.currentSelection != null) {
        getBatch().begin(projectContext.currScene.cam);
        xHandle.render(getBatch());//from w  ww  . j a v a 2  s  . c om
        yHandle.render(getBatch());
        zHandle.render(getBatch());
        getBatch().end();
    } else if (projectContext.currScene.currentSelection != null) {
        Viewport vp = projectContext.currScene.viewport;

        GameObject go = projectContext.currScene.currentSelection;
        go.getTransform().getTranslation(temp0);
        Vector3 pivot = projectContext.currScene.cam.project(temp0);

        shapeRenderMat.setToOrtho2D(vp.getScreenX(), vp.getScreenY(), vp.getScreenWidth(),
                vp.getScreenHeight());
        switch (state) {
        case TRANSFORM_X:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(Color.BLACK);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.setColor(COLOR_X);
            shapeRenderer.circle(pivot.x, pivot.y, 7);
            shapeRenderer.end();
            break;
        case TRANSFORM_Y:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(Color.BLACK);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.setColor(COLOR_Y);
            shapeRenderer.circle(pivot.x, pivot.y, 7);
            shapeRenderer.end();
            break;
        case TRANSFORM_Z:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(Color.BLACK);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.setColor(COLOR_Z);
            shapeRenderer.circle(pivot.x, pivot.y, 7);
            shapeRenderer.end();
            break;
        default:
            break;
        }
    }

}

From source file:com.mbrlabs.mundus.editor.tools.ScaleTool.java

License:Apache License

@Override
public void render() {
    super.render();

    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    ProjectContext projectContext = getProjectManager().current();
    if (projectContext.currScene.currentSelection != null) {
        getBatch().begin(projectContext.currScene.cam);
        xHandle.render(getBatch());// w  w w  .  j  a v a  2s . com
        yHandle.render(getBatch());
        zHandle.render(getBatch());
        xyzHandle.render(getBatch());
        getBatch().end();

        GameObject go = projectContext.currScene.currentSelection;
        go.getTransform().getTranslation(temp0);
        if (viewport3d == null) {
            viewport3d = UI.INSTANCE.getSceneWidget().getViewport();
        }

        Vector3 pivot = projectContext.currScene.cam.project(temp0, viewport3d.getScreenX(),
                viewport3d.getScreenY(), viewport3d.getWorldWidth(), viewport3d.getWorldHeight());

        shapeRenderMat.setToOrtho2D(viewport3d.getScreenX(), viewport3d.getScreenY(),
                viewport3d.getScreenWidth(), viewport3d.getScreenHeight());
        switch (state) {
        case TRANSFORM_X:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(COLOR_X);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.end();
            break;
        case TRANSFORM_Y:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(COLOR_Y);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.end();
            break;
        case TRANSFORM_Z:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(COLOR_Z);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.end();
            break;
        case TRANSFORM_XYZ:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(COLOR_XYZ);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.end();
            break;
        default:
            break;
        }
    }

}

From source file:com.mbrlabs.mundus.editor.tools.TranslateTool.java

License:Apache License

@Override
public void render() {
    super.render();
    if (getProjectManager().current().currScene.currentSelection != null) {
        getBatch().begin(getProjectManager().current().currScene.cam);
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        xHandle.render(getBatch());// w  w  w  .j a va 2s .c o m
        yHandle.render(getBatch());
        zHandle.render(getBatch());
        xzPlaneHandle.render(getBatch());

        getBatch().end();
    }
}

From source file:com.mbrlabs.mundus.tools.RotateTool.java

License:Apache License

@Override
public void render() {
    super.render();

    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    if (state == TransformState.IDLE && projectContext.currScene.currentSelection != null) {
        batch.begin(projectContext.currScene.cam);
        xHandle.render(batch);/*from  ww w  .  ja  v a2  s.c o  m*/
        yHandle.render(batch);
        zHandle.render(batch);
        batch.end();
    } else if (projectContext.currScene.currentSelection != null) {
        Viewport vp = projectContext.currScene.viewport;

        GameObject go = projectContext.currScene.currentSelection;
        go.getTransform().getTranslation(temp0);
        Vector3 pivot = projectContext.currScene.cam.project(temp0);

        shapeRenderMat.setToOrtho2D(vp.getScreenX(), vp.getScreenY(), vp.getScreenWidth(),
                vp.getScreenHeight());
        switch (state) {
        case TRANSFORM_X:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(Color.BLACK);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.setColor(COLOR_X);
            shapeRenderer.circle(pivot.x, pivot.y, 7);
            shapeRenderer.end();
            break;
        case TRANSFORM_Y:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(Color.BLACK);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.setColor(COLOR_Y);
            shapeRenderer.circle(pivot.x, pivot.y, 7);
            shapeRenderer.end();
            break;
        case TRANSFORM_Z:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(Color.BLACK);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.setColor(COLOR_Z);
            shapeRenderer.circle(pivot.x, pivot.y, 7);
            shapeRenderer.end();
            break;
        default:
            break;
        }
    }

}

From source file:com.mbrlabs.mundus.tools.ScaleTool.java

License:Apache License

@Override
public void render() {
    super.render();

    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    if (projectContext.currScene.currentSelection != null) {
        batch.begin(projectContext.currScene.cam);
        xHandle.render(batch);/*from w w  w.ja v  a2 s  .  c  o m*/
        yHandle.render(batch);
        zHandle.render(batch);
        xyzHandle.render(batch);
        batch.end();

        GameObject go = projectContext.currScene.currentSelection;
        go.getTransform().getTranslation(temp0);
        if (viewport3d == null) {
            viewport3d = Ui.getInstance().getWidget3D().getViewport();
        }

        Vector3 pivot = projectContext.currScene.cam.project(temp0, viewport3d.getScreenX(),
                viewport3d.getScreenY(), viewport3d.getWorldWidth(), viewport3d.getWorldHeight());

        shapeRenderMat.setToOrtho2D(viewport3d.getScreenX(), viewport3d.getScreenY(),
                viewport3d.getScreenWidth(), viewport3d.getScreenHeight());
        switch (state) {
        case TRANSFORM_X:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(COLOR_X);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.end();
            break;
        case TRANSFORM_Y:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(COLOR_Y);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.end();
            break;
        case TRANSFORM_Z:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(COLOR_Z);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.end();
            break;
        case TRANSFORM_XYZ:
            shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
            shapeRenderer.setColor(COLOR_XYZ);
            shapeRenderer.setProjectionMatrix(shapeRenderMat);
            shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(),
                    Gdx.graphics.getHeight() - Gdx.input.getY(), 2);
            shapeRenderer.end();
            break;
        default:
            break;
        }
    }

}

From source file:com.mbrlabs.mundus.tools.TranslateTool.java

License:Apache License

@Override
public void render() {
    super.render();
    if (projectManager.current().currScene.currentSelection != null) {
        batch.begin(projectManager.current().currScene.cam);
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        xHandle.render(batch);/*w w  w.j  a  v a 2s  . c om*/
        yHandle.render(batch);
        zHandle.render(batch);
        xzPlaneHandle.render(batch);

        batch.end();
    }
}

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 ww .  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

private void doDistortionAndSuperSample() {
    int FBWidth = this.mc.displayFBWidth;
    int FBHeight = this.mc.displayFBHeight;

    if (this.mc.vrSettings.useDistortion || this.mc.vrSettings.useSupersample || this.mc.vrSettings.useFXAA) {
        // Setup ortho projection
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glLoadIdentity();/* ww  w .  j a  v  a 2 s  .c om*/
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glLoadIdentity();

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

    if (this.mc.vrSettings.useSupersample) {
        FBWidth = (int) ceil(this.mc.displayFBWidth * this.mc.vrSettings.superSampleScaleFactor);
        FBHeight = (int) ceil(this.mc.displayFBHeight * this.mc.vrSettings.superSampleScaleFactor);
    }

    if (mc.vrSettings.useDistortion) {
        //mc.checkGLError("Before distortion");

        preDistortionFBO.bindTexture();

        if (this.mc.vrSettings.useFXAA) {
            //chain into the FXAA FBO
            fxaaFBO.bindRenderTarget();
        } else if (this.mc.vrSettings.useSupersample) {
            //chain into the superSample FBO
            postDistortionFBO.bindRenderTarget();
        } else {
            unbindFBORenderTarget();
        }

        GL11.glClearColor(1.0f, 1.0f, 1.0f, 0.5f);
        GL11.glClearDepth(1.0D);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer on the framebuffer to black

        // Render onto the entire screen framebuffer
        GL11.glViewport(0, 0, FBWidth, FBHeight);

        // Set the distortion shader as in use
        ARBShaderObjects.glUseProgramObjectARB(_Distortion_shaderProgramId);

        // Set up the fragment shader uniforms
        ARBShaderObjects.glUniform1iARB(_DistortionShader_RenderTextureUniform, 0);

        if (this.mc.vrSettings.useDistortionTextureLookupOptimisation) {
            distortParams.bindTexture_Unit1();
            ARBShaderObjects.glUniform1iARB(_DistortionShader_DistortionMapUniform, 1);
        }

        ARBShaderObjects.glUniform1iARB(_DistortionShader_half_screenWidthUniform,
                distortParams.half_screenWidth);
        ARBShaderObjects.glUniform2fARB(_DistortionShader_LeftLensCenterUniform, distortParams.leftLensCenterX,
                distortParams.leftLensCenterY);
        ARBShaderObjects.glUniform2fARB(_DistortionShader_RightLensCenterUniform,
                distortParams.rightLensCenterX, distortParams.rightLensCenterY);
        ARBShaderObjects.glUniform2fARB(_DistortionShader_LeftScreenCenterUniform,
                distortParams.leftScreenCenterX, distortParams.leftScreenCenterY);
        ARBShaderObjects.glUniform2fARB(_DistortionShader_RightScreenCenterUniform,
                distortParams.rightScreenCenterX, distortParams.rightScreenCenterY);
        ARBShaderObjects.glUniform2fARB(_DistortionShader_ScaleUniform, distortParams.scaleX,
                distortParams.scaleY);
        ARBShaderObjects.glUniform2fARB(_DistortionShader_ScaleInUniform, distortParams.scaleInX,
                distortParams.scaleInY);
        ARBShaderObjects.glUniform4fARB(_DistortionShader_HmdWarpParamUniform, distortParams.DistortionK[0],
                distortParams.DistortionK[1], distortParams.DistortionK[2], distortParams.DistortionK[3]);
        ARBShaderObjects.glUniform4fARB(_DistortionShader_ChromAbParamUniform, distortParams.ChromaticAb[0],
                distortParams.ChromaticAb[1], distortParams.ChromaticAb[2], distortParams.ChromaticAb[3]);

        drawQuad();

        // Stop shader use
        ARBShaderObjects.glUseProgramObjectARB(0);

        OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
        //mc.checkGLError("After distortion");
    }

    if (this.mc.vrSettings.useFXAA) {
        fxaaFBO.bindTexture();

        if (this.mc.vrSettings.useSupersample) {
            //chain into the superSample FBO
            postDistortionFBO.bindRenderTarget();
        } else {
            unbindFBORenderTarget();
        }

        GL11.glClearColor(1.0f, 1.0f, 1.0f, 0.5f);
        GL11.glClearDepth(1.0D);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer on the framebuffer to black

        // Render onto the entire screen framebuffer
        GL11.glViewport(0, 0, FBWidth, FBHeight);

        // Set the distortion shader as in use
        ARBShaderObjects.glUseProgramObjectARB(_FXAA_shaderProgramId);

        // Set up the fragment shader uniforms
        ARBShaderObjects.glUniform1iARB(_FXAA_RenderTextureUniform, 0);
        ARBShaderObjects.glUniform2fARB(_FXAA_RenderedTextureSizeUniform, (float) FBWidth, (float) FBHeight);

        drawQuad();

        // Stop shader use
        ARBShaderObjects.glUseProgramObjectARB(0);

        OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
        //ShaderHelper.checkGLError("After fxaa");
    }

    if (this.mc.vrSettings.useSupersample) {
        // Now switch to 1st pass target framebuffer
        postSuperSampleFBO.bindRenderTarget();

        // Bind the FBO
        postDistortionFBO.bindTexture();

        GL11.glClearColor(0.0f, 0.0f, 1.0f, 0.5f);
        GL11.glClearDepth(1.0D);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer on the framebuffer to black

        // Render onto the entire screen framebuffer
        GL11.glViewport(0, 0, this.mc.displayFBWidth, FBHeight);

        // Set the downsampling shader as in use
        ARBShaderObjects.glUseProgramObjectARB(_Lanczos_shaderProgramId);

        // Set up the fragment shader uniforms
        ARBShaderObjects.glUniform1fARB(_LanczosShader_texelWidthOffsetUniform,
                1.0f / (3.0f * (float) this.mc.displayFBWidth));
        ARBShaderObjects.glUniform1fARB(_LanczosShader_texelHeightOffsetUniform, 0.0f);
        ARBShaderObjects.glUniform1iARB(_LanczosShader_inputImageTextureUniform, 0);

        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

        // Pass 1
        drawQuad();

        // mc.checkGLError("After Lanczos Pass1");

        // Pass 2
        // Now switch to 2nd pass screen framebuffer
        unbindFBORenderTarget();
        postSuperSampleFBO.bindTexture();

        GL11.glViewport(0, 0, this.mc.displayFBWidth, this.mc.displayFBHeight);
        GL11.glClearColor(0.0f, 0.0f, 1.0f, 0.5f);
        GL11.glClearDepth(1.0D);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

        // Bind the texture
        GL13.glActiveTexture(GL13.GL_TEXTURE0);

        // Set up the fragment shader uniforms for pass 2
        ARBShaderObjects.glUniform1fARB(_LanczosShader_texelWidthOffsetUniform, 0.0f);
        ARBShaderObjects.glUniform1fARB(_LanczosShader_texelHeightOffsetUniform,
                1.0f / (3.0f * (float) this.mc.displayFBHeight));
        ARBShaderObjects.glUniform1iARB(_LanczosShader_inputImageTextureUniform, 0);

        drawQuad();

        // Stop shader use
        ARBShaderObjects.glUseProgramObjectARB(0);
        // mc.checkGLError("After Lanczos Pass2");
    }
}