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.phatcode.rel.multimedia.Renderer.java

License:Open Source License

Renderer(int screenWidth, int screenHeight) {
    try {//from   w  ww  .  j a va2 s. c o m
        Display.setDisplayMode(new DisplayMode(screenWidth, screenHeight));
        Display.create();
        Display.setTitle("AnyaBasic 0.4.0 beta");
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    this.screenWidth = screenWidth;
    this.screenHeight = screenHeight;

    GL11.glViewport(0, 0, screenWidth, screenHeight);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();

    GL11.glOrtho(0, screenWidth, screenHeight, 0, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    GL11.glLoadIdentity();

    GL11.glShadeModel(GL11.GL_SMOOTH); //set shading to smooth(try GL_FLAT)
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); //set Clear color to BLACK
    GL11.glClearDepth(1.0f); //Set Depth buffer to 1(z-Buffer)
    GL11.glDisable(GL11.GL_DEPTH_TEST); //Disable Depth Testing so that our z-buffer works

    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_COLOR_MATERIAL);

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);

    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.375f, 0.375f, 0); // magic trick

}

From source file:net.slimevoid.tmf.client.renderers.ItemRendererToolBelt.java

License:Open Source License

private void renderItem(EntityLivingBase entityliving, ItemStack itemstack, int index,
        TextureManager texturemanager) {
    GL11.glPushMatrix();//from   w ww  .  j  a v a  2  s.co  m
    IIcon icon = entityliving.getItemIcon(itemstack, index);

    if (icon == null) {
        GL11.glPopMatrix();
        return;
    }

    texturemanager.bindTexture(texturemanager.getResourceLocation(itemstack.getItemSpriteNumber()));
    Tessellator tessellator = Tessellator.instance;
    float f = icon.getMinU();
    float f1 = icon.getMaxU();
    float f2 = icon.getMinV();
    float f3 = icon.getMaxV();
    float f4 = 0.0F;
    float f5 = 0.3F;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    /*
     * GL11.glTranslatef( -f4, -f5, 0.0F); float f6 = 1.5F; GL11.glScalef(
     * f6, f6, f6); GL11.glRotatef( 50.0F, 0.0F, 1.0F, 0.0F);
     * GL11.glRotatef( 335.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(
     * -0.9375F, -0.0625F, 0.0F);
     */
    ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 0.0625F);

    if (itemstack.hasEffect(index)) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        texturemanager.bindTexture(RES_ITEM_GLINT);
        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);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        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);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
    }
    GL11.glPopMatrix();
}

From source file:net.smert.frameworkgl.opengl.OpenGL1.java

License:Apache License

public OpenGL1 setBlendingFunctionDstColorAndZero() {
    GL11.glBlendFunc(BlendFunctions.DST_COLOR, BlendFunctions.ZERO);
    return this;
}

From source file:net.smert.frameworkgl.opengl.OpenGL1.java

License:Apache License

public OpenGL1 setBlendingFunctionOneAndOne() {
    GL11.glBlendFunc(BlendFunctions.ONE, BlendFunctions.ONE);
    return this;
}

From source file:net.smert.frameworkgl.opengl.OpenGL1.java

License:Apache License

public OpenGL1 setBlendingFunctionOneAndOneMinusSrcAlpha() {
    GL11.glBlendFunc(BlendFunctions.ONE, BlendFunctions.ONE_MINUS_SRC_ALPHA);
    return this;
}

From source file:net.smert.frameworkgl.opengl.OpenGL1.java

License:Apache License

public OpenGL1 setBlendingFunctionOneAndZero() {
    GL11.glBlendFunc(BlendFunctions.ONE, BlendFunctions.ZERO);
    return this;
}

From source file:net.smert.frameworkgl.opengl.OpenGL1.java

License:Apache License

public OpenGL1 setBlendingFunctionSrcAlphaAndOneMinusSrcAlpha() {
    GL11.glBlendFunc(BlendFunctions.SRC_ALPHA, BlendFunctions.ONE_MINUS_SRC_ALPHA);
    return this;
}

From source file:net.wurstclient.features.mods.BowAimbotMod.java

License:Open Source License

@Override
public void onRender(float partialTicks) {
    if (target == null)
        return;/*from w w  w. ja v a 2  s  .  c  om*/

    // GL settings
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glLineWidth(2);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_DEPTH_TEST);

    GL11.glPushMatrix();
    GL11.glTranslated(-mc.getRenderManager().renderPosX, -mc.getRenderManager().renderPosY,
            -mc.getRenderManager().renderPosZ);

    // set position
    GL11.glTranslated(target.posX, target.posY, target.posZ);

    // set size
    double boxWidth = target.width + 0.1;
    double boxHeight = target.height + 0.1;
    GL11.glScaled(boxWidth, boxHeight, boxWidth);

    // move to center
    GL11.glTranslated(0, 0.5, 0);

    double v = 1 / velocity;
    GL11.glScaled(v, v, v);

    // draw outline
    GL11.glColor4d(1, 0, 0, 0.5F * velocity);
    RenderUtils.drawOutlinedBox(TARGET_BOX);

    // draw box
    GL11.glColor4d(1, 0, 0, 0.25F * velocity);
    RenderUtils.drawSolidBox(TARGET_BOX);

    GL11.glPopMatrix();

    // GL resets
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
}

From source file:net.wurstclient.features.mods.BowAimbotMod.java

License:Open Source License

@Override
public void onRenderGUI() {
    if (target == null)
        return;/* w  w w  . j  a va  2s  . c o  m*/

    // GL settings
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glPushMatrix();

    String message;
    if (velocity < 1)
        message = "Charging: " + (int) (velocity * 100) + "%";
    else
        message = "Ready To Shoot";

    // translate to center
    ScaledResolution sr = new ScaledResolution(mc);
    int msgWidth = Fonts.segoe15.getStringWidth(message);
    GL11.glTranslated(sr.getScaledWidth() / 2 - msgWidth / 2, sr.getScaledHeight() / 2 + 1, 0);

    // background
    GL11.glColor4f(0, 0, 0, 0.5F);
    GL11.glBegin(GL11.GL_QUADS);
    {
        GL11.glVertex2d(0, 0);
        GL11.glVertex2d(msgWidth + 3, 0);
        GL11.glVertex2d(msgWidth + 3, 10);
        GL11.glVertex2d(0, 10);
    }
    GL11.glEnd();

    // text
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    Fonts.segoe15.drawString(message, 2, -1, 0xffffffff);

    GL11.glPopMatrix();

    // GL resets
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.FWEntityRenderer.java

License:Open Source License

public static void render(Entity wrapper, nova.core.entity.Entity entity, double x, double y, double z) {
    Optional<DynamicRenderer> opRenderer = entity.components.getOp(DynamicRenderer.class);

    if (opRenderer.isPresent()) {
        BWModel model = new BWModel();
        model.matrix.translate(x, y, z).scale(entity.scale()).translate(entity.pivot())
                .rotate(entity.rotation()).translate(entity.pivot().negate());

        opRenderer.get().onRender.accept(model);

        if (model.blendSFactor > 0 && model.blendDFactor > 0) {
            glShadeModel(GL_SMOOTH);//  w  w w  . j  a  v a2 s.  co  m
            glEnable(GL_BLEND);
            GL11.glBlendFunc(model.blendSFactor, model.blendDFactor);
        }

        Tessellator.instance.startDrawingQuads();
        model.render(Optional.of(RenderManager.instance));
        Tessellator.instance.draw();

        if (model.blendSFactor > 0 && model.blendDFactor > 0) {
            RenderUtility.disableBlending();
        }
    }
}