title: Android OpenGL glTexImage2D not drawing
body: <p>I'm trying to display image on opengl texture using ndk.
  I have an image structure:</p>
  
  <pre><code>struct image {
  png_uint_32 imWidth, imHeight; //real size
  png_uint_32 glWidth, glHeight; //size for OpenGL
  int bit_depth, color_type;
  char* data; //data RGB/RGBA
  };
  </code></pre>
  
  <p>I'm read image:</p>
  
  <pre><code>image imJpeg = readJpeg("/data/data/com.lodoss.app/app_imageDir/0.jpg");
  </code></pre>
  
  <p>readJpeg implementation:</p>
  
  <pre><code>static int reNpot(int w) {
      bool NON_POWER_OF_TWO_SUPPORTED = false;
      if (NON_POWER_OF_TWO_SUPPORTED) {
          if (w % 2) w++;
      } else {
          if (w &lt;= 4) w = 4;
          else if (w &lt;= 8) w = 8;
          else if (w &lt;= 16) w = 16;
          else if (w &lt;= 32) w = 32;
          else if (w &lt;= 64) w = 64;
          else if (w &lt;= 128) w = 128;
          else if (w &lt;= 256) w = 256;
          else if (w &lt;= 512) w = 512;
          else if (w &lt;= 1024) w = 1024;
          else if (w &lt;= 2048) w = 2048;
          else if (w &lt;= 4096) w = 4096;
      }
      return w;
  }
  
  //read JPEG from file
  static image readJpeg(const char* fileName) {
      image im;
      FILE* file = fopen(fileName, "rb");
  
      struct jpeg_decompress_struct cinfo;
      struct my_error_mgr jerr;
  
      cinfo.err = jpeg_std_error(&amp;jerr.pub);
      jerr.pub.error_exit = my_error_exit;
      if (setjmp(jerr.setjmp_buffer)) {
          jpeg_destroy_decompress(&amp;cinfo);
          return im;
      }
  
      jpeg_create_decompress(&amp;cinfo);
      jpeg_stdio_src(&amp;cinfo, file);
  
      //получаем данные о картинке
      jpeg_read_header(&amp;cinfo, TRUE);
      jpeg_start_decompress(&amp;cinfo);
  
      im.imWidth = cinfo.image_width;
      im.imHeight = cinfo.image_height;
      im.glWidth = reNpot(im.imWidth);
      im.glHeight = reNpot(im.imHeight);
  
      //JPEG не имеет прозрачности так что картинка всегда 3х-байтная (RGB)
      int row = im.glWidth * 3;
      im.data = new char[row * im.glHeight];
  
      //построчно читаем данные
      unsigned char* line = (unsigned char*) (im.data);
      while (cinfo.output_scanline &lt; cinfo.output_height) {
          jpeg_read_scanlines(&amp;cinfo, &amp;line, 1);
          line += row;
      }
  
      //подчищаем
      jpeg_finish_decompress(&amp;cinfo);
      jpeg_destroy_decompress(&amp;cinfo);
  
      return im;
  }
  </code></pre>
  
  <p>I get implementation of this function <a href="http://habrahabr.ru/post/173303/" rel="nofollow">here</a>(Sorry, but only in russian)</p>
  
  <p>And then display it:</p>
  
  <pre><code>    GLuint texture2;
      glGenTextures(1, &amp;texture2);
      glBindTexture(GL_TEXTURE_2D, texture2);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, engine-&gt;state.im.imWidth, engine-&gt;state.im.imHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, engine-&gt;state.im.data);
  </code></pre>
  
  <p><strong>engine</strong> points to my image</p>
  
  <p>But nothing happens. No errors and no displaing image. Only black screen
  Why it may happen?</p>