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.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);//from   w w  w  . j  a  va  2s  .  c o  m
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    //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.opengrave.og.base.Picking.java

License:Open Source License

public static void pickRender(BaseState s) {
    GL11.glClearColor(0, 0, 0, 0);//w  ww  .j ava  2 s  .c  o m
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    allPickables = new HashMap<Long, Pickable>();
    lastInt = 1;
    MainThread.set2D();
    s.renderGuiForPicking();
}

From source file:com.opengrave.og.base.Picking.java

License:Open Source License

public static void pickCleanup() {
    lastInt = 0;//from  ww w.j  a  v a  2  s  .com
    allPickables = null;
    GL11.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
}

From source file:com.opengrave.og.engine.RenderView.java

License:Open Source License

public void render(int totalx, int totaly, int width, int height) {
    this.totalx = totalx;
    this.totaly = totaly;
    this.width = width;
    this.height = height;
    if (sceneNode == null) {
        System.out.println("No scene node to render");
        return;/*from  w w  w.  j av  a  2s. co  m*/
    }
    if (cam == null) {
        System.out.println("No camera to render from");
        return;
    }
    Shadow2D skyLight = sceneNode.getSkyLight();
    if (shadows && hasshadows) {
        // For each light source we map out a texture using a quick
        // render.
        prepare3DShadow();

        skyLight.getFramebuffer().bindDraw();
        // GL11.glEnable(GL32.GL_DEPTH_CLAMP); // TODO Simu;ate depth clamp in shadow shader when z < 0. This way we force distanced objects to still cast a shadow.
        sceneNode.renderShadows(ident, skyLight);
        skyLight.getFramebuffer().unbindDraw();
        int count = 0;
        ArrayList<PointLightNode> lightList = new ArrayList<PointLightNode>();
        sceneNode.getAllLights(lightList, ident, cam.getLocation().toVector4());
        Collections.sort(lightList, new PointLightSorter());
        for (PointLightNode light : lightList) {
            if (light.getColour().x > 0 || light.getColour().y > 0 || light.getColour().z > 0) {
                // Render each face
                if (lightShadows.size() == count) {
                    ShadowCube shadow = new ShadowCube(MainThread.config.getInteger("shadowSize", 1024));
                    lightShadows.add(shadow);
                }
                ShadowCube shadow = lightShadows.get(count);
                shadow.setLight(light);
                for (int i = 0; i < 6; i++) {
                    shadow.getFramebuffer().bindDraw(i);
                    Util.checkErr();
                    shadow.setFace(i);
                    Util.checkErr();
                    sceneNode.renderShadows(ident, shadow);
                    Util.checkErr();
                    shadow.getFramebuffer().unbindDraw();
                    Util.checkErr();
                }

                count++;
            }
            if (count == 16) {
                break;
            }
        }
        GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);

    }
    GL11.glViewport(totalx, totaly, width, height);
    GL11.glScissor(totalx, totaly, width, height);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glClearColor(clearCol.x, clearCol.y, clearCol.z, clearCol.w);
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | (clear ? GL11.GL_COLOR_BUFFER_BIT : 0));
    Util.checkErr();

    prepare3DOpaque();
    sceneNode.render(ident);
    Util.checkErr();
    prepare3DTransparent();
    sceneNode.renderSemiTransparent(ident);
    MouseRenderableHoverEvent lF = MainThread.main.input.getLastHovered();
    if (lF != null) {
        if (lF.getRenderable() instanceof BaseObject) {
            /*
             * GL11.glDepthFunc(GL11.GL_LESS);
             * GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
             * GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_LINE);
             * 
             * GL11.glLineWidth(10f);
             * GL11.glCullFace(GL11.GL_FRONT);
             * GL11.glEnable(GL11.GL_CULL_FACE);
             * GL11.glDisable(GL11.GL_BLEND);
             * BaseObject bo = (BaseObject) lF.getRenderable();
             * RenderStyle rs = bo.getRenderStyle();
             * bo.setRenderStyle(RenderStyle.HALO);
             * sceneNode.renderOne(ident, bo, ident);
             * 
             * GL11.glDisable(GL11.GL_BLEND);
             * 
             * bo.setRenderStyle(rs);
             * GL11.glCullFace(GL11.GL_BACK);
             * GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
             * GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_FILL);
             * 
             * GL11.glLineWidth(1f);
             * sceneNode.renderOne(ident, bo, ident);
             */

        }
    }

    revertSettings();
    GL11.glDisable(GL11.GL_SCISSOR_TEST);

}

