title: Install OpenGL ES and compile code for android
body: <p>I've just started learning OpenGL ES on android (using <a href="https://rads.stackoverflow.com/amzn/click/com/1430226471" rel="noreferrer" rel="nofollow noreferrer">this book</a>) and came across an issue of adopting <a href="http://apress.com/book/view/9781430226475" rel="noreferrer">source</a> code from chapter 5 to existing methods of using jni in android (actually, it also concerns simply running a native GL app). I'm trying to compile the native code to get the .so lib and use it further in .apk archive. But compilation is not possible if certain libs are not present (which are GLES/gl.h, EGL/egl.h, GLES/gl.h, GLES/glext.h). </p>
  
  <p>So the question is how do I install those libs (AFAIU, OpenGL ES and EGL installation) and compile the most trivial native code? (tutorials are highly admired).</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT: I've tried the <a href="https://github.com/richq/glbuffer" rel="noreferrer">glbuffer</a> example as was suggested (slightly changed .mk file), but still no success. Compiler gives me the same result as before: </p>
  
  <blockquote>
    <p>ndk-build</p>
    
    <p>Compile thumb: egl &lt;= cube.c</p>
    
    <p>/path/jni/cube.c:5:21: error: GLES/gl.h: No such file or directory // same message for glbuffer when gl.h is being included</p>
  </blockquote>
  
  <p>Here is the cube.c code:</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  #include &lt;GLES/gl.h&gt;
  
  #define FIXED_ONE 0x10000
  #define one 1.0f
  
  typedef unsigned char byte;
  
  extern void jni_printf(char *format, ...);
  
  // Cube static 
  GLfloat vertices[24] = {        -one, -one, -one,       one, -one,
  -one,       one,  one, -one,        -one,  one, -one,       -one, -one,  one,       one, -one,  one,        one,  one,  one,        -one,  one,  one, };
  
  static GLfloat colors[] = {         0,    0, 0,  one,       one,    0,    0,  one,      one,  one,    0,  one,      0,  one,    0&gt; ,  one,      0,    0,  one,  one,        one, 0,  one,  one,         one,  one,  one,  one,      0,  one,  one,  one, };
  
  static byte indices[] = {       0, 4, 5,   0, 5, 1,         1, 5, 6,    1, 6, 2,        2, 6, 7,    2, 7, 3,        3, 7, 4,    3, 4, 0,        4, 7, 6,    4, 6, 5,        3, 0, 1,   3, 1, 2 };
  
  
  void Cube_draw() {
  glFrontFace(GL_CW);
  glVertexPointer(3, GL_FLOAT, 0, vertices);
  glColorPointer(4, GL_FLOAT, 0 , colors);
  glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, indices); }
  </code></pre>
  
  <p>It's awfully trivial and not working, yet.</p>
  
  <p>Android.mk:</p>
  
  <pre><code>LOCAL_PATH := $(call my-dir)
  
  include $(CLEAR_VARS)
  
  LOCAL_LDLIBS := -lGLESv1_CM.so
  LOCAL_MODULE    := egl
  LOCAL_SRC_FILES := cube.c cuberenderer.c
  
  include $(BUILD_SHARED_LIBRARY)
  </code></pre>