Combination ShapeRenderer with ModelBatch

Anything about development not directly related to libgdx, e.g. OpenGL, Android APIs etc.

Combination ShapeRenderer with ModelBatch

Postby Gamdim » Wed Sep 25, 2019 1:10 pm

Hello.
I want to draw a ring around a sphere. A ring is created using a ShapeRenderer. Sphere using meshPartBuilder.sphere (1, 1, 1, 10, 10).
When I look at the ring from the side, it is completely drawn behind the sphere. (or in front of the sphere if shapeRenderer is called after modelBatch).
Help fix if there is a way.
Code: Select all
public void render()
    {
        Gdx.gl.glClearColor(0,0,0,1);
        Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
       
        shapeRenderer.setProjectionMatrix(camera.combined);
        shapeRenderer.begin(ShapeType.Line);
        shapeRenderer.setColor(Color.RED);
        shapeRenderer.circle(0,0,1,30);
        shapeRenderer.end();
       
        modelBatch.begin(camera);
        modelBatch.render(sphereInstance, environment);
        modelBatch.render(axisInstance);
        modelBatch.end();
    }

https://gamedev.ru/files/images/?id=141614
https://gamedev.ru/files/images/?id=141613
Gamdim
 
Posts: 4
Joined: Sat Jun 08, 2019 4:04 pm

Return to General Development

Who is online

Users browsing this forum: No registered users and 1 guest