Example usage for com.badlogic.gdx.graphics GL10 GL_STENCIL_TEST

List of usage examples for com.badlogic.gdx.graphics GL10 GL_STENCIL_TEST

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics GL10 GL_STENCIL_TEST.

Prototype

int GL_STENCIL_TEST

To view the source code for com.badlogic.gdx.graphics GL10 GL_STENCIL_TEST.

Click Source Link

Usage

From source file:org.interreg.docexplore.reader.book.page.BookPageShadow.java

License:Open Source License

public void render() {
    GL11 gl = Gdx.gl11;/* w  ww . j  av  a2  s. c  o m*/
    gl.glEnable(GL11.GL_DEPTH_TEST);
    gl.glPolygonMode(GL10.GL_FRONT_AND_BACK, GL10.GL_FILL);
    gl.glClearStencil(0);
    gl.glClear(GL11.GL_STENCIL_BUFFER_BIT);
    gl.glColorMask(false, false, false, false);
    gl.glDepthMask(false);
    gl.glDisable(GL11.GL_LIGHTING);
    gl.glEnable(GL10.GL_STENCIL_TEST);
    //page.book.setupModelview();

    gl.glDisable(GL11.GL_CULL_FACE);
    gl.glStencilFunc(GL10.GL_ALWAYS, 0, 1);
    gl.glStencilOp(GL10.GL_KEEP, GL10.GL_KEEP, GL10.GL_INCR);
    //      gl.glCullFace(GL11.GL_FRONT);
    mesh.render(GL11.GL_TRIANGLES);

    //      gl.glStencilFunc(GL10.GL_ALWAYS, 0, 0xffff);
    //      gl.glStencilOp(GL10.GL_KEEP, GL10.GL_KEEP, GL10.GL_DECR);
    //      gl.glCullFace(GL11.GL_BACK);
    //      mesh.render(GL11.GL_TRIANGLES);

    gl.glDisable(GL11.GL_CULL_FACE);
    gl.glDisable(GL11.GL_DEPTH_TEST);
    gl.glColorMask(true, true, true, true);
    gl.glStencilFunc(GL10.GL_NOTEQUAL, 0, 1);
    gl.glStencilOp(GL10.GL_KEEP, GL10.GL_KEEP, GL10.GL_KEEP);
    gl.glColor4f(0, 0, 0, .5f);

    gl.glMatrixMode(GL11.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glMatrixMode(GL11.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glOrthof(0, 1, 0, 1, -1, 1);

    quad.render(GL11.GL_TRIANGLES);

    gl.glMatrixMode(GL11.GL_MODELVIEW);
    gl.glPopMatrix();
    gl.glMatrixMode(GL11.GL_PROJECTION);
    gl.glPopMatrix();

    gl.glEnable(GL11.GL_LIGHTING);
    gl.glEnable(GL11.GL_DEPTH_TEST);
    gl.glEnable(GL11.GL_CULL_FACE);
    gl.glDisable(GL10.GL_STENCIL_TEST);
    gl.glCullFace(GL11.GL_BACK);
    gl.glDepthMask(true);
    //page.book.unsetupModelview();
}

From source file:org.interreg.docexplore.reader.book.ParchmentMini.java

License:Open Source License

public void renderWidget() {
    GL10 gl = Gdx.gl10;//from  w w w  . j a  va  2s  .c om
    gl.glDisable(GL10.GL_TEXTURE_2D);
    gl.glDisable(GL10.GL_LIGHTING);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_STENCIL_TEST);
    gl.glColor4f(0, 0, 0, .25f * fullAlpha * alpha);
    GfxUtils.fillQuad(x - .5f * w, y - .5f * w, 0, 0, x + w + .5f * w, y + h + .5f * w, 1, 1);

    super.renderWidget();

    float px = engine.camera.position.x + .5f;
    float ch = (float) (engine.book.pages.size() / engine.book.aspectRatio);
    float py = -engine.camera.position.y / ch;
    float pw = (float) (engine.camera.position.z * .8f);
    float ph = pw * Gdx.graphics.getHeight() / (ch * Gdx.graphics.getWidth());

    gl.glDisable(GL10.GL_TEXTURE_2D);
    gl.glDisable(GL10.GL_LIGHTING);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_STENCIL_TEST);
    gl.glColor4f(.5f, .5f, 1f, .75f * fullAlpha * alpha);
    GfxUtils.fillQuad(x + (px - .5f * pw) * w, y + (py - .5f * ph) * h, 0, 0, x + (px + .5f * pw) * w,
            y + (py + .5f * ph) * h, 1, 1);
}

From source file:org.interreg.docexplore.reader.gui.Button.java

License:Open Source License

public void renderWidget() {
    GL10 gl = Gdx.gl10;/*from w  w w .  j  a v  a 2  s .  c om*/

    gl.glDisable(GL10.GL_LIGHTING);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_STENCIL_TEST);

    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glColor4f(color[0], color[1], color[2], .75f * alpha);
    texture.bind();
    GfxUtils.fillQuad(x, y, 0, 0, x + w, y + h, 1, 1);

    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_TEXTURE_2D);
}

From source file:org.interreg.docexplore.reader.gui.Dialog.java

License:Open Source License

public void renderWidget() {
    if (!ready)/*from   ww  w.java  2 s  .  co m*/
        return;

    GL10 gl = Gdx.gl10;

    gl.glDisable(GL10.GL_LIGHTING);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_STENCIL_TEST);

    int x0 = (Gdx.graphics.getWidth() - buffer.getWidth()) / 2, y0 = (Gdx.graphics.getHeight() - height) / 2;

    gl.glDisable(GL10.GL_TEXTURE_2D);
    gl.glColor4f(1, 1, 1, .75f * alpha);
    GfxUtils.fillQuad(0, 0, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, 0);
    //gl.glColor4f(1, 1, 1, .9f*alpha);
    //GfxUtils.doQuad(x0, y0, 0, 0, x0+buffer.getWidth(), y0+height, 0, 0);

    gl.glEnable(GL10.GL_TEXTURE_2D);
    texture.bind();
    gl.glColor4f(GuiLayer.defaultColor[0], GuiLayer.defaultColor[1], GuiLayer.defaultColor[2], alpha);
    GfxUtils.fillQuad(x0, y0, 0, 0, x0 + buffer.getWidth(), y0 + height, 1, tmax);

    if (clickedButton >= 0) {
        float bx1 = (clickedButton + 1) * buffer.getWidth() * 1f / (buttons.length + 1)
                - .5f * buttonBuffer.getWidth();
        float by1 = titleAndMessageHeight;
        float bx2 = bx1 + buttonBuffer.getWidth();
        float by2 = by1 + buttonHeights[clickedButton];
        float s1 = bx1 / texture.width(), t1 = by1 / texture.height(), s2 = bx2 / texture.width(),
                t2 = by2 / texture.height();
        //float halpha = alpha < .5 ? 12*alpha*alpha-16*alpha*alpha*alpha : 16*alpha*alpha*alpha-36*alpha*alpha+24*alpha-4;
        float halpha = 1 - (1 - alpha) * (1 - alpha) * (1 - alpha) * (1 - alpha);
        gl.glColor4f(GuiLayer.defaultHighlightColor[0], GuiLayer.defaultHighlightColor[1],
                GuiLayer.defaultHighlightColor[2], halpha);
        float boost = 0;
        GfxUtils.fillQuad(x() + bx1 - boost, y() + by1 - boost, s1, t1, x() + bx2 + 2 * boost,
                y() + by2 + 2 * boost, s2, t2);
    }

    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_TEXTURE_2D);
}

From source file:org.interreg.docexplore.reader.gui.Label.java

License:Open Source License

public void renderWidget() {
    GL10 gl = Gdx.gl10;/*w w w. j  a  va 2 s.  com*/

    gl.glDisable(GL10.GL_LIGHTING);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_STENCIL_TEST);

    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glColor4f(color[0], color[1], color[2], fullAlpha * alpha);
    texture.bind();
    GfxUtils.fillQuad(x, y, 0, 0, x + w, y + h, 1, 1);

    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_TEXTURE_2D);
}

From source file:org.interreg.docexplore.reader.shelf.ShelfEngine.java

License:Open Source License

public synchronized void render() {
    if (alpha < .01)
        return;// ww w  . java 2 s  .  c  o m

    GL10 gl = Gdx.gl10;

    gl.glDisable(GL10.GL_LIGHTING);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_STENCIL_TEST);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glOrthof(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, -1, 1);

    gl.glEnable(GL10.GL_TEXTURE_2D);

    if (textures == null)
        cursor = -1;
    else if (cursor > textures.length)
        cursor = textures.length - 1;
    if (cursor >= 0) {
        for (int i = 0; i < textures.length; i++) {
            int j = (textures.length / 2 + (i + 1) / 2 * (i % 2 == 0 ? 1 : -1)) % textures.length;
            int index = (cursor + j) % textures.length;
            Texture tex = textures[index];
            if (tex != null) {
                double x = getEntryX(j);
                double y = getEntryY(j);
                float k = (float) (.75 + .125 * (y + 1));
                k *= k;
                //float colk = (float)(.5*(y+1));
                gl.glColor4f(1, 1, 1, alpha * k);
                float x0 = (float) (.5 * (Gdx.graphics.getWidth() - k * tex.width())
                        + x * Gdx.graphics.getWidth() / 4);
                float y0 = (float) (.5 * (Gdx.graphics.getHeight() - k * tex.height())
                        + y * Gdx.graphics.getHeight() / 5);
                tex.bind();
                GfxUtils.fillQuad(x0, y0, 0, 0, x0 + k * tex.width(), y0 + k * tex.height(), 1, 1);
            }
        }
    }

    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPopMatrix();
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPopMatrix();

    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_TEXTURE_2D);
}