I've started using libgdx and am trying to simply make a circle with a pretty thick stroke. As of yet I have not found anyway to make a stroke at all. pixmap.setStrokeWidth()
is even in the API but appears to have been removed (?), and Gdx.gl10.glLineWidth(width);
has no effect. How can I just change the stroke of the line?
Here is a snippet of my current code:
@Override
public void create() {
w = Gdx.graphics.getWidth();
batch = new SpriteBatch();
pixmap = new Pixmap(2 * w, 2 * w, Pixmap.Format.RGBA8888);
pixmap.setColor(Color.BLACK);
pixmap.drawCircle(w, w, w);
texture = new Texture(pixmap);
pixmap.dispose();
sprite = new Sprite(texture);
}
@Override
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
sprite.setPosition(-w / 2, -w);
sprite.draw(batch);
batch.end();
}
The OpenGL "line width" API is lame. The standard only requires that width 1.0 is supported, so many implementations (especially in mobile devices) do not support more than that. See Libgdx gl10.glLineWidth().
You might try drawing two filled discs, both with the same center. The second one should have a smaller radius and should be drawn to the Pixmap in such a way to set the alpha to 0 where its drawn. That should leave a "fat" circle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With