title: problem in rendering triangles in Opengl-es 2.0
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6501458/problem-when-going-from-opengl-1-1-to-opengl-es-2-0">Problem when going from opengl 1.1 to Opengl-es 2.0</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to render an isosurface by drawing triangles which takes its data from a text file and render it using opengl-es 2.0 . I was able to do it in Opengl 1.1 but because in opengl-es 2.0 some functions are not present so I am getting difficulty in  buffer or may be some other problem I am actually not able to understand . I am pasting my both draw triangle code opengl and opengl-es 2.0 . Can you tell me why is am not able to get the same result . i am doing coding in ubuntu 10.10 with the use of pvrsdk.</p>
  
  <p>OpenGL-ES 2.0 code :</p>
  
  <pre><code>    for (surfnum=0;surfnum&lt;surftotal;surfnum++)
      {
          glClearColor(0.6f, 0.8f, 1.0f, 1.0f);
          for (i=0;i&lt;triNum[surfnum];i++)
          {
              GLfloat *Vertices[] = {    
                              triArray[surfnum][i].pt1, 
                              triArray[surfnum][i].pt2,
                              triArray[surfnum][i].pt3
                          };
  
  
              glGenBuffers(1, &amp;ui32Vbo);
              glBindBuffer(GL_ARRAY_BUFFER, ui32Vbo);
              unsigned int uiSize = 3 * (sizeof(GLfloat) * 3); 
              glBufferData(GL_ARRAY_BUFFER, uiSize,*Vertices, GL_DYNAMIC_DRAW);
  
          }
  
          for(int i = 0; i &lt; 8000; ++i)
          {
              glClear(GL_COLOR_BUFFER_BIT);
              int i32Location = glGetUniformLocation(uiProgramObject, "projmatrix");
              glUniformMatrix4fv( i32Location, 1, GL_FALSE, projmatrix);
              glEnableVertexAttribArray(VERTEX_ARRAY);
              glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, 0);
              //glDrawElements(GL_TRIANGLE_FAN, triNum[surfnum], GL_UNSIGNED_BYTE,Vertices);
              glDrawArrays(GL_TRIANGLES,0,triNum[surfnum]);
              eglSwapBuffers(eglDisplay, eglSurface);
          }
      }
  </code></pre>
  
  <p>same thing I have done it in OpenGL :
  OpenGL code :</p>
  
  <pre><code>for (surfnum=0;surfnum&lt;surftotal;surfnum++)
  {
      for (i=0;i&lt;triNum[surfnum];i++)
      {
          glBegin(GL_TRIANGLES);
          glVertex3fv(triArray[surfnum][i].pt1);
          glVertex3fv(triArray[surfnum][i].pt2);
          glVertex3fv(triArray[surfnum][i].pt3);
          glEnd();
          glFlush();
          glutSwapBuffers();
      }
  }
  </code></pre>
  
  <p>surfnum , vertex_array , surftotal are defined variables.
  Also i am getting a result but not the same for both and I am also getting a warnig :
  libegl : software fallback </p>
  
  <p>P.S = here if I try to get first all the vertices and then try to bind it in a single buffer then it gives segmentation fault . May be I am doing that wrong . If thats a correct way you can tell me to how to do that .
  If you want any other information tell me.</p>
  
  <p>HI christian as you said that I can do this without using glmapbuffer I try to do that but it still gives me error:</p>
  
  <pre><code>glGenBuffers(surftotal, uiVBO);
  {
      for(surfnum=0; surfnum&lt;surftotal; ++surfnum)
      {
              glBindBuffer(GL_ARRAY_BUFFER, uiVBO[surfnum]);
              size_t buf_size = 9*sizeof(GLfloat)*triNum[surfnum];
              GLfloat* const pData = (GLfloat*)malloc(buf_size);
              for(i=0; i&lt;triNum[surfnum]; ++i) {
                  memcpy(pData+i*9,   triArray[surfnum][i].pt1, 3*sizeof(GLfloat));
                  memcpy(pData+i*9+3, triArray[surfnum][i].pt2, 3*sizeof(GLfloat));
                  memcpy(pData+i*9+6, triArray[surfnum][i].pt3, 3*sizeof(GLfloat));
              }
              glBufferData(GL_ARRAY_BUFFER, buf_size, pData, GL_STATIC_DRAW);
              free(pData);
      }   
      glBindBuffer(GL_ARRAY_BUFFER, 0);
      glEnableVertexAttribArray(VERTEX_ARRAY);
      for(surfnum=0; surfnum&lt;surftotal; ++surfnum)
      {
              glBindBuffer(GL_ARRAY_BUFFER, uiVBO[surfnum]);
              glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, 0);
              glDrawArrays(GL_TRIANGLES, 0, 3*triNum[surfnum]);
      }
      glBindBuffer(GL_ARRAY_BUFFER, 0);        //clean up, of course      
  
  }
  </code></pre>
  
  <p>thats the error I am getting while compiling the above program</p>
  
  <blockquote>
    <p>libEGL warning: use software fallback</p>
  </blockquote>