LibGDX: ShapeRenderer drawing… nothing

给你一囗甜甜゛ 提交于 2019-12-25 12:08:25

问题


So drawing a shape should be really easy, right? Well, the following draws exactly nothing.

...why?

Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

camera.update();
shapeRenderer.setProjectionMatrix(camera.combined);

shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(Color.WHITE);
shapeRenderer.rect(WIDTH / 2, HEIGHT / 2, 50, 50);
shapeRenderer.end();

回答1:


Make sure your camera is properly initialized.

For Example:

camera = new OrthographicCamera(); //Put this in init
camera.setToOrtho(0,0,WIDTH,HEIGHT); 


来源:https://stackoverflow.com/questions/24062348/libgdx-shaperenderer-drawing-nothing

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