Embedding ShapeRenderer.begin / end in SpriteBatch.begin / end

Is it possible to draw shapes using a ShapeRenderer between calls to SpriteBatch begin and end .

I tried, but no result, only the SpriteBatch textures are drawn, it doesn’t appear on the scene. Sample code is as follows:

 shapeRenderer.begin(ShapeType.FilledCircle); shapeRenderer.setColor(0f, 1f, 0f, 1f); shapeRenderer.filledCircle( 100, 100, 100); shapeRenderer.end(); 

I have a spelling camera created by these commands:

 camera = new OrthographicCamera(1, Gdx.graphics.getHeight() / Gdx.graphics.getWidth()); camera.setToOrtho(true); 
+6
source share
1 answer

Both ShapeRenderer and SpriteBatch set the state in OpenGL so that they expect to remain constant during their use. Nesting them can create problems. See this post in the badlogic forum .

This should probably be more clearly described in the documents.

+8
source

All Articles