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

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

Introduction

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

Prototype

int GL_POINTS

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

Click Source Link

Usage

From source file:com.badlogic.gdx.tests.lw.StageTestLW.java

License:Apache License

@Override
public void render() {
    GL10 gl = Gdx.graphics.getGL10();// w  w w. j  av  a  2 s  .c o  m
    gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    if (Gdx.input.isTouched()) {
        stage.toStageCoordinates(Gdx.input.getX(), Gdx.input.getY(), point);
        Actor actor = stage.hit(point.x, point.y);

        if (actor != null)
            if (actor instanceof Image)
                ((Image) actor).color.set((float) Math.random(), (float) Math.random(), (float) Math.random(),
                        0.5f + 0.5f * (float) Math.random());
    }

    int len = stage.getGroups().size();
    for (int i = 0; i < len; i++)
        if (rotateSprites)
            stage.getGroups().get(i).rotation += Gdx.graphics.getDeltaTime();
        else
            stage.getGroups().get(i).rotation = 0;

    scale += vScale * Gdx.graphics.getDeltaTime();
    if (scale > 1) {
        scale = 1;
        vScale = -vScale;
    }
    if (scale < 0.5f) {
        scale = 0.5f;
        vScale = -vScale;
    }

    len = images.size();
    for (int i = 0; i < len; i++) {
        Image img = images.get(i);
        if (rotateSprites)
            img.rotation -= 40 * Gdx.graphics.getDeltaTime();
        else
            img.rotation = 0;

        if (scaleSprites) {
            img.scaleX = scale;
            img.scaleY = scale;
        } else {
            img.scaleX = 1;
            img.scaleY = 1;
        }
    }

    stage.draw();

    Gdx.graphics.getGL10().glPointSize(4);
    renderer.begin(GL10.GL_POINTS);
    len = stage.getRoot().getGroups().size();
    for (int i = 0; i < len; i++) {
        renderer.color(1, 0, 0, 1);
        Group group = stage.getRoot().getGroups().get(i);
        renderer.vertex(group.x + group.originX, group.y + group.originY, 0);
    }
    renderer.end();
    Gdx.graphics.getGL10().glPointSize(4);

    ((Label) ui.findActor("fps")).setText("fps: " + Gdx.graphics.getFramesPerSecond() + ", actors "
            + images.size() + ", groups " + stage.getGroups().size());
    ui.draw();
}