GlShadeModel(GL_FLAT) equivalent for OpenGL ES ?



  • I'm drawing triangles with GL_TRIANGLE_STRIP, each triangle with diferent colors, but they are smoth and I want them to be flat.
    glShadeModel(GL_FLAT) is not valid in OpenGL ES, so how to do it ?



  • You will have to split the vertices in the triangles, (GL_TRIANGLE_STRIP to GL_TRIANGLE). This way you can set same color for three vertices in the triangle.



  • That seems a good workaround.
    I'm trying to draw a 3D graph with a pattern of 2 square colors. Right now I have a arrai of points and a arrai of colors. It works but the arrai of colors seems a waste of memory since I only have 2 colors, that repeat themselves in a pattern. Perhaps I can do something about it ?
    In the good old desktop fixed pipeline I would eliminate the color arrai with something like:

    @glBegin(GL_QUAD_STRIP);
    for(int i=0;i<x.size();i++)
    {
    if (i%2 == 0)
    {
    glColor3d(Red_a, Green_a, Blue_a);
    }
    else
    {
    glColor3d(Red_b, Green_b, Blue_b);
    }
    glVertex3d(x.at(i),y.at(i),z.at(i));
    }
    glEnd(); @

    Don't know if I'll be able to do something like this in the fragment shader, I'll have to think about this.
    Also regarding your sugestion, I'm using glDrawArrays(), shoud I add extra vertices to my arrai, or create another arrai with geometry info and use glDrawElements() ? Any sugestions ?



  • [quote author="john_god" date="1337295150"]
    Don't know if I'll be able to do something like this in the fragment shader, I'll have to think about this.[/quote]
    Since you don't have any topology information in vertex shader, you can't. You can do it with uniform, but then you have to do a lot of glDraw* call. Maybe if you can determine, let's say, by vertex position...
    [quote]
    Also regarding your sugestion, I'm using glDrawArrays(), shoud I add extra vertices to my arrai, or create another arrai with geometry info and use glDrawElements() ? Any sugestions ?[/quote]
    I prefer indexed array (glDrawElements) but that doesn't mean it's best for your case. If it's easier for your to implement with glDrawArrays, then go with that.



  • Thank you minimoog77


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.