Example usage for org.lwjgl.opengl GL11 glAlphaFunc

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

Introduction

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

Prototype

public static native void glAlphaFunc(@NativeType("GLenum") int func, @NativeType("GLfloat") float ref);

Source Link

Document

The alpha test discards a fragment conditionally based on the outcome of a comparison between the incoming fragment’s alpha value and a constant value.

Usage

From source file:net.malisis.core.renderer.MalisisRenderer.java

License:Open Source License

/**
 * Enables the blending for the rendering. Ineffective for ISBRH.
 *///  w w  w .jav  a 2  s .c o  m
public void enableBlending() {
    if (renderType == RenderType.ISBRH_WORLD)
        return;

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F);

}

From source file:net.malisis.doors.renderer.MixedBlockRenderer.java

License:Open Source License

@Override
public void render() {
    if (!setup())
        return;//from www  .  j a v  a2  s . c om

    if (MalisisDoorsSettings.simpleMixedBlockRendering.get()) {
        renderSimple();
        return;
    }

    if (renderType == TYPE_ITEM_INVENTORY) {
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.0F);
        GL11.glEnable(GL11.GL_COLOR_MATERIAL);
        GL11.glShadeModel(GL11.GL_SMOOTH);
        enableBlending();
    }

    set(block1, metadata1);
    drawPass(true);
    set(block2, metadata2);
    drawPass(false);
}

From source file:net.malisis.doors.renderer.VanishingBlockRenderer.java

License:Open Source License

private void renderVanishingTileEntity() {
    VanishingTileEntity te = (VanishingTileEntity) this.tileEntity;

    if (!te.inTransition && !te.vibrating) {
        if (!te.powered && te.copiedTileEntity != null) {
            clean();/*from   www.j  av  a 2 s  .  c  om*/
            TileEntityRendererDispatcher.instance.renderTileEntity(te.copiedTileEntity, partialTick);
        }
        return;
    }

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0);

    float fx = 0.0F;
    float fy = 0.0F;
    float fz = 0.0F;
    float scale = (float) (te.getDuration() - te.transitionTimer) / (float) te.getDuration();
    boolean rendered = te.copiedBlock != null;

    RenderParameters rp = new RenderParameters();
    rp.useBlockBounds.set(false);
    rp.interpolateUV.set(false);

    Shape shape = ShapePreset.Cube();
    // randomize position for vibrations
    if (!te.inTransition && !te.powered) {
        rp.alpha.set(200);
        fx = rand.nextFloat() * 0.05F;
        fy = rand.nextFloat() * 0.05F;
        fz = rand.nextFloat() * 0.05F;
        if (rand.nextBoolean())
            GL11.glTranslated(fx, fy, fz);
        else
            GL11.glRotatef(rand.nextInt(5), 1, 1, 1);
    } else {
        int alpha = te.copiedBlock != null ? 255 - (int) (scale * 255) : (int) (scale * 255);
        rp.alpha.set(alpha);
        shape.scale(scale - 0.001F);
    }

    if (te.copiedBlock != null) {
        RenderBlocks renderBlocks = new RenderBlocks(ProxyAccess.get(world));
        renderBlocks.renderAllFaces = true;
        try {
            boolean smbr = MalisisDoorsSettings.simpleMixedBlockRendering.get();
            MalisisDoorsSettings.simpleMixedBlockRendering.set(true);

            GL11.glPushMatrix();
            GL11.glTranslated(0.5F, 0.5F, 0.5F);
            GL11.glScalef(scale, scale, scale);
            GL11.glTranslated(-x - 0.5F, -y - 0.5F, -z - 0.5F);

            GL11.glBlendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA);
            GL14.glBlendColor(0, 0, 0, 1 - scale);
            renderBlocks.overrideBlockTexture = block.getIcon(blockMetadata, 0);
            rendered = renderBlocks.renderBlockByRenderType(te.copiedBlock, x, y, z);
            renderBlocks.overrideBlockTexture = null;
            next();

            if (te.copiedBlock.canRenderInPass(0)) {
                GL14.glBlendColor(0, 0, 0, scale);
                rendered |= renderBlocks.renderBlockByRenderType(te.copiedBlock, x, y, z);
                next();
            }
            if (te.copiedBlock.canRenderInPass(1)) {
                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                rendered |= renderBlocks.renderBlockByRenderType(te.copiedBlock, x, y, z);
                next();
            }

            if (!rendered)
                drawShape(shape, rp);

            GL11.glPopMatrix();

            if (te.copiedTileEntity != null) {
                clean();
                TileEntityRendererDispatcher.instance.renderTileEntity(te.copiedTileEntity, partialTick);
            }

            MalisisDoorsSettings.simpleMixedBlockRendering.set(smbr);

        } catch (Exception e) {
            drawShape(shape, rp);
        }

    } else
        drawShape(shape, rp);
}

