daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Mar 18th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. uniform mat4 m;      
  2. uniform mat4 v;      
  3. uniform mat4 p;      
  4. attribute vec3 pos;    
  5. attribute vec2 normale;    
  6. void main()                    
  7. {                                
  8.      float linewidth = 4.0;                        
  9.      mat4 mv = v * m;                        
  10.      vec4 delta = vec4(linewidth * normale.x, linewidth * normale.y, 0.0,0.0);                        
  11.      vec4 pos2 = mv * vec4(pos.xy, 0.0, 1.0) ;                        
  12.    gl_Position = p * (pos2 + delta);  
  13. }
  14.      
  15. for (int i = 0, valuesLength = values.length; i < valuesLength; i++) {//todo do not allocate
  16.      float value = (float) values[i] / maxValue; // make it [0:1]
  17.      Vertex v1 = new Vertex();//todo rewrite without allocatinos
  18.      Vertex v2 = new Vertex();//todo rewrite without allocatinos
  19.      float x = i;
  20.      float y = value;
  21.      if (vertices.size() > 0) {
  22.          // copy normale vecotrs from prev vertices
  23.          Vertex t1 = new Vertex();
  24.          Vertex t2 = new Vertex();
  25.          t1.x = x;
  26.          t1.y = y;
  27.          t1.z = 1;
  28.          t1.normale_x = vertices.get(vertices.size() - 2).normale_x;
  29.          t1.normale_y = vertices.get(vertices.size() - 2).normale_y;
  30.          t2.x = x;
  31.          t2.y = y;
  32.          t2.z = -1;
  33.          t2.normale_x = vertices.get(vertices.size() - 1).normale_x;
  34.          t2.normale_y = vertices.get(vertices.size() - 1).normale_y;
  35.          vertices.add(t1);
  36.          vertices.add(t2);
  37.      }
  38.      v1.x = x ;
  39.      v1.y = y ;
  40.      v1.z = 1;
  41.  
  42.      v2.x = x;
  43.      v2.y = y;
  44.      v2.z = -1;
  45.  
  46.      vertices.add(v1);
  47.      vertices.add(v2);
  48.  
  49.  
  50.      if (i == valuesLength - 1) {
  51.          int j = i - 1;
  52.          //todo last vertex
  53.      } else {
  54.          double nextValue = (float) values[i + 1] / column.maxValue;
  55.          double dy = nextValue - value;
  56.          double l = (float) Math.sqrt(1f + dy * dy);
  57.          dy /= l;
  58.          double dx = 1f / l;
  59.  
  60.          v1.normale_x = (float) -dy * 10;
  61.          v1.normale_y = (float) dx;
  62.          v2.normale_x = (float) dy * 10;
  63.          v2.normale_y = (float) -dx;
  64.      }
  65. }
  66.      
  67. Matrix.orthoM(PROJ, 0, 0, w, 0, h, -1.0f, 1.0f);
  68.  
  69. Matrix.setIdentityM(MODEL, 0);
  70. Matrix.scaleM(MODEL, 0, mywpx/(float)maxXValue, myhpx , 1.0f);
  71.  
  72. Matrix.setIdentityM(VIEW, 0);
  73. Matrix.translateM(VIEW, 0, dxpx, dypx ,0);
  74.  
  75. GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, vertices.size());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top