Is this what you'd expect to happen?

Started by
17 comments, last by darren_mfuk 17 years, 1 month ago
You gotta remember that calling a function makes the stack grow and other things.

Remember 2Ghz is dedicated to your entire system not just your one application. Windows constantly grabs different programs to run and switches back and forth. Not only does that take up some of those 2Ghz, but it also has to store specific program data each time, eating up more of the 2Ghz.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Advertisement
hhmmm strange ** scratches head also **

Does the app actually seem slow, is it jerky, does your mouse pause etc etc..

Or is this just an impression given by your FPS.

maybe you could have a problem with the FPS calculation somewhere.

Also do you calculate your FPS in the DrawScene() or main loop.

I know it's a stab in the dark, but I had FPS issues, when calculating it during DrawScene()
(or what ever your render scene function is called !)

So I moved it into the main loop, after reading another thread and it solved many problems
----------------------------------------Now just hit that link that says 'Rate This User' [wink]
Quote:Original post by SirSmokey

Well what I meant was that when you comment out the function call, the compiler sees that inside the loop, nothing happens (no function call or anything) so it might remove the loop eniterly.

But if your in debug mode, then no optimizations should be happening... i think.


Ah, that makes sense. :)

I added

i = 0


outside the loop. Then
			i = x % 3 ? i << 2 : i + 1;

inside the loop. Then
x = i;

outside the loop, hoping to 'detrigger' any optimization. The frame rate dropped to ~20fps.

hmmm, maybe I am asking too much from the hardware.
I doubt you are asking to much from the hardware.

I would say that was a very simple calculation for a computer, plus you are not actually telling it to do any additonal rendering.

Plus you are practically using the lowest possible resolution of 640x480.
Not knowing your complete hardware spec, but I doubt what you are doing should have such an effect !

Just try something simple and rule out the external function call.

ie.....

change
for (x = 0; x < width; x++)
{
function_to_call();
}

TO


int i =0;

for (x = 0; x < width; x++)
{
i = x;
}

Just so your loop is doing something, and rule out the externals.
should pin-point the problem area, although I can't really see anything wrong with the code.

I know you said it was a typo earlier, maybe you could copy and paste the code again, just so we can see 'exactly' what you have ;-)
----------------------------------------Now just hit that link that says 'Rate This User' [wink]
Quote:Original post by darren_mfuk
hhmmm strange ** scratches head also **

Does the app actually seem slow, is it jerky, does your mouse pause etc etc..

Yes.

Quote:Original post by darren_mfuk
Or is this just an impression given by your FPS.

maybe you could have a problem with the FPS calculation somewhere.

Also do you calculate your FPS in the DrawScene() or main loop.

I know it's a stab in the dark, but I had FPS issues, when calculating it during DrawScene()
(or what ever your render scene function is called !)

So I moved it into the main loop, after reading another thread and it solved many problems


The frame rate is calculated in the main loop.

while (...){  copy_to_screen(surface, width, height);  ticks = GetTickCount();  fps = 1000.0 / (float)(ticks - last_ticks);  last_ticks = GetTickCount();}


That isn't the exact code, but the basic idea.


Quote:
Just try something simple and rule out the external function call.

ie.....

...

Just so your loop is doing something, and rule out the externals.
should pin-point the problem area, although I can't really see anything wrong with the code.

That's what I did with the previous
			i = x % 3 ? i << 2 : i + 1; 

line.

Quote:
I know you said it was a typo earlier, maybe you could copy and paste the code again, just so we can see 'exactly' what you have ;-)

