Example usage for org.lwjgl.opengl GL11 glIsEnabled

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

Introduction

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

Prototype

@NativeType("GLboolean")
public static boolean glIsEnabled(@NativeType("GLenum") int cap) 

Source Link

Document

Determines if cap is currently enabled (as with #glEnable Enable ) or disabled.

Usage

From source file:blusunrize.immersiveengineering.client.ClientUtils.java

public static void toggleLightmap(boolean pre, boolean disabled) {
    GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    if (pre) {//w w w  . j av a2  s. c om
        lightmapState = Optional.of(GL11.glIsEnabled(GL11.GL_TEXTURE_2D));
        if (disabled)
            GlStateManager.disableTexture2D();
        else
            GlStateManager.enableTexture2D();
    } else if (lightmapState.isPresent()) {
        if (lightmapState.get())
            GlStateManager.enableTexture2D();
        else
            GlStateManager.disableTexture2D();
        lightmapState = Optional.empty();
    }
    GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
}

From source file:blusunrize.immersiveengineering.client.render.ItemRendererIEOBJ.java

@Override
public void renderByItem(ItemStack stack, float partialTicks) {
    GlStateManager.enableCull();/*from w  w  w  .  ja  v a 2 s  .  c  o m*/
    partialTicks = mc().getRenderPartialTicks();
    if (stack.getItem() instanceof IOBJModelCallback) {
        IOBJModelCallback<ItemStack> callback = (IOBJModelCallback<ItemStack>) stack.getItem();
        World w = IESmartObjModel.tempEntityStatic != null ? IESmartObjModel.tempEntityStatic.world : null;
        IBakedModel model = mc().getRenderItem().getItemModelWithOverrides(stack, w,
                IESmartObjModel.tempEntityStatic);
        if (model instanceof IESmartObjModel) {
            GlStateManager.disableCull();

            ItemStack shader = ItemStack.EMPTY;
            ShaderCase sCase = null;
            if (!stack.isEmpty() && stack.hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) {
                CapabilityShader.ShaderWrapper wrapper = stack.getCapability(CapabilityShader.SHADER_CAPABILITY,
                        null);
                if (wrapper != null) {
                    shader = wrapper.getShaderItem();
                    if (!shader.isEmpty() && shader.getItem() instanceof IShaderItem)
                        sCase = ((IShaderItem) shader.getItem()).getShaderCase(shader, stack,
                                wrapper.getShaderType());
                }
            }
            IESmartObjModel obj = (IESmartObjModel) model;
            Map<String, Boolean> visible = new HashMap<>(
                    ((OBJModel.OBJState) obj.getState()).getVisibilityMap());
            Tessellator tes = Tessellator.getInstance();
            BufferBuilder bb = tes.getBuffer();
            ItemCameraTransforms.TransformType transformType = obj.lastCameraTransform;
            List<Pair<BakedQuad, ShaderLayer>> quads = new ArrayList<>();
            for (String[] groups : callback.getSpecialGroups(stack, transformType,
                    IESmartObjModel.tempEntityStatic)) {
                GlStateManager.pushMatrix();
                Matrix4 mat = callback.getTransformForGroups(stack, groups, transformType, mc().player,
                        ItemRendererIEOBJ.mat, partialTicks);
                GlStateManager.multMatrix(mat.toFloatBuffer(transform));
                boolean wasLightmapEnabled, wasLightingEnabled;
                {
                    GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
                    wasLightmapEnabled = GL11.glIsEnabled(GL11.GL_TEXTURE_2D);
                    GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
                    wasLightingEnabled = GL11.glIsEnabled(GL11.GL_LIGHTING);
                }
                boolean bright = callback.areGroupsFullbright(stack, groups);
                if (bright) {
                    GlStateManager.disableLighting();
                    ClientUtils.setLightmapDisabled(true);
                }
                renderQuadsForGroups(groups, callback, obj, quads, stack, sCase, shader, bb, tes, visible,
                        partialTicks);
                if (bright) {
                    if (wasLightingEnabled)
                        GlStateManager.enableLighting();
                    if (wasLightmapEnabled)
                        ClientUtils.setLightmapDisabled(false);
                }
                GlStateManager.popMatrix();
            }
            renderQuadsForGroups(visible.keySet().toArray(new String[0]), callback, obj, quads, stack, sCase,
                    shader, bb, tes, visible, partialTicks);
            GlStateManager.enableCull();
        }
    }
}

From source file:blusunrize.immersiveengineering.client.render.TileRenderTeslaCoil.java

@Override
public void render(TileEntityTeslaCoil tile, double x, double y, double z, float partialTicks, int destroyStage,
        float alpha) {
    if (tile.isDummy() || !tile.getWorld().isBlockLoaded(tile.getPos(), false))
        return;//from  w ww  .j a  v  a 2s.  c o m
    Iterator<LightningAnimation> animationIt = TileEntityTeslaCoil.effectMap.get(tile.getPos()).iterator();

    setLightmapDisabled(true);
    boolean wasLightingEnabled = GL11.glIsEnabled(GL11.GL_LIGHTING);
    GlStateManager.disableLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    while (animationIt.hasNext()) {
        LightningAnimation animation = animationIt.next();
        if (animation.shoudlRecalculateLightning())
            animation.createLightning(Utils.RAND);

        GlStateManager.pushMatrix();
        GlStateManager.translate(x, y, z);

        GlStateManager.disableTexture2D();
        GlStateManager.enableBlend();

        double tx = tile.getPos().getX();
        double ty = tile.getPos().getY();
        double tz = tile.getPos().getZ();
        float curWidth = GL11.glGetFloat(GL11.GL_LINE_WIDTH);
        drawAnimation(animation, tx, ty, tz, new float[] { 77 / 255f, 74 / 255f, 152 / 255f, .75f }, 4f);
        drawAnimation(animation, tx, ty, tz, new float[] { 1, 1, 1, 1 }, 1f);
        GL11.glLineWidth(curWidth);

        GlStateManager.enableTexture2D();
        GlStateManager.disableBlend();

        GlStateManager.popMatrix();
    }
    if (wasLightingEnabled)
        GlStateManager.enableLighting();
    else
        GlStateManager.disableLighting();
    setLightmapDisabled(false);
}

From source file:cn.academy.core.client.ACRenderingHelper.java

License:GNU General Public License

public static void lineSegment(double x0, double y0, double x1, double y1, float width) {
    boolean pre = GL11.glIsEnabled(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*ww  w.  ja  v  a2  s .c  om*/

    dirQuad(x0, y0, x1, y1, width);

    if (pre)
        GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:cn.lambdalib.util.client.HudUtils.java

License:MIT License

public static void colorRect(double x, double y, double width, double height) {
    boolean prev = GL11.glIsEnabled(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from  w  ww .j a v a  2s  .  c o  m*/
    Tessellator t = Tessellator.instance;
    t.startDrawingQuads();
    t.addVertex(x + 0, y + height, zLevel);
    t.addVertex(x + width, y + height, zLevel);
    t.addVertex(x + width, y + 0, zLevel);
    t.addVertex(x + 0, y + 0, zLevel);
    t.draw();

    if (prev)
        GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java

License:Apache License

public boolean glIsEnabled(int cap) {
    return GL11.glIsEnabled(cap);
}

From source file:com.jmex.bui.BComponent.java

License:Open Source License

/**
 * Activates scissoring and sets the scissor region to the intersection of the current region
 * (if any) and the specified rectangle.  After rendering the scissored region, call
 * {@link #restoreScissorState} to restore the previous state.
 *
 * @param store a rectangle to hold the previous scissor region for later restoration
 * @return <code>true</code> if scissoring was already enabled, false if it was not.
 *//*w w w .  j  a v  a  2s .com*/
protected static boolean intersectScissorBox(Rectangle store, int x, int y, int width, int height) {
    boolean enabled = GL11.glIsEnabled(GL11.GL_SCISSOR_TEST);
    if (enabled) {
        GL11.glGetInteger(GL11.GL_SCISSOR_BOX, _bbuf);
        store.set(_bbuf.get(0), _bbuf.get(1), _bbuf.get(2), _bbuf.get(3));
        int x1 = Math.max(x, store.x), y1 = Math.max(y, store.y),
                x2 = Math.min(x + width, store.x + store.width),
                y2 = Math.min(y + height, store.y + store.height);
        GL11.glScissor(x, y, Math.max(0, x2 - x1), Math.max(0, y2 - y1));
    } else {
        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        GL11.glScissor(x, y, width, height);
    }
    return enabled;
}

From source file:com.kegare.caveworld.util.CaveUtils.java

License:Minecraft Mod Public

@SideOnly(Side.CLIENT)
public static boolean renderItemStack(Minecraft mc, ItemStack itemstack, int x, int y, boolean overlay,
        String txt) {/*from ww w  .  ja  va 2 s.c om*/
    GL11.glColor3f(1.0F, 1.0F, 1.0F);

    boolean isLightingEnabled = GL11.glIsEnabled(GL11.GL_LIGHTING);
    boolean rc = false;

    if (itemstack != null && itemstack.getItem() != null) {
        Block block = Block.getBlockFromItem(itemstack.getItem());

        if (GameRegistry.findUniqueIdentifierFor(block).modId.equals("EnderIO")
                && !block.renderAsNormalBlock()) {
            return false;
        }

        rc = true;
        boolean isRescaleNormalEnabled = GL11.glIsEnabled(GL12.GL_RESCALE_NORMAL);
        GL11.glPushMatrix();
        GL11.glTranslatef(0.0F, 0.0F, 32.0F);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glEnable(GL11.GL_LIGHTING);
        short short1 = 240;
        short short2 = 240;
        RenderHelper.enableGUIStandardItemLighting();
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, short1 / 1.0F, short2 / 1.0F);
        RenderItem itemRender = RenderItem.getInstance();

        itemRender.zLevel += 100.0F;
        boolean rendered;

        try {
            rendered = ForgeHooksClient.renderInventoryItem(RenderBlocks.getInstance(), mc.getTextureManager(),
                    itemstack, itemRender.renderWithColor, itemRender.zLevel, x, y);
        } catch (Throwable e) {
            rendered = false;
        }

        if (!rendered) {
            try {
                itemRender.renderItemIntoGUI(mc.fontRenderer, mc.getTextureManager(), itemstack, x, y, true);
            } catch (Throwable e) {
            }
        }

        if (overlay) {
            try {
                itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, mc.getTextureManager(), itemstack, x, y,
                        txt);
            } catch (Throwable e) {
            }
        }

        itemRender.zLevel -= 100.0F;

        GL11.glPopMatrix();

        if (isRescaleNormalEnabled) {
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        } else {
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        }
    }

    if (isLightingEnabled) {
        GL11.glEnable(GL11.GL_LIGHTING);
    } else {
        GL11.glDisable(GL11.GL_LIGHTING);
    }

    return rc;
}

From source file:com.teambrmodding.neotech.client.renderers.tiles.TileRenderHelper.java

License:Creative Commons License

protected int[][] saveGLState(int[] bitsToSave) {
    if (bitsToSave == null) {
        return null;
    }//from   ww  w.j a v  a 2 s.  c  o m

    int[][] savedGLState = new int[bitsToSave.length][2];
    int count = 0;

    for (int glBit : bitsToSave) {
        savedGLState[count][0] = glBit;
        savedGLState[count++][1] = GL11.glIsEnabled(glBit) ? 1 : 0;
    }
    return savedGLState;
}

From source file:com.teambrmodding.neotech.client.renderers.tiles.TileRenderHelper.java

License:Creative Commons License

protected int[][] modifyGLState(int[] bitsToDisable, int[] bitsToEnable, int[] bitsToSave) {
    if (bitsToDisable == null && bitsToEnable == null && bitsToSave == null) {
        return null;
    }//from ww w. java  2s. c  o  m

    int[][] savedGLState = new int[(bitsToDisable != null ? bitsToDisable.length : 0)
            + (bitsToEnable != null ? bitsToEnable.length : 0)
            + (bitsToSave != null ? bitsToSave.length : 0)][2];
    int count = 0;

    if (bitsToDisable != null) {
        for (int glBit : bitsToDisable) {
            savedGLState[count][0] = glBit;
            savedGLState[count++][1] = GL11.glIsEnabled(glBit) ? 1 : 0;
            GL11.glDisable(glBit);
        }
    }
    if (bitsToEnable != null) {
        for (int glBit : bitsToEnable) {
            savedGLState[count][0] = glBit;
            savedGLState[count++][1] = GL11.glIsEnabled(glBit) ? 1 : 0;
            GL11.glEnable(glBit);
        }
    }
    if (bitsToSave != null) {
        for (int glBit : bitsToSave) {
            savedGLState[count][0] = glBit;
            savedGLState[count++][1] = GL11.glIsEnabled(glBit) ? 1 : 0;
        }
    }

    return savedGLState;
}