在SpriteBatch.begin/end中嵌套ShapeRenderer.begin/end [英] Nesting ShapeRenderer.begin/end in SpriteBatch.begin/end

查看:124
本文介绍了在SpriteBatch.begin/end中嵌套ShapeRenderer.begin/end的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在SpriteBatch beginend调用之间使用ShapeRenderer绘制形状.

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

我尝试过但没有结果,只绘制了SpriteBatch纹理,没有任何形状.示例代码如下:

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

推荐答案

ShapeRendererSpriteBatch都在OpenGL中设置了它们希望在使用过程中保持不变的状态.嵌套它们会产生问题.请参阅此帖子在badlogic论坛中.

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.

这篇关于在SpriteBatch.begin/end中嵌套ShapeRenderer.begin/end的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