Reputation: 123
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.
Upvotes: 1
Views: 3187
Reputation: 626
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.
GL_POINTS
: 1GL_LINES
, GL_LINE_*
: 2GL_TRIANGLES
, GL_TRIANGLE_*
: 3GL_QUADS
, GL_QUAD_*
: 4Upvotes: 1
Reputation: 83527
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.
Upvotes: 3