From source file:com.opengrave.og.light.Depth2DFramebuffer.java

License:Open Source License

@Override
public void bindDraw() {
    Util.checkErr();//from ww  w  .j  a  va  2s  .  co  m

    for (int i = GL13.GL_TEXTURE0; i < GL13.GL_TEXTURE31; i++) {
        GL13.glActiveTexture(i);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
        GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, 0);
        GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, 0);
    }
    Util.checkErr();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
    Util.checkErr();
    GL11.glDisable(GL11.GL_BLEND);
    Util.checkErr();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LESS);
    GL11.glDepthMask(true);
    Util.checkErr();
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    Util.checkErr();
    GL11.glViewport(0, 0, framebufferSize, framebufferSize);

}

From source file:com.opengrave.og.light.DepthCubeFramebuffer.java

License:Open Source License

public void bindDraw(int direction) {
    Util.checkErr();//from   w w w .  ja v a 2  s .  c  om
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
    shadowMap.bindToFrameBuffer(direction);
    Util.checkErr();

    Util.checkErr();
    GL11.glDisable(GL11.GL_BLEND);
    Util.checkErr();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LESS);
    GL11.glDepthMask(true);
    Util.checkErr();
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    Util.checkErr();
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glViewport(0, 0, framebufferSize, framebufferSize);

}

From source file:com.opengrave.og.MainThread.java

License:Open Source License

public void gameLoop() {
    Util.checkErr();/*from  w  w w . j a v  a 2  s.  c o  m*/
    double lasttime = getTime(), lastFPS = getTime();
    int fps = 0;
    while (running) {
        if (needsConfigUpdate) {
            createConfig();
            needsConfigUpdate = false;
        }
        synchronized (toDoList) {
            while (toDoList.size() > 0) {
                Runnable runnable = toDoList.remove(0);
                runnable.run();
            }
        }

        if (nextState != null) {

            // Something has caused us to switch states, stop the last
            // cleanly and start the next
            if (state != null) {
                state.stop();
                state.finalise();
            }

            state = nextState;
            state.prestart();
            state.start();

            nextState = null;
        }
        // Update FPS counter in window title TODO: Remove from window title
        // and place into a debug context ingame
        if (getTime() - lastFPS > 1000) {
            // use fps value
            fps = 0;
            lastFPS += 1000;
        }

        fps++;
        // Prepare time delta for updating graphics
        double time = getTime();
        float delta = (float) (time - lasttime); // TODO Change delta to double as a rule?
        lasttime = time;
        input.doEet(state, delta);
        Util.checkErr();
        state.updateGUI(delta);
        Util.checkErr();
        state.update(delta); // Pre-render update
        Util.checkErr();

        // Clear frame ready for next frame
        GL11.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT);
        GL11.glViewport(0, 0, lastW, lastH);

        set2D();
        state.renderGUI();
        if (glfwWindowShouldClose(window) == GL_TRUE) {
            running = false;
        }
        glfwPollEvents();
        // if (fpsCap > 10) {
        glfwSwapBuffers(window);
        // }
        Util.checkErr();

    }

    running = false;
    // soundSystem.cleanup();
    System.exit(1);
}

From source file:com.owens.oobjloader.Main.java

License:BSD License

