Example usage for com.badlogic.gdx.graphics GL20 GL_SCISSOR_TEST

List of usage examples for com.badlogic.gdx.graphics GL20 GL_SCISSOR_TEST

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics GL20 GL_SCISSOR_TEST.

Prototype

int GL_SCISSOR_TEST

To view the source code for com.badlogic.gdx.graphics GL20 GL_SCISSOR_TEST.

Click Source Link

Usage

From source file:com.sasluca.lcl.utils.LCLUtils.java

License:Apache License

public static void startScrissor(float x, float y, float width, float height) {
    vector3.x = x;//w  w w  . j  a va  2 s  .c o  m
    LCL.getCamera().project(vector3);
    x = vector3.x;

    vector3.y = y;
    LCL.getCamera().project(vector3);
    y = vector3.y;

    vector3.x = width;
    LCL.getCamera().project(vector3);
    width = vector3.x;

    vector3.y = height;
    LCL.getCamera().project(vector3);
    height = vector3.y;

    LCL.getSpriteBatch().flush();

    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);
    Gdx.gl.glScissor((int) x, (int) y, (int) width, (int) height);
}

From source file:com.sasluca.lcl.utils.LCLUtils.java

License:Apache License

public static void endScrissor() {
    Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
    LCL.getSpriteBatch().flush();
}

From source file:com.thetruthbeyond.gui.utility.gl.GlUtils.java

License:Open Source License

public static void clearAlpha(Area area) {
    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);
    Gdx.gl.glScissor(area.getX(), Consts.SCREEN_H - area.getY() - area.getH(), area.getW(), area.getH());

    // Setting alpha channel throughout the image to 1.
    Gdx.gl20.glColorMask(false, false, false, true);
    Gdx.gl20.glClearColor(0, 0, 0, 1.0f);
    Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

    Gdx.gl20.glColorMask(true, true, true, true);
    Gdx.gl20.glClearColor(0, 0, 0, 0);//from w ww  .j a va2 s.  com

    Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
}

From source file:com.thetruthbeyond.gui.utility.gl.GlUtils.java

License:Open Source License

public static void setAlpha(Area area, float alpha) {
    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);
    Gdx.gl.glScissor(area.getX(), Consts.SCREEN_H - area.getY() - area.getH(), area.getW(), area.getH());

    // Setting alpha channel throughout the image to alpha.
    Gdx.gl20.glColorMask(false, false, false, true);
    Gdx.gl20.glClearColor(0, 0, 0, alpha);
    Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

    Gdx.gl20.glColorMask(true, true, true, true);
    Gdx.gl20.glClearColor(0, 0, 0, 0);// w  ww  .j ava  2 s .c o  m

    Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
}

From source file:com.uwsoft.editor.gdx.ui.components.ItemPhysicsEditor.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    //super.draw(batch, parentAlpha);

    if (isTransform())
        applyTransform(batch, computeTransform());
    Rectangle calculatedScissorBounds = Pools.obtain(Rectangle.class);
    getStage().calculateScissors(new Rectangle(0, 0, getWidth(), getHeight()), calculatedScissorBounds);
    // Enable scissors.
    if (ScissorStack.pushScissors(calculatedScissorBounds)) {
        drawChildren(batch, parentAlpha);
        ScissorStack.popScissors();/* w w  w  . j  a  v  a2s. c o m*/
        if (isTransform())
            resetTransform(batch);
    }

    batch.end();

    Gdx.gl.glLineWidth(2);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    //

    shapeRenderer.setProjectionMatrix(stage.getCamera().combined);
    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);
    Gdx.gl.glScissor((int) calculatedScissorBounds.x, (int) calculatedScissorBounds.y, (int) getWidth(),
            (int) getHeight());
    Pools.free(calculatedScissorBounds);
    if (currentMode == EditMode.Create) {
        drawOutlines();
        drawPoints();
        drawNextLine();
    }
    if (currentMode == EditMode.Edit) {
        drawPolygon();
        drawOutlines();
        drawPoints();

    }
    Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
    Gdx.gl.glDisable(GL20.GL_BLEND);
    if (currentMode == EditMode.Test) {
        box2dRenderer.render(physicsEditorWorld, stage.getCamera().combined.scl(1 / PhysicsBodyLoader.SCALE));
    }
    batch.begin();
}

From source file:com.watabou.noosa.Game.java

License:Open Source License

public void onSurfaceCreated() {
    Gdx.gl.glEnable(GL20.GL_BLEND);// w  w w  .  j av  a2s . c o  m
    // For premultiplied alpha:
    // Gdx.gl.glBlendFunc( GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA );
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);

    TextureCache.reload();
}

From source file:lpool.gui.DirectionalShadowLight.java

License:Apache License

public void begin() {
    final int w = fbo.getWidth();
    final int h = fbo.getHeight();
    fbo.begin();/*from w ww .  j  a  v a  2 s. co m*/
    Gdx.gl.glViewport(0, 0, w, h);
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);
    Gdx.gl.glScissor(1, 1, w - 2, h - 2);
}

From source file:lpool.gui.DirectionalShadowLight.java

License:Apache License

public void end() {
    Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
    fbo.end();
}

From source file:tilo.Tilo.java

License:Open Source License

public void create() {
    int width = 800;
    int height = 600;
    Tilo.width = width;/*from ww w  .  j a  va2  s .com*/
    Tilo.height = height;

    script = new lua();

    // LOAD PLUGINS
    g.plugin_load();
    script.put("graphics", g);
    script.put("timer", t);
    script.put("window", w);
    script.put("math", m);
    script.put("input", i);
    script.put("audio", a);

    if (getPlatform().equalsIgnoreCase("desktop")) {
        width = 800;
        height = 600;

        Tilo.width = width;
        Tilo.height = height;

        boolean fullscreen = false;
        Gdx.graphics.setDisplayMode(width, height, fullscreen);
    }
    assets = new AssetManager();
    Gdx.input.setInputProcessor(this);

    // LOAD SCRIPT
    FileHandle main = file("main.lua");

    if (main.exists()) {
        script.eval(main.readString());
    } else {
        error(TAG, E_RESOURCE + main.name());
        quit();
    }

    // Enable non power of two textures.
    FileTextureData.copyToPOT = true;

    // Set OpenGL features
    Gdx.gl.glDisable(GL20.GL_CULL_FACE);
    Gdx.gl.glDisable(GL20.GL_DITHER);
    Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);
    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);

    script.invoke("tilo", "load", assets);
    ready = true;
}