title: Loading a texture from assets folder for OpenGL
body: <p>I know there are many questions relating to this question, but few appear to be for openGL.  </p>
  
  <p>I'm trying to load some PNG files from the assets folder into a Bitmap, but for some reason the returned Bitmap is null which in turn throws a NullPointerException here:</p>
  
  <pre><code>GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
  </code></pre>
  
  <p>The code I am using to load the image from the assets folder:</p>
  
  <pre><code>public static Bitmap getBitmapFromAsset(AssetManager mgr, String path)
  {
      InputStream is = null;
      Bitmap bitmap = null;
      try {
          is = mgr.open(path);
          BitmapFactory.Options options = new BitmapFactory.Options();
          options.inScaled = false;
          bitmap = BitmapFactory.decodeStream(is, null, options);
      }
      catch (final IOException e)
      {
          bitmap = null;
          Log.e(TAG, "FAILED TO get getBitmapFromAsset: " + e.getMessage());
      }
      finally
      {
         if (is != null)
         {
              try 
              {
                   is.close();
              } 
              catch (IOException ignored) 
              {
              }
          }
      }
  
      return bitmap;
  }
  </code></pre>
  
  <p>I've tried it a few different ways, e.g without the BitmapFactory.Options, but no matter what I am getting the NullPointerException, so I'm guessing there's another procedure I should be doing.</p>
  
  <p>P.S.  I can load them from the res/raw folder, but I can't have subdirectories to organise my assets.</p>