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

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

Introduction

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

Prototype

int GL_CULL_FACE

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

Click Source Link

Usage

From source file:com.digitale.mygdxgame.SplashRenderer.java

License:Open Source License

private void renderSun(GL10 gl, float radius, float x, float y, float z, Application app) {

    gl.glDisable(GL10.GL_LIGHTING);/* w ww  . j a v a 2s  .  c om*/
    radius = radius * worldscale;
    sunTexture.bind();
    gl.glPushMatrix();
    //move away from origin
    gl.glTranslatef(x, y, z);
    //scale to size of earth
    gl.glScalef(radius, radius, radius);
    gl.glDisable(GL10.GL_CULL_FACE);

    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
    gl.glPushMatrix();
    gl.glDisable(GL10.GL_LIGHTING);
    //gl.glRotatef((Splash.planetmove/10), .25f, .75f, .5f);
    sunMesh.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();
    gl.glEnable(GL10.GL_LIGHTING);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

}

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

License:Open Source License

public void render() {
    BookSpecification spec = engine.book;
    BookModel model = engine.model;// ww  w  .j  a  v  a  2 s.co m

    GL10 gl = Gdx.gl10;

    cnt += .01;

    engine.attractor.attract(engine.camera, .075f);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    engine.camera.apply(gl);

    gl.glEnable(GL10.GL_LIGHTING);
    gl.glEnable(GL10.GL_LIGHT0);
    gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_AMBIENT, ambient);
    gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, diffuse);
    gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, position);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glTranslatef((float) engine.globalTrans, 0, 0);
    gl.glRotatef((float) (engine.globalRot * 180 / Math.PI), 0, 1, 0);

    boolean pageIsActive = engine.hand.pageIsActive;
    int leftPageIndex = model.leftStack.nStackPages > 0 ? 1 + 2 * (model.leftStack.nStackPages - 1) : -1;
    int rightPageIndex = model.rightStack.nStackPages > 0 ? leftPageIndex + 1 + (pageIsActive ? 2 : 0) : -1;

    Bindable leftPage = leftPageIndex >= 0 ? spec.pages.get(leftPageIndex).getTexture() : null;
    Bindable rightPage = rightPageIndex >= 0 ? spec.pages.get(rightPageIndex).getTexture() : null;
    Bindable pageFront = pageIsActive ? spec.pages.get(leftPageIndex + 1).getTexture() : null;
    Bindable pageBack = pageIsActive ? spec.pages.get(leftPageIndex + 2).getTexture() : null;

    Gdx.gl10.glEnable(GL10.GL_CULL_FACE);
    gl.glPolygonMode(GL10.GL_FRONT_AND_BACK, GL10.GL_FILL);

    boolean zoomed = engine.zoom.active;
    model.render(leftPage, rightPage, pageFront, pageBack, engine.book.coverTex, engine.book.innerCoverTex,
            zoomed ? null : leftRoiMask, zoomed ? null : rightRoiMask);

    for (Component extension : engine.components)
        extension.render();

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

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

License:Open Source License

