Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

LessThanJoe

Optimization and loops

This topic is 5649 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 }

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
(1) yes
(2) drawing one line should be plenty fast

In general though you can speed up geometry that doesn''t change using display lists and geometry that does change using vertex arrays etc. But get it correct before you get it optimized.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!