Page 1 of 1

[SOLVED]OpenGL and SDL regular lags

Posted: Wed Jan 13, 2010 1:54 pm
by Milch
Hey!
In my SDL+OpenGL program I experienc regular lags every 5 seconds or so.
It does that on every pc I tested - from ultra low to ultra high.
I cant post the whole sourcecode because its a large project and I just wanted to know if anyone experienced similar problems with SDL+OpenGL. ( or only with OpenGL )

Just for the info - it has to do with the rendering.
I disabled everything ( input, collision,...) but the lag still occurs =/

I only use ortho in the game - its a 2d jump and run game.

Re: OpenGL and SDL regular lags

Posted: Wed Jan 13, 2010 2:28 pm
by dandymcgee
Never seen lag in any of my SDL / OGL projects. I've seen things run REALLY slow, but always at a constant speed.

Re: OpenGL and SDL regular lags

Posted: Wed Jan 13, 2010 5:57 pm
by Live-Dimension
There is any number of things that could create this programming wise. There IS a known de-sync issue on dual-core/quad-core processors in WinXP, but it generally happens quicker, ie, 1-2 seconds max. It affects other programs, especially other games, but not all programs/games have the issue. It can be patched though.

What you may find is your doing something every 5 seconds that causes the lag (Loading a whole bunch of resources, reinitialising stuff, doing 10-trillion calculations in a single frame, etc). I'd look very close at anything in your code that checks at regular exact intervals (250ms/500ms/1s/5s) even if it's not meant to be triggering during play. You may find it somehow got past you and is still doing stuff in the background, such as reloading all resources. Past that there's obviously some kind programming bug at work here.

Re: OpenGL and SDL regular lags

Posted: Wed Jan 13, 2010 7:36 pm
by Lord Pingas
Perhaps it has something to do with the frames per second?
Sorry, I don't know much when it comes to game programming. Still learning the language. ;)

Re: OpenGL and SDL regular lags

Posted: Thu Jan 14, 2010 6:42 am
by Milch
Thank you, Lord Pingas ;D
I just checked my fps-regulating function - this is where the lag came from. :D

Re: OpenGL and SDL regular lags

Posted: Thu Jan 14, 2010 9:18 am
by Falco Girgis
Lord Pingas wrote:Perhaps it has something to do with the frames per second?
Sorry, I don't know much when it comes to game programming. Still learning the language. ;)
Milch wrote:Thank you, Lord Pingas ;D
I just checked my fps-regulating function - this is where the lag came from. :D
:shock:

Re: [SOLVED]OpenGL and SDL regular lags

Posted: Thu Jan 14, 2010 11:04 am
by Milch
Wow - something strange happened.
I changed this and that - and came to the conclusion that NOTHING was wrong.
I took out my fps-function and reimplemented it again and all of a sudden everything worked with no lag oO
MinGW is strange...or am I? <.<

Re: OpenGL and SDL regular lags

Posted: Thu Jan 14, 2010 2:32 pm
by RyanPridgeon
GyroVorbis wrote:
Lord Pingas wrote:Perhaps it has something to do with the frames per second?
Sorry, I don't know much when it comes to game programming. Still learning the language. ;)
Milch wrote:Thank you, Lord Pingas ;D
I just checked my fps-regulating function - this is where the lag came from. :D
:shock:
Ditto on that.

Re: OpenGL and SDL regular lags

Posted: Thu Jan 14, 2010 6:14 pm
by XianForce
RyanPridgeon wrote:
GyroVorbis wrote:
Lord Pingas wrote:Perhaps it has something to do with the frames per second?
Sorry, I don't know much when it comes to game programming. Still learning the language. ;)
Milch wrote:Thank you, Lord Pingas ;D
I just checked my fps-regulating function - this is where the lag came from. :D
:shock:
Ditto on that.
Same here...

Re: OpenGL and SDL regular lags

Posted: Thu Jan 14, 2010 7:15 pm
by Lord Pingas
XianForce wrote:
RyanPridgeon wrote:
GyroVorbis wrote:
Lord Pingas wrote:Perhaps it has something to do with the frames per second?
Sorry, I don't know much when it comes to game programming. Still learning the language. ;)
Milch wrote:Thank you, Lord Pingas ;D
I just checked my fps-regulating function - this is where the lag came from. :D
:shock:
Ditto on that.
Same here...
OMG, I'm a miracle maker! I Guess from now on you can refer to me as MASTER Lord Pingas. ;)

Glad I could help. :mrgreen:

Re: [SOLVED]OpenGL and SDL regular lags

Posted: Fri Jan 15, 2010 9:29 pm
by dandymcgee
Milch wrote:Wow - something strange happened.
I changed this and that - and came to the conclusion that NOTHING was wrong.
I took out my fps-function and reimplemented it again and all of a sudden everything worked with no lag oO
MinGW is strange...or am I? <.<
My guess is that you had something else running in the background (not in your program, but rather a completely different process on your computer). Although it never hurts to check for major memory leaks (Task Manager, see if your process's memory usage is skyrocketing rather quickly after the initial resource loading).