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:net.lyonlancer5.mcmp.karasu.client.renderer.block.BlockSlimeRender.java

License:Apache License

@Override
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
    Tessellator tessellator = Tessellator.instance;
    //OpenGLHelper.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    //OpenGLHelper.enableBlend();
    GL11.glEnable(GL11.GL_BLEND);/*from   w  w  w . j  av a 2 s  .  co m*/
    //OpenGLHelper.translate(-0.5F, -0.5F, -0.5F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

    float f = 0.0625F;
    renderer.setRenderBounds(f * 3, f * 3, f * 3, f * 13, f * 13, f * 13);
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1.0F, 0.0F);
    renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 0, meta));
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 1, meta));
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 2, meta));
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 3, meta));
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
    renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 4, meta));
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 5, meta));
    tessellator.draw();

    renderer.setRenderBounds(0, 0, 0, 1, 1, 1);
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1.0F, 0.0F);
    renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 0, meta));
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 1, meta));
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 2, meta));
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 3, meta));
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
    renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 4, meta));
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 5, meta));
    tessellator.draw();

    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:net.malisis.blocks.renderer.VanishingBlockRenderer.java

License:Open Source License

private void renderVanishingTileEntity() {
    tileEntity = TileEntityUtils.getTileEntity(VanishingTileEntity.class, world, pos);
    if (tileEntity == null)
        return;//from   ww w .  ja v  a2 s  . c  o  m

    //      if (!tileEntity.blockDrawn/* || (!tileEntity.isInTransition() && !tileEntity.isVibrating())*/)
    //      {
    //         if (!tileEntity.isPowered() && tileEntity.getCopiedTileEntity() != null)
    //         {
    //            clean();
    //            TileEntityRendererDispatcher.instance.renderTileEntity(tileEntity.getCopiedTileEntity(), partialTick, 0);
    //         }
    //         if (tileEntity.blockDrawn)
    //            return;
    //      }

    enableBlending();

    float fx = 0.0F;
    float fy = 0.0F;
    float fz = 0.0F;
    float scale = (float) (tileEntity.getDuration() - tileEntity.getTransitionTimer())
            / tileEntity.getDuration();
    boolean rendered = tileEntity.getCopiedState() != null;

    RenderParameters rp = new RenderParameters();
    rp.useBlockBounds.set(false);
    rp.interpolateUV.set(false);

    // randomize position for vibrations
    if (tileEntity.isVibrating()) {
        rp.alpha.set(200);
        fx = rand.nextFloat() * 0.05F;
        fy = rand.nextFloat() * 0.05F;
        fz = rand.nextFloat() * 0.05F;
        if (rand.nextBoolean())
            GL11.glTranslated(fx, fy, fz);
        else
            GL11.glRotatef(rand.nextInt(5), 1, 1, 1);
    } else if (tileEntity.isInTransition()) {
        int alpha = tileEntity.getCopiedState() != null ? 255 - (int) (scale * 255) : (int) (scale * 255);
        rp.alpha.set(alpha);
        cube.scale(scale - 0.001F);
    } else if (tileEntity.blockDrawn)
        return;

    if (tileEntity.getCopiedState() != null) {
        BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
        wr.setVertexFormat(DefaultVertexFormats.BLOCK);
        try {
            boolean smbr = MalisisBlocksSettings.simpleMixedBlockRendering.get();
            MalisisBlocksSettings.simpleMixedBlockRendering.set(true);

            BlockPos translate = BlockPosUtils.chunkPosition(pos);
            //GlStateManager.pushMatrix();
            GlStateManager.translate(0.5F, 0.5F, 0.5F);
            GlStateManager.scale(scale, scale, scale);
            if (tileEntity.getCopiedState().getBlock().getRenderType() == MalisisCore.malisisRenderType)
                GlStateManager.translate(-translate.getX(), -translate.getY(), -translate.getZ());
            else
                GlStateManager.translate(-pos.getX(), -pos.getY(), -pos.getZ());
            GlStateManager.translate(-0.5F, -0.5F, -0.5F);

            GL11.glBlendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA);
            //            GL11.glAlphaFunc(GL11.GL_GREATER, 1F);
            //GL14.glBlendColor(0, 0, 0, 1 - scale);
            //TODO: render underlying model with vanishing block texture
            //            renderBlocks.overrideBlockTexture = block.getIcon(blockMetadata, 0);
            //            rendered = renderBlocks.renderBlockByRenderType(tileEntity.copiedBlock, x, y, z);
            //            renderBlocks.overrideBlockTexture = null;
            //            next();

            GL14.glBlendColor(0, 0, 0, scale);
            for (EnumWorldBlockLayer layer : EnumWorldBlockLayer.values()) {
                if (!tileEntity.getCopiedState().getBlock().canRenderInLayer(layer))
                    continue;

                ForgeHooksClient.setRenderLayer(layer);
                if (layer == EnumWorldBlockLayer.TRANSLUCENT)
                    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA,
                            GL11.GL_ONE, GL11.GL_ZERO);
                if (tileEntity.getCopiedState().getBlock().getRenderType() == MalisisCore.malisisRenderType)
                    blockRenderer.renderBlock(tileEntity.getCopiedState(), pos, ProxyAccess.get(world), wr);
                else {
                    IBakedModel model = blockRenderer.getModelFromBlockState(tileEntity.getCopiedState(),
                            ProxyAccess.get(world), pos);
                    rendered |= blockRenderer.getBlockModelRenderer().renderModel(ProxyAccess.get(world), model,
                            tileEntity.getCopiedState(), pos, wr, false);
                }

                next();
            }

            if (!rendered)
                drawShape(cube, rp);

            //GlStateManager.popMatrix();

            if (tileEntity.getCopiedTileEntity() != null) {
                clean();
                TileEntityRendererDispatcher.instance.renderTileEntity(tileEntity.getCopiedTileEntity(),
                        partialTick, 0);
            }

            MalisisBlocksSettings.simpleMixedBlockRendering.set(smbr);

        } catch (Exception e) {
            drawShape(cube, rp);
        }

    } else
        drawShape(cube, rp);
}

