Example usage for org.lwjgl.opengl GL11 glEnable

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

Introduction

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

Prototype

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

Source Link

Document

Enables the specified OpenGL state.

Usage

From source file:buildcraft.core.lib.gui.GuiBuildCraft.java

License:Minecraft Mod Public

/**
 * Draws the screen and all the components in it.
 *///from   w w w  . ja v  a2s  .co  m
@Override
public void drawScreen(int mouseX, int mouseY, float par3) {
    super.drawScreen(mouseX, mouseY, par3);
    int left = this.guiLeft;
    int top = this.guiTop;

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glPushMatrix();
    GL11.glTranslatef(left, top, 0.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    RenderHelper.disableStandardItemLighting();

    InventoryPlayer playerInv = this.mc.thePlayer.inventory;

    if (playerInv.getItemStack() == null) {
        drawToolTips(container.getWidgets(), mouseX - left, mouseY - top, left, top);
        drawToolTips(buttonList, mouseX, mouseY, 0, 0);
        drawToolTips(inventorySlots.inventorySlots, mouseX, mouseY, 0, 0);
    }

    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}

From source file:buildcraft.core.lib.render.FluidRenderer.java

License:Minecraft Mod Public

public static int[] getFluidDisplayLists(FluidStack fluidStack, World world, boolean flowing) {
    if (fluidStack == null) {
        return null;
    }//w w w  . ja  va 2  s.  c om
    Fluid fluid = fluidStack.getFluid();
    if (fluid == null) {
        return null;
    }
    Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
    int[] diplayLists = cache.get(fluid);
    if (diplayLists != null) {
        return diplayLists;
    }

    diplayLists = new int[DISPLAY_STAGES];

    if (fluid.getBlock() != null) {
        liquidBlock.baseBlock = fluid.getBlock();
        liquidBlock.texture = getFluidTexture(fluidStack, flowing);
    } else {
        liquidBlock.baseBlock = Blocks.water;
        liquidBlock.texture = getFluidTexture(fluidStack, flowing);
    }

    cache.put(fluid, diplayLists);

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_CULL_FACE);

    for (int s = 0; s < DISPLAY_STAGES; ++s) {
        diplayLists[s] = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(diplayLists[s], 4864 /*GL_COMPILE*/);

        liquidBlock.minX = 0.01f;
        liquidBlock.minY = 0;
        liquidBlock.minZ = 0.01f;

        liquidBlock.maxX = 0.99f;
        liquidBlock.maxY = Math.max(s, 1) / (float) DISPLAY_STAGES;
        liquidBlock.maxZ = 0.99f;

        RenderEntityBlock.INSTANCE.renderBlock(liquidBlock);

        GL11.glEndList();
    }

    GL11.glColor4f(1, 1, 1, 1);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);

    return diplayLists;
}

From source file:buildcraft.core.render.BlockHighlightHandler.java

License:Minecraft Mod Public

@SideOnly(Side.CLIENT)
@SubscribeEvent/*  ww  w.j a  v  a 2  s  . c  o  m*/
public void handleBlockHighlight(DrawBlockHighlightEvent e) {
    if (e.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
        int x = e.target.blockX;
        int y = e.target.blockY;
        int z = e.target.blockZ;
        Block block = e.player.worldObj.getBlock(x, y, z);
        if (block instanceof ICustomHighlight) {
            AxisAlignedBB[] aabbs = ((ICustomHighlight) block).getBoxes(e.player.worldObj, x, y, z, e.player);
            Vec3 pos = e.player.getPosition(e.partialTicks);
            GL11.glEnable(GL11.GL_BLEND);
            OpenGlHelper.glBlendFunc(770, 771, 1, 0);
            GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
            GL11.glLineWidth(2.0F);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glDepthMask(false);
            double exp = ((ICustomHighlight) block).getExpansion();
            for (AxisAlignedBB aabb : aabbs) {
                RenderGlobal.drawOutlinedBoundingBox(aabb.copy().expand(exp, exp, exp).offset(x, y, z)
                        .offset(-pos.xCoord, -pos.yCoord, -pos.zCoord), -1);
            }
            GL11.glDepthMask(true);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_BLEND);
            e.setCanceled(true);
        }
    }
}

From source file:buildcraft.core.render.FluidRenderer.java

License:Minecraft Mod Public

