title: Loading ETC1 Textures with alpha using Shader cocos2dx
body: <p>I am following this link:
  <a href="http://sbcgamesdev.blogspot.in/2013/06/etc1-textures-loading-and-alpha.html" rel="nofollow">http://sbcgamesdev.blogspot.in/2013/06/etc1-textures-loading-and-alpha.html</a></p>
  
  <p>I have two texture, SpinWheel-hd.pkm(rgb) and SpinWheel1-hd.pkm (alpha). I am trying to load an ETC1 texture with alpha.
  There resulting image comes white, where in according to the link, it should be my rgb texture with alpha. What am I doing wrong? I am using cocos2dx 2.2.5</p>
  
  <p>Here's my loading code:</p>
  
  <pre><code> rgbTex = CCTextureCache::sharedTextureCache()-&gt;addETCImage("SpinWheel-hd.pkm");
         MainScreen1 = CCSprite::create("SpinWheel-hd.pkm");
     CCSize size1 = CCDirector::sharedDirector()-&gt;getWinSize();
     MainScreen1-&gt;setPosition(ccp(size1.width/2+70, size1.height/2+70));
     this-&gt;addChild(MainScreen1);
     alphaTex = CCTextureCache::sharedTextureCache()-&gt;addETCImage("SpinWheel1-hd.pkm");
  
     alphaTex-&gt;setAliasTexParameters();
  
       CCGLProgram *shader = CCShaderCache::sharedShaderCache()-&gt;programForKey("monochromeShader");
      shader-&gt;reset();
      /    // Same code as before to initialize the shader
      shader-&gt;initWithVertexShaderByteArray(cc_MonoChromeV, cc_MonoChrome);
  
  MainScreen1-&gt;setShaderProgram(shader);
  
  MainScreen1-&gt;getShaderProgram()-&gt;addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
  MainScreen1-&gt;getShaderProgram()-&gt;addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
  
  MainScreen1-&gt;getShaderProgram()-&gt;link();
  
  MainScreen1-&gt;getShaderProgram()-&gt;updateUniforms();
  
  
  _maskLocation = glGetUniformLocation( MainScreen1-&gt;getShaderProgram()-&gt;getProgram(),"u_colorRampTexture");
  glUniform1i(_maskLocation,1);
  
  _textureLocation = glGetUniformLocation( MainScreen1-&gt;getShaderProgram()-&gt;getProgram(),"u_texture");
  glUniform1i(_textureLocation, 0);
  
  
  MainScreen1-&gt;getShaderProgram()-&gt;use();
  
  
  glActiveTexture(GL_TEXTURE0);
  glBindTexture(GL_TEXTURE_2D, rgbTex-&gt;getName());
  glActiveTexture(GL_TEXTURE1);
  glBindTexture(GL_TEXTURE_2D,alphaTex-&gt;getName());
  glActiveTexture(GL_TEXTURE0);
  </code></pre>
  
  <p>Here is my fragment shader</p>
  
  <pre><code> "\n\
    #ifdef GL_ES \n\
    precision mediump float;\n\
     #endif\n\
    uniform sampler2D u_texture;\n\
    uniform sampler2D u_colorRampTexture;\n\
    varying mediump vec2 v_texture;\n\
    void main(void)\n\
    {\n\
         gl_FragColor = vec4(texture2D(u_texture, v_texture).rgb, texture2D(u_colorRampTexture, v_texture).r);\n\
    }\n\
  ";
  </code></pre>
  
  <p>Here's my vertex shader:</p>
  
  <pre><code> "\n\
      attribute vec4 a_position;                                \n\
      attribute mediump vec2 a_texture;\n\
      \n\
      #ifdef GL_ES\n\
     varying mediump vec2 v_texture;\n\
     #else                                                    \n\
     varying vec2 v_texture;                                \n\
    #endif                                                    \n\
    \n\
    void main(void)\n\
    {\n\
         gl_Position = CC_MVPMatrix * a_position;\n\
  v_texture = a_texture;\n\
    }\n\
    ";
  </code></pre>
  
  <p>Where am I going wrong? All I see is a pure white image.</p>