3
private Mesh mesh;
private Texture texture;
private SpriteBatch batch;
@Override
public void create() {
if (mesh == null) {
mesh = new Mesh(true, 3, 3, new VertexAttribute(Usage.Position, 3,
"a_position"));
mesh.setVertices(new float[] { -0.5f, -0.5f, 0,
0.5f, -0.5f, 0,
0, 0.5f, 0 });
mesh.setIndices(new short[] { 0, 1, 2 });
texture = new Texture(Gdx.files.internal("data/circle.png"));
batch = new SpriteBatch();
}
}
@Override
public void render() {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.begin();
mesh.render(GL10.GL_TRIANGLES, 0, 3);
batch.draw(texture, 10, 10);
batch.end();
}
我想在屏幕上使用libgdx繪製一個三角形和一個圓(從一個PNG)。繪製網格和紋理libgdx
當我運行這個時,我只能看到屏幕上的紋理(圓圈)。我應該怎麼做才能使網格和紋理可見?