title: Possible to set an initial value for a shader uniform? (Android, OpenGL ES 2.0)
body: <p><strong>edit</strong>: As suggested, I'm trying to set an 'initial' value to my shaders uniform in my constructor, I have included some code and would be grateful if someone could explain why I get a blank screen if I pass the values in via my constructor - thanks</p>
  
  <p><strong>Method to load my texture</strong></p>
  
  <pre><code>public void setTexture(GLSurfaceView view, Bitmap imgTexture) {
      this.imgTexture=imgTexture;
      iProgId = Utils.LoadProgram(strVShader, strFShader);
      iBaseMap = GLES20.glGetUniformLocation(iProgId, "u_baseMap");
      iPosition = GLES20.glGetAttribLocation(iProgId, "a_position");
      iTexCoords = GLES20.glGetAttribLocation(iProgId, "a_texCoords");
      texID = Utils.LoadTexture(view, imgTexture);
  
      //Everything is working if I include the lines as part of my setTexture() method
      GLES20.glUseProgram(iProgId);
      mOpacityHandle = GLES20.glGetUniformLocation(iProgId, "opValue");
      GLES20.glUniform1f(mOpacityHandle, 1.0f);
  }
  </code></pre>
  
  <p>but if I place them in my constructor, nothing....</p>
  
  <pre><code>public Quad() {
      //iProgId = Utils.LoadProgram(strVShader, strFShader); //I've tried with and without this line - I can confirm that loading / linking is working OK
      GLES20.glUseProgram(iProgId);
      mOpacityHandle = GLES20.glGetUniformLocation(iProgId, "opValue");          
      GLES20.glUniform1f(mOpacityHandle, 1.0f);           
  }
  </code></pre>
  
  <p>I've actually copied my entire texture load routine into my constructor and passed it the relevant parameters when creating my quads but I still nothing unless I set the value sometime after the constructor has run!</p>
  
  <p>I have a fragment shader as below:</p>
  
  <pre><code>String strFShader =
      "precision mediump float;" +
      "uniform float opValue;"+
      "varying vec2 v_texCoords;" +
      "uniform sampler2D u_baseMap;" +
      "void main()" +
      "{" +
      "gl_FragColor = texture2D(u_baseMap, v_texCoords);" +
      "gl_FragColor *= opValue;"+
      "}";
  </code></pre>
  
  <p>And when I create my objects (quads) I have a method where I can set the opacity of the said quad like so:</p>
  
  <pre><code>public void setOpacity(float op) {  
      GLES20.glUseProgram(iProgId);       
      mOpacityHandle = GLES20.glGetUniformLocation(iProgId, "opValue");
      GLES20.glUniform1f(mOpacityHandle, op);
  }
  </code></pre>
  
  <p>However, I only want to have to run my setOpacity method if I want my sprite(quad) to have some level of transparency.  If I don't specify an opacity level (i.e. if I don't run the setOpacity method) I would like it to use a default or 'initial' value (which obviously I would like to be a float of 1.0).</p>
  
  <p>Is this at all possible?</p>