/**
 * Runs the program (the "main loop")//ww  w  .j ava  2  s .  co m
 */
private static void run(String filename, String defaultTextureMaterial) {
    DisplayModel scene = null;

    scene = new DisplayModel();

    log.log(INFO, "Parsing WaveFront OBJ file");
    Build builder = new Build();
    Parse obj = null;
    try {
        obj = new Parse(builder, filename);
    } catch (java.io.FileNotFoundException e) {
        log.log(SEVERE, "Exception loading object!  e=" + e);
        e.printStackTrace();
    } catch (java.io.IOException e) {
        log.log(SEVERE, "Exception loading object!  e=" + e);
        e.printStackTrace();
    }
    log.log(INFO, "Done parsing WaveFront OBJ file");

    log.log(INFO, "Splitting OBJ file faces into list of faces per material");
    ArrayList<ArrayList<Face>> facesByTextureList = createFaceListsByMaterial(builder);
    log.log(INFO, "Done splitting OBJ file faces into list of faces per material, ended up with "
            + facesByTextureList.size() + " lists of faces.");

    TextureLoader textureLoader = new TextureLoader();
    int defaultTextureID = 0;
    if (defaultTextureMaterial != null) {
        log.log(INFO, "Loading default texture =" + defaultTextureMaterial);
        defaultTextureID = setUpDefaultTexture(textureLoader, defaultTextureMaterial);
        log.log(INFO, "Done loading default texture =" + defaultTextureMaterial);
    }
    if (defaultTextureID == -1) {
        BufferedImage img = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
        Graphics g = img.getGraphics();
        g.setColor(Color.BLUE);
        g.fillRect(0, 0, 256, 256);
        g.setColor(Color.RED);
        for (int loop = 0; loop < 256; loop++) {
            g.drawLine(loop, 0, loop, 255);
            g.drawLine(0, loop, 255, loop);
        }
        defaultTextureID = textureLoader.convertToTexture(img);
    }
    int currentTextureID = -1;
    for (ArrayList<Face> faceList : facesByTextureList) {
        if (faceList.isEmpty()) {
            log.log(INFO, "ERROR: got an empty face list.  That shouldn't be possible.");
            continue;
        }
        log.log(INFO, "Getting material " + faceList.get(0).material);
        currentTextureID = getMaterialID(faceList.get(0).material, defaultTextureID, builder, textureLoader);
        log.log(INFO, "Splitting any quads and throwing any faces with > 4 vertices.");
        ArrayList<Face> triangleList = splitQuads(faceList);
        log.log(INFO, "Calculating any missing vertex normals.");
        calcMissingVertexNormals(triangleList);
        log.log(INFO, "Ready to build VBO of " + triangleList.size() + " triangles");
        ;

        if (triangleList.size() <= 0) {
            continue;
        }
        log.log(INFO, "Building VBO");

        VBO vbo = VBOFactory.build(currentTextureID, triangleList);

        log.log(INFO, "Adding VBO with text id " + currentTextureID + ", with " + triangleList.size()
                + " triangles to scene.");
        scene.addVBO(vbo);
    }
    log.log(INFO, "Finally ready to draw things.");

    GL11.glEnable(GL11.GL_CULL_FACE);

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_LIGHT0);
    GL11.glEnable(GL11.GL_LIGHT1);

    float lightAmbient[] = { 1.0f, 1.0f, 1.0f, 1.0f };
    float lightDiffuse[] = { 0.5f, 0.5f, 1.0f, 1.0f };
    float lightSpecular[] = { 0.0f, 1.0f, 1.0f, 0.0f };

    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, asFloatBuffer(lightAmbient));
    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, asFloatBuffer(lightDiffuse));
    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, asFloatBuffer(lightSpecular));

    GL11.glLight(GL11.GL_LIGHT1, GL11.GL_AMBIENT, asFloatBuffer(lightAmbient));
    GL11.glLight(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, asFloatBuffer(lightDiffuse));
    GL11.glLight(GL11.GL_LIGHT1, GL11.GL_SPECULAR, asFloatBuffer(lightSpecular));

    float lightPosition0[] = { posix, posiy, posiz, 1.0f };
    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, asFloatBuffer(lightPosition0));
    float lightPosition1[] = { posix, posiy, posizz, 1.0f };
    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, asFloatBuffer(lightPosition1));

    while (!finished) {
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glLoadIdentity();

        GLU.gluLookAt(orix, oriy, oriz, cenx, ceny, cenz, 0, 1, 0);

        // rotate(based on camera)
        GL11.glRotatef(rotateSee, 0, 1, 0);
        GL11.glRotatef(rotateSeeAnother, 1, 0, 0);
        // transform
        GL11.glTranslated(0, -0.75, -2);
        // rotate(based on model)
        GL11.glRotatef(rotate, 0, 1, 0);
        GL11.glRotatef(rotateAnother, 1, 0, 0);

        // Always call Window.update(), all the time - it does some behind the
        // scenes work, and also displays the rendered output
        Display.update();

        // Check for close requests
        if (Display.isCloseRequested()) {
            finished = true;
        } // The window is in the foreground, so render!
        else if (Display.isActive()) {
            logic();
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
            scene.render();
            Display.sync(FRAMERATE);
        } // The window is not in the foreground, so we can allow other stuff to run and infrequently update
        else {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
            }
            logic();

            // Only bother rendering if the window is visible or dirty
            if (Display.isVisible() || Display.isDirty()) {
                System.err.print(".");
                scene.render();
            }
        }
    }
}

