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:eu.over9000.veya.Veya.java

License:Open Source License

private static void init() throws LWJGLException {
    final Canvas canvas = new Canvas();
    frame = new Frame();
    frame.add(canvas);/*from ww w.  j a  v  a  2 s  . co m*/
    frame.setSize(1280, 720);
    frame.setLocationByPlatform(true);
    frame.setVisible(true);
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    frame.setIconImage(loadIcon());

    Display.setParent(canvas);
    Display.create(new PixelFormat().withSamples(4).withDepthBits(24), new ContextAttribs(3, 3));

    System.out.println("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION));
    System.out.println("Java version: " + System.getProperty("java.version"));
    System.out.println("graphics adapter: " + Display.getAdapter());

    Veya.program_normal = new Program("normal",
            new String[] { "modelMatrix", "viewMatrix", "projectionMatrix", "lightPosition", "lightColor",
                    "lightFactors", "colorSwitch", "aoSwitch", "cameraPosition", "lightSpaceMatrix",
                    "textureData", "shadowMap" });
    Veya.program_shadow = new Program("shadow", new String[] { "modelMatrix", "lightSpaceMatrix" });
    Veya.program_debug = new Program("debug", new String[] { "near_plane", "far_plane" });

    Util.checkGLError();

    Veya.camera = new Camera(-40, 120, -40);
    Veya.scene = new Scene(1337);

    Util.checkGLError();

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glLineWidth(2.5f);

    Util.checkGLError();

    GL11.glEnable(GL31.GL_PRIMITIVE_RESTART);
    GL31.glPrimitiveRestartIndex(Veya.RESTART);
    GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
    GL11.glClearColor(124f / 255f, 169f / 255f, 255f / 255f, 1.0f);

    Mouse.setGrabbed(true);

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

    Console.start();
}

From source file:flash.display.DisplayObject.java

License:Open Source License

public final void JITB$renderDisplayObject() {
    if (!visible()) {
        return;//from  w w  w  . j  ava2 s  . co m
    }

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    transform().matrix().JITB$toDoubleBuffer(modelViewMatrix);
    GL11.glLoadMatrix(modelViewMatrix);

    //GL11.glTranslated(x(), y(), 0.0);
    //GL11.glRotatef(_rotationRad, 0.0f, 0.0f, 1.0f);
    //GL11.glScaled(_scaleX, _scaleY, 1.0);
    GL11.glColor4d(_transform.colorTransform().redMultiplier, _transform.colorTransform().greenMultiplier,
            _transform.colorTransform().blueMultiplier, _transform.colorTransform().alphaMultiplier);
    final String blendMode = blendMode();
    boolean disableDepthTest = false;

    if (blendMode.equals(BlendMode.ADD)) {
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
        disableDepthTest = true;
    }

    try {
        JITB$render();
    } finally {
        if (disableDepthTest) {
            GL11.glDisable(GL11.GL_BLEND);
        }
        GL11.glPopMatrix();
    }
}

From source file:forestry.apiculture.render.EntityBeeFX.java

License:Open Source License

public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) {

    tessellator.draw();//  ww  w . j  av a 2  s  . c  o  m
    GL11.glPushMatrix();

    GL11.glDepthMask(false);
    GL11.glEnable(3042);
    GL11.glBlendFunc(770, blendmode);

    Proxies.common.bindTexture(texture);

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

    float f10 = 0.1F * particleScale;
    float f11 = (float) ((prevPosX + (posX - prevPosX) * f) - interpPosX);
    float f12 = (float) ((prevPosY + (posY - prevPosY) * f) - interpPosY);
    float f13 = (float) ((prevPosZ + (posZ - prevPosZ) * f) - interpPosZ);

    // GL11.glRotatef(this.rand.nextFloat(), 0.0F, 1.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.setBrightness(0x0000f0);

    tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 1.0F);
    tessellator.addVertexWithUV(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10, 0, 1);
    tessellator.addVertexWithUV((f11 - f1 * f10) + f4 * f10, f12 + f2 * f10, (f13 - f3 * f10) + f5 * f10, 1, 1);
    tessellator.addVertexWithUV(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10, 1, 0);
    tessellator.addVertexWithUV((f11 + f1 * f10) - f4 * f10, f12 - f2 * f10, (f13 + f3 * f10) - f5 * f10, 0, 0);

    tessellator.draw();

    GL11.glDisable(3042);
    GL11.glDepthMask(true);

    GL11.glPopMatrix();
    GL11.glBindTexture(3553 /* GL_TEXTURE_2D *//* GL_TEXTURE_2D */,
            Proxies.common.getClientInstance().renderEngine.getTexture("/particles.png"));
    tessellator.startDrawingQuads();
}

From source file:forestry.apiculture.render.ParticleRenderer.java

License:Open Source License

