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

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

Introduction

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

Prototype

int GL_DEPTH_TEST

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

Click Source Link

Usage

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  ww. java2s .  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);// ww w . j  av  a  2s.  com
    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;/*  w w w .  j  a  v  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 v  a 2s.c  om
        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;//from  www  . jav a 2s . 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], 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;//w w w . j  av a2s  . c  o 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();
}

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

License:Open Source License

public void create() {
    try {//from w  ww.j  av a2  s .  c om
        Gdx.graphics.setVSync(true);
        this.renderThread = Thread.currentThread();
        renderThread.setName("Render Thread");
        this.client = new ReaderClient(this, startup);
        client.start("127.0.0.1", 8787);
        this.renderTasks = new LinkedList<Runnable>();
        //this.sound = new SoundManager();

        client.registerStreamType(StreamedImage.class, StreamedImage.allocator);
        client.registerStreamType(StreamedTexture.class, StreamedTexture.allocator);
        //client.registerStreamType(StreamedSound.class, StreamedSound.allocator);
        client.registerStreamType(StreamedXML.class, StreamedXML.allocator);

        Gdx.gl10.glEnable(GL10.GL_BLEND);
        Gdx.gl10.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
        Gdx.gl10.glEnable(GL10.GL_COLOR_MATERIAL);
        Gdx.gl10.glEnable(GL10.GL_DEPTH_TEST);
        Gdx.gl10.glEnable(GL10.GL_MULTISAMPLE);
        Gdx.gl10.glCullFace(GL10.GL_BACK);

        this.modules = new LinkedList<Module>();
        modules.add(shelf = new ShelfEngine(this));
        modules.add(bookEngine = new BookEngine(this, 1, .7f));
        modules.add(parchmentEngine = new ParchmentEngine(this));
        modules.add(gui = new GuiLayer(this));
        modules.add(input = new InputManager(this));
        modules.add(debugGfx = new DebugGraphics(this));
        input.addListenerFirst(gui);

        bookEngine.addRoiLayoutListener(new BookEngine.ROILayoutListener() {
            public void roiLayoutChanged(ROISpecification[] rois) {
                input.notifyLayoutChange(rois);
            }
        });

        List<PluginConfig> plugins = startup.filterPlugins(InputPlugin.class);
        for (PluginConfig config : plugins) {
            InputPlugin plugin = (InputPlugin) config.clazz.newInstance();
            plugin.setHost(input);
        }

        if (!startup.nativeCursor)
            try {
                Mouse.setNativeCursor(
                        new Cursor(1, 1, 0, 0, 1, BufferUtils.createIntBuffer(1).put(0, 0), null));
            } catch (Exception e) {
                e.printStackTrace();
            }

        emptyTex = new Texture(ImageUtils.read(Thread.currentThread().getContextClassLoader().getResource(
                BookSpecification.class.getPackage().getName().replace('.', '/') + "/emptyPageTex.png")),
                false);

        waitDialog = new Dialog(this);
        waitDialog.set(XMLResourceBundle.getBundledString("waitLabel"),
                XMLResourceBundle.getBundledString("imagesLabel"));
        gui.addWidget(waitDialog);

        this.logger = new ActivityLogger(new File(DocExploreTool.getHomeDir(), "activity.log"), 10000);
        logger.addEntry("Startup");

        this.mainTask = new ReaderMainTask(this);
        mainTask.start();
    } catch (Exception e) {
        ErrorHandler.defaultHandler.submit(e, false);
        System.exit(0);
    }
}

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

License:Open Source License

public synchronized void render() {
    if (alpha < .01)
        return;//from  ww w .ja  v a  2 s .  co 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);
}

From source file:se.claremont.android.wallpaper.ClaremontWallpaper.java

License:Apache License

@Override
public void render() {

    ///*  w  w  w  .  j a  v a2s.c om*/
    // Set GL state
    //
    GL10 gl = Gdx.graphics.getGL10();
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    gl.glDisable(GL10.GL_DITHER);
    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glEnable(GL10.GL_COLOR_MATERIAL);
    gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST);
    gl.glEnable(GL10.GL_LIGHTING);
    gl.glEnable(GL10.GL_LIGHT0);

    //
    // Update light position
    //
    lightPosition.put(0, perspectiveCamera.position.x);
    lightPosition.put(1, perspectiveCamera.position.y);
    lightPosition.put(2, perspectiveCamera.position.z);
    gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPosition);

    //
    // Update camera position/direction
    //
    perspectiveCamera.position.set(perspectiveCameraCurrentPosition);
    perspectiveCamera.direction.set(perspectiveCameraCurrentDirection);
    perspectiveCamera.position.rotate(Gdx.graphics.getDeltaTime(), 0f, 1f, 0f);
    perspectiveCamera.direction.rotate(Gdx.graphics.getDeltaTime(), 0f, 1f, 0f);
    perspectiveCameraCurrentPosition = perspectiveCamera.position;
    perspectiveCameraCurrentDirection = perspectiveCamera.direction;
    perspectiveCamera.update();
    perspectiveCamera.apply(gl);

    //
    // Render Claremont text model
    //
    gl.glPushMatrix();
    gl.glColor4f(1f, 1f, 1f, 1f);
    gl.glRotatef(0.25f, 1f, 0f, 0f);
    claremontText.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();

    //
    // Render Claremont orb model
    //
    gl.glPushMatrix();
    gl.glColor4f(0.36862745f, 0.63921569f, 0.82352941f, 1f);
    gl.glRotatef(0.25f, 1f, 0f, 0f);
    claremontOrb.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();

}