我在libgdx中有片段着色器問題。以下是我的片段着色器。片段着色器:在着色器中沒有統一名稱
#ifdef GL_ES
precision mediump float;
#endif
uniform float u_aspectRatio;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
void main()
{
gl_FragColor = texture2D(u_texture, v_texCoords);
}
在節目我做
shader.setUniformi("u_texture", 0); // work fine
shader.setUniformf("u_aspectRatio", 0.0f); //no uniform with name 'u_aspectRatio' in shader
shader.isCompiled()返回true和第一套做工精細,但在第二次我有錯誤「名爲‘u_aspectRatio’着色器沒有統一的」。如果刪除行:
uniform float u_aspectRatio;
從着色器都工作正常,但是當我加入這一行(在功能,我想與此對象的工作),並嘗試建立一些數據我有錯誤。
我找到答案。在着色器不能統一哪個不使用psobject – Dima