Example usage for org.lwjgl.opengl GL11 glBlendFunc

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

Introduction

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

Prototype

public static void glBlendFunc(@NativeType("GLenum") int sfactor, @NativeType("GLenum") int dfactor) 

Source Link

Document

Specifies the weighting factors used by the blend equation, for both RGB and alpha functions and for all draw buffers.

Usage

From source file:$.DrawSystem.java

License:Open Source License

@Override
    protected void processEntities(ImmutableBag<Entity> entities) {
        GL11.glClearColor(0.1f, 0, 0, 1f);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
        List<Entity> entititesSortedByZ = new ArrayList<>(entities.size());
        for (int i = 0, n = entities.size(); i < n; ++i) {
            final Entity e = entities.get(i);
            if (e.isEnabled()) {
                entititesSortedByZ.add(e);
            }/*from  w  ww  .ja v  a 2s .co  m*/
        }
        Collections.sort(entititesSortedByZ, zComparator);

        GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_TRANSFORM_BIT | GL11.GL_HINT_BIT | GL11.GL_COLOR_BUFFER_BIT
                | GL11.GL_SCISSOR_BIT | GL11.GL_LINE_BIT | GL11.GL_TEXTURE_BIT);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();

        updateViewPort();
        GL11.glViewport(viewPort.x, viewPort.y, viewPort.width, viewPort.height);
        GLU.gluOrtho2D(-toolkit.getVirtualResolutionWidth() / 2.0f, toolkit.getVirtualResolutionWidth() / 2.0f,
                toolkit.getVirtualResolutionHeight() / 2.0f, -toolkit.getVirtualResolutionHeight() / 2.0f);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LINE_SMOOTH);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_SCISSOR_TEST);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);

        Game game = (Game) world;
        Entity hero = game.getHero();
        if (null != hero) {
            Sprite heroSprite = spriteMapper.get(hero);
            Vector heroPos = spriteProjector.project(heroSprite.getPosition());
            GL11.glTranslatef(-heroPos.x, -heroPos.y, 0.0f);
        }

        for (Entity e : entititesSortedByZ) {
            MainMenu mainMenu = mainMenuMapper.getSafe(e);
            if (null != mainMenu) {
                mainMenu.draw();
            }
            DialogueComponent dialog = dialogMapper.getSafe(e);
            if (null != dialog) {
                dialog.draw();
            }
            Level level = levelMapper.getSafe(e);
            if (null != level) {
                drawLevel(level);
            }
            Sprite sprite = spriteMapper.getSafe(e);
            if (null != sprite) {
                drawSprite(sprite);
            }
        }
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPopMatrix();
        GL11.glPopAttrib();

    }

From source file:a1.gui.GUI_Map.java

License:Open Source License

public void CreateLightMap() {

    //Coord screen_size = new Coord(Config.getScreenWidth(), Config.getScreenHeight());
    //Coord screen_coord = new Coord(GUI.map.mc).sub(screen_size.div(2));
    List<Coord> lst = new ArrayList<Coord>();

    for (RenderPart p : render_parts) {
        Drawable d = p.owner.getattr(Drawable.class);
        if (d != null) {
            if (d.name.contains("fir")) {
                lst.add(p.dc);//from ww  w  .j  a v a2  s. c o m
            }
            if (d.name.contains("player")) {
                lst.add(p.dc);
            }
        }
    }

    //      for (Obj o : ObjCache.objs.values()) {
    //         Drawable d = o.getattr(Drawable.class);
    //         if (d != null) {
    //            if (d.name.contains("tree")) {
    //               if (o.getpos().in_rect(screen_coord, screen_size))
    //                  lst.add(o.getpos());
    //            }
    //         }
    //      }

    if (first) {
        first = false;
        boolean FBOEnabled = GLContext.getCapabilities().GL_EXT_framebuffer_object;
        if (!FBOEnabled)
            Log.info("No FBO");
        myFBOId = EXTFramebufferObject.glGenFramebuffersEXT();
        //LightMap = GL11.glGenTextures();

        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, myFBOId);
        EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
                EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, LightMap, 0);
        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);
    }

    //ByteBuffer bb = ByteBuffer.allocate(1024 * 1024 * 4);
    //GL11.glReadPixels(0, 0, 1024, 768, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, bb);

    // ? FBO  ?  ?
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, myFBOId);
    //      GL11.glPushAttrib(GL11.GL_VIEWPORT_BIT);
    //  ?
    //      GL11.glViewport( 0, 0, 1024, 1024 );
    //      
    // ? 
    //   ?
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glClearColor(0.3f, 0.3f, 0.4f, 1.0f);
    GL11.glClear(GL_COLOR_BUFFER_BIT);

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);

    //  ? ? ?
    for (Coord c : lst)
        DrawLight(c, 100, 100);

    /*GL11.glTranslatef(0, 0, -6f);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3f(0, 0, 0);
    GL11.glVertex3f(200, 0, 0);
    GL11.glVertex3f(200, 200, 0);
    GL11.glVertex3f(0, 200, 0);
    GL11.glEnd();*/
    //      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);
    //      GL11.glPopAttrib();

    //      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
    //      
    //  
    //GL11.glBindTexture(GL11.GL_TEXTURE_2D, LightMap);
    //Render2D.CheckError();

    //    ?  - ? 
    //GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, 0, 0, 1024, 1024, 0);
    //GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1024, 1024);
    //Render2D.CheckError();

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

}