From source file:com.pahimar.ee3.core.handlers.DrawBlockHighlightHandler.java

License:LGPL

public void drawInWorldTransmutationOverlay(DrawBlockHighlightEvent event) {

    double x = event.target.blockX + 0.5F;
    double y = event.target.blockY + 0.5F;
    double z = event.target.blockZ + 0.5F;
    double iPX = event.player.prevPosX + (event.player.posX - event.player.prevPosX) * event.partialTicks;
    double iPY = event.player.prevPosY + (event.player.posY - event.player.prevPosY) * event.partialTicks;
    double iPZ = event.player.prevPosZ + (event.player.posZ - event.player.prevPosZ) * event.partialTicks;
    int texture = event.context.renderEngine.getTexture(Textures.EFFECT_WORLD_TRANSMUTATION);

    float xScale = 1;
    float yScale = 1;
    float zScale = 1;
    float xShift = 0.1F;
    float yShift = 0.1F;
    float zShift = 0.1F;
    int chargeLevel;
    int itemChargeLevel = 0;

    if (event.currentItem.getItem() instanceof IChargeable) {
        itemChargeLevel = ((IChargeable) event.currentItem.getItem()).getCharge(event.currentItem);
    }/* www . j a va  2 s  .  c  o  m*/
    chargeLevel = 1 + itemChargeLevel * 2;

    ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit);

    switch (sideHit) {
    case UP: {
        xScale = chargeLevel + 0.1F;
        zScale = chargeLevel + 0.1F;
        xShift = 0;
        zShift = 0;
        break;
    }
    case DOWN: {
        xScale = chargeLevel + 0.1F;
        zScale = chargeLevel + 0.1F;
        xShift = 0;
        yShift = -yShift;
        zShift = 0;
        break;
    }
    case NORTH: {
        xScale = chargeLevel + 0.1F;
        yScale = chargeLevel + 0.1F;
        xShift = 0;
        yShift = 0;
        zShift = -zShift;
        break;
    }
    case SOUTH: {
        xScale = chargeLevel + 0.1F;
        yScale = chargeLevel + 0.1F;
        xShift = 0;
        yShift = 0;
        break;
    }
    case EAST: {
        yScale = chargeLevel + 0.1F;
        zScale = chargeLevel + 0.1F;
        yShift = 0;
        zShift = 0;
        break;
    }
    case WEST: {
        yScale = chargeLevel + 0.1F;
        zScale = chargeLevel + 0.1F;
        xShift = -xShift;
        yShift = 0;
        zShift = 0;
        break;
    }
    default:
        break;
    }

    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_CULL_FACE);

    for (int i = 0; i < 6; i++) {
        ForgeDirection forgeDir = ForgeDirection.getOrientation(i);
        int zCorrection = i == 2 ? -1 : 1;
        GL11.glPushMatrix();
        GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift);
        GL11.glScalef(1F * xScale, 1F * yScale, 1F * zScale);
        GL11.glRotatef(90, forgeDir.offsetX, forgeDir.offsetY, forgeDir.offsetZ);
        GL11.glTranslated(0, 0, 0.5f * zCorrection);
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        renderPulsingQuad(texture, 0.75F);
        GL11.glPopMatrix();
    }

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(true);
}

