AGP
AGP

Reputation: 459

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);

Upvotes: 6

Views: 2414

Answers (1)

P.T.
P.T.

Reputation: 25177

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.

Upvotes: 8

Related Questions