From source file:a1.gui.GUI_Map.java

License:Open Source License

public void RenderLightMap() {
    GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_SRC_COLOR);
    //Log.info("lightmap: "+LightMap);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, LightMap); //Resource.textures.get("core_skin").getTextureID());

    GL11.glTranslatef(0, 0, 0);//from   w ww.  ja  va2  s. co  m
    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

    float texwidth = 1024;
    float texheight = 1024;

    float newTextureOffsetX = 0 / texwidth;
    float newTextureOffsetY = 0 / texheight;
    float newTextureWidth = 1024 / texwidth;
    float newTextureHeight = 1024 / texheight;

    int w = 1024;
    int h = 1024;

    GL11.glBegin(GL11.GL_QUADS);
    {
        glTexCoord2f(newTextureOffsetX, newTextureOffsetY);
        glVertex2i(0, 0);

        glTexCoord2f(newTextureOffsetX, newTextureOffsetY + newTextureHeight);
        glVertex2i(0, h);

        glTexCoord2f(newTextureOffsetX + newTextureWidth, newTextureOffsetY + newTextureHeight);
        glVertex2i(w, h);

        glTexCoord2f(newTextureOffsetX + newTextureWidth, newTextureOffsetY);
        glVertex2i(w, 0);
    }

    GL11.glEnd();

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}

From source file:a1.Main.java

License:Open Source License

private void initGL() {
    // enable textures since we're going to use these for our sprites
    GL11.glPointSize(1);//from w  w w. j ava2 s  .co m
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_LIGHTING);

    glClearColor(0.0f, 0.0f, 0.0f, 0);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    // disable the OpenGL depth test since we're rendering 2D graphics
    GL11.glDisable(GL11.GL_DEPTH_TEST);
}

From source file:additionalpipes.client.gui.components.GuiSlotEx.java

License:Minecraft Mod Public

