PDA

View Full Version : Why not GLUT?



Night Hacker
02-18-2004, 05:21 PM
I have read various responses from people that don't recommend using GLUT for creating a game and I don't understand why not.

The only reason I have ever seen NOT to use GLUT is because of what appears to be slower rendering or whatever. But I found an excellent tutorial that revealed why every tutorial I have seen is slower when using glut AND how to solve the problem. http://www.lighthouse3d.com/opengl/glut/index.php3?7

At that site it explains that if you disable keyboard auto repeat and check for keypress and release the problem disapears and glut seems just as fast as normal GL code.

I was wondering if this slowdown was the only reason why people don't recomend using it or if there is something more?

There doesn't seem to be a speed issue once you take care of the keyboard repeat problem which seems to be a huge bottleneck.

Nychold
02-18-2004, 09:03 PM
"GLUT is easy to use and learn, and although it does not provide you with all the functionality the operating system offers, it works quite well for demos and simple applications.

"Because your ultimate goal is to create a fairly complex game, you're going to need more flexibility than GLUT offers...."

This is directly from OpenGL Game Programming. It's a little vague, though. Basically, GLUT does not offer enough features relating specifically to operating systems or graphical interfaces, so using GLUT and GLUT alone would be ill-suited to all but the simplest of games. For anything complex, access to the OS would be required. This doesn't mean GLUT can't be used, but that GLUT can't be exclusively used. Personally, I don't use GLUT at all, and I'm getting around 50~60 FPS for complex scenes. It's probably a matter of taste.

nexusone
02-19-2004, 05:16 AM
Not that you can not use glut for a game, just not most poeples first choice, do to some of the limitations of it.

Have you looked into what is called Game GLUT?
I have not used it, but it my be something you may want to look at.

marcus256
02-19-2004, 10:49 AM
Well, I can think of several reasons for not using GLUT:

1) Keyboard input. GLUT uses a hardcoded US-ASCII LUT for the keyboard mapping, and hence is not very internationalized. It can't tell you if the 'K' key was pressed, but only if the keyboard produced a 'k' or 'K' character (you have to figure out caps etc using your own logic). GLUT does not differ between left/right modifiers (shift etc). And the list goes on...

2) Joystick input. GLUT has a very limited joystick interface, that has only been implemented under Windows (so no joystick under Linux, for instance) - obviously a simple hack (it simply mirrors the functionality of the Win32 MMSYSTEM joystick API - with some limitations).

3) Timer. glutGet(GLUT_ELAPSED_TIME) has a resolution that is, at best, 1 ms precise. It can be much worse. It simply isn't good enough for a real game.

4) When you close a GLUT window with the X button, exit() is called, efficently terminating your game completely.

Fortunately, GLFW (http://glfw.sf.net/) solves these problems, and many more http://www.opengl.org/discussion_boards/ubb/smile.gif You may want to check it out.

Night Hacker
02-19-2004, 11:30 AM
Thanks alot for the replies.

I had told a friend of mine that glut was good for learning opengl but not for creating an actual game with.

He had read that tutorial I posted a link to and found out that you could increase the speed of glut by disabling auto key repeat, or something to that affect. The only limitations I ever knew about glut seemed to be the speed so when that was taken care of I was starting to wonder why everyone who knew more than I did about opengl advised against using it for games. This seems to answer those questions for me (and hopefully others wondering the same things about glut).

Thanks again.

chemdog
02-19-2004, 11:42 AM
LEGAL reasons also prevent GLUT from being used in many situations. The LICENSE on my version of GLUT allows me only to use it for research.