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:cn.liutils.util.render.Font.java

License:Open Source License

public void draw(String str, double x, double y, double size, int color, Align align) {
    GL11.glEnable(GL11.GL_BLEND);
    //GL11.glDepthMask(false);
    double scale = size / mcFont.FONT_HEIGHT;
    GL11.glPushMatrix();//w  w  w  .  j  a va  2 s .  com
    {
        GL11.glTranslated(x, y, 0);
        GL11.glScaled(scale, scale, 1);
        String[] ss = str.split("\n");
        for (int i = 0; i < ss.length; ++i) {
            GL11.glPushMatrix();
            {
                double dy = i * mcFont.FONT_HEIGHT;
                GL11.glTranslated(0, dy, 0);
                drawSingleLine(ss[i], color, align);
            }
            GL11.glPopMatrix();
        }
    }
    GL11.glPopMatrix();
}

From source file:cn.liutils.util.render.LambdaFont.java

License:Open Source License

public void draw(String str, double x, double y, double size, Align align) {
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    //GL11.glDepthMask(false);
    double psx = HudUtils.SCALE_X, psy = HudUtils.SCALE_Y;
    GL11.glPushMatrix();/*w w  w  . j  a va 2s  . c  o m*/
    {
        GL11.glTranslated(x, y, 0);
        GL11.glScaled(size, size, 1);
        String[] ss = str.split("\n");
        for (int i = 0; i < ss.length; ++i) {
            GL11.glPushMatrix();
            {
                double dy = i * (fontSize + spacing) / fontSize;
                GL11.glTranslated(0, dy, 0);
                drawSingleLine(ss[i], align);
            }
            GL11.glPopMatrix();
        }
    }
    GL11.glPopMatrix();
    //GL11.glDepthMask(true);
    HudUtils.SCALE_X = psx;
    HudUtils.SCALE_Y = psy;
}

From source file:cn.liutils.util.render.LambdaFont.java

License:Open Source License

/**
 * It must be guaranteed that the string contains no line-break characters
 * @returns area of drawing/*from   ww w.ja v a2s .  com*/
 */
public Vector2d drawLinebreak(String str, double x, double y, double size, double cst) {
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    double psx = HudUtils.SCALE_X, psy = HudUtils.SCALE_Y;
    GL11.glPushMatrix();
    GL11.glTranslated(x, y, 0);
    GL11.glScaled(size, size, 1);

    List<Pair<String, Boolean>> arr = dlbPreProc(str, size, cst);

    double spcstp = getExtent(' ').getStep();

    double y0 = 0;
    double curLen = 0;
    double maxLen = 0;
    for (int i = 0; i < arr.size(); ++i) {
        Pair<String, Boolean> pair = arr.get(i);
        double len = widthSingleLine(pair.first);
        if (size * len < cst && size * (curLen + len) > cst) {
            --i;
            maxLen = Math.max(curLen, maxLen);
            curLen = 0;
            y0 += 1.0;
            continue;
        }

        GL11.glPushMatrix();
        {
            GL11.glTranslated(curLen, y0, 0);
            drawSingleLine(pair.first, Align.LEFT);
        }
        GL11.glPopMatrix();
        curLen += len + (pair.second ? spcstp : 0);

        if (size * len > cst) {
            maxLen = Math.max(curLen, maxLen);
            curLen = 0;
            y0 += 1.0;
        }
    }
    maxLen = Math.max(curLen, maxLen);
    GL11.glPopMatrix();
    HudUtils.SCALE_X = psx;
    HudUtils.SCALE_Y = psy;

    return new Vector2d(maxLen * size, y0 * size + size + spacing * size / fontSize);
}

From source file:cn.liutils.util.RenderUtils.java

License:Open Source License

public static void renderOverlay_Equip(ResourceLocation src) {
    //Setup/*w  ww.j a  v a  2  s  .co  m*/
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDisable(GL11.GL_LIGHTING);
    loadTexture(src);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    float f7 = 0.76F;
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    //Push texture mat
    GL11.glPushMatrix();
    float f8 = 0.125F;
    GL11.glScalef(f8, f8, f8);
    float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
    GL11.glTranslatef(f9, 0.0F, 0.0F); //xOffset loops between 0.0 and 8.0
    GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
    ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
    GL11.glPopMatrix();

    //Second pass
    GL11.glPushMatrix();
    GL11.glScalef(f8, f8, f8);
    f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F; //Loop between 0 and 8, longer loop
    GL11.glTranslatef(-f9, 0.0F, 0.0F); //Still xOffset
    GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); //However, different rotation!
    ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
    GL11.glPopMatrix();
    //Pop texture mat
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.liutils.util.RenderUtils.java

License:Open Source License