/**
 * draws the slot to the screen, pass in mouse's current x and y and partial ticks
 *///from  w  w w.  ja va2  s .  com
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    this.mouseX = mouseX;
    this.mouseY = mouseY;
    drawBackground();
    int size = getSize();
    int slotLeft = xPos + marginLeft + 2;
    int slotRight = xPos + width - 2;
    if (getHiddenHeight() > 0) {
        slotRight = getScrollBarX() - 2;
    }

    if (Mouse.isButtonDown(0)) {
        if (initialClickY == -1.0F) {
            boolean slotClicked = true;

            if (mouseX >= xPos && mouseX < xPos + width && mouseY >= yPos && mouseY < yPos + height) {
                int mouseSlotY = mouseY - yPos - marginTop + (int) amountScrolled - getGradientHeight();
                int hovered = mouseSlotY / slotHeight;
                if (/*mouseX < slotLeft || mouseX > slotRight || */hovered < -1 || hovered >= size) {
                    hovered = -1;
                }

                boolean doubleClick = hovered == selectedElement
                        && Minecraft.getSystemTime() - lastClicked < 250L;
                lastClicked = Minecraft.getSystemTime();
                elementClicked(hovered, mouseX - xPos, doubleClick);

                if (hovered >= 0) {
                    selectedElement = hovered;
                } else if (mouseX >= slotLeft && mouseX <= slotRight && mouseSlotY < 0) {
                    marginClicked(mouseX - slotLeft,
                            mouseY - yPos + (int) amountScrolled - getGradientHeight());
                    slotClicked = false;
                }

                int scrollBarX = getScrollBarX();
                if (mouseX >= scrollBarX && mouseX < scrollBarX + scrollBarWidth) {
                    scrollMultiplier = -1.0F;
                    int hiddenHeight = getHiddenHeight();

                    if (hiddenHeight < 1) {
                        hiddenHeight = 1;
                    }

                    int slotBottom = height * height / getContentHeight();

                    if (slotBottom < 32) {
                        slotBottom = 32;
                    }

                    if (slotBottom > height - getGradientHeight() * 2) {
                        slotBottom = height - getGradientHeight() * 2;
                    }

                    scrollMultiplier /= (float) (height - slotBottom) / (float) hiddenHeight;
                } else {
                    scrollMultiplier = 1.0F;
                }

                if (slotClicked) {
                    initialClickY = mouseY;
                } else {
                    initialClickY = -2.0F;
                }
            } else {
                initialClickY = -2.0F;
            }
        } else if (initialClickY >= 0.0F) {
            float scroll = amountScrolled;
            amountScrolled -= (mouseY - initialClickY) * scrollMultiplier;
            bindAmountScrolled();
            if (scroll != amountScrolled) {
                initialClickY = mouseY;
            }
        }
    } else if (mouseX >= xPos && mouseX < xPos + width && mouseY >= yPos && mouseY < yPos + height) {
        while (!mc.gameSettings.touchscreen && Mouse.next()) {
            int wheel = Mouse.getEventDWheel();

            if (wheel != 0) {
                if (wheel > 0) {
                    wheel = -1;
                } else if (wheel < 0) {
                    wheel = 1;
                }

                amountScrolled += wheel * slotHeight / 2;
                bindAmountScrolled();
            }
        }

        initialClickY = -1.0F;
    }

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_FOG);
    Tessellator tessellator = Tessellator.instance;
    drawContainerBackground(tessellator);
    int scrolledTop = yPos + getGradientHeight() - (int) amountScrolled;
    if (!drawGradient) {
        scrolledTop += 2;
    }

    if (drawMarginTop) {
        drawMarginTop(slotLeft, scrolledTop, tessellator);
    }

    for (int i = 0; i < size; ++i) {
        int slotTop = scrolledTop + i * slotHeight + marginTop;
        int slotHeight = this.slotHeight - 4;

        if (slotTop <= yPos + height && slotTop + slotHeight >= yPos) {
            if (showSelectionBox && isSelected(i)) {
                int outlineLeft = slotLeft - 2;
                int outlineRight = slotRight + 2;
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                GL11.glDisable(GL11.GL_TEXTURE_2D);
                tessellator.startDrawingQuads();
                tessellator.setColorOpaque_I(0x808080);
                tessellator.addVertexWithUV(outlineLeft, slotTop + slotHeight + 2, 0.0D, 0.0D, 1.0D);
                tessellator.addVertexWithUV(outlineRight, slotTop + slotHeight + 2, 0.0D, 1.0D, 1.0D);
                tessellator.addVertexWithUV(outlineRight, slotTop - 2, 0.0D, 1.0D, 0.0D);
                tessellator.addVertexWithUV(outlineLeft, slotTop - 2, 0.0D, 0.0D, 0.0D);
                tessellator.setColorOpaque_I(0x000000);
                tessellator.addVertexWithUV(outlineLeft + 1, slotTop + slotHeight + 1, 0.0D, 0.0D, 1.0D);
                tessellator.addVertexWithUV(outlineRight - 1, slotTop + slotHeight + 1, 0.0D, 1.0D, 1.0D);
                tessellator.addVertexWithUV(outlineRight - 1, slotTop - 1, 0.0D, 1.0D, 0.0D);
                tessellator.addVertexWithUV(outlineLeft + 1, slotTop - 1, 0.0D, 0.0D, 0.0D);
                tessellator.draw();
                GL11.glEnable(GL11.GL_TEXTURE_2D);
            }

            drawSlot(i, slotLeft, slotTop, slotHeight, tessellator);
        }
    }

    GL11.glDisable(GL11.GL_DEPTH_TEST);
    drawOverlay();

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    drawGradient(tessellator);
    drawScrollBar(tessellator);

    drawFinish(mouseX, mouseY);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:advancedbrewing.renderer.ItemGlintOverlayRenderer.java

License:Minecraft Mod Public