public static int[] getFluidDisplayLists(FluidStack fluidStack, World world, boolean flowing) {
    if (fluidStack == null) {
        return null;
    }//  w ww. jav  a2s . c  om
    Fluid fluid = fluidStack.getFluid();
    if (fluid == null) {
        return null;
    }
    Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
    int[] diplayLists = cache.get(fluid);
    if (diplayLists != null) {
        return diplayLists;
    }

    diplayLists = new int[DISPLAY_STAGES];

    if (fluid.getBlock() != null) {
        liquidBlock.baseBlock = fluid.getBlock();
        liquidBlock.texture = getFluidTexture(fluidStack, flowing);
    } else {
        liquidBlock.baseBlock = Blocks.water;
        liquidBlock.texture = getFluidTexture(fluidStack, flowing);
    }

    cache.put(fluid, diplayLists);

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_CULL_FACE);

    for (int s = 0; s < DISPLAY_STAGES; ++s) {
        diplayLists[s] = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(diplayLists[s], 4864 /*GL_COMPILE*/);

        liquidBlock.minX = 0.01f;
        liquidBlock.minY = 0;
        liquidBlock.minZ = 0.01f;

        liquidBlock.maxX = 0.99f;
        liquidBlock.maxY = (float) s / (float) DISPLAY_STAGES;
        liquidBlock.maxZ = 0.99f;

        RenderEntityBlock.INSTANCE.renderBlock(liquidBlock, world, 0, 0, 0, false, true);

        GL11.glEndList();
    }

    GL11.glColor4f(1, 1, 1, 1);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);

    return diplayLists;
}

From source file:buildcraft.core.render.LiquidRenderer.java

License:Minecraft Mod Public

public static int[] getLiquidDisplayLists(LiquidStack liquid, World world, boolean flowing) {
    if (liquid == null) {
        return null;
    }/*from w  w w .j  a v a  2 s.co m*/
    liquid = liquid.canonical();
    if (liquid == null) {
        throw new LiquidCanonException(liquid);
    }
    Map<LiquidStack, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
    int[] diplayLists = cache.get(liquid);
    if (diplayLists != null) {
        return diplayLists;
    }

    diplayLists = new int[DISPLAY_STAGES];

    if (liquid.itemID < Block.blocksList.length && Block.blocksList[liquid.itemID] != null) {
        liquidBlock.baseBlock = Block.blocksList[liquid.itemID];
        if (!flowing) {
            liquidBlock.texture = getLiquidTexture(liquid);
        }
    } else if (Item.itemsList[liquid.itemID] != null) {
        liquidBlock.baseBlock = Block.waterStill;
        liquidBlock.texture = getLiquidTexture(liquid);
    } else {
        return null;
    }

    cache.put(liquid, diplayLists);

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_CULL_FACE);
    ItemStack stack = liquid.asItemStack();
    int color = stack.getItem().getColorFromItemStack(stack, 0);
    float c1 = (float) (color >> 16 & 255) / 255.0F;
    float c2 = (float) (color >> 8 & 255) / 255.0F;
    float c3 = (float) (color & 255) / 255.0F;
    GL11.glColor4f(c1, c2, c3, 1);
    for (int s = 0; s < DISPLAY_STAGES; ++s) {
        diplayLists[s] = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(diplayLists[s], 4864 /*GL_COMPILE*/);

        liquidBlock.minX = 0.01f;
        liquidBlock.minY = 0;
        liquidBlock.minZ = 0.01f;

        liquidBlock.maxX = 0.99f;
        liquidBlock.maxY = (float) s / (float) DISPLAY_STAGES;
        liquidBlock.maxZ = 0.99f;

        RenderEntityBlock.renderBlock(liquidBlock, world, 0, 0, 0, false, true);

        GL11.glEndList();
    }

    GL11.glColor4f(1, 1, 1, 1);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);

    return diplayLists;
}

From source file:buildcraft.core.render.RenderBox.java

License:Minecraft Mod Public

public static void doRender(TextureManager t, ResourceLocation texture, Box box) {
    GL11.glPushMatrix();/* w  w  w . j a  v a  2s .c o m*/
    GL11.glDisable(2896 /* GL_LIGHTING */);

    box.createLaserData();

    for (LaserData l : box.lasersData) {
        l.update();
        GL11.glPushMatrix();
        GL11.glTranslated(0.5F, 0.5F, 0.5F);
        RenderLaser.doRenderLaser(t, l, texture);
        GL11.glPopMatrix();
    }

    GL11.glEnable(2896 /* GL_LIGHTING */);
    GL11.glPopMatrix();
}

From source file:buildcraft.core.render.RenderBuilder.java

