简体   繁体   中英

Drawing Stage behind 3d scene in libgdx

I am trying to draw a stage (with a parallax effect) behind my 3d scene in libgdx (as a background). When I call stage.draw() before screen.render() i can only see the 3d scene. When I call screen.render() before stage.draw() i can only see the background. Is there a way to make the screen somehow see through?

I am calling:

stage.act();
stage.draw();
screen.render(delta);

My render() operation in screen looks like this:

Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
modelBatch.begin(mainCamera);
modelBatch.render(instances, environment);
modelBatch.end();

Okay, so I figured it out:
Instead of calling stage.act() and stage.draw() before screen.render() ,

I simply called stage.act() and stage.draw() in the render() operation after

Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM