Skip to main content
gamedev.net
🔒 Locked

Optimization and loops

Started by LessThanJoe Dec 6, 2002 at 5:33 PM 2 replies 300+ views
Original Post
LessThanJoe
LessThanJoe
Ok, first, my main question is... Can I have a look inside the glBegin() and glEnd() functions? For example glBegin(GL_POINTS); for (int counter = 0; counter < array.length(); counter++) glVertex3f(ArrayX[counter], ArrayY[counter], 0.0f); glEnd; and my second question... I am using the basic shell from nehe''s first tutorial, and the only thing I''m changing is the DrawGLScene function. my code is below. My question is, how could I make this faster? int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing { int newx = radius * cos(ConvertDegreesToRadians(angle)) + centerx; int newy = radius * sin(ConvertDegreesToRadians(angle-1.570795)) + centery; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glLoadIdentity(); // Reset The Current Modelview Matrix glTranslatef( -5.0f, 3.75f, -9.03f ); // Move Left 1.5 Units And Into The Screen 6.0 glBegin(GL_LINES); // Drawing Using Points glVertex3f(CONV_X float(centerx), CONV_Y float(centery), 0.0f); glVertex3f(CONV_X float(newx), CONV_Y float(newy), 0.0f); glEnd(); angle++; if(angle == 360) angle = 0; return TRUE; // Everything Went OK }
LessThanJoe
LessThanJoe
Oh, it works. I have a line spinning in a circle (which''ll soon be a bunch of points spinning in a moving circle...)
I just wish it rotated a bit quicker. I know I can just incriment by two or three, but then it may become choppy.
LessThanJoe
LessThanJoe
Nevermind, I can just incriment by two and the difference is not noticable.

Thanks for answering the first question though.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.