use fallback when std_derivative shaders failed to compile
This commit is contained in:
parent
77721db328
commit
ae951dc4bd
@ -52,7 +52,7 @@ public final class LineRenderer {
|
||||
lineFragmentShader);
|
||||
if (lineProgram[0] == 0) {
|
||||
Log.e(TAG, "Could not create line program.");
|
||||
return false;
|
||||
//return false;
|
||||
}
|
||||
|
||||
lineProgram[1] = GlUtils.createProgram(lineVertexShader,
|
||||
@ -63,6 +63,9 @@ public final class LineRenderer {
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (lineProgram[i] == 0)
|
||||
continue;
|
||||
|
||||
hLineMatrix[i] = GL.glGetUniformLocation(lineProgram[i], "u_mvp");
|
||||
hLineScale[i] = GL.glGetUniformLocation(lineProgram[i], "u_wscale");
|
||||
hLineWidth[i] = GL.glGetUniformLocation(lineProgram[i], "u_width");
|
||||
@ -90,7 +93,6 @@ public final class LineRenderer {
|
||||
GL20.GL_NEAREST, GL20.GL_NEAREST,
|
||||
GL20.GL_MIRRORED_REPEAT, GL20.GL_MIRRORED_REPEAT);
|
||||
|
||||
Log.d(TAG, "Line Texture >>>>>>>>> " + mTexID);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -112,6 +114,10 @@ public final class LineRenderer {
|
||||
|
||||
GLState.blend(true);
|
||||
|
||||
// FIXME HACK: fallback to simple shader
|
||||
if (lineProgram[mode] == 0)
|
||||
mode = 1;
|
||||
|
||||
GLState.useProgram(lineProgram[mode]);
|
||||
|
||||
int uLineScale = hLineScale[mode];
|
||||
@ -291,7 +297,11 @@ public final class LineRenderer {
|
||||
// where wscale is 'filter width' / 'line width' and 0 <= len <= sqrt(2)
|
||||
//+ " gl_FragColor = u_color * smoothstep(0.0, u_wscale, 1.0 - len);"
|
||||
//+ " gl_FragColor = mix(vec4(1.0,0.0,0.0,1.0), u_color, smoothstep(0.0, u_wscale, 1.0 - len));"
|
||||
+ " gl_FragColor = u_color * min(1.0, (1.0 - len) / u_wscale);"
|
||||
+ " float alpha = min(1.0, (1.0 - len) / u_wscale);"
|
||||
+ " if (alpha > 0.2)"
|
||||
+ " gl_FragColor = u_color * alpha;"
|
||||
+ " else"
|
||||
+ " discard;"
|
||||
+ "}";
|
||||
|
||||
private final static String lineFragmentShader = ""
|
||||
|
||||
@ -107,6 +107,10 @@ public class LineTexRenderer {
|
||||
public static Layer draw(Layers layers, Layer curLayer,
|
||||
MapPosition pos, Matrices m, float div) {
|
||||
|
||||
// shader failed to compile
|
||||
if (shader == 0)
|
||||
return curLayer.next;
|
||||
|
||||
GLState.blend(true);
|
||||
GLState.useProgram(shader);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user