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

人走茶凉 提交于 2019-12-23 09:21:18

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/14177186/nesting-shaperenderer-begin-end-in-spritebatch-begin-end

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!