private synchronized void render(float partialTicks) {
    Minecraft.getMinecraft().mcProfiler.startSection(name + "-render");

    float rotationX = ActiveRenderInfo.rotationX;
    float rotationZ = ActiveRenderInfo.rotationZ;
    float rotationYZ = ActiveRenderInfo.rotationYZ;
    float rotationXY = ActiveRenderInfo.rotationXY;
    float rotationXZ = ActiveRenderInfo.rotationXZ;

    EntityLivingBase player = Minecraft.getMinecraft().renderViewEntity;
    EntityFX.interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
    EntityFX.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
    EntityFX.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;

    // bind the texture
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);

    // save the old gl state
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    // gl states/settings for drawing
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDepthMask(false);// w  w  w.jav a  2 s. c  o m
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);

    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();

    for (EntityFX particle : particles) {
        tessellator.setBrightness(particle.getBrightnessForRender(partialTicks));

        particle.renderParticle(tessellator, partialTicks, rotationX, rotationXZ, rotationZ, rotationYZ,
                rotationXY);
    }

    tessellator.draw();

    // restore previous gl state
    GL11.glPopAttrib();

    Minecraft.getMinecraft().mcProfiler.endSection();
}

From source file:forestry.core.gui.GuiForestry.java

License:Open Source License

public void drawItemStack(ItemStack stack, int xPos, int yPos) {
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);/*w  w  w .j  av a 2 s .  com*/
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderHelper.enableGUIStandardItemLighting();

    GL11.glTranslatef(0.0F, 0.0F, 32.0F);
    this.zLevel = 100.0F;
    itemRender.zLevel = 100.0F;
    FontRenderer font = null;
    if (stack != null) {
        font = stack.getItem().getFontRenderer(stack);
    }
    if (font == null) {
        font = fontRendererObj;
    }
    itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), stack, xPos, yPos);
    itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), stack, xPos, yPos);
    this.zLevel = 0.0F;
    itemRender.zLevel = 0.0F;

    RenderHelper.disableStandardItemLighting();
    GL11.glPopAttrib();
}

From source file:forestry.core.render.CrateRenderingHandler.java

License:Open Source License

private void renderIn3D(ItemStack stack) {
    GL11.glPushMatrix();//from  ww  w .ja v  a 2  s  . co m
    Tessellator tessellator = Tessellator.instance;
    if (RenderManager.instance.renderEngine == null) {
        return;
    }

    int meta = stack.getItemDamage();
    for (int pass = 0; pass < stack.getItem().getRenderPasses(meta); ++pass) {
        IIcon icon = stack.getItem().getIconFromDamageForRenderPass(meta, pass);
        if (icon == null) {
            continue;
        }

        if (renderItem.renderWithColor) {
            int color = stack.getItem().getColorFromItemStack(stack, pass);
            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.0F);
        }

        float minU = icon.getMinU();
        float maxU = icon.getMaxU();
        float minV = icon.getMinV();
        float maxV = icon.getMaxV();

        if (stack.getItemSpriteNumber() == 0) {
            RenderManager.instance.renderEngine.bindTexture(BLOCK_TEXTURE);
        } else {
            RenderManager.instance.renderEngine.bindTexture(ITEM_TEXTURE);
        }

        ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(),
                icon.getIconHeight(), PIXEL);

        if (stack.hasEffect(pass)) {
            GL11.glDepthFunc(GL11.GL_EQUAL);
            GL11.glDisable(GL11.GL_LIGHTING);
            RenderManager.instance.renderEngine.bindTexture(GLINT_TEXTURE);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            float f13 = 0.76F;
            GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F);
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glPushMatrix();
            float f14 = 0.125F;
            GL11.glScalef(f14, f14, f14);
            float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
            GL11.glTranslatef(f15, 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, 255, 255, PIXEL);
            GL11.glPopMatrix();
            GL11.glPushMatrix();
            GL11.glScalef(f14, f14, f14);
            f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
            GL11.glTranslatef(-f15, 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, 255, 255, PIXEL);
            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:forestry.core.render.CrateRenderingHandler.java

License:Open Source License

private void render(ItemRenderType type, ItemStack stack) {
    GL11.glPushMatrix();//w w  w.j a  v  a 2  s  .  c  om
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    IIcon crateTexture = stack.getIconIndex();
    renderItem.renderIcon(0, 0, crateTexture, 16, 16);

    ItemStack contained = getContainedFromCrate(stack);

    if (contained != null) {

        int meta = contained.getItemDamage();

        float scale = 0.5f;
        GL11.glScalef(scale, scale, 1);
        GL11.glTranslatef(6f, 8f, 0);
        if (type == ItemRenderType.ENTITY) {
            GL11.glTranslatef(0, 0, -0.1f);
        }

        if (contained.getItem() instanceof ItemBlock) {
            GL11.glScalef(16f, 16f, 1f);
            GL11.glTranslatef(1f, 1f, 0.1f);
            GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
            renderIn3D(contained);
        } else {
            for (int pass = 0; pass < contained.getItem().getRenderPasses(meta); ++pass) {
                IIcon containedTexture = contained.getItem().getIconFromDamageForRenderPass(meta, pass);
                if (containedTexture == null) {
                    continue;
                }

                if (renderItem.renderWithColor) {
                    int color = contained.getItem().getColorFromItemStack(contained, pass);
                    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.0F);
                }

                renderItem.renderIcon(0, 0, containedTexture, 16, 16);
            }
        }
    }

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

