Slow In Fullscreen

Started by
9 comments, last by nanobyte 22 years, 8 months ago
I am writing a pong game and whenever I execute the program in windowed mode, everything moves at the right speed. But, when I switch to fullscreen (same width & height window), everything slows down about 40%. The frame rate is not slowing down as far as I can tell, just the objects. For example, when I press the "arrow keys" the paddle moves accross the screen, but it fullscreen, it moves much slower. I thought that things would run faster in fullscreen? Im running win2k, geforce2 pro, Detonator 12.90s.
Advertisement
in fullscreen there are more pixels / side. So if you want to move the same speed you have to multiply all your vectors by (1 + window.height / screen.height). Or something. Also make sure you keep the same width / height ratio in your window as in the fullscreen. Hope that makes sense
ack! that should be multiply your vectors by (screen.height / window.height) sorry
Well, the best solution to that would be
FPS independent movement. Just remember
your physics and everything should be easy.

The position of an object after t
seconds is:

x'' = x + v * t

So if you keep track of your loop time
in a variable, t, you just use
v as a value that is the movement in
units/second. That way your movement
will always be constant.

This concept could of course be expanded
to include acceleration.

Just ask if you need further explanation.
Oops, that AP was me.
Ok, here is the code for when the ''right'' arrow key is pressed:

float x = mysquarematrix._41;
x = x + .05;
D3DXMatrixTranslation(&mysquarematrix, x, -13.0f, 0.0f);
my_square.SetWorldMatrix(&mysquarematrix);

When you say screen width /height, you mean 800/600 right?

Thanks
Change the

x = x + .05;

To

  float fSpeed = 5.0f; //Units per second. Before you had 0.05 per framex = x + (fSpeed * fDeltaTime); //fDeltaTime = Time elapsed during previous frame in seconds  


If it still isn''t clear, just ask again
Thanks for all the help. But, one more question I have read in the Opengl game programming book about the time. Could you give me the complete code for the timeing because I don''t know how to calculate the deltatime, etc..

thanks
This isn''t the high performance way, which you get by
using the QueryPerformanceCounter() but this will
do, trust me.

  float fStartTime, fEndTime, fDeltaTime;fEndTime = GetTickCount();//MainLoop{  fStartTime = GetTickCount();  fDeltaTime = (fEndTime - fStartTime) / 1000.0f; //Divide by 1000 since it''s in milliseconds  //All the logic and render code  fEndTime = GetTickCount();}  
Thanks so much, works perfect! I have also figured out how to make the high precision timer in "opengl game programming" to work. Thanks for your time one again.

This topic is closed to new replies.

Advertisement