OpenGL Backwards on Mac OS X??

Member
Posts: 100
Joined: 2006.05
Post: #1
This is a really puzzling problem for me. I have a collection of source code written in straight C++ using OpenGL. I work on this project at work (Where I use a Windows machine) and also at home (on my Mac). Strangely, everything turns up backwards when I run it at work, and then when I fix it, it is backwards again at home. If I shift the camera to the left on one machine, it goes the wrong direction on the other. The same goes for any kind of translation and rotation of the camera. It is really quite baffling that the two would be inconsistent.

I must say, however, that I am partial to the Windows implementation. When I translate the camera left, I use the negative of that value when I call glTranslatef() (moving the camera to the left is the same as moving the world to the right). It seems odd to me that the Mac version would work (that is, appear to operate normally) without this negative sign.

All the source code, minus the code that creates the Window, is the same. The glFrustum() call, all of the vertex calls, everything is the same. What could be causing this behavior?
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #2
Are you reading in anything from files? I think that therin lies your problem. The mac does not render opengl backwards, so it must be a problem with your input to the variables.

It's not magic, it's Ruby.
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #3
Are the mouse coordinates the same on both systems?
Quote this message in a reply
Moderator
Posts: 3,574
Joined: 2003.06
Post: #4
Nevada Wrote:All the source code, minus the code that creates the Window, is the same. The glFrustum() call, all of the vertex calls, everything is the same. What could be causing this behavior?
I'm saying the gl implementation is fine. Your windowing code is the prime suspect. (don't forget windowing systems are flipped vertically in relation to OpenGL on the Mac too, for whatever that might be worth)
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #5
It might be what AnotherJake said, but I'll have to wait until I get back to work to confirm. I do read from files, but if that was backwards I'd get fatal errors. I haven't implemented the mouse yet so that's no problem. The reason I suspected implementation, was because even if the models are loaded backwards, they should still translate in the correct direction.
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #6
Do you have a PPC or Intel Mac. I think what Nayr was suggesting is that it could be an endian issue.
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #7
It's a PPC. I understand the endian differences, but I would be thoroughly surprised if that showed through. I thought 'endianness' was more of a RAM issue than a file issue. I could be wrong, but I think my data would be severely mangled if it was a file read issue.
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #8
If the file is binary, then it's probably an endian issue..
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #9
It's text.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #10
Try reversing mouse coords.

It's not magic, it's Ruby.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #11
Just so you know, there is no difference what so ever with the OpenGL coordinates between systems. The problem is somewhere your end.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #12
You say in your original post that you can "fix" it to run in the right direction, for either platform. Seems kind of like that's a good place to start looking.

OpenGL itself, as has been said above, probably isn't your culprit. I've never seen anything like this, personally.

We need more information. Is the rendering backwards? Or just the motion? If the rendering is backwards, is it mirrored? E.g., do textures flip too?

There's any number of things that could be going pear shaped. Your projection matrix might somehow be flipped on one platform. Or, if you're doing render-to-texture, then blitting that to the screen, perhaps the blit is flipping?

Is it possible to show any code? I'm guessing no, but hey, might as well ask.
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #13
Wow. I figured it out. It turns out that [NSDateObject timeIntervalSinceNow] returns a negative number if the receiver is earlier than the current time. It makes perfect sense but I never thought to look at it. It was making all of my game play appear backwards. My bad, sorry about that...
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #14
Wow, that's a tricky bug to find. Smile Makes a good case for assert()s, though – in the best of all worlds, you would've had assert(step >= 0.0f) at the top. Wink
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #15
Why would you have an NSDate object at all? Just use +timeIntervalSinceReferenceDate...
Quote this message in a reply
Post Reply