title: Render video frame via openGLES2 with Android NDK
body: <p>I made a bin code with NDK to get video frames by ffmpeg decoding, and rendered to opengles, but the screen had nothing changed, it still displayed the launcher. </p>
  
  <p>*<strong><em>But</strong>  when i made a apk tolaunch，it always show black。</em>*</p>
  
  <p>my opengles2.0 ini code is below：</p>
  
  <pre><code>static int window_init_display(void)
  {
      EGLint attribs [] = {
        EGL_RED_SIZE,        8,
        EGL_GREEN_SIZE,      8,
        EGL_BLUE_SIZE,       8,
        EGL_ALPHA_SIZE,      8,
        EGL_DEPTH_SIZE,     16,
        EGL_STENCIL_SIZE,    0,
        EGL_SAMPLE_BUFFERS,  0,
        EGL_SAMPLES,         0,
        EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
        EGL_NONE
      };
  
      EGLint w, h, format;
      EGLint numConfigs;
      EGLConfig config;
      EGLSurface surface;
      EGLContext context;
  
      EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
  
      eglInitialize(display, 0, 0);
  
      eglChooseConfig(display, attribs, &amp;config, 1, &amp;numConfigs);
  
      eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &amp;format);
  
      ANativeWindow_setBuffersGeometry(g_application-&gt;window, 0, 0, format);
  
      surface = eglCreateWindowSurface(display, config, g_application-&gt;window, NULL);
  
      eglQuerySurface(display, surface, EGL_WIDTH, &amp;w);    
      eglQuerySurface(display, surface, EGL_HEIGHT, &amp;h);
      LOGI("EGL_WIDTH=%d, EGL_HEIGHT=%d",w,h);
  
      eglBindAPI(EGL_OPENGL_ES_API);
  
      EGLint contextAttrs[] =
      {
         EGL_CONTEXT_CLIENT_VERSION, 2,
         EGL_NONE
      };
      context = eglCreateContext(display, config, NULL, contextAttrs);
  
      if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) 
      {         
              LOGW("Unable to eglMakeCurrent");      
              return -1;   
  }
  
      LOGI("OK init EGL !!!!");
  </code></pre>
  
  <p>}</p>
  
  <p>My render code is below:</p>
  
  <pre><code>int m_rgbBufferSize = pPicture-&gt;iDisplayWidth*pPicture-&gt;iDisplayHeight*4;
  m_rgbBuffer = new unsigned char[m_rgbBufferSize];
  
  struct SwsContext *m_sw_context=NULL;
  m_sw_context = m_dllSwScale.sws_getCachedContext(m_sw_context,
                                                    pPicture-&gt;iWidth, pPicture-&gt;iHeight, PIX_FMT_YUV420P,
                                                    pPicture-&gt;iWidth, pPicture-&gt;iHeight, PIX_FMT_RGBA,
                                                    SWS_FAST_BILINEAR, NULL, NULL, NULL);
  
  uint8_t *psrc[] = { pPicture-&gt;data[0], pPicture-&gt;data[1], pPicture-&gt;data[2], 0 };
  int srcStride[] = { pPicture-&gt;iLineSize[0], pPicture-&gt;iLineSize[1], pPicture-&gt;iLineSize[2], 0 };
  uint8_t *dst[]  = { m_rgbBuffer, 0, 0, 0 };
  int dstStride[] = { pPicture-&gt;iDisplayWidth*4, 0, 0, 0 };
  m_dllSwScale.sws_scale(m_sw_context, psrc, srcStride, 0, pPicture-&gt;iDisplayHeight, dst, dstStride);
  //LOGV("swscale OK");
  glEnable(GL_TEXTURE_2D);
  glPixelStorei(GL_UNPACK_ALIGNMENT,1);
  if(textureid == 0)
      glGenTextures(1, &amp;textureid);
  glActiveTexture(GL_TEXTURE2);
  glBindTexture(GL_TEXTURE_2D, textureid);
  glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 
                  pPicture-&gt;iDisplayWidth, pPicture-&gt;iDisplayHeight, GL_RGBA, GL_UNSIGNED_BYTE, m_rgbBuffer);
  </code></pre>
  
  <p>Why does nothing display? Should I use abk not bin file to run?</p>