Skip to main content
GameDev.net gamedev.net
🔒 Locked

Looping picture problems...

Started by kc_0045 Aug 2, 2005 at 1:55 AM 3 replies 650+ views
Original Post
kc_0045
kc_0045
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]
TomasH
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.
kc_0045
kc_0045
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)
kc_0045
kc_0045
Any ideas? or any ideas on how to get the same effect, a differnt way?
kc_0045
kc_0045
Id hate to just keep bumping...but i cant figure it out :S Any ideas Please?

Topic Locked

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

Sign in to reply to this topic.