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:appeng.client.render.items.ToolWirelessTerminalRender.java

License:Open Source License

@Override
public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) {
    Entity itemLocation = item.getItemFrame();
    if (itemLocation == null) {
        itemLocation = Minecraft.getMinecraft().thePlayer;
    }/*from   www .  j av a2 s. com*/

    final boolean displayAntenna = ((ToolWirelessTerminal) item.getItem()).getIsUsable(item, itemLocation);
    final boolean hasPower = ((ToolWirelessTerminal) item.getItem()).hasPower(null, 0.5, item);

    IIcon border;
    if (displayAntenna) {
        border = ExtraItemTextures.WirelessTerminal_Border.getIcon();
    } else {
        border = ExtraItemTextures.WirelessTerminal_Border_Inactive.getIcon();
    }
    final IIcon scrollBar = ExtraItemTextures.WirelessTerminal_ScrollBar.getIcon();
    final IIcon icons = ExtraItemTextures.WirelessTerminal_Icons.getIcon();
    IIcon screen = ExtraItemTextures.WirelessTerminal_Screen.getIcon();

    final AEColor color = ToolWirelessTerminal.getColor(item);
    if (color == null) {
        screen = item.getIconIndex();
    }

    final Tessellator tessellator = Tessellator.instance;
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);

    //translate stuff for different item render types
    if (type != ItemRenderType.INVENTORY) {
        if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
            GL11.glTranslatef(0.0F, 0.0F, 0.0F);
        } else if (type == ItemRenderType.EQUIPPED) {
            GL11.glTranslatef(0.0F, 0.0F, 0.0F);
        } else {
            GL11.glTranslatef(-0.5F, -0.3F, 0.01F);
        }
    } else {
        GL11.glColor4f(1, 1, 1, 1.0F);
        GL11.glScalef(16F, 16F, 10F);
        GL11.glTranslatef(0.0F, 1.0F, 0.0F);
        GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }

    final float f12 = 0.0625F;

    //Border, which is uncolored
    subRenderItem(type, tessellator, border, f12);

    if (hasPower) {
        RenderHelper.disableStandardItemLighting();
    }

    //If a terminal isn't colored, use the default icon which doesn't require icons or scrollbar
    if (color != null) {
        //Icons, which are dark colored
        {
            final int blackColor = color.blackVariant;
            final float r = (blackColor >> 16) & 0xFF;
            final float g = (blackColor >> 8) & 0xFF;
            final float b = blackColor & 0xFF;
            GL11.glColor3f(r / 256.0f, g / 256.0f, b / 256.0f);

            subRenderItem(type, tessellator, icons, f12);
        }

        //Scrollbar, which is medium colored
        {
            final int medColor = color.mediumVariant;
            final float r = (medColor >> 16) & 0xFF;
            final float g = (medColor >> 8) & 0xFF;
            final float b = medColor & 0xFF;
            GL11.glColor3f(r / 256.0f, g / 256.0f, b / 256.0f);

            subRenderItem(type, tessellator, scrollBar, f12);
        }
    }

    //Screen, which is light colored
    {
        if (color != null) {
            final int whiteColor = color.whiteVariant;
            final float r = (whiteColor >> 16) & 0xFF;
            final float g = (whiteColor >> 8) & 0xFF;
            final float b = whiteColor & 0xFF;
            GL11.glColor3f(r / 256.0f, g / 256.0f, b / 256.0f);
        }

        subRenderItem(type, tessellator, screen, f12);
    }

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

From source file:appeng.entity.RenderTinyTNTPrimed.java

License:Open Source License

private void renderPrimedTNT(final EntityTinyTNTPrimed tnt, final double x, final double y, final double z,
        final float life) {
    GL11.glPushMatrix();//from www .  j av a2s  . co m
    GL11.glTranslatef((float) x, (float) y - 0.25f, (float) z);
    float f2;

    if (tnt.fuse - life + 1.0F < 10.0F) {
        f2 = 1.0F - (tnt.fuse - life + 1.0F) / 10.0F;

        if (f2 < 0.0F) {
            f2 = 0.0F;
        }

        if (f2 > 1.0F) {
            f2 = 1.0F;
        }

        f2 *= f2;
        f2 *= f2;
        final float f3 = 1.0F + f2 * 0.3F;
        GL11.glScalef(f3, f3, f3);
    }

    GL11.glScalef(0.5f, 0.5f, 0.5f);
    f2 = (1.0F - (tnt.fuse - life + 1.0F) / 100.0F) * 0.8F;
    this.bindEntityTexture(tnt);
    this.blockRenderer.renderBlockAsItem(Blocks.tnt, 0, tnt.getBrightness(life));

    if (tnt.fuse / 5 % 2 == 0) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, f2);
        this.blockRenderer.renderBlockAsItem(Blocks.tnt, 0, 1.0F);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }

    GL11.glPopMatrix();
}

From source file:appeng.parts.reporting.AbstractPartMonitor.java

License:Open Source License

private void tesrRenderScreen(final Tessellator tess, final IAEItemStack ais) {
    // GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );

    final ForgeDirection d = this.getSide();

    GL11.glTranslated(d.offsetX * 0.77, d.offsetY * 0.77, d.offsetZ * 0.77);

    switch (d) {//from w w  w.  ja  va  2s .  co  m
    case UP:
        GL11.glScalef(1.0f, -1.0f, 1.0f);
        GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
        GL11.glRotatef(this.getSpin() * 90.0F, 0, 0, 1);
        break;
    case DOWN:
        GL11.glScalef(1.0f, -1.0f, 1.0f);
        GL11.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
        GL11.glRotatef(this.getSpin() * -90.0F, 0, 0, 1);
        break;
    case EAST:
        GL11.glScalef(-1.0f, -1.0f, -1.0f);
        GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
        break;
    case WEST:
        GL11.glScalef(-1.0f, -1.0f, -1.0f);
        GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
        break;
    case NORTH:
        GL11.glScalef(-1.0f, -1.0f, -1.0f);
        break;
    case SOUTH:
        GL11.glScalef(-1.0f, -1.0f, -1.0f);
        GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
        break;

    default:
        break;
    }

    try {
        final ItemStack sis = ais.getItemStack();
        sis.stackSize = 1;

        final int br = 16 << 20 | 16 << 4;
        final int var11 = br % 65536;
        final int var12 = br / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * 0.8F, var12 * 0.8F);

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        // RenderHelper.enableGUIStandardItemLighting();
        tess.setColorOpaque_F(1.0f, 1.0f, 1.0f);

        ClientHelper.proxy.doRenderItem(sis, this.getTile().getWorldObj());
    } catch (final Exception e) {
        AELog.error(e);
    } finally {
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    }

    GL11.glTranslatef(0.0f, 0.14f, -0.24f);
    GL11.glScalef(1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f);

    final long stackSize = ais.getStackSize();
    final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm(stackSize);

    final FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
    final int width = fr.getStringWidth(renderedStackSize);
    GL11.glTranslatef(-0.5f * width, 0.0f, -1.0f);
    fr.drawString(renderedStackSize, 0, 0, 0);

    // GL11.glPopAttrib();
}

From source file:ar.com.quark.backend.lwjgl.opengl.DesktopGLES20.java

License:Apache License

/**
 * {@inheritDoc}
 */
@Override
public void glEnable(int value) {
    GL11.glEnable(value);
}

From source file:arekkuusu.grimoireOfAlice.client.render.ItemRenderHolyKeyStone.java

License:Open Source License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();//from  w  ww . j  av a  2 s .c o  m
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glRotatef(-5F, 1F, 0F, 0F);
    TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileEntityHolyKeyStone(), 0.0D, 0.0D, 0.0D,
            0.0F);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}

From source file:arekkuusu.grimoireOfAlice.client.render.ItemRenderHolyStone.java

License:Open Source License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();//from  w  w w . j ava 2s  .  c  o  m
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    float s = 1.4F;
    GL11.glScalef(s, s, s);
    GL11.glRotatef(-5F, 1F, 0F, 0F);
    TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileEntityHolyStone(), 0.0D, 0.0D, 0.0D, 0.0F);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}

