gpt4 book ai didi

java - libgdx - 尝试使用 ShapeRenderer 时出错

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:44:24 25 4
gpt4 key购买 nike

我正在尝试使用带有此代码的 ShapeRenderer 来实现淡入淡出效果:

            Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl20.glBlendFunc(GL20.GL_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
//ShaderProgram.pedantic = false;

shapeRenderer.setProjectionMatrix(stage.getCamera().combined);
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(new Color(0,0,0,fadeTimeElapsed/1.5f));
shapeRenderer.rect(0,0,Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
shapeRenderer.end();

Gdx.gl20.glDisable(GL20.GL_BLEND);

我得到以下异常:

FATAL EXCEPTION: GLThread 2715 java.lang.IllegalArgumentException: no uniform with name 'u_projModelView' in shader at com.badlogic.gdx.graphics.glutils.ShaderProgram.fetchUniformLocation(ShaderProgram.java:287) at com.badlogic.gdx.graphics.glutils.ShaderProgram.fetchUniformLocation(ShaderProgram.java:277) at com.badlogic.gdx.graphics.glutils.ShaderProgram.setUniformMatrix(ShaderProgram.java:507) at com.badlogic.gdx.graphics.glutils.ShaderProgram.setUniformMatrix(ShaderProgram.java:498) at com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20.flush(ImmediateModeRenderer20.java:147) at com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20.end(ImmediateModeRenderer20.java:160) at com.badlogic.gdx.graphics.glutils.ShapeRenderer.end(ShapeRenderer.java:1104) at net.ukk.rpg.Level.render(Level.java:93) at com.badlogic.gdx.Game.render(Game.java:46) at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:422) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1542) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1266)

顺便说一句,对于 ShaderProgram.pedantic=false,我没有得到任何填充的矩形。提前致谢。

最佳答案

问题是我在线程中实例化 ShapeRenderer。在 show() 方法中调用构造函数解决了这个问题。

关于java - libgdx - 尝试使用 ShapeRenderer 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29321615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com