PDA

View Full Version : Rotating a circle of points



danny1238
04-22-2001, 02:29 AM
I've managed to draw out a circle of points out onto a window screen. Now I'm trying to rotate it with the use of the glRotatef() and the glutTimerFunc(). I compiled and executed the program, but the window screen is totally transparent. Can anybody help me with the syntax on my code? Perhaps I'm either missing a gl function or my math logic is totally wrong.

danny1238
04-22-2001, 02:37 AM
Here's the the code for drawing the window contents and the callback function for glutTimerFunc().

void RenderScene()
{
GLfloat x, y, angle;
GLfloat PI = 3.1415;
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(Xrot, 1.0f, 0.0f, 0.0f);
glRotatef(Yrot, 0.0f, 1.0f, 0.0f);
glBegin(GL_POINTS);
for(angle = 0.0f; angle <= 2.0 * PI; angle += 0.0f)
{
x = 50.0f * sin(angle);
y = 50.0f * cos(angle);
glVertex3f(x, y, 0.0f);
}
glEnd();
glPopMatrix();
glutSwapBuffers();
}

void TimerFunction(int value)
{
Xrot += 0.1f;
Yrot += 0.1f;
glutPostRedisplay();
glutTimerFunc(33, TimerFunction, 1);
}

ipo
04-22-2001, 05:54 PM
I haven't tried your code but I can see that you're in an infinite loop. You're not incrementing angle.

danny1238
04-24-2001, 11:47 AM
Yeah, I kinda figured that out a couple days ago, and that was the problem within the source code. I just get a little blurred vision when I'm copying code from pencil to paper to keyboard. Thanx for the help though.