From source file:net.malisis.core.client.gui.component.UIComponent.java

License:Open Source License

/**
 * Draws this {@link UIComponent} Called by {@link #parent} component.<br>
 * Will set the size of {@link #shape} according to the size of this <code>UIComponent</code><br>
 * Rendering is surrounded by glPushAttrib(GL_ALL_ATTRIB_BITS) so no state should bleed between components. Also, a draw() is triggered
 * between background and foreground.//from w w w  .  j a  v a 2s . c o  m
 *
 * @param renderer the renderer
 * @param mouseX the mouse x
 * @param mouseY the mouse y
 * @param partialTick the partial tick
 */
public void draw(GuiRenderer renderer, int mouseX, int mouseY, float partialTick) {
    if (!isVisible())
        return;

    if (shape != null) {
        shape.resetState();
        shape.setSize(getWidth(), getHeight());
    }
    if (rp != null)
        rp.reset();

    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    if (getAlpha() < 255) {
        GL11.glBlendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA);
        GL14.glBlendColor(1, 1, 1, (float) getAlpha() / 255);
    }

    //draw background
    renderer.currentComponent = this;
    drawBackground(renderer, mouseX, mouseY, partialTick);
    renderer.next();

    //draw foreground
    renderer.currentComponent = this;

    ClipArea area = this instanceof IClipable ? ((IClipable) this).getClipArea() : null;
    if (area != null)
        renderer.startClipping(area);

    //GL11.glColor4f(1, 1, 1, 0.5F);

    drawForeground(renderer, mouseX, mouseY, partialTick);

    if (area != null)
        renderer.endClipping(area);

    renderer.next();

    for (IControlComponent c : controlComponents)
        c.draw(renderer, mouseX, mouseY, partialTick);

    GL11.glPopAttrib();
}

