• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Slow In Fullscreen

## Recommended Posts

nanobyte    122
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.

##### Share on other sites
Guest Anonymous Poster
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

##### Share on other sites
Guest Anonymous Poster
ack! that should be multiply your vectors by (screen.height / window.height) sorry

##### Share on other sites
Guest Anonymous Poster
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
will always be constant.

This concept could of course be expanded
to include acceleration.

Just ask if you need further explanation.

##### Share on other sites
CrazySwede    122
Oops, that AP was me.

##### Share on other sites
nanobyte    122
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

##### Share on other sites
CrazySwede    122
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

##### Share on other sites
nanobyte    122
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

##### Share on other sites
CrazySwede    122
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();}

##### Share on other sites
nanobyte    122
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.