Java – why does libgdx SpriteBatch / bitmapfont destroy texture bind?

I'm using libgdx to write games for Android Here are some codes for painting texture torus:

Gdx.gl10.glPushMatrix();
Gdx.gl10.glTranslatef(center.x,center.y,0);
Gdx.gl10.glRotatef(0,1,angle * 360f / (2f * (float)Math.PI));
texture.bind();
mesh.render(GL10.GL_TRIANGLE_STRIP);
Gdx.gl10.glPopMatrix();

... here's some code to draw some text:

spriteBatch.begin();
spriteBatch.setColor(1,1);
float fps = 1f / Gdx.graphics.getDeltaTime();
font.draw(spriteBatch,"fps: " + fps,50);
spriteBatch.end();

The first bit code works frame by frame until the second bit code runs After that, the first triangular strip is rendered only with the latest glmaterial Do you know why?

Update: solved! It turns out that SpriteBatch End() calls gldisable (gl_text_2d) Just reading source

Solution

It's actually the same in JavaDocs Rule of thumb: all libgdx classes connected to OpenGL es will change the minimum state quantity, and it is likely that things will not be reset because the GL cost of querying the state is high

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>