public void render() {
    if (book == null || !active)
        return;//  w  ww. j a va 2s . c  o  m

    GL10 gl = Gdx.gl10;

    cnt += .01;

    globalFrame.attract(camera, .075f);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    gl.glLoadIdentity();
    camera.apply(gl);

    Gdx.gl10.glEnable(GL10.GL_TEXTURE_2D);
    Gdx.gl10.glDisable(GL10.GL_CULL_FACE);
    Gdx.gl10.glDisable(GL10.GL_LIGHTING);
    gl.glPolygonMode(GL10.GL_FRONT_AND_BACK, GL10.GL_FILL);

    int page = (int) (-camera.position.y * book.aspectRatio);
    int p0 = Math.max(0, page - pageSpread), p1 = Math.min(book.pages.size() - 1, page + pageSpread);
    for (int i = p0; i <= p1; i++) {
        book.pages.get(i).getTexture().bind();
        GfxUtils.fillQuad(-.5f, -(float) (i / book.aspectRatio), 0, 0, .5f,
                -(float) ((i + 1) / book.aspectRatio), 1, 1);
    }

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

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

License:Open Source License

public void renderWidget() {
    GL10 gl = Gdx.gl10;/*from w  ww.j  a  va 2 s .com*/
    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.book.roi.ROIOverlay.java

License:Open Source License

public void render() {
    if (alpha < alphaGoal)
        alpha += .02f;//from   w w w.j  av  a2  s  .  c o m
    else if (alpha > alphaGoal)
        alpha -= .02f;
    alpha = alpha < 0 ? 0 : alpha > 1 ? 1 : alpha;
    if (alpha == 0)
        return;
    GL10 gl = Gdx.gl10;

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

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

    gl.glDisable(GL10.GL_TEXTURE_2D);
    gl.glColor4f(0, 0, 0, .75f * alpha);
    doQuad(-2 * offsetMargin, 1, 1, -1);

    float y0 = 0;
    gl.glEnable(GL10.GL_TEXTURE_2D);

    gl.glColor4f(1, 1, 1, alpha);
    for (OverlayElement element : elements) {
        float w = elementWidth(element);
        float h = elementHeight(w, element);
        if (element.bind()) {
            doQuad(-offsetMargin + .5f - .5f * w, 1 - y0 + offset, -offsetMargin + .5f + .5f * w,
                    1 - y0 - h + offset);
            y0 += h + vmargin * element.marginFactor();
        }
    }

    if (offset > 0) {
        up.bind();
        gl.glColor4f(1, 1, 1, .5f * alpha);
        float bw = .05f;
        doQuad(1 - bw, 1, 1, 1 - (bw * Gdx.graphics.getWidth() / Gdx.graphics.getHeight()));
    }
    if (offset < maxOffset) {
        down.bind();
        gl.glColor4f(1, 1, 1, .5f * alpha);
        float bw = .05f;
        doQuad(1 - bw, (bw * Gdx.graphics.getWidth() / Gdx.graphics.getHeight()) - 1, 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);
}

From source file:org.interreg.docexplore.reader.DebugGraphics.java

License:Open Source License

public void render() {
    gl.glDisable(GL10.GL_LIGHTING);/*from   w ww  .j a v  a2s .c o m*/
    gl.glDisable(GL10.GL_TEXTURE_2D);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_DEPTH_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);

    for (Graphics.Renderable listener : listeners)
        try {
            listener.render(this);
        } catch (Throwable e) {
            e.printStackTrace();
        }

    gl.glEnable(GL10.GL_TEXTURE_2D);
    synchronized (overlays) {
        for (Map.Entry<BufferedImage, ImageOverlay> entry : overlays.entrySet()) {
            ImageOverlay overlay = entry.getValue();
            if (overlay.tex == null)
                overlay.tex = new Texture(entry.getKey(), false);
            gl.glColor4f(overlay.r, overlay.g, overlay.b, overlay.a);
            overlay.tex.bind();
            GfxUtils.fillQuad((float) overlay.x, (float) overlay.y, 0, 0, (float) (overlay.x + overlay.w),
                    (float) (overlay.y + overlay.h), 1, 1);
        }
    }
    gl.glColor4f(1, 1, 1, 1);

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

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

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

License:Open Source License

public void renderWidget() {
    GL10 gl = Gdx.gl10;/*from ww w  .j av  a 2s . co m*/

    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 w w w  .j a va2 s  . c  o  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 ava2s  .  c  o m

    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.InputManager.java

License:Open Source License

public void render() {
    if (cursor == null)
        return;/*from   w w  w.  j  av a2 s.co  m*/

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

    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glDisable(GL10.GL_LIGHTING);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glColor4f(1, 1, 1, 1);

    if (cursor != null) {
        cursor.bind();
        int my = Gdx.graphics.getHeight() - Mouse.getY();
        GfxUtils.fillQuad(Mouse.getX() - cursorHotSpot[0], my - cursorHotSpot[1], 0, 0,
                Mouse.getX() - cursorHotSpot[0] + cursor.width(), my - cursorHotSpot[1] + cursor.height(), 1,
                1);
    }

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

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

    app.debugGfx.render();
}