Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. GlShadeModel(GL_FLAT) equivalent for OpenGL ES ?
Forum Updated to NodeBB v4.3 + New Features

GlShadeModel(GL_FLAT) equivalent for OpenGL ES ?

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 2 Posters 7.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    john_god
    wrote on last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      minimoog77
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        john_god
        wrote on last edited by
        #3

        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 ?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          minimoog77
          wrote on last edited by
          #4

          [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.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            john_god
            wrote on last edited by
            #5

            Thank you minimoog77

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved