Advertisement

two questions, is stl vector very fast? and, my sprite's movement is jerky...,

Started by July 03, 2002 10:16 AM
12 comments, last by mickey 22 years, 5 months ago
sdk should not change anything.

i use that technique and my apps recieve messages fine. i dont see why it would not work. PeekMessage() returns one when a message is availible. you use if() to check this. the while() simply continues to retrieven messages until no more are availible (ie PeekMessage() returns 0). in any case it work fine for me. also you would need to add a flah outside the while(PeekMessage()) loop to exit the while(1) loop when you get the WM_QUIT message.

vsync is controlled by the parms you use when creating the device. if you are using immediate, or discard, vsync would be off. vsync_copy (or something similar) turns vsync on.
If you use a while loop for processing messages and your message queue gets backed up, you might find messages coming in as fast are they are being processed = endless loop. In this case give the message queue a small timeslice before calling your gameloop() something like 10ms.

I got this from someone who noticed the DDraw sdk examples on MSDN did it. It solved a problem I had with the Win GDI quite well.


Another possibility, and one I think more probable is something running intermittently in the background, or your game loop taking more time in some iterations than others.

EG

102fps average

frames 1 and 50 take longer because of AI/Something else.

F1 1/4 second = 1/4 sec
F2-F51 1/25 Second = 1/4 sec
F52 1/4 second =1/4 sec
F53-F102 1/25 Second = 1/4 sec

Movement calculated on these times will #jump# when a long frame occurs such as F1 or F52. I use an averageing method to avoid this and spread the load.



,Jay



Advertisement
a person,

i installed once again, the DXSDK, and the jerkiness movement happens again, but this thing solved it,

i changed the D3DSWAPEFFECT_DISCARD to some other value like,
D3DSWAPEFFECT_COPY.., thanks!!!

but why? i barely understood the definition in the SDK for these flags..,

from the DXSDK which i think the reason why the jerkiness happens..,

"D3DSWAPEFFECT_DISCARD will be enforced in the debug run time by filling any buffer with noise after it is presented." and "Although this is not enforced, the debug version of the runtime will overwrite the contents of discarded back buffers with random data ...."

because i installed the debug-runtime sdk, and it says there, ''by filling any buffer with noise'' with very minimal understanding of the ''noise'' it says about, maybe this is the reason?

also, aren''t i going to have any performace cost for using the D3DSWAPEFFECT_COPY? i think, D3DSWAPEFFECT_DISCARD has the less overhead?

jason zelos, would the gameloop your''re talking about is something like this?

void GameLoop()
{
InputLoop();
AILoop();
RenderLoop();
FrameMoveLoop();
SoundLoop();
...
}

hehe, because same as the SDK, i barely understood what you''re trying to explain.., also, give my message a timeslice? a pseudocode would be ver helpful..,

many thanks guys,
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,

  while(1){	if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))	{		if(msg.message == WM_QUIT) break;				TranslateMessage(&msg); 		          	DispatchMessage(&msg);		        }        if (timeGetTime()>LastTime+10) //very short        {	        GameLoop();                LastTime=timeGetTime();        }	}  


You may not need this, I was using the windows GDI with a screen refresh each iteration of the gameloop. As I said before I was told it was on MSDN, but I havn''t checked. It makes sense though.

As for the timeing stuff, it depends on exactly how you are timeing each step.

IE.
If your AI is only called twice per second, then the time taken for that frame is going to be much greater than other frames where AI is not called. If your movement on screen is affected by time, then jumps may occur during these frames.

MovementPerFrame = MovementPerSecond*TimeTakenForFrame

You would mainly see this on older/lesser computers that struggle to work through your AI loop.

Hope thats a better explanation

,Jay

This topic is closed to new replies.

Advertisement