From source file:arekkuusu.grimoireOfAlice.client.render.ItemRenderOnbashira.java

License:Open Source License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();/*from   ww w. j  av a 2s  . c o  m*/
    GL11.glTranslatef(0F, -0.7F, -0.5F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    float s = 0.5F;
    GL11.glScalef(s, s, s);
    GL11.glRotatef(0F, 0F, 0F, 0F);
    TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileEntityOnbashira(), 0.0D, 0.0D, 0.0D, 0.0F);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}

From source file:arg.RenderRecipe.java

License:Open Source License

/**
 * Draws the screen and all the components in it.
 *///from   www .  ja v a  2s . c  o m
@Override
public void drawScreen(int par1, int par2, float par3) {
    this.drawDefaultBackground();
    int k = this.guiLeft;
    int l = this.guiTop;
    this.drawGuiContainerBackgroundLayer(par3, par1, par2);
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    RenderHelper.disableStandardItemLighting();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    RenderHelper.enableGUIStandardItemLighting();
    GL11.glPushMatrix();
    GL11.glTranslatef((float) k, (float) l, 0.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    short short1 = 240;
    short short2 = 240;
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) short1 / 1.0F,
            (float) short2 / 1.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int i1;

    // crafting result
    drawSlotInventory((Slot) inventorySlots.inventorySlots.get(0));

    incredientList.clear();

    for (int j1 = 1; j1 < inventorySlots.inventorySlots.size(); ++j1) {
        Slot slot = (Slot) inventorySlots.inventorySlots.get(j1);
        drawSlotInventory(slot);
    }

    this.drawGuiContainerForegroundLayer(par1, par2);

    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    RenderHelper.enableStandardItemLighting();
}

From source file:arg.RenderRecipe.java

License:Open Source License

/**
 * Draws an itemstack at a specific position
 *///from w w w.ja va2  s  . c  o  m
protected void drawItemStackAtPosition(ItemStack itemstack, int x, int y) {
    if (itemstack == null)
        return;

    this.zLevel = 100.0F;
    itemRenderer.zLevel = 100.0F;

    String s = null;
    if (itemstack.stackSize > 1)
        s = "" + itemstack.stackSize;

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.renderEngine, itemstack, x, y);
    itemRenderer.renderItemOverlayIntoGUI(fontRenderer, mc.renderEngine, itemstack, x, y, s);

    itemRenderer.zLevel = 0.0F;
    this.zLevel = 0.0F;
}

From source file:arg.RenderRecipe.java

License:Open Source License

public void draw() {

    File dir = new File(Minecraft.getMinecraft().mcDataDir, "recipes");
    if (!dir.exists() && !dir.mkdirs()) {
        throw new RuntimeException("The recipes directory could not be created: " + dir);
    }/*  ww  w.  java  2 s  . c om*/

    name = name.replace(" ", "");
    File file = new File(Minecraft.getMinecraft().mcDataDir, "recipes/" + name + ".png");

    if (file.exists())
        return;

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glViewport(0, 0, width, height);
    GL11.glOrtho(0.0D, xSize, ySize, 0.0D, 1000.0D, 3000.0D);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
    GL11.glLineWidth(1.0F);

    GL11.glEnable(GL11.GL_COLOR_MATERIAL);

    try {
        drawScreen(0, 0, 0);
    } catch (Exception e) {
        e.printStackTrace();
    }

    int[] pixels = new int[width * height];
    int bindex;

    ByteBuffer fb = ByteBuffer.allocateDirect(width * height * 3);

    GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, fb);
    GL11.glPopMatrix();
    GL11.glPopAttrib();
    GL11.glPopClientAttrib();
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    try {
        Display.swapBuffers();
    } catch (LWJGLException e1) {
        e1.printStackTrace();
    }

    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            int i = (x + (width * y)) * 3;
            int r = fb.get(i) & 0xFF;
            int g = fb.get(i + 1) & 0xFF;
            int b = fb.get(i + 2) & 0xFF;
            image.setRGB(x, height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b);
        }
    }

    try {
        ImageIO.write(image, "png", file);
    } catch (Exception e) {
        e.printStackTrace();
    }
}