DOES NOT COMPUTE!!!

Started by
7 comments, last by Monkey D Smiley 15 years, 9 months ago
I've been experimenting with openGL and SDL for a while now, everything was going great until i decided to compile my project on my laptop. Specs: Toshiba A100 - cpu: T2300@1.66 ram: 512 gpu:ATI (X?)1600 Mobility(or something), Running WinXP Pro SP3,v.3264, instaled is VC++ 2005 express edition. I often use my desktop PC. specs: Desktop - C2D E6750 @ 2.67, ram 2GB,gpu: 8800GTS 512, Vista Home premium 64Bit with Service Pack 1(can't find version, name of installer used (Windows6.0-KB936330-X64-wave1.exe)). Installed is VC++ 2008 Express edition. Now for the bombshell, when i rotate a simple triangle using glRotatef(... the laptop build rotates much faster! A float variable incremented at 0.1f per loop is dead slow on my desktop but rotates much faster on the laptop. My past knowledge with OGL tells me the laptop is rotating at the correct speed. I saw similar results with an Allegro project i was working on, character animations ran faster on the laptop but slower on my desktop, which is odd considering the animations where timed! So i am all out of ideas. Either this is a complex problem related to something i am yet to understand or it's something silly my brain forgot or Microsoft (I am eying the last one). Btw it does this with all builds, Debug, Static or whatever. Sorry for the Nooby use of Caps.
Advertisement
My guess would be some kind of bug in your timing code. How are you doing your timing? Are you waiting for Vsynch on the desktop but not the laptop?
Well, have you specified the speed at which the triangle rotates? If you haven't, there should be no surprise that the triangle rotates at different speeds on different computers—after all, what you don't specify has no reason to be the same everywhere. If you have, post the corresponding code so we can determine whether you made a mistake.
Well, if you are just incrementing by .1 every update, then your laptop and desktop will not rotate the same speed because the animation will be based on frame rate and not time. Basically if you want them to rotate at the same speed you have to multiply by time.

rot += 90*dt; //this rotates 90 degrees per second
It's highly probable that you simply have not taken any measures to ensure correct timing in your program, and that vsynch is enabled on your desktop but not your laptop. It's not a bug, it's simply carelessness on your part.

To fix this, the first thing you should do is use timers to limit the speed with which things happen in your program, either by limiting FPS or decoupling the speed of the program from the amount of times per second the main loop happens to be executed. Secondly, you should make sure vsynch is disabled on both your computers. Third, you should explicitly tell SDL not to vsynch your program by passing the appropriate variable to SDL_Init. Check the SDL documentation for details.

Quote:Either this is a complex problem related to something i am yet to understand or it's something silly my brain forgot or Microsoft (I am eying the last one).

In 99.99% of all cases, the bug in your program is your fault. If the bug is not your fault, you have to work around it anyway so in practice the difference is academic.
-------------Please rate this post if it was useful.
Quote:Original post by j0mich01
Well, if you are just incrementing by .1 every update, then your laptop and desktop will not rotate the same speed because the animation will be based on frame rate and not time. Basically if you want them to rotate at the same speed you have to multiply by time.
I think the OP's question was more along the lines of 'why does the laptop push a higher frame-rate than the desktop?', to which my answer is that I have no idea - but for such a trivial test, the results are pretty much meaningless anyway.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Quote:My guess would be some kind of bug in your timing code. How are you doing your timing? Are you waiting for Vsynch on the desktop but not the laptop?
No timing, and i don't even touch Vsync, so i could have enabled it by default on vista. Let me check.

Quote:Original post by j0mich01
Well, if you are just incrementing by .1 every update, then your laptop and desktop will not rotate the same speed because the animation will be based on frame rate and not time. Basically if you want them to rotate at the same speed you have to multiply by time.

rot += 90*dt; //this rotates 90 degrees per second


True that but did you read the specs?
Quote:Original post by Monkey D Smiley
True that but did you read the specs?


The specs would only have had a point if you had configured your movement speed to be "as fast as possible". However, you have left it to be "whatever damn speed you choose", meaning the fast computer can choose to spend its time doing something other than rendering heaps of frames for your games, and end up being slower than the slow one.

Well turns out it was Vsync after all! The idea never even crossed my mind! Well i am sort of new to all this, self teaching myself oGL and SDL. Most of my test applications ran under allegro fixed +30 fps.

Well, thanks.

This topic is closed to new replies.

Advertisement