[SOLVED]OpenGL and SDL regular lags

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Milch
Chaos Rift Junior
Chaos Rift Junior
Posts: 241
Joined: Sat Jul 11, 2009 5:55 am
Programming Language of Choice: C++
Location: Austria, Vienna

[SOLVED]OpenGL and SDL regular lags

Post 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.
Last edited by Milch on Thu Jan 14, 2010 6:43 am, edited 1 time in total.
Follow me on twitter!
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: OpenGL and SDL regular lags

Post 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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
Live-Dimension
Chaos Rift Junior
Chaos Rift Junior
Posts: 345
Joined: Tue Jan 12, 2010 7:23 pm
Favorite Gaming Platforms: PC - Windows 7
Programming Language of Choice: c++;haxe
Contact:

Re: OpenGL and SDL regular lags

Post 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.
Image
User avatar
Lord Pingas
Chaos Rift Regular
Chaos Rift Regular
Posts: 178
Joined: Thu Dec 31, 2009 9:33 am
Favorite Gaming Platforms: NES, SNES, Nintendo 64, Dreamcast, Wii
Programming Language of Choice: C++
Location: Hiding In My Mum's Basement With My Pokemon Cards

Re: OpenGL and SDL regular lags

Post 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. ;)
User avatar
Milch
Chaos Rift Junior
Chaos Rift Junior
Posts: 241
Joined: Sat Jul 11, 2009 5:55 am
Programming Language of Choice: C++
Location: Austria, Vienna

Re: OpenGL and SDL regular lags

Post by Milch »

Thank you, Lord Pingas ;D
I just checked my fps-regulating function - this is where the lag came from. :D
Follow me on twitter!
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: OpenGL and SDL regular lags

Post 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:
User avatar
Milch
Chaos Rift Junior
Chaos Rift Junior
Posts: 241
Joined: Sat Jul 11, 2009 5:55 am
Programming Language of Choice: C++
Location: Austria, Vienna

Re: [SOLVED]OpenGL and SDL regular lags

Post 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? <.<
Follow me on twitter!
User avatar
RyanPridgeon
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 447
Joined: Sun Sep 21, 2008 1:34 pm
Current Project: "Triangle"
Favorite Gaming Platforms: PC
Programming Language of Choice: C/C++
Location: UK
Contact:

Re: OpenGL and SDL regular lags

Post 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.
Ryan Pridgeon
C, C++, C#, Java, ActionScript 3, HaXe, PHP, VB.Net, Pascal
Music | Blog
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: OpenGL and SDL regular lags

Post 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...
User avatar
Lord Pingas
Chaos Rift Regular
Chaos Rift Regular
Posts: 178
Joined: Thu Dec 31, 2009 9:33 am
Favorite Gaming Platforms: NES, SNES, Nintendo 64, Dreamcast, Wii
Programming Language of Choice: C++
Location: Hiding In My Mum's Basement With My Pokemon Cards

Re: OpenGL and SDL regular lags

Post 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:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: [SOLVED]OpenGL and SDL regular lags

Post 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).
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
Post Reply