License:Minecraft Mod Public

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
    super.renderTileEntityAt(tileentity, x, y, z, f);

    TileAbstractBuilder builder = (TileAbstractBuilder) tileentity;

    if (builder != null) {
        GL11.glPushMatrix();/* w ww . j  a  v a  2 s.com*/
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        GL11.glTranslated(x, y, z);
        GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord);

        if (builder.getPathLaser() != null) {
            for (LaserData laser : builder.getPathLaser()) {
                if (laser != null) {
                    GL11.glPushMatrix();
                    RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.field_147553_e, laser,
                            EntityLaser.LASER_TEXTURES[4]);
                    GL11.glPopMatrix();
                }
            }
        }

        //GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glPopAttrib();
        GL11.glPopMatrix();

        renderItems.render(tileentity, x, y, z);
    }
}

From source file:buildcraft.core.render.RenderEntityBlock.java

License:Minecraft Mod Public

public void doRenderBlock(EntityBlock entity, double i, double j, double k) {
    if (entity.isDead) {
        return;//  w  ww.  j a v a2s.c  om
    }

    shadowSize = entity.shadowSize;
    World world = entity.worldObj;
    RenderInfo util = new RenderInfo();
    util.texture = entity.texture;
    bindTexture(TextureMap.locationBlocksTexture);

    for (int iBase = 0; iBase < entity.iSize; ++iBase) {
        for (int jBase = 0; jBase < entity.jSize; ++jBase) {
            for (int kBase = 0; kBase < entity.kSize; ++kBase) {

                util.minX = 0;
                util.minY = 0;
                util.minZ = 0;

                double remainX = entity.iSize - iBase;
                double remainY = entity.jSize - jBase;
                double remainZ = entity.kSize - kBase;

                util.maxX = remainX > 1.0 ? 1.0 : remainX;
                util.maxY = remainY > 1.0 ? 1.0 : remainY;
                util.maxZ = remainZ > 1.0 ? 1.0 : remainZ;

                GL11.glPushMatrix();
                GL11.glTranslatef((float) i, (float) j, (float) k);
                GL11.glRotatef(entity.rotationX, 1, 0, 0);
                GL11.glRotatef(entity.rotationY, 0, 1, 0);
                GL11.glRotatef(entity.rotationZ, 0, 0, 1);
                GL11.glTranslatef(iBase, jBase, kBase);

                int lightX, lightY, lightZ;

                lightX = (int) (Math.floor(entity.posX) + iBase);
                lightY = (int) (Math.floor(entity.posY) + jBase);
                lightZ = (int) (Math.floor(entity.posZ) + kBase);

                GL11.glDisable(2896 /* GL_LIGHTING */);
                renderBlock(util, world, 0, 0, 0, lightX, lightY, lightZ, false, true);
                GL11.glEnable(2896 /* GL_LIGHTING */);
                GL11.glPopMatrix();

            }
        }
    }
}

From source file:buildcraft.core.render.RenderRobot.java

License:Minecraft Mod Public

private void doRender(EntityRobot robot, double x, double y, double z, float f, float f1) {
    GL11.glPushMatrix();/*from  www  . java 2s . c om*/
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glTranslated(x, y, z);

    renderManager.renderEngine.bindTexture(robot.getTexture());

    float factor = (float) (1.0 / 16.0);

    box.render(factor);

    if (robot.laser.isVisible) {
        robot.laser.head.x = robot.posX;
        robot.laser.head.y = robot.posY;
        robot.laser.head.z = robot.posZ;

        RenderLaser.doRenderLaser(renderManager.renderEngine, robot.laser, EntityLaser.LASER_TEXTURES[1]);
    }

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();

}

From source file:buildcraft.core.render.RenderRobot.java

License:Minecraft Mod Public

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    if (RenderManager.instance == null || RenderManager.instance.renderEngine == null) {
        return;/*from   ww  w  . j av  a2 s. c  om*/
    }

    RenderBlocks renderBlocks = (RenderBlocks) data[0];

    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_LIGHTING);

    // FIXME: Texture localisation should be factorized between items and
    // entities.
    if (item.getItem() == BuildCraftCore.robotBaseItem) {
        RenderManager.instance.renderEngine.bindTexture(TEXTURE_BASE);
    } else if (item.getItem() == BuildCraftCore.robotBuilderItem) {
        RenderManager.instance.renderEngine.bindTexture(TEXTURE_BUILDER);
    } else if (item.getItem() == BuildCraftCore.robotPickerItem) {
        RenderManager.instance.renderEngine.bindTexture(TEXTURE_PICKER);
    }

    float factor = (float) (1.0 / 16.0);

    if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
        GL11.glTranslated(0.25F, 0.5F, 0);
    }

    box.render(1F / 16F);

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