From source file:forestry.core.render.EntitySnowFX.java

License:Open Source License

public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) {

    tessellator.draw();/*www  .  j  a v  a 2  s.c  o m*/
    GL11.glPushMatrix();

    GL11.glDepthMask(false);
    GL11.glEnable(3042);
    GL11.glBlendFunc(770, blendmode);

    Proxies.common.bindTexture(texture);

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

    float f10 = 0.1F * particleScale;
    float f11 = (float) ((prevPosX + (posX - prevPosX) * f) - interpPosX);
    float f12 = (float) ((prevPosY + (posY - prevPosY) * f) - interpPosY);
    float f13 = (float) ((prevPosZ + (posZ - prevPosZ) * f) - interpPosZ);

    GL11.glRotatef((float) motionY, 0.0F, 1.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.setBrightness(0x0000f0);

    tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 1.0F);
    tessellator.addVertexWithUV(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10, 0, 1);
    tessellator.addVertexWithUV((f11 - f1 * f10) + f4 * f10, f12 + f2 * f10, (f13 - f3 * f10) + f5 * f10, 1, 1);
    tessellator.addVertexWithUV(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10, 1, 0);
    tessellator.addVertexWithUV((f11 + f1 * f10) - f4 * f10, f12 - f2 * f10, (f13 + f3 * f10) - f5 * f10, 0, 0);

    tessellator.draw();

    GL11.glDisable(3042);
    GL11.glDepthMask(true);

    GL11.glPopMatrix();
    GL11.glBindTexture(3553 /* GL_TEXTURE_2D *//* GL_TEXTURE_2D */,
            Proxies.common.getClientInstance().renderEngine.getTexture("/particles.png"));
    tessellator.startDrawingQuads();
}

From source file:forestry.farming.render.FarmItemRenderer.java

License:Open Source License

private void renderFarmBlock(RenderBlocks render, ItemStack item, float translateX, float translateY,
        float translateZ) {
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);/*  w  ww .  j  av a2 s .c om*/
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    Tessellator tessellator = Tessellator.instance;
    BlockFarm block = (BlockFarm) StackUtils.getBlock(item);
    if (block == null) {
        return;
    }

    block.setBlockBoundsForItemRender();
    render.setRenderBoundsFromBlock(block);

    EnumFarmBlock type = EnumFarmBlock.getFromCompound(item.getTagCompound());

    GL11.glTranslatef(translateX, translateY, translateZ);

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1F, 0.0F);
    render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D,
            block.getBlockTextureFromSideAndMetadata(type, 0, item.getItemDamage()));
    render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getOverlayTextureForBlock(0, item.getItemDamage()));
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D,
            block.getBlockTextureFromSideAndMetadata(type, 1, item.getItemDamage()));
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getOverlayTextureForBlock(1, item.getItemDamage()));
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1F);
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D,
            block.getBlockTextureFromSideAndMetadata(type, 2, item.getItemDamage()));
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getOverlayTextureForBlock(2, item.getItemDamage()));
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D,
            block.getBlockTextureFromSideAndMetadata(type, 3, item.getItemDamage()));
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getOverlayTextureForBlock(3, item.getItemDamage()));
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(-1F, 0.0F, 0.0F);
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D,
            block.getBlockTextureFromSideAndMetadata(type, 4, item.getItemDamage()));
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getOverlayTextureForBlock(4, item.getItemDamage()));
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D,
            block.getBlockTextureFromSideAndMetadata(type, 5, item.getItemDamage()));
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getOverlayTextureForBlock(5, item.getItemDamage()));
    tessellator.draw();

    GL11.glTranslatef(0.5F, 0.5F, 0.5F);

    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

    GL11.glPopAttrib();
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DCircle.java

License:Open Source License

private void drawCircle() {
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);//from w w  w  .j a v a2s.c  om

    if (customColor) {
        GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor3f(innerColor.r, innerColor.g, innerColor.b);
    }
    GL11.glVertex3f(0.0f, 0.0f, 0.0f); // center

    float step = 2f * (float) Math.PI / (float) quality;
    if (customColor) {

        GL11.glColor4f(outerColor.r, outerColor.g, outerColor.b, outerColor.a);
    }

    for (int i = 0; i <= quality; i++) {
        GL11.glVertex3f((float) (radius * Math.cos(step * i)), (float) (radius * Math.sin(step * i)), 0f);
    }

    if (customColor) {

        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glPopAttrib();
    }

    GL11.glEnd();

}