Results 1 to 2 of 2

Thread: Porting OpenGL sw to OpenGL-ES, help needed - take 2

  1. #1
    Junior Member
    Join Date
    Oct 2004
    Posts
    4

    Porting OpenGL sw to OpenGL-ES, help needed - take 2

    Follow up on http://khronos.org/cgi-bin/ubb/ultim...c&f=4&t=000121

    Got rid of most of the glBegin/glEnd stuff, only polygons needs rewriting. Thought this was relatively easy, but unfortunately it's not.

    The game's original code does something like this texture most of its model:
    glBegin (GL_POLYGON);
    for (i=0 ; i<numVertex ; i++)
    {
    glTexCoord2f(tex[i][0], tex[i][1]);
    glVertex3fv(vertex[i]);
    }
    glEnd ();

    Which I've replaced with:

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glVertexPointer(3, GL_FLOAT, 0, GetVertex(0));
    glTexCoordPointer(2, GL_FLOAT, 0, GetTexture(0));
    glDrawArrays(GL_TRIANGLE_FAN, 0, numVertex);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);

    I store the original tex[] and vertex[] vector info in some global float arrays accessible via GetVertex () and GetTexture().

    The model gets drawn ok, but small triangles and rectangulars are not correctly textured. They appear solid grey. As I move around in the game, the areas that are not correctly textured change all the time, resulting in a very flickery look and feel.

    I've also tried to rewrite the polygon code by drawing n-2 triangles (GL_TRIANGLES) for an n polygon. The (not too surprising) result is exactly the same as for GL_TRIANGLE_FAN.

    Am I making an obvious mistake?

    cheers, Pete

  2. #2
    Junior Member
    Join Date
    Oct 2004
    Posts
    4

    Re: Porting OpenGL sw to OpenGL-ES, help needed - take 2

    Found the problem!

    For the record...
    The game draws (1) the 3D model using polygons and then (2) applies lightning also using polygons. Things get messed up if I only change GL_POLYGON to GL_TRIANGLE_FAN in (1), if I change this in (2) as well then all works just fine.

    Pete

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. Porting OpenGL sw to OpenGL-ES, help needed
    By yipton in forum OpenGL ES general technical discussions
    Replies: 3
    Last Post: 10-30-2004, 05:17 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
  •