title: OpenGL ES drawing issues in Android NDK
body: <p>Due to performance issues, I have had to transfer my android opengl code from Java to C.  I believe I transfered all of the OpenGL code, but I now have many errors with the section of my code that draws a bitmap as a texture to the screen.</p>
  
  <p>When I run the project in an emulator, the current code does not display anything and appears to have a memory leak because it slowly takes up all the memory and forces other apps to close.</p>
  
  <p>Here is the code that controls this part:</p>
  
  <p>In the header file:</p>
  
  <pre><code>extern unsigned char colors[1024*512*3];   // 3 bytes per pixel
  </code></pre>
  
  <p>In the c file:</p>
  
  <pre><code>void appRender(int width, int height, unsigned char colors)
  {
      unsigned int textureID;
      float vertices[] = 
      {
          0.0f, 0.0f,
          512.0f, 0.0f,
          0.0f, 1024.0f,
          512.0f, 1024.0f
      };
  
      float texture[] =
      {
          0.0f, 0.0f,
         1.0f, 0.0f,
         0.0f, 1.0f,
         1.0f, 1.0f
      };
  
      unsigned char indices[] = 
      {
         0, 1, 3,
         0, 3, 2
      };
  
      UpdateView();
  
  
      //onDraw 
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glOrthof(0.0f, 320.0f, 430.0f, 0.0f, 1.0f, -1.0f);
  
      //texture stuff
      glGenTextures(1,&amp;textureID);
      glBindTexture(GL_TEXTURE_2D, textureID);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  
      //Different possible texture parameters, e.g
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  
      glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 512, 1024, 0, GL_RGB ,GL_UNSIGNED_BYTE, colors);
  
      glEnableClientState(GL_VERTEX_ARRAY);
      glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  
      glVertexPointer(2, GL_FLOAT, 0, vertices);
      glTexCoordPointer(2, GL_FLOAT, 0, texture);
  
      glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices);
  
      glDisableClientState(GL_VERTEX_ARRAY);
      glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  }
  </code></pre>
  
  <p>Any help would be greatly appreciated. </p>