private void renderItem3D(ItemRenderType type, ItemStack itemStack, Object... data) {
    TextureManager renderEngine = FMLClientHandler.instance().getClient().renderEngine;
    Tessellator tessellator = Tessellator.instance;

    if (this.shouldRenderOverlay(itemStack)) {
        // render colored overlay
        renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
        this.setColorByItemStack(itemStack);
        Icon icon = this.getIcon(itemStack, 0);
        ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(),
                icon.getIconWidth(), icon.getIconHeight(), 0.0625F);

        // render glint
        if (itemStack.hasEffect(0)) {
            renderEngine.bindTexture(ItemGlintOverlayRenderer.RES_ITEM_GLINT);

            GL11.glDepthFunc(GL11.GL_EQUAL);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glMatrixMode(GL11.GL_TEXTURE);

            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);

            // first pass
            GL11.glPushMatrix();/* www. j av  a 2 s.c  o m*/
            GL11.glScalef(0.125F, 0.125F, 0.125F);
            float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
            GL11.glTranslatef(f9, 0.0F, 0.0F);
            GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
            GL11.glPopMatrix();

            // second pass
            GL11.glPushMatrix();
            GL11.glScalef(0.125F, 0.125F, 0.125F);
            f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
            GL11.glTranslatef(-f9, 0.0F, 0.0F);
            GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
            GL11.glPopMatrix();

            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
    }

    // render uncolored icon
    renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    Icon icon = this.getIcon(itemStack, 1);
    ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(),
            icon.getIconWidth(), icon.getIconHeight(), 0.0625F);
}

From source file:advancedbrewing.renderer.ItemGlintOverlayRenderer.java

License:Minecraft Mod Public

private void renderItem2D(ItemRenderType type, ItemStack itemStack, Object... data) {
    TextureManager renderEngine = FMLClientHandler.instance().getClient().renderEngine;
    Tessellator tessellator = Tessellator.instance;

    if (this.shouldRenderOverlay(itemStack)) {
        // render colored overlay
        renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
        this.setColorByItemStack(itemStack);
        Icon icon = this.getIcon(itemStack, 0);
        ItemGlintOverlayRenderer.RENDERITEM.renderIcon(0, 0, icon, 16, 16);

        // render glint
        if (itemStack.hasEffect(0)) {
            renderEngine.bindTexture(ItemGlintOverlayRenderer.RES_ITEM_GLINT);

            GL11.glDepthFunc(GL11.GL_GREATER);
            GL11.glDepthMask(false);//from w w w .  ja  v a  2 s .co  m
            GL11.glEnable(GL11.GL_BLEND);

            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);

            // first pass
            float f2 = Minecraft.getSystemTime() % 3000L / 3000.0F * 256.0F;
            tessellator.startDrawingQuads();
            tessellator.addVertexWithUV(-2, -2 + 20, -50.0F, (f2 + 20 * 4.0F) * 0.00390625F, 20 * 0.00390625F);
            tessellator.addVertexWithUV(-2 + 20, -2 + 20, -50.0F, (f2 + 20 + 20 * 4.0F) * 0.00390625F,
                    20 * 0.00390625F);
            tessellator.addVertexWithUV(-2 + 20, -2, -50.0F, (f2 + 20) * 0.00390625F, 0);
            tessellator.addVertexWithUV(-2, -2, -50.0F, (f2) * 0.00390625F, 0);
            tessellator.draw();

            // second pass
            f2 = Minecraft.getSystemTime() % 4873L / 4873.0F * 256.0F;
            tessellator.startDrawingQuads();
            tessellator.addVertexWithUV(-2, -2 + 20, -50.0F, (f2 + 20 * -1.0F) * 0.00390625F, 20 * 0.00390625F);
            tessellator.addVertexWithUV(-2 + 20, -2 + 20, -50.0F, (f2 + 20 + 20 * -1.0F) * 0.00390625F,
                    20 * 0.00390625F);
            tessellator.addVertexWithUV(-2 + 20, -2, -50.0F, (f2 + 20) * 0.00390625F, 0);
            tessellator.addVertexWithUV(-2, -2, -50.0F, (f2) * 0.00390625F, 0);
            tessellator.draw();

            GL11.glDisable(GL11.GL_BLEND);
            GL11.glDepthMask(true);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
    }

    // render uncolored icon
    renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    Icon icon = this.getIcon(itemStack, 1);
    ItemGlintOverlayRenderer.RENDERITEM.renderIcon(0, 0, icon, 16, 16);
}

From source file:akarnokd.opengl.experiment.FontExample.java

License:Apache License

/**
 * Initialise the GL display//w w  w .jav  a2  s. c  o  m
 * 
 * @param width The width of the display
 * @param height The height of the display
 */
