我的游戏在较新的设备上运行良好(例如..droid turbo,galaxy note 3),但在我的motorola xoom上存在问题,例如:
1)我的shaderProgram导致在其中绘制的舞台不被渲染
2)每次使用InputProcessor时触摸输入都不起作用(只有90%的时间感知)
这些是我目前注意到的问题。这可能是因为它是较旧的OS版本(4.1.2)吗?不是那么老了。用libgdx的ShaderProgram知道错误吗?即使这样,触摸输入也不会感知每次点击是非常奇怪的。感谢您的时间和帮助!我的shaderProgram的渲染代码都是正确的,因此无需显示。而对于touchInput,我只是使用InputProcessor中的touchDown方法。
编辑: shaderProgram产生的错误 “(22):错误C1101:模糊重载函数引用”smoothstep(mediump float,float,lowp float)“
顶点着色器
#version 100
attribute vec4 a_position;
attribute vec4 a_color;
attribute vec2 a_texCoord0;
uniform mat4 u_worldView;
uniform vec2 u_lightPos;
uniform vec3 u_lightColor;
uniform vec4 u_spaceColor;
varying vec4 v_color;
varying vec2 v_texCoords;
varying vec2 v_lightPos;
varying vec3 v_lightColor;
varying vec2 v_position;
varying vec4 v_spaceColor;
void main() {
v_color = a_color;
v_lightColor = u_lightColor;
v_lightPos = u_lightPos;
v_position.xy = a_position.xy;
v_texCoords = a_texCoord0;
gl_Position = u_worldView * a_position;
v_spaceColor = u_spaceColor;
}
片段着色器
#version 100
#ifdef GL_ES
precision lowp float;
#endif
varying vec4 v_color;
varying vec2 v_texCoords;
varying vec2 v_lightPos;
varying vec3 v_lightColor;
varying vec2 v_position;
varying vec4 v_spaceColor;
uniform sampler2D u_texture;
void main() {
for(int row = 0; row < 2; row++) {
for(int col = 0; col < 2; col++) {
float dist = distance(v_position, vec2(-1 + col, 1 - row));
float delta = 0.1;
float alpha = smoothstep(100.0-delta, 100.0, dist);
if(dist > 23.0){
gl_FragColor = mix(v_spaceColor, v_color, alpha);
}
else{
gl_FragColor = v_color * texture2D(u_texture, v_texCoords);
}
}
}
}