Hello
I’m sorry for my english.
Tell me who knows, I need to fill a polygon texture like this:
But i get this:
This my code:
package com.absoft.balance.screen;
import java.util.ArrayList;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.PolygonRegion;
import com.badlogic.gdx.graphics.g2d.PolygonSprite;
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.EarClippingTriangulator;
public class GameScreen implements Screen {
TextureRegion textureRegion;
PolygonSpriteBatch batch;
ArrayList<PolygonSprite> polygonSprites = new ArrayList<PolygonSprite>();
public GameScreen() {
batch = new PolygonSpriteBatch();
textureRegion = new TextureRegion(new Texture(
Gdx.files.internal("123.png")));
float t = 0;
float[] vertices = new float[] { 0 + t, 0 + t, 250 + t, 250 + t,
500 + t, 0 + t };
polygonSprites.add(new PolygonSprite(new PolygonRegion(textureRegion,
vertices, new EarClippingTriangulator().computeTriangles(
vertices).toArray())));
}
@Override
public void render(float delta) {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
// batch.setShader(shader);
for (int i = 0; i < polygonSprites.size(); i++) {
polygonSprites.get(i).draw(batch);
// batch.flush();//uncomment for expected result
}
batch.end();
}
@Override
public void resize(int width, int height) {
}
@Override
public void show() {
}
@Override
public void hide() {
}
@Override
public void resume() {
}
@Override
public void dispose() {
}
@Override
public void pause() {
}
}
What do you think?? what i do wrong?