public static void renderOverlay_Inv(ResourceLocation src) {
    GL11.glDepthFunc(GL11.GL_EQUAL);//from   w  ww.j  a  v  a  2  s.  co  m
    GL11.glDisable(GL11.GL_LIGHTING);
    loadTexture(src);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    float f7 = 0.76F;
    //GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glPushMatrix();
    float f8 = 0.125F;
    GL11.glScalef(f8, f8, f8);
    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);
    t.startDrawingQuads();
    t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0);
    t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0);
    t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0);
    t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0);
    t.draw();
    GL11.glPopMatrix();
    GL11.glPushMatrix();
    GL11.glScalef(f8, f8, f8);
    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);
    t.startDrawingQuads();
    t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0);
    t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0);
    t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0);
    t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0);
    t.draw();
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.liutils.util.RenderUtils.java

License:Open Source License

public static void renderSimpleOverlay_Inv(ResourceLocation src) {
    //GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDisable(GL11.GL_LIGHTING);//  ww  w  . j av a 2 s.c o  m
    RenderUtils.loadTexture(src);
    t.startDrawingQuads();
    t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0);
    t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0);
    t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0);
    t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0);
    t.draw();
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.weaponmod.api.client.render.RenderBulletWeapon.java

License:Open Source License

public static void renderMuzzleflashIn2d(Tessellator t, String texture, double tx, double ty, double tz) {

    Vec3 a1 = RenderUtils.newV3(1.2, -0.4, -0.5), a2 = RenderUtils.newV3(1.2, 0.4, -0.5),
            a3 = RenderUtils.newV3(1.2, 0.4, 0.3), a4 = RenderUtils.newV3(1.2, -0.4, 0.3);

    float u1 = 0.0F, v1 = 0.0F, u2 = 1.0F, v2 = 1.0F;

    t = Tessellator.instance;//from  www  .j av  a 2s  .c  o  m
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderUtils.loadTexture(texture);

    GL11.glRotatef(45, 0.0F, 0.0F, 1.0F);
    GL11.glTranslated(tx, ty + 0.1F, tz + 0.1F);

    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
    t.startDrawingQuads();
    t.setColorRGBA_F(0.8F, .8F, .8F, 1.0F);
    t.setBrightness(15728880);
    addVertex(a1, u2, v2);
    addVertex(a2, u2, v1);
    addVertex(a3, u1, v1);
    addVertex(a4, u1, v2);
    t.draw();

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

}

From source file:cn.weaponmod.api.client.render.RenderDualWieldWeapon.java

License:Open Source License

@Override
public void renderEquipped(ItemStack item, RenderBlocks render, EntityLivingBase entity, ItemRenderType type) {

    GL11.glPushMatrix();/*from  w  ww.  j ava2 s  .c  om*/

    super.doRenderEquipped(item, render, entity, false, type);

    boolean firstPerson = (entity == Minecraft.getMinecraft().thePlayer
            && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0)
            && Minecraft.getMinecraft().currentScreen == null;

    GL11.glTranslatef(0.0F, 0.0F, firstPerson ? -1.7F : 0.8F);
    GL11.glScalef(1.0F, 1.0F, -1.0F);

    GL11.glDisable(GL11.GL_CULL_FACE);
    super.doRenderEquipped(item, render, entity, true, type);
    GL11.glEnable(GL11.GL_CULL_FACE);

    GL11.glPopMatrix();

}

From source file:cn.weaponmod.api.client.render.RendererBulletWeapon.java

License:Open Source License

public static void renderMuzzleflashIn2d(Tessellator t, ResourceLocation texture, double tx, double ty,
        double tz, float size) {
    Vec3 a1 = RenderUtils.newV3(1.2, -0.4, -0.5), a2 = RenderUtils.newV3(1.2, 0.4, -0.5),
            a3 = RenderUtils.newV3(1.2, 0.4, 0.3), a4 = RenderUtils.newV3(1.2, -0.4, 0.3);

    float u1 = 0.0F, v1 = 0.0F, u2 = 1.0F, v2 = 1.0F;

    t = Tessellator.instance;//from  w ww.j  a v  a2 s .c  o  m
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderUtils.loadTexture(texture);

    GL11.glRotatef(45, 0.0F, 0.0F, 1.0F);
    GL11.glTranslated(tx, ty + 0.1F, tz + 0.1F);
    GL11.glScalef(size, size, size);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
    t.startDrawingQuads();
    t.setBrightness(15728880);
    addVertex(a1, u2, v2);
    addVertex(a2, u2, v1);
    addVertex(a3, u1, v1);
    addVertex(a4, u1, v2);
    t.draw();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glPopMatrix();
}

From source file:cn.weaponry.api.client.render.RendererWeapon.java

License:Open Source License

@Override
public final void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    if (type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.EQUIPPED) {
        ItemInfo info = ItemInfoProxy.getInfo(player);
        RenderInfo ri = (RenderInfo) (info == null ? null : RenderInfo.get(info));
        EntityLivingBase holder = (EntityLivingBase) data[1];
        if (ri != null && holder == player) {
            handleHeldRender(ri, type == ItemRenderType.EQUIPPED_FIRST_PERSON);
        } else {//  www.  jav a  2 s.c  o  m
            handleSimpleRender(item);
        }
    } else {
        if (type == ItemRenderType.ENTITY) {
            handleEntityItemRender(item);
        } else {
            handleSimpleRender(item);
        }
    }

}