Rewrite this code for Opengl ES 1.0

Hi!

Could someone please help me rewrite this lines of code for OpenGL ES 1.0.
The problem with these lines of code is that OpenGL ES 1.0 does not support glTexCoord3f and glVertex3f, glBegin and glEnd.

What you can use is glVertexPointer and glTexPointer and glDrawElements.
Unfortunately I can’t figure out how to make them work.

I haven’t managed to get it working properly so please help.

Here is the code.

 glBegin(GL_TRIANGLES);
  currPtr = tDispObj->group[i].objTngls;
  while (currPtr != NULL)
  {
     if (!currPtr->NormType)
        glNormal3f(currPtr->faceNorm.x, currPtr->faceNorm.y, currPtr->faceNorm.z);
     else
        glNormal3f(tDispObj->objNorms[currPtr->n1].x, tDispObj->objNorms[currPtr->n1].y, tDispObj->objNorms[currPtr->n1].z);
     if (currPtr->t1 > 0)
        glTexCoord3f(tDispObj->objTexts[currPtr->t1].u, tDispObj->objTexts[currPtr->t1].v, tDispObj->objTexts[currPtr->t1].w);
     glVertex3f(tDispObj->objVerts[currPtr->v1].x, tDispObj->objVerts[currPtr->v1].y, tDispObj->objVerts[currPtr->v1].z);

     if (currPtr->NormType)
        glNormal3f(tDispObj->objNorms[currPtr->n2].x, tDispObj->objNorms[currPtr->n2].y, tDispObj->objNorms[currPtr->n2].z);
     if (currPtr->t2 > 0)
        glTexCoord3f(tDispObj->objTexts[currPtr->t2].u, tDispObj->objTexts[currPtr->t2].v, tDispObj->objTexts[currPtr->t2].w);
     glVertex3f(tDispObj->objVerts[currPtr->v2].x, tDispObj->objVerts[currPtr->v2].y, tDispObj->objVerts[currPtr->v2].z);

     if (currPtr->NormType)
        glNormal3f(tDispObj->objNorms[currPtr->n3].x, tDispObj->objNorms[currPtr->n3].y, tDispObj->objNorms[currPtr->n3].z);
     if (currPtr->t3 > 0)
        glTexCoord3f(tDispObj->objTexts[currPtr->t3].u, tDispObj->objTexts[currPtr->t3].v, tDispObj->objTexts[currPtr->t3].w);
     glVertex3f(tDispObj->objVerts[currPtr->v3].x, tDispObj->objVerts[currPtr->v3].y, tDispObj->objVerts[currPtr->v3].z);

     currPtr = currPtr->next;
  }
  glEnd();

Thanks

Looks like you are traversing a linked list containing your data. That is not going to work; you will need to convert to array of structs or a set of arrays for your geometry data. How to do this best is difficult to say without knowing your app better. But once everything is in arrays, you should be able to use the glXXXXPointer functions to set the array addresses, and use glDrawArray or glDrawElements to render your triangles.

Hope this helps.

  • HM

Ok. I was thinking of maybe rewriting the whole app to work with arrays.
The thing is that the app works fine using normal OpenGL. But since some functions are not supported in OpenGL ES then it does not work properly.

Could a quick fix be that the values sent to glVertex3f and glTexCoord, are stored in an local array that later are sent to glTexPointer and glVertexPointer??

Thanks!

Sure. That’s what OpenGL drivers usually do internally between glBegin and glEnd anyway.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.