Well you can't say you didn't ask for it!!!!
[source lang=C]static void function_to_call(void){}static void CopyToScreen(SDL_Surface* pSurface, TEuint* pixels, TEuint width, TEuint height){	// pixels have the format 0xRRGGBBAAu	TEuint x, y;	TEuint i;//	SDL_Color c;//	TEuint p;//	c.r = (Uint8)(0xFFu);//	c.g = (Uint8)(0xFFu);//	c.b = (Uint8)(0xFFu);//	p = 0xFFFFFFFFu;	i = 0;	SDL_LockSurface ( pSurface );# if 1	for (y = 0; y &lt; height; y++)	{		for (x = 0; x &lt; width; x++)		{//			p = pixels[y*width+x];//			c.r = (Uint8)((p & 0xFF000000u) &gt;&gt; 24);//			c.g = (Uint8)((p & 0x00FF0000u) &gt;&gt; 16);//			c.b = (Uint8)((p & 0x0000FF00u) &gt;&gt; 8);	//		c.a = (Uint8)(p & 0x000000FFu);			/*i = i + x &lt;&lt; 2*/			i = x % 3 ? i &lt;&lt; 2 : i + 1;// ;		//	function_to_call();//			SetSDLPixel(pSurface, x, y, c);		}	}//	x = i;# endif	SDL_UnlockSurface ( pSurface );	SDL_UpdateRect ( pSurface , 0 , 0 , 0 , 0 );}TEdllapi TEvoid TEvideo_BlastScreen(TEvoid){	TEuint width, height, bpp;	TEuint* pixels;	TEsint* normals;	TEuint i, j;	translate_mode(Mode, &width, &height, &bpp);	pixels = TEDBcolor_GetBuffer(ScreenColors);	normals = TEDBnormal_GetBuffer(ScreenNormals);#if 0	j = 0;	for (i = 0; i &lt; width*height; i++)	{		pixels = get_pixel_color(pixels, normals[j], normals[j+1], normals[j+2]);		j+= 3;	}#endif	CopyToScreen(SDLScreenData.Screen, pixels, width, height);} /* ************************************************************* *//*     IN MAIN FUNCTION                                          */	while (TE_PumpMessages())	{ //		TEvideo_ClearScreen();//		TEvideo_BltScreen(cb, nb, x, y, w, h);		if (x+inc &gt;= 640-w)			inc = -inc;		if (y+inc &gt;= 480-h)			inc = -inc;		x+=inc;		y+=inc;		TEvideo_BlastScreen();		ticks = GetTickCount();		fps = (float)(ticks-last_tick_count);		fps = 1000.0f / fps;		fprintf(c_file, "%f\n", fps);		last_tick_count = GetTickCount();	}


[Edited by - Kryptyglyf on March 9, 2007 10:13:53 PM]
hey,

just a tip ;-)
check this link
http://www.gamedev.net/community/forums/faq.asp#tags

I know they are starting to ban people for posting huge amounts of code.
I know I asked for it lol, but be warned.


ok I don't see anything that really springs out here.
TEdllapi TEvoid TEvideo_BlastScreen(TEvoid){	TEuint width, height, bpp;	TEuint* pixels;	TEsint* normals;	TEuint i, j;	translate_mode(Mode, &width, &height, &bpp);	pixels = TEDBcolor_GetBuffer(ScreenColors);	normals = TEDBnormal_GetBuffer(ScreenNormals);#if 0	j = 0;	for (i = 0; i < width*height; i++)	{		pixels = get_pixel_color(pixels, normals[j], normals[j+1], normals[j+2]);		j+= 3;	}#endif	CopyToScreen(SDLScreenData.Screen, pixels, width, height);}


Not sure what translate_mode(Mode, &width, &height, &bpp); does.
But I don't actually see where you are assigning width & height.
I see it declared but never assigned before calling CopyToScreen()
----------------------------------------Now just hit that link that says 'Rate This User' [wink]
Thanks for the link. It would have been nice if there was a link for it in the reply page.:)

translate_mode() gets the height, width, and bpp of Mode. It was basically an idiotic hack I put in there for some reason I don't remember. I needed the height and width of the screen but for some reason didn't want to store the height and width explicitly. It's basically just a switch statement that fills in the width, height, and bpp.

Well, I've got to be getting to bed, thanks for the help. I'll pick this back up tomorrow.
That's the only point I see a problem for in the code so far.

maybe pop a messagebox in there or << cout....
so you know you have got the right height and width.

looks like you are parsing height & width TO translate_mode() .. but how are you returning it FROM, for those local variables ?


Quote:Original post by Kryptyglyf
It was basically an idiotic hack I put in there for some reason I don't remember.

 // Comments are your best friend // you'll forget half of what your code does in a months time
----------------------------------------Now just hit that link that says 'Rate This User' [wink]

This topic is closed to new replies.

Advertisement