private void initGL(int width, int height) {
    try {
        Display.setDisplayMode(new DisplayMode(width, height));
        Display.create();
        Display.setVSyncEnabled(true);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(0);
    }

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearDepth(1);

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

    GL11.glViewport(0, 0, width, height);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, width, height, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}

From source file:aphelion.client.Client.java

License:Open Source License

public static void initGL() {
    int displayWidth = Display.getWidth();
    int displayHeight = Display.getHeight();

    glDisableAll();//from   ww w  .j  a v a 2  s . com

    GL11.glViewport(0, 0, displayWidth, displayHeight);

    GL11.glMatrixMode(GL11.GL_PROJECTION); // Apply subsequent matrix operations to the projection matrix stack.
    GL11.glLoadIdentity();
    GL11.glOrtho(0, displayWidth, displayHeight, 0, -1, 1);

    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glLoadIdentity();

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

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);
    AsyncTexture.unbind();

    // Enable alpha channels for images
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);

    Graph.g.setDimensions(displayWidth, displayHeight);
    Graphics.setCurrent(Graph.g);
    Graph.g.setDrawMode(Graphics.MODE_NORMAL);
}

From source file:appeng.client.render.BusRenderer.java

License:Open Source License

@Override
public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) {
    if (item == null) {
        return;/*w  ww  . j  a  va  2s  .  c  o m*/
    }

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_LIGHTING);

    if (AEConfig.instance.isFeatureEnabled(AEFeature.AlphaPass) && item.getItem() instanceof IAlphaPassItem
            && ((IAlphaPassItem) item.getItem()).useAlphaPass(item)) {
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_BLEND);
    } else {
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.4f);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glDisable(GL11.GL_BLEND);
    }

    if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
        GL11.glTranslatef(-0.2f, -0.1f, -0.3f);
    }

    if (type == ItemRenderType.ENTITY) {
        GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
        GL11.glScalef(0.8f, 0.8f, 0.8f);
        GL11.glTranslatef(-0.8f, -0.87f, -0.7f);
    }

    if (type == ItemRenderType.INVENTORY) {
        GL11.glTranslatef(0.0f, -0.1f, 0.0f);
    }

    GL11.glTranslated(0.2, 0.3, 0.1);
    GL11.glScaled(1.2, 1.2, 1.);

    GL11.glColor4f(1, 1, 1, 1);
    Tessellator.instance.setColorOpaque_F(1, 1, 1);
    Tessellator.instance.setBrightness(14 << 20 | 14 << 4);

    BusRenderHelper.INSTANCE.setBounds(0, 0, 0, 1, 1, 1);
    BusRenderHelper.INSTANCE.setTexture(null);
    BusRenderHelper.INSTANCE.setInvColor(0xffffff);
    this.getRenderer().blockAccess = ClientHelper.proxy.getWorld();

    BusRenderHelper.INSTANCE.setOrientation(ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH);

    this.getRenderer().uvRotateBottom = this.getRenderer().uvRotateEast = this
            .getRenderer().uvRotateNorth = this.getRenderer().uvRotateSouth = this
                    .getRenderer().uvRotateTop = this.getRenderer().uvRotateWest = 0;
    this.getRenderer().useInventoryTint = false;
    this.getRenderer().overrideBlockTexture = null;

    if (item.getItem() instanceof IFacadeItem) {
        final IFacadeItem fi = (IFacadeItem) item.getItem();
        final IFacadePart fp = fi.createPartFromItemStack(item, ForgeDirection.SOUTH);

        if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
            GL11.glRotatef(160.0f, 0.0f, 1.0f, 0.0f);
            GL11.glTranslated(-0.4, 0.1, -1.6);
        }

        if (fp != null) {
            fp.renderInventory(BusRenderHelper.INSTANCE, this.getRenderer());
        }
    } else {
        final IPart ip = this.getRenderer(item, (IPartItem) item.getItem());
        if (ip != null) {
            if (type == ItemRenderType.ENTITY) {
                final int depth = ip.cableConnectionRenderTo();
                GL11.glTranslatef(0.0f, 0.0f, -0.04f * (8 - depth) - 0.06f);
            }

            ip.renderInventory(BusRenderHelper.INSTANCE, this.getRenderer());
        }
    }

    this.getRenderer().uvRotateBottom = this.getRenderer().uvRotateEast = this
            .getRenderer().uvRotateNorth = this.getRenderer().uvRotateSouth = this
                    .getRenderer().uvRotateTop = this.getRenderer().uvRotateWest = 0;

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}