title: android opengles displaying image into texture
body: <p>i have rendered an image of size 480 * 800 into openGL Texture using below code, which rendered the image nicely in Samsung S3, which is of 720*1280 resolution in portrait mode.</p>
  
  <pre><code>//initialization
  glEnable(GL_TEXTURE_2D);
  glGenTextures(1, &amp;s_texture);
  glBindTexture(GL_TEXTURE_2D, s_texture);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
  glShadeModel(GL_FLAT);
  check_gl_error("glShadeModel");
  
  glColor4x(0x10000, 0x10000, 0x10000, 0x10000);
  check_gl_error("glColor4x");
  glTexImage2D(GL_TEXTURE_2D, /* target*/
      0, /* level*/
      GL_RGBA, /* internal format*/
      480, /* width*/
      800, /* height*/
      0, /* border*/
      GL_RGBA, /* format*/
      GL_UNSIGNED_BYTE,/* type*/ //can it be GL_UNSIGNED_SHORT_5_6_5??
      0); /*source pixels*/ 
      check_gl_error("glTexImage2D");
  
  //rendering loop
  glClear(GL_COLOR_BUFFER_BIT);
  glTexParameterf(GL_TEXTURE_2D,
                         GL_TEXTURE_WRAP_S,
                         GL_REPEAT);
      check_gl_error("glTexParameterf:GL_TEXTURE_WRAP_S ");
      glTexParameterf(GL_TEXTURE_2D,
                         GL_TEXTURE_WRAP_T,
                         GL_REPEAT);
      check_gl_error("glTexParameterf:GL_TEXTURE_WRAP_T");
  int rect[4] = { 0, 800, 480, -800 };
      glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, rect);
  glTexSubImage2D(GL_TEXTURE_2D, 0,0, 0, 480, 800, GL_RGBA, GL_UNSIGNED_BYTE, s_pixels);
  check_gl_error("glTexSubImage2D");
  
  
  glDrawTexiOES(0, 0, 0, screen_width, screen_height); //draw into full available window
  </code></pre>
  
  <p>Now i changed source image to size 720 * 1280 , Also the rendering target which is of 720*1360 resolution and is a tablet.</p>
  
  <p>Now changing the above code like below doesn't seem to be working as it worked on a portrait mode device(above case). The image is not fully displayed and the partial image is repeated many times.</p>
  
  <pre><code>//initialization
  glEnable(GL_TEXTURE_2D);
  glGenTextures(1, &amp;s_texture);
  glBindTexture(GL_TEXTURE_2D, s_texture);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
  glShadeModel(GL_FLAT);
  check_gl_error("glShadeModel");
  
  glColor4x(0x10000, 0x10000, 0x10000, 0x10000);
  check_gl_error("glColor4x");
  glTexImage2D(GL_TEXTURE_2D, /* target*/
      0, /* level*/
      GL_RGBA, /* internal format*/
      720, /* width*/
      1280, /* height*/
      0, /* border*/
      GL_RGBA, /* format*/
      GL_UNSIGNED_BYTE,/* type*/ //can it be GL_UNSIGNED_SHORT_5_6_5??
      /*s_pixels*/0); /*source pixels*/ 
      check_gl_error("glTexImage2D");
  
  //rendering loop
  glClear(GL_COLOR_BUFFER_BIT);
  glTexParameterf(GL_TEXTURE_2D,
                         GL_TEXTURE_WRAP_S,
                         GL_REPEAT);
      check_gl_error("glTexParameterf:GL_TEXTURE_WRAP_S ");
      glTexParameterf(GL_TEXTURE_2D,
                         GL_TEXTURE_WRAP_T,
                         GL_REPEAT);
      check_gl_error("glTexParameterf:GL_TEXTURE_WRAP_T");
  int rect[4] = { 0, 720, 1280, -720};
      glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, rect);
  glTexSubImage2D(GL_TEXTURE_2D, 0,0, 0, 720, 1280, GL_RGBA, GL_UNSIGNED_BYTE, s_pixels);
  check_gl_error("glTexSubImage2D");
  
  
  glDrawTexiOES(0, 0, 0, screen_width, screen_height); //draw into full available window
  </code></pre>
  
  <hr>
  
  <p>1 .Can someone explain me where i do mistake ? </p>
  
  <p>2 .Can someone explain me how to deal with rendering various resolution images in various dimension displays, cos all examples i saw showed that using <code>glDrawTexiOES(0, 0, 0, screen_width, screen_height);</code> will do it correctly, but it's not the case.</p>
  
  <p>3 .If i remove <code>int rect[4] = { 0, 720, 1280, -720};
          glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, rect);</code> i dont' see anything on screen, that's why i am using it, but i really know not the purpose of it and how to use it, can anyone tell me it's purpose and proper usage?</p>