Libgdx circle with line width

I started using libgdx and try to just make a circle with a rather thick stroke. At the moment, I still could not make a hit. pixmap.setStrokeWidth() even in the API, but it seems to have been deleted (?), and Gdx.gl10.glLineWidth(width); It does not work. How can I just change the course 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(); } 
+5
source share
1 answer

The OpenGL "line width" API is lame. The standard only requires support for a width of 1.0, so many implementations (especially on mobile devices) do not support more. See libgdx gl10.glLineWidth () .

You can try to draw two filled disks, both with the same center. The second should have a smaller radius and should be drawn for the Pixmap in such a way as to set the alpha value to 0 where it was drawn. This should leave a bold circle.

+6
source

Source: https://habr.com/ru/post/1201290/


All Articles