From source file:net.malisis.demo.lavapool.LavaPoolRenderer.java

License:Open Source License

@Override
public void render() {
    int a = 155;//from   www  . ja v  a  2s . co m
    enableBlending();
    tileEntity = (LavaPoolTileEntity) super.tileEntity;
    block = (LavaPoolBlock) super.block;
    if (tileEntity.startAnim) {
        ar.setStartTime();
        tileEntity.startAnim = false;
        rp.alpha.set(a);
        renderBlocks = new RenderBlocks(LavaPoolDemo.lavaPool.multiBlock);
    }

    AlphaTransform at = new AlphaTransform(a, 0).forTicks(40, 40);
    ar.animate(rp, at);
    rp.interpolateUV.set(false);

    for (BlockState state : block.multiBlock) {
        if (!state.matchesWorld(world)) {
            GL11.glPushMatrix();
            GL11.glTranslated(0.5F, 0.5F, 0.5F);
            GL11.glTranslated(-x - 0.5F, -y - 0.5F, -z - 0.5F);

            GL11.glBlendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA);
            GL14.glBlendColor(0, 0, 0, rp.alpha.get() / 255F);
            renderBlocks.renderBlockByRenderType(state.getBlock(), state.getX(), state.getY(), state.getZ());

            GL11.glPopMatrix();
        }
    }
}

From source file:net.malisis.doors.door.renderer.ForcefieldRenderer.java

License:Open Source License

@Override
public void render() {
    tileEntity = MultiBlock.getOriginProvider(ForcefieldTileEntity.class, world, x, y, z);
    if (tileEntity == null || tileEntity.isOpened() || !MultiBlock.isOrigin(world, x, y, z))
        return;//from  w ww .  jav a 2 s.c o  m

    enableBlending();

    tileEntity = (ForcefieldTileEntity) super.tileEntity;
    direction = ForgeDirection.getOrientation(tileEntity.getDirection());

    model.resetState();

    //ar.setStartTime(tileEntity.getStartNanoTime());
    if (tileEntity.getMovement() == null)
        return;

    AxisAlignedBB aabb = tileEntity.getMovement().getBoundingBox(tileEntity, false, BoundingBoxType.COLLISION);
    if (aabb == null)
        return;

    aabb.offset(-x, -y, -z);
    rp.renderBounds.set(aabb);
    direction = ForgeDirection.NORTH;
    if ((int) aabb.minY == (int) aabb.maxY) {
        direction = ForgeDirection.UP;
        model.rotate(90, 1, 0, 0, 0, 0, 0);
    } else if ((int) aabb.minX == (int) aabb.maxX) {
        direction = ForgeDirection.EAST;
        model.rotate(90, 0, 1, 0, 0, 0, 0);
    }

    setTextureMatrix();
    GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
    GL11.glDisable(GL11.GL_CULL_FACE);

    model.render(this, rp);
    next();

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:net.malisis.doors.renderer.VanishingBlockRenderer.java

License:Open Source License

private void renderVanishingTileEntity() {
    VanishingTileEntity te = (VanishingTileEntity) this.tileEntity;

    if (!te.inTransition && !te.vibrating) {
        if (!te.powered && te.copiedTileEntity != null) {
            clean();/*from   w  w w.  j a  va  2 s  . com*/
            TileEntityRendererDispatcher.instance.renderTileEntity(te.copiedTileEntity, partialTick);
        }
        return;
    }

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0);

    float fx = 0.0F;
    float fy = 0.0F;
    float fz = 0.0F;
    float scale = (float) (te.getDuration() - te.transitionTimer) / (float) te.getDuration();
    boolean rendered = te.copiedBlock != null;

    RenderParameters rp = new RenderParameters();
    rp.useBlockBounds.set(false);
    rp.interpolateUV.set(false);

    Shape shape = ShapePreset.Cube();
    // randomize position for vibrations
    if (!te.inTransition && !te.powered) {
        rp.alpha.set(200);
        fx = rand.nextFloat() * 0.05F;
        fy = rand.nextFloat() * 0.05F;
        fz = rand.nextFloat() * 0.05F;
        if (rand.nextBoolean())
            GL11.glTranslated(fx, fy, fz);
        else
            GL11.glRotatef(rand.nextInt(5), 1, 1, 1);
    } else {
        int alpha = te.copiedBlock != null ? 255 - (int) (scale * 255) : (int) (scale * 255);
        rp.alpha.set(alpha);
        shape.scale(scale - 0.001F);
    }

    if (te.copiedBlock != null) {
        RenderBlocks renderBlocks = new RenderBlocks(ProxyAccess.get(world));
        renderBlocks.renderAllFaces = true;
        try {
            boolean smbr = MalisisDoorsSettings.simpleMixedBlockRendering.get();
            MalisisDoorsSettings.simpleMixedBlockRendering.set(true);

            GL11.glPushMatrix();
            GL11.glTranslated(0.5F, 0.5F, 0.5F);
            GL11.glScalef(scale, scale, scale);
            GL11.glTranslated(-x - 0.5F, -y - 0.5F, -z - 0.5F);

            GL11.glBlendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA);
            GL14.glBlendColor(0, 0, 0, 1 - scale);
            renderBlocks.overrideBlockTexture = block.getIcon(blockMetadata, 0);
            rendered = renderBlocks.renderBlockByRenderType(te.copiedBlock, x, y, z);
            renderBlocks.overrideBlockTexture = null;
            next();

            if (te.copiedBlock.canRenderInPass(0)) {
                GL14.glBlendColor(0, 0, 0, scale);
                rendered |= renderBlocks.renderBlockByRenderType(te.copiedBlock, x, y, z);
                next();
            }
            if (te.copiedBlock.canRenderInPass(1)) {
                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                rendered |= renderBlocks.renderBlockByRenderType(te.copiedBlock, x, y, z);
                next();
            }

            if (!rendered)
                drawShape(shape, rp);

            GL11.glPopMatrix();

            if (te.copiedTileEntity != null) {
                clean();
                TileEntityRendererDispatcher.instance.renderTileEntity(te.copiedTileEntity, partialTick);
            }

            MalisisDoorsSettings.simpleMixedBlockRendering.set(smbr);

        } catch (Exception e) {
            drawShape(shape, rp);
        }

    } else
        drawShape(shape, rp);
}

