title: Bitmap to texture
body: <p>I have to convert bitmap image to texture format. And need to display it . For this I have written a function to convert bit map to texture . But when running the code it shows a blank image without any crashes. Please help to identify </p>
  
  <p>In privew.java , I have created a bitmap object for an image (inside resource folder )in onCreate() function.</p>
  
  <pre><code>//Creating a sample image's resource id for testing in GlRenderer
      drawableResourceId = this.getResources().getIdentifier("flower", "drawable", this.getPackageName());
      System.out.println("FLOWER ID "+drawableResourceId);
      InputStream is =this.getResources().openRawResource(drawableResourceId);
      Bitmap tBitmap;
      tBitmap = BitmapFactory.decodeStream(is, null, sBitmapOptions);
      ThisAppGlobals.texture_bitmap=tBitmap;
  </code></pre>
  
  <p>And in GlRenderer.java (Renderer class for OpenGl) used a function named "loadGLTextureFromBitmap()" to create texture for corresponding bitmap object . 
  I'am called that function onSurfaceCreated() of openGl class .</p>
  
  <pre><code>  // setup texture //
         int mTextureID
         System.out.println("Calling loadGLTextureFromBitmap");
         mTextureID = loadGLTextureFromBitmap(ThisAppGlobals.texture_bitmap, gl );
         System.out.println("Called loadGLTextureFromBitmap"+  mTextureID);
  </code></pre>
  
  <p>And the function is ,</p>
  
  <pre><code>    private int loadGLTextureFromBitmap(Bitmap sideBysideImg, GL10 gl) {
      // TODO Auto-generated method stub
  
  
      // Generate one texture pointer
      int[] textureIds = new int[1];
      gl.glGenTextures( 1, textureIds, 0 );
  
      // bind this texture
      gl.glBindTexture( GLES20.GL_TEXTURE_2D, textureIds[0] );
  
      // Create Nearest Filtered Texture
      gl.glTexParameterf( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR );
      gl.glTexParameterf( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR );
  
      gl.glTexParameterf( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT );
      gl.glTexParameterf( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT );
  
      // Use the Android GLUtils to specify a two-dimensional texture image from our bitmap
      GLUtils.texImage2D( GLES20.GL_TEXTURE_2D, 0,sideBysideImg, 0 );
      return textureIds[0];
  
  
  }
  </code></pre>
  
  <p>And onSurfaceChanged() consists </p>
  
  <pre><code>GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureID);
         checkGlError("glBindTexture mTextureID");
  
         GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER,
                             GLES20.GL_NEAREST);
         GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER,
                             GLES20.GL_LINEAR);
  
         /*
          * Create the SurfaceTexture that will feed this textureID,
          * and pass it to the MediaPlayer
          */
         mSurface = new SurfaceTexture(mTextureID);
         mSurface.setOnFrameAvailableListener(this);
  
       Surface surface = new Surface(mSurface);
               surface.release();
  </code></pre>