Results 1 to 4 of 4

Thread: Rewrite this code for Opengl ES 1.0

  1. #1
    Junior Member
    Join Date
    Mar 2009
    Posts
    2

    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

  2. #2
    Senior Member
    Join Date
    Sep 2003
    Location
    Seattle, WA
    Posts
    246

    Re: Rewrite this code for Opengl ES 1.0

    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

  3. #3
    Junior Member
    Join Date
    Mar 2009
    Posts
    2

    Re: Rewrite this code for Opengl ES 1.0

    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!

  4. #4
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: Rewrite this code for Opengl ES 1.0

    Quote Originally Posted by Hachaso
    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??
    Sure. That's what OpenGL drivers usually do internally between glBegin and glEnd anyway.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

Similar Threads

  1. Trouble porting OpenGL code to iPhone's OpenGL ES
    By vamshivakul in forum Cross API and window system integration
    Replies: 3
    Last Post: 10-26-2011, 01:27 AM
  2. Trouble porting OpenGL code to iPhone's OpenGL ES
    By vamshivakul in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 04-16-2009, 07:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •