1
votes
          glBegin(GL_TRIANGLE_STRIP);
        for(i; i <= degree; i++)
        {
            float 
            sunX=-200/2*cos(i*M_PI/180),
            sunZ=200/2*sin(i*M_PI/180);

            glVertex3f(0, 0, 0);
            glVertex3f(sunX, 0, sunZ);
        }
        glEnd();

This code is work. But...

for(i; i <= degree; i++)
        {
            float 
            sunX=-200/2*cos(i*M_PI/180),
            sunZ=200/2*sin(i*M_PI/180);
                            glBegin(GL_TRIANGLE_STRIP);
            glVertex3f(0, 0, 0);
            glVertex3f(sunX, 0, sunZ);
                            glEnd();
        }

But this doesn't work. Wtf? Where is logic? I need to insert another code into for cycle for text out:

glPushAttrib(GL_LIST_BIT);
glListBase(1000);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
glPopAttrib();

but i can't to insert it, because beetwen glBegin(GL_TRIANGLE_STRIP) and glEnd() it does not work. And i can't write glBegin(GL_TRIANGLE_STRIP), glEnd() inside for cycle, because it does not work there.

2
Don't use glBegin/glEnd and the rest of the old pipeline... it is no longer good practice...dtech

2 Answers

2
votes

Every time you call glBegin(GL_TRIANGLE_STRIP); you are starting a brand new triangle strip. It will not be connected to the other vertices from previous iterations of the for loop.

1
votes

From the documentation of glBegin

"... Lines, triangles, quadrilaterals, and polygons that are incompletely specified are not drawn. Incomplete specification results when either too few vertices are provided to specify even a single primitive or when an incorrect multiple of vertices is specified. The incomplete primitive is ignored; the rest are drawn. ..."

You need to specify a minimum number of vertices between a glBegin/glEnd pair; the number is dependant on the parameter you supply to glBegin.

  1. GL_POINTS : 1
  2. GL_LINES, GL_LINE_*: 2
  3. GL_TRIANGLES, GL_TRIANGLE_* : 3
  4. GL_QUADS, GL_QUAD_* : 4