android : Error on Shading Language with opengl es2.0 on android 2.2 -


i have problem application. simple application atm using opengl es2.0 running on android 2.2 device htc sense. can running application on 4.0.3 emulator device running android 4.0.

when running on android 2.2, have error:

> fatal exception: glthread 9 java.lang.runtimeexception: error compiling shader:  simpleshader.loadshader(simpleshader.java:87) simpleshader.<init>(simpleshader.java:54) etc 

i assumed device can run android 2.2 document told links documentation, not sure shader part though.

here shader code:

string verticesshader =         "uniform mat4 uscreen;\n" +             "attribute vec2 aposition;\n" +         "attribute vec3 acolor;\n" +         "attribute vec2 atexpos; \n" +         "varying vec2 vtexpos; \n" +          "varying vec3 vcolor;\n" +         "void main() {\n" +         " vtexpos = atexpos; \n" +           " gl_position = uscreen * vec4(aposition.xy, 0.0, 1.0);\n" +         "  vcolor = acolor;\n" +         "}";        // our fragment shader. return vcolor.       // if @ source , said 'wtf?', remember       // attributes defined in vertex shader ,       // 'varying' vars considered output of vertex shader       // , input of fragment shader. here use color       // received , add alpha value of 1.       string fragmentshader =         "uniform float uusetexture; \n" +         "uniform float ualpha; \n" +         "uniform sampler2d utexture;\n" +         "precision mediump float;\n"+         "varying vec2 vtexpos; \n" +         "varying vec3 vcolor;\n" +          "void main(void)\n" +         "{\n" +          " if ( uusetexture != 1.0 ) \n" +         "  gl_fragcolor = vec4(vcolor.xyz, 1); \n" +         " else \n" +         "  gl_fragcolor = texture2d(utexture, vtexpos); \n" +         " gl_fragcolor.a *= ualpha;" +         //"  gl_fragcolor = vec4(vcolor.xyz, 1);\n" +         "}";  private int loadshader(int shader, string shadersrc) {     // todo auto-generated method stub     int handle = gles20.glcreateshader(shader);      if (handle == gles20.gl_false)         throw new runtimeexception("error creating shader!");      gles20.glshadersource(handle, shadersrc);     gles20.glcompileshader(handle);      int[] compilestatus = new int[1];     gles20.glgetshaderiv(handle, gles20.gl_compile_status, compilestatus, 0);      if (compilestatus[0] ==0)       {         string error = gles20.glgetshaderinfolog(handle);         gles20.gldeleteshader(handle);         throw new runtimeexception("error compiling shader: " + error);       }       else         return handle;  } 

the application works fine on latest device android 4.0+

have considered checking opengl es glsl version on both android 2.2 device , android 4.0+ device? can print gles20.glgetstring(gles20.gl_shading_language_version).


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -