Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nesting ShapeRenderer.begin/end in SpriteBatch.begin/end

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

I have tried but no result, only SpriteBatch textures are drawn, no shape is on the scene. Sample code is as followed below :

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

I have a orthographic camera created by these commands :

camera = new OrthographicCamera(1, Gdx.graphics.getHeight() / Gdx.graphics.getWidth());
camera.setToOrtho(true);
like image 667
AGP Avatar asked Jan 05 '13 22:01

AGP


1 Answers

Both ShapeRenderer and SpriteBatch set state in OpenGL 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 spelled out a bit more clearly in the docs.

like image 159
P.T. Avatar answered Nov 13 '22 00:11

P.T.