views:

65

answers:

2

I recently wrote a maze game in opengl (using freeglut) that works fine when built in Ubuntu or Cygwin, but when built on Fedora Core 12 with freeglut, the game falls apart, and my professor can't see a thing when he builds it on his machine (the OS of which he has failed to disclose).

Also, on previous assignments, I got flickering even though I've implemented double buffering and and am flushing the buffer after each display. The flickering occurs on my Fedora machine, infrequently on my Ubunutu machine, and not at all in cygwin.

Finally, on the Fedora machine, the fog is extremely dense and seems to be ignoring the call to 'glFogf(GL_FOG_DENSITY, 0.1)'. However, on Cygwin and Ubuntu the fog performs flawlessly.

Are there that many differences between implementations of freeglut between OS's that this would be an issue? My professor seems like he's about ready to fail me on these projects, but I have no clue why opengl is acting this erratic between operating systems.

Please let me know if you have any insight and thanks for your time.

A: 

I my experience teaching OpenGL, this kind of thing happens when glut is used in a way differently from what is intended. Some implementations/drivers handle it, and others don't - there are quite large differences between implementations when they are used in non-standard ways. When used in standard ways the differences are pretty small.

The most common reason I've seen for this is when glutPostRedisplay isn't being called after each change to the screen.

Other possible reasons are drawing in places other than the display function, or not having the callbacks set up correctly.

Beyond this, I can only guess what's going on, but if one implementation is showing nothing at all then I'd be pretty sure you've got something basic wrong.

RD1
A: 

I got the following two calls mixed up in order. Should be this way.

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutCreateWindow("My Window");

I had it this way:

glutCreateWindow("My Window"); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

As such I wasn't guaranteed a double-buffered window and thus sometimes it would flicker and sometimes it wouldn't.

Also in Red-Hat distributions, size_t is defined as a signed int while Ubuntu uses an unsigned int. This led to a loop issue on my professors machine when trying to use the function fread(), whose return type is -1 in Fedora and static_cast(-1) in Ubuntu, which I imagine is not good :/. Took me a couple days to track down the issue in the Ubuntu kernel source.

Nuvious