title: Why does glGenTextures returns zero on OpenGL context Thread (Android)?
body: <p>I'm having a problem where GLES20.glGenTextures() is returning zero for the texture name, even when run on the original thread (which is the OpenGL context thread).</p>
  
  <p>When I run the code </p>
  
  <pre><code>final Handler handlerForOriginalThread = new Handler(activity.getMainLooper());
  
  final int[] textureHandleA = new int[1];
  GLES20.glGenTextures(1, textureHandleA, 0);
  Log.v(TAG, "textureHandle (A): " + textureHandleA[0]);
  
  new Thread(new Runnable() 
  {
      public void run() 
      {
          //[Prepare bitmap here]
  
          handlerForOriginalThread.post(new Runnable() 
          {
              public void run() 
              {
                  final int[] textureHandle = new int[1];
                  GLES20.glGenTextures(1, textureHandle, 0);
                  Log.v(TAG, "textureHandle (B): " + textureHandle[0]);
  
                  //[Load bitmap to texture here]
              }
          });
      }
  }).start();
  </code></pre>
  
  <p>glGenTextures returns a valid name for (A) and zero for (B).  </p>
  
  <p>Why is this occurring?</p>
  
  <p>This is similar to <a href="https://stackoverflow.com/questions/3467935/glgentextures-returns-zero-in-background-thread">glGenTextures returns zero in background thread</a> , but in this case the code is actually running on the OpenGL context thread.  </p>