From source file:com.pahimar.ee3.core.handlers.TransmutationTargetOverlayHandler.java

License:LGPL

private static void renderStoneHUD(Minecraft minecraft, EntityPlayer player, ItemStack stack,
        float partialTicks) {

    float overlayScale = ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE;
    float blockScale = overlayScale / 2;
    float overlayOpacity = ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY;

    GL11.glPushMatrix();//  ww w.  j  a  v  a 2 s . c o m
    ScaledResolution sr = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth,
            minecraft.displayHeight);
    GL11.glClear(256);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0.0D, sr.getScaledWidth_double(), sr.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.0F, 0.0F, -2000.0F);

    GL11.glPushMatrix();
    RenderHelper.enableGUIStandardItemLighting();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glEnable(GL11.GL_LIGHTING);

    int hudOverlayX = 0;
    int hudOverlayY = 0;
    int hudBlockX = 0;
    int hudBlockY = 0;

    switch (ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION) {
    case 0: {
        hudOverlayX = 0;
        hudBlockX = (int) (16 * overlayScale / 2 - 8);
        hudOverlayY = 0;
        hudBlockY = (int) (16 * overlayScale / 2 - 8);
        break;
    }
    case 1: {
        hudOverlayX = (int) (sr.getScaledWidth() - 16 * overlayScale);
        hudBlockX = (int) (sr.getScaledWidth() - 16 * overlayScale / 2 - 8);
        hudOverlayY = 0;
        hudBlockY = (int) (16 * overlayScale / 2 - 8);
        break;
    }
    case 2: {
        hudOverlayX = 0;
        hudBlockX = (int) (16 * overlayScale / 2 - 8);
        hudOverlayY = (int) (sr.getScaledHeight() - 16 * overlayScale);
        hudBlockY = (int) (sr.getScaledHeight() - 16 * overlayScale / 2 - 8);
        break;
    }
    case 3: {
        hudOverlayX = (int) (sr.getScaledWidth() - 16 * overlayScale);
        hudBlockX = (int) (sr.getScaledWidth() - 16 * overlayScale / 2 - 8);
        hudOverlayY = (int) (sr.getScaledHeight() - 16 * overlayScale);
        hudBlockY = (int) (sr.getScaledHeight() - 16 * overlayScale / 2 - 8);
        break;
    }
    default: {
        break;
    }
    }

    RenderUtils.renderItemIntoGUI(minecraft.fontRenderer, minecraft.renderEngine, stack, hudOverlayX,
            hudOverlayY, overlayOpacity, overlayScale);

    if (TransmutationHelper.targetBlockStack != null
            && TransmutationHelper.targetBlockStack.getItem() instanceof ItemBlock) {
        RenderUtils.renderRotatingBlockIntoGUI(minecraft.fontRenderer, minecraft.renderEngine,
                TransmutationHelper.targetBlockStack, hudBlockX, hudBlockY, -90, blockScale);
    }

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}