Friday, April 29, 2011

Converting an OpenGL application to make it work on the iPhone

Hello everyone, I am trying to convert an openGL application to make it work for iPhone. I am almost finished with everything. but got nothing & stuck up with this part. Can anyone tell me is everything ok with the following converted part.

for(int y=0;y<wet->h-1;y++)
{
    glDrawElements(GL_TRIANGLE_STRIP, wet->w, GL_UNSIGNED_BYTE,tex);
    glDrawElements(GL_TRIANGLE_STRIP, wet->w, GL_UNSIGNED_BYTE,col);
    glDrawElements(GL_TRIANGLE_STRIP, wet->w, GL_UNSIGNED_BYTE,vert);

    glDrawElements(GL_TRIANGLE_STRIP, wet->w, GL_UNSIGNED_BYTE, &tex[i+wet->w]);
    glDrawElements(GL_TRIANGLE_STRIP, wet->w, GL_UNSIGNED_BYTE, &col[i+wet->w]);
    glDrawElements(GL_TRIANGLE_STRIP, wet->w, GL_UNSIGNED_BYTE, &vert[i+wet->w]);
}

in place of:

for(int y=0;y<wet->h-1;y++)
{
    glBegin(GL_TRIANGLE_STRIP);
    for(int x=0;x<wet->w;x++)
    {
     glArrayElement(i);
     glArrayElement(i+wet->w);
     i++;
    }
    glEnd();
}
From stackoverflow
  • It could be useful if you say what problem you're seeing.

    You seem to not be incrementing i in the new loop. How about a little i += wet->w, or using y * wet->w instead of i?

0 comments:

Post a Comment