PDA

View Full Version : glBegin/glEnd



GuitarFan
06-22-2013, 01:13 PM
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.

aqnuep
06-22-2013, 02:15 PM
Sure it doesn't, because glEnd finishes your primitive, and you render triangle strips which require at least three vertices to produce a primitive, otherwise it doesn't product anything, and you only passed two.

When you do glBegin it won't magically catch up from where you left.