From source file:net.mcmoddev.client.renderer.RenderBlockExtended.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float f) {
    if (!(tileEntity instanceof TileEntityBlockExtended))
        return;//from   ww w  .  j a v  a2s.c o m

    TileEntityBlockExtended ext = (TileEntityBlockExtended) tileEntity;

    IModelBlockExtended model = _defaultModel;

    if (ext.getExtendedMeta() != -1
            && ((BlockExtended) tileEntity.getBlockType()).getBlockMeta(ext.getExtendedMeta()) != null)
        model = ((BlockExtended) tileEntity.getBlockType()).getBlockMeta(ext.getExtendedMeta()).getModelBlock();

    if (ext.getWorldObj() != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
        GL11.glRotatef(0, 0.0F, 1.0F, 0.0F);
        GL11.glScalef(1.0F, -1F, -1F);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);
        model.renderModel(this, ext, 0.0625F);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopMatrix();
    } else {
        GL11.glPushMatrix();
        GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.4F, (float) d2 + 0.5F);
        GL11.glRotatef(0, 0.0F, 1.0F, 0.0F);
        GL11.glScalef(1.0F, -1F, -1F);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);
        model.renderModel(this, ext, 0.0625F);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopMatrix();
    }
}

From source file:net.minecraftforge.fml.client.GuiScrollingList.java

License:Open Source License

public void drawScreen(int mouseX, int mouseY, float p_22243_3_) {
    this.mouseX = mouseX;
    this.mouseY = mouseY;
    this.drawBackground();
    int listLength = this.getSize();
    int scrollBarXStart = this.left + this.listWidth - 6;
    int scrollBarXEnd = scrollBarXStart + 6;
    int boxLeft = this.left;
    int boxRight = scrollBarXStart - 1;
    int var10;
    int var11;
    int var13;
    int var19;

    if (Mouse.isButtonDown(0)) {
        if (this.initialMouseClickY == -1.0F) {
            boolean var7 = true;

            if (mouseY >= this.top && mouseY <= this.bottom) {
                var10 = mouseY - this.top - this.field_27261_r + (int) this.scrollDistance - 4;
                var11 = var10 / this.slotHeight;

                if (mouseX >= boxLeft && mouseX <= boxRight && var11 >= 0 && var10 >= 0 && var11 < listLength) {
                    boolean var12 = var11 == this.selectedIndex
                            && System.currentTimeMillis() - this.lastClickTime < 250L;
                    this.elementClicked(var11, var12);
                    this.selectedIndex = var11;
                    this.lastClickTime = System.currentTimeMillis();
                } else if (mouseX >= boxLeft && mouseX <= boxRight && var10 < 0) {
                    this.func_27255_a(mouseX - boxLeft, mouseY - this.top + (int) this.scrollDistance - 4);
                    var7 = false;
                }/*from  w  w  w.  java2s.  co  m*/

                if (mouseX >= scrollBarXStart && mouseX <= scrollBarXEnd) {
                    this.scrollFactor = -1.0F;
                    var19 = this.getContentHeight() - (this.bottom - this.top - 4);

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

                    var13 = (int) ((float) ((this.bottom - this.top) * (this.bottom - this.top))
                            / (float) this.getContentHeight());

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

                    if (var13 > this.bottom - this.top - 8) {
                        var13 = this.bottom - this.top - 8;
                    }

                    this.scrollFactor /= (float) (this.bottom - this.top - var13) / (float) var19;
                } else {
                    this.scrollFactor = 1.0F;
                }

                if (var7) {
                    this.initialMouseClickY = (float) mouseY;
                } else {
                    this.initialMouseClickY = -2.0F;
                }
            } else {
                this.initialMouseClickY = -2.0F;
            }
        } else if (this.initialMouseClickY >= 0.0F) {
            this.scrollDistance -= ((float) mouseY - this.initialMouseClickY) * this.scrollFactor;
            this.initialMouseClickY = (float) mouseY;
        }
    } else {
        while (Mouse.next()) {
            int var16 = Mouse.getEventDWheel();

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

                this.scrollDistance += (float) (var16 * this.slotHeight / 2);
            }
        }

        this.initialMouseClickY = -1.0F;
    }

    this.applyScrollLimits();
    Tessellator tess = Tessellator.getInstance();
    WorldRenderer worldr = tess.getWorldRenderer();
    if (this.client.theWorld != null) {
        this.drawGradientRect(this.left, this.top, this.right, this.bottom, -1072689136, -804253680);
    } else {
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_FOG);
        this.client.renderEngine.bindTexture(Gui.optionsBackground);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        float var17 = 32.0F;
        worldr.startDrawingQuads();
        worldr.setColorOpaque_I(2105376);
        worldr.addVertexWithUV((double) this.left, (double) this.bottom, 0.0D,
                (double) ((float) this.left / var17),
                (double) ((float) (this.bottom + (int) this.scrollDistance) / var17));
        worldr.addVertexWithUV((double) this.right, (double) this.bottom, 0.0D,
                (double) ((float) this.right / var17),
                (double) ((float) (this.bottom + (int) this.scrollDistance) / var17));
        worldr.addVertexWithUV((double) this.right, (double) this.top, 0.0D,
                (double) ((float) this.right / var17),
                (double) ((float) (this.top + (int) this.scrollDistance) / var17));
        worldr.addVertexWithUV((double) this.left, (double) this.top, 0.0D,
                (double) ((float) this.left / var17),
                (double) ((float) (this.top + (int) this.scrollDistance) / var17));
        tess.draw();
    }
    //        boxRight = this.listWidth / 2 - 92 - 16;
    var10 = this.top + 4 - (int) this.scrollDistance;

    if (this.field_27262_q) {
        this.func_27260_a(boxRight, var10, tess);
    }

    int var14;

    for (var11 = 0; var11 < listLength; ++var11) {
        var19 = var10 + var11 * this.slotHeight + this.field_27261_r;
        var13 = this.slotHeight - 4;

        if (var19 <= this.bottom && var19 + var13 >= this.top) {
            if (this.field_25123_p && this.isSelected(var11)) {
                var14 = boxLeft;
                int var15 = boxRight;
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                GL11.glDisable(GL11.GL_TEXTURE_2D);
                worldr.startDrawingQuads();
                worldr.setColorOpaque_I(8421504);
                worldr.addVertexWithUV((double) var14, (double) (var19 + var13 + 2), 0.0D, 0.0D, 1.0D);
                worldr.addVertexWithUV((double) var15, (double) (var19 + var13 + 2), 0.0D, 1.0D, 1.0D);
                worldr.addVertexWithUV((double) var15, (double) (var19 - 2), 0.0D, 1.0D, 0.0D);
                worldr.addVertexWithUV((double) var14, (double) (var19 - 2), 0.0D, 0.0D, 0.0D);
                worldr.setColorOpaque_I(0);
                worldr.addVertexWithUV((double) (var14 + 1), (double) (var19 + var13 + 1), 0.0D, 0.0D, 1.0D);
                worldr.addVertexWithUV((double) (var15 - 1), (double) (var19 + var13 + 1), 0.0D, 1.0D, 1.0D);
                worldr.addVertexWithUV((double) (var15 - 1), (double) (var19 - 1), 0.0D, 1.0D, 0.0D);
                worldr.addVertexWithUV((double) (var14 + 1), (double) (var19 - 1), 0.0D, 0.0D, 0.0D);
                tess.draw();
                GL11.glEnable(GL11.GL_TEXTURE_2D);
            }

            this.drawSlot(var11, boxRight, var19, var13, tess);
        }
    }

    GL11.glDisable(GL11.GL_DEPTH_TEST);
    byte var20 = 4;
    if (this.client.theWorld == null) {
        this.overlayBackground(0, this.top, 255, 255);
        this.overlayBackground(this.bottom, this.listHeight, 255, 255);
    }
    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);
    worldr.startDrawingQuads();
    worldr.setColorRGBA_I(0, 0);
    worldr.addVertexWithUV((double) this.left, (double) (this.top + var20), 0.0D, 0.0D, 1.0D);
    worldr.addVertexWithUV((double) this.right, (double) (this.top + var20), 0.0D, 1.0D, 1.0D);
    worldr.setColorRGBA_I(0, 255);
    worldr.addVertexWithUV((double) this.right, (double) this.top, 0.0D, 1.0D, 0.0D);
    worldr.addVertexWithUV((double) this.left, (double) this.top, 0.0D, 0.0D, 0.0D);
    tess.draw();
    worldr.startDrawingQuads();
    worldr.setColorRGBA_I(0, 255);
    worldr.addVertexWithUV((double) this.left, (double) this.bottom, 0.0D, 0.0D, 1.0D);
    worldr.addVertexWithUV((double) this.right, (double) this.bottom, 0.0D, 1.0D, 1.0D);
    worldr.setColorRGBA_I(0, 0);
    worldr.addVertexWithUV((double) this.right, (double) (this.bottom - var20), 0.0D, 1.0D, 0.0D);
    worldr.addVertexWithUV((double) this.left, (double) (this.bottom - var20), 0.0D, 0.0D, 0.0D);
    tess.draw();
    var19 = this.getContentHeight() - (this.bottom - this.top - 4);

    if (var19 > 0) {
        var13 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();

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

        if (var13 > this.bottom - this.top - 8) {
            var13 = this.bottom - this.top - 8;
        }

        var14 = (int) this.scrollDistance * (this.bottom - this.top - var13) / var19 + this.top;

        if (var14 < this.top) {
            var14 = this.top;
        }

        worldr.startDrawingQuads();
        worldr.setColorRGBA_I(0, 255);
        worldr.addVertexWithUV((double) scrollBarXStart, (double) this.bottom, 0.0D, 0.0D, 1.0D);
        worldr.addVertexWithUV((double) scrollBarXEnd, (double) this.bottom, 0.0D, 1.0D, 1.0D);
        worldr.addVertexWithUV((double) scrollBarXEnd, (double) this.top, 0.0D, 1.0D, 0.0D);
        worldr.addVertexWithUV((double) scrollBarXStart, (double) this.top, 0.0D, 0.0D, 0.0D);
        tess.draw();
        worldr.startDrawingQuads();
        worldr.setColorRGBA_I(8421504, 255);
        worldr.addVertexWithUV((double) scrollBarXStart, (double) (var14 + var13), 0.0D, 0.0D, 1.0D);
        worldr.addVertexWithUV((double) scrollBarXEnd, (double) (var14 + var13), 0.0D, 1.0D, 1.0D);
        worldr.addVertexWithUV((double) scrollBarXEnd, (double) var14, 0.0D, 1.0D, 0.0D);
        worldr.addVertexWithUV((double) scrollBarXStart, (double) var14, 0.0D, 0.0D, 0.0D);
        tess.draw();
        worldr.startDrawingQuads();
        worldr.setColorRGBA_I(12632256, 255);
        worldr.addVertexWithUV((double) scrollBarXStart, (double) (var14 + var13 - 1), 0.0D, 0.0D, 1.0D);
        worldr.addVertexWithUV((double) (scrollBarXEnd - 1), (double) (var14 + var13 - 1), 0.0D, 1.0D, 1.0D);
        worldr.addVertexWithUV((double) (scrollBarXEnd - 1), (double) var14, 0.0D, 1.0D, 0.0D);
        worldr.addVertexWithUV((double) scrollBarXStart, (double) var14, 0.0D, 0.0D, 0.0D);
        tess.draw();
    }

    this.func_27257_b(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:net.neilcsmith.praxis.video.opengl.internal.GLRenderer.java

License:Apache License

private void renderMesh() {

    if (idx == 0) {
        return;//from ww  w  .ja v a2 s .c  o m
    }

    int spritesInBatch = idx / 20;

    if (tex0 == null) {
        LOGGER.log(Level.WARNING, "Texture is null - returning : idx = {0}", idx);
        return;
    }

    tex0.bind();
    mesh.setVertices(vertices, 0, idx);

    if (blendingDisabled) {
        GL11.glDisable(GL11.GL_BLEND);
    } else {
        GL11.glEnable(GL11.GL_BLEND);
        if (blendSrcFunc == blendSrcAlphaFunc && blendDstFunc == blendDstAlphaFunc) {
            GL11.glBlendFunc(blendSrcFunc, blendDstFunc);
        } else {
            GL14.glBlendFuncSeparate(blendSrcFunc, blendDstFunc, blendSrcAlphaFunc, blendDstAlphaFunc);
        }
    }

    if (customShader != null) {
        LOGGER.finest("Rendering with custom shader");
        mesh.render(customShader, GL11.GL_TRIANGLES, 0, spritesInBatch * 6);
    } else {
        LOGGER.finest("Rendering with default shader");
        mesh.render(shader, GL11.GL_TRIANGLES, 0, spritesInBatch * 6);
    }

    idx = 0;
    currBufferIdx++;
    if (currBufferIdx == buffers.length) {
        currBufferIdx = 0;
    }
    mesh = buffers[currBufferIdx];
}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void setBlendMode(int mode) {
    switch (mode) {
    case 0://from   ww  w .j av a2  s.com
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        break;
    case 1:
        GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
        break;
    default:
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    }

}