From source file:net.phatcode.rel.multimedia.Renderer.java

License:Open Source License

Renderer(int screenWidth, int screenHeight) {
    try {//from w w  w  .ja v a  2s  . c  om
        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:org.craftmania.rendering.ChunkMeshRenderer.java

License:Apache License

public static void renderChunkMesh(Chunk chunk, MeshType meshType) {
    if (chunk.getMesh().getVBO(meshType) <= 0) {
        return;//from  w w w .jav a2s.c o  m
    }

    /* Bind the correct texture */
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    TextureStorage.getTexture("terrain").bind();

    if (meshType == MeshType.OPAQUE) {
        GL11.glDisable(GL11.GL_BLEND);
    } else if (meshType == MeshType.TRANSLUCENT) {
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f);
    }

    ChunkMesh mesh = chunk.getMesh();

    /* Bind the buffer */
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, mesh.getVBO(meshType));

    /* Enable the different kinds of data in the buffer */
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    // System.out.println("Chunk Vertices = " + mesh.getVertexCount());

    /* Define the starting positions */
    GL11.glVertexPointer(POSITION_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, POSITION_OFFSET * FLOAT_SIZE);
    GL11.glTexCoordPointer(TEX_COORD_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, TEX_COORD_OFFSET * FLOAT_SIZE);
    GL11.glColorPointer(COLOR_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, COLOR_OFFSET * FLOAT_SIZE);

    /* Draw the buffer */
    GL11.glDrawArrays(GL11.GL_QUADS, 0, mesh.getVertexCount(meshType));

    /* Unbind the buffer */
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 0);

    /* Disable the different kindds of data */
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    if (meshType == MeshType.TRANSLUCENT) {
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }
}

From source file:org.free.jake2.render.lwjgl.Misc.java

License:Open Source License

void GL_SetDefaultState() {
    GL11.glClearColor(1f, 0f, 0.5f, 0.5f); // original quake2
    //GL11.glClearColor(0, 0, 0, 0); // replaced with black
    GL11.glCullFace(GL11.GL_FRONT);//  w  ww. j a  va  2  s . c  o  m
    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.666f);

    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_BLEND);

    GL11.glColor4f(1, 1, 1, 1);

    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    GL11.glShadeModel(GL11.GL_FLAT);

    GL_TextureMode(gl_texturemode.string);
    GL_TextureAlphaMode(gl_texturealphamode.string);
    GL_TextureSolidMode(gl_texturesolidmode.string);

    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max);

    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);

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

    GL_TexEnv(GL11.GL_REPLACE);

    if (qglPointParameterfEXT) {
        // float[] attenuations = { gl_particle_att_a.value, gl_particle_att_b.value, gl_particle_att_c.value };
        FloatBuffer att_buffer = BufferUtils.createFloatBuffer(4);
        att_buffer.put(0, gl_particle_att_a.value);
        att_buffer.put(1, gl_particle_att_b.value);
        att_buffer.put(2, gl_particle_att_c.value);

        GL11.glEnable(GL11.GL_POINT_SMOOTH);
        GL14.glPointParameterf(EXTPointParameters.GL_POINT_SIZE_MIN_EXT, gl_particle_min_size.value);
        GL14.glPointParameterf(EXTPointParameters.GL_POINT_SIZE_MAX_EXT, gl_particle_max_size.value);
        GL14.glPointParameter(EXTPointParameters.GL_DISTANCE_ATTENUATION_EXT, att_buffer);
    }

    if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f) {
        GL11.glEnable(EXTSharedTexturePalette.GL_SHARED_TEXTURE_PALETTE_EXT);

        GL_SetTexturePalette(d_8to24table);
    }

    GL_UpdateSwapInterval();

    /*
     * vertex array extension
     */
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL13.glClientActiveTexture(GL_TEXTURE0);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
}

