Sign in to follow this  
kc_0045

Looping picture problems...

Recommended Posts

kc_0045    122
Hey, im trying to make a screen saver that "loop" though a buch oh pictures that all connect, like so it seems like your going down a tunnel, but heres my problem as i keep going though more and more, it seems to slow down alot. Heres my code for the drawing.
void DrawFaceOffset(float scale,bool firstcall)
{
     //glScalef(scale,scale,0);
     if(firstcall) 
     {
        glColor3f(1.0f,0.0f,0.0f);
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D,BlankTxt);
     }
     else
     {    
       glColor3f(1.0f,1.0f,1.0f);
       glBindTexture(GL_TEXTURE_2D,0);
     }
     //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

     float width,height;
     width=scale;
     height=scale;
     glBegin(GL_QUADS);
		glTexCoord2f(0,0);
		glVertex2f(-width,-height);
        glTexCoord2f(1,0);
		glVertex2f(+width,-height);
        glTexCoord2f(1,1);
		glVertex2f(+width,+height);	
        glTexCoord2f(0,1);
		glVertex2f(-width,+height);		
     glEnd();
     glDisable(GL_TEXTURE_2D);
     if(scale>0)
        DrawFaceOffset(scale*0.1f,1);
} 
That is called in the draw function, and scale is set to "zoom" which is a float that keeps geting larger as time goes on(it goes up by time, so its not because of the framerate) And you can download the .exe here http://mindcasterstudios.com/kc/picloop1.zip For an Eg of the problem Thanks in advanced. [Edited by - kc_0045 on August 3, 2005 8:50:08 PM]

Share this post


Link to post
Share on other sites
TomasH    360
Well, your rendering function is recursive (for some reason) and the number of times it recurses is proportional to the value of scale, so if you increase scale as time goes, it's not strange that it takes longer and longer to execute.
I'm not sure exactly what that is supposed to do, but I'd say that using a float*0.1<=0 to stop recursion might be a bad idea..
You should also look out for enabling/disabling texturing too often, as well as re-binding the same texture over and over again.

Share this post


Link to post
Share on other sites
kc_0045    122
Quote:
Original post by TomasH
Well, your rendering function is recursive (for some reason) and the number of times it recurses is proportional to the value of scale, so if you increase scale as time goes, it's not strange that it takes longer and longer to execute.
I'm not sure exactly what that is supposed to do, but I'd say that using a float*0.1<=0 to stop recursion might be a bad idea..
You should also look out for enabling/disabling texturing too often, as well as re-binding the same texture over and over again.


Ya i know, i plan on adding/fixing things like that, but it olny renders about, 4 on the screen and it starts to slow down, but im not talking about fps wise, it just seems to "grow" at a slower rate, while the fps stays the same(around 1500)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this