Exemplo n.º 1
0
 @Override
 public void prepare(int color, float alpha, int fbufWidth, int fbufHeight) {
   ctx.checkGLError("colorShader.prepare start");
   boolean wasntAlreadyActive = super.prepare(fbufWidth, fbufHeight);
   if (wasntAlreadyActive || color != lastColor || alpha != lastAlpha) {
     flush();
     glUniform1f(uAlpha, alpha);
     lastAlpha = alpha;
     float a = (float) ((color >> 24) & 0xff) / 255;
     float r = (float) ((color >> 16) & 0xff) / 255;
     float g = (float) ((color >> 8) & 0xff) / 255;
     float b = (float) ((color >> 0) & 0xff) / 255;
     glUniform4f(uColor, r, g, b, a);
     lastColor = color;
     ctx.checkGLError("colorShader.prepare end");
   }
 }
Exemplo n.º 2
0
    @Override
    public void prepare(Object texObj, float alpha, int fbufWidth, int fbufHeight) {
      ctx.checkGLError("textureShader.prepare start");
      boolean wasntAlreadyActive = super.prepare(fbufWidth, fbufHeight);
      if (wasntAlreadyActive) {
        glActiveTexture(GL_TEXTURE0);
        glUniform1i(uTexture, 0);
      }

      int tex = (Integer) texObj;
      if (wasntAlreadyActive || tex != lastTex || alpha != lastAlpha) {
        flush();
        glUniform1f(uAlpha, alpha);
        lastAlpha = alpha;
        lastTex = tex;
        ctx.checkGLError("textureShader.prepare end");
      }
    }