From source file:org.getspout.spout.config.MipMapUtils.java

License:Open Source License

public static void onTick(int texture, float targetFade, float currentFade) {
    GL11.glPushMatrix();// w ww  .  ja va  2 s  .c om
    GL11.glBindTexture(3553, texture);

    if (targetFade != currentFade) {
        if (targetFade < currentFade) {
            currentFade -= 0.01f;
            if (currentFade <= targetFade) {
                currentFade = targetFade;
            }
        } else {
            currentFade += 0.01f;
            if (currentFade >= targetFade) {
                currentFade = targetFade;
            }
        }

        if (currentFade <= 0.0f) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
            GL11.glAlphaFunc(GL11.GL_GREATER, 0.01F); //default blend state

            updateTerrain = false;
            GL11.glPopMatrix();
            return;
        } else {
            GL11.glTexEnvf(GL14.GL_TEXTURE_FILTER_CONTROL, GL14.GL_TEXTURE_LOD_BIAS,
                    getMipmapLevels(texture) * (currentFade - 1.0f));
        }
    }

    switch (mode) {
    case 1:
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        break;

    case 2:
        EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_2D);
        break;
    }
    GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.3F); //more strict blend state
    GL11.glPopMatrix();
}

From source file:org.spoutcraft.client.config.MipMapUtils.java

License:Open Source License

public static void onTick(int texture, float targetFade, float currentFade) {
    GL11.glPushMatrix();//from w  ww .  j a  va  2  s. c o m
    SpoutClient.getHandle().renderEngine.bindTexture(texture);

    if (targetFade != currentFade) {
        if (targetFade < currentFade) {
            currentFade -= 0.01f;
            if (currentFade <= targetFade) {
                currentFade = targetFade;
            }
        } else {
            currentFade += 0.01f;
            if (currentFade >= targetFade) {
                currentFade = targetFade;
            }
        }

        if (currentFade <= 0.0f) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
            GL11.glAlphaFunc(GL11.GL_GREATER, 0.01F); // Default blend state

            updateTerrain = false;
            GL11.glPopMatrix();
            return;
        } else {
            GL11.glTexEnvf(GL14.GL_TEXTURE_FILTER_CONTROL, GL14.GL_TEXTURE_LOD_BIAS,
                    getMipmapLevels(texture) * (currentFade - 1.0f));
        }
    }

    switch (mode) {
    case 1:
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        break;
    case 2:
        EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_2D);
        break;
    }
    GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.3F); // More strict blend state
    GL11.glPopMatrix();
}

From source file:org.spoutcraft.client.gui.MCRenderDelegate.java

License:Open Source License

public void render(GenericCheckBox checkBox) {
    if (checkBox.isVisible()) {
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.01F);
        Texture checkBoxCross = CustomTextureManager.getTextureFromJar("/res/ui/box_check.png");
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) Math.floor(checkBox.getScreenX()), (float) Math.floor(checkBox.getScreenY()),
                0);/*w  ww  . j  a v  a  2  s .c o  m*/
        renderBaseBox(checkBox, true);
        FontRenderer font = SpoutClient.getHandle().fontRenderer;
        Color color = getColor(checkBox);
        if (!checkBox.isChecked()) {
            color.setAlpha(0.2F);
        } else {
            color.setRed(0).setGreen(1).setBlue(0);
        }
        drawTexture(checkBoxCross, 20, 20, color, true);
        font.drawString(checkBox.getText(), 22, 7, getColor(checkBox).toInt());
    }
}

From source file:org.voxels.platform.LWJGLOpenGLAdapter.java

License:Open Source License

@Override
public void glAlphaFunc(final int func, final float ref) {
    GL11.glAlphaFunc(func, ref);
}