Capping framerate
Yeah, just wondering if it would be a good idea to have a maximum framerate,
the thing is though ive not seen it done in SDL anywhere so maybe its a bad thing to do,
My current run loop code is
the thing is though ive not seen it done in SDL anywhere so maybe its a bad thing to do,
My current run loop code is
Code:
while(1) {
while(SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
SDL_Quit();
return 1;
break;
default:
break;
}
}
drawGL();
}Sir, e^iπ + 1 = 0, hence God exists; reply!
It's not a bad idea, it certainly makes coding a little easier. If this is for the same 2D game you've been asking about, then I would probably say yes.
You *could* be drawing at 300fps, but what would be the point? At most, you are going to see enough frames as the refresh rate. An even better idea would be to enable VBL sync, which waits for the monitor to refresh before swapping buffers. 2D games can look awful with this turned off if they are fast moving.
You *could* be drawing at 300fps, but what would be the point? At most, you are going to see enough frames as the refresh rate. An even better idea would be to enable VBL sync, which waits for the monitor to refresh before swapping buffers. 2D games can look awful with this turned off if they are fast moving.
It is the same game.
Well with a 75Hz monitor 300fps is 225 frames that you dont see so yeah, not much pont.
VBL sync, is that an SDL thing?
What would be the best way to capp framerate?
Some example code would be so useful.
Well with a 75Hz monitor 300fps is 225 frames that you dont see so yeah, not much pont.
VBL sync, is that an SDL thing?
What would be the best way to capp framerate?
Some example code would be so useful.
Sir, e^iπ + 1 = 0, hence God exists; reply!
Search the forums. All of your recent questions have been discussed here before.
For example, SDL VBL.
For example, SDL VBL.
So is VBL going to work multiplatorm?
Sir, e^iπ + 1 = 0, hence God exists; reply!
The method of forcing VBL sync will differ per platform.
Oh right, thats not really a problem it just means a bit more coding then.
But would forcing a maximum framerate of about 60 do kinda a similar thing?
But would forcing a maximum framerate of about 60 do kinda a similar thing?
Sir, e^iπ + 1 = 0, hence God exists; reply!
No, generating 60 fps is not the same thing as making sure the page flip happens when the screen isn't refreshing. If you generate exactly 60 fps but don't sync to VBL you'll have a nice stationary tear running across your content.
Ahhh, I understand now.
Right and will that happen regarless of whether im rendering usng OpenGL or somthing else?
Right and will that happen regarless of whether im rendering usng OpenGL or somthing else?
Sir, e^iπ + 1 = 0, hence God exists; reply!
Yes - it's about redrawing the screen while the screen buffer is updated - half of the screen will be this frame, but the rest will be the last frame you displayed.
yeah, that seems like it would be a big problem but why dont I see code for this in any other games?
Does anyone have SDL code for this that would work multiplatorm, or even can It be ahcieved with multipatform with SDL?
Does anyone have SDL code for this that would work multiplatorm, or even can It be ahcieved with multipatform with SDL?
Sir, e^iπ + 1 = 0, hence God exists; reply!
There is currently no way to enable VBL using SDL. You'll have to have code for each system.
hmmmm, I could use a ./configure to fix the code for each OS.
It might be tricky but Ill see what I can do.
thanks a lot for the help Skorche, arekkusu, Fenris!
It might be tricky but Ill see what I can do.
thanks a lot for the help Skorche, arekkusu, Fenris!
Sir, e^iπ + 1 = 0, hence God exists; reply!
unknown Wrote:hmmmm, I could use a ./configure to fix the code for each OS.
It might be tricky but Ill see what I can do.
thanks a lot for the help Skorche, arekkusu, Fenris!
Just use #ifdef, enabling VBL on Mac is just 2 lines of code...
What two lines?
Sir, e^iπ + 1 = 0, hence God exists; reply!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| iPhone 3GS OpenGL strange framerate bug | airfire | 2 | 2,893 |
Dec 2, 2009 09:22 AM Last Post: airfire |
|
| GLUT consistant framerate? | JeroMiya | 2 | 3,816 |
Apr 30, 2007 02:25 AM Last Post: OneSadCookie |
|
| SDL Framerate Control | joellevin | 10 | 7,192 |
Jan 4, 2007 01:26 PM Last Post: arekkusu |
|
| Weird framerate problem | Jesse | 4 | 2,745 |
Sep 1, 2003 01:01 AM Last Post: Jesse |
|

