Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've started learning how to use OpenGL a while back, using the OpenGL SuperBible, Fifth Edition, and I've had people arguing about the fact that the book doesn't really teach how to use OpenGL but instead it teaches how to use two of the wrapper libraries related to it, glut and glTools.

I've also been told that glut should never be used for full-blown projects, but there was no valid reason supplied with the argument.

My question is why, and when should I not use the glTools/glut libraries, and what should I use instead?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

GLTools and GLUT are not the same thing. GLUT is responsible for dealing with things outside of OpenGL. GLUT creates and manages a window and an OpenGL context; the actual stuff that goes on within that context (aka: OpenGL) is not GLUT's responsibility.

Maik already covered the reasons why you don't see GLUT in serious applications. GLTools is another matter.

GLTools is just a framework, a wrapper around OpenGL stuff. There are many reasons not to use it in serious work:

  1. It's inefficient. If performance matters, you're going to want to sidestep it.
  2. It's not very good. Take the GLShaderManager for example. It either loads the shaders or returns 0. If there is a compiler/linker error, it gives no information on this. Yes, it writes the log to stderr, but not everyone has stderr piped to somewhere that is visible. Exceptions are rather harder to ignore.

I've had people arguing about the fact that the book doesn't really teach how to use OpenGL but instead it teaches how to use two of the wrapper libraries related to it

This is an aside, but generally the problem with regard to this is quite simple. 5th teaches you to use the framework before explaining what that framework is doing. So you learn how to use its mesh loading, how to use its perspective matrix generation code, its default shaders, etc, all before learning what a shader is, what vertex attributes are, and so forth.

It's basically fixed-function programming for the first part of the book. It just uses its own fixed-function code rather than OpenGL's.

It's not that it uses a framework that's the problem. The problem is that it uses the framework to hide details that haven't been explained, rather than to hide details that are unimportant to the current lesson. After you've seen the shader loading code a few times, you don't need to see it again, so it can be a library function.

A better way to structure the book would have been to use the pieces of the framework after showing the underlying OpenGL calls that the framework is doing. The standard set of shaders are fine, but it should use them only after the user has seen shaders in action manually. The same goes for mesh loading and handling, textures, etc.

share|improve this answer
    
Thank you very much, very exhaustive and insightful answer. –  Gabriele Cirulli Jul 20 '11 at 18:16

The argument against glut in big projects is that you don't have access to the application loop, so you can't change it to fit your needs. All it has are some callbacks which are triggered from glut, but you don't have much control about it.

However, the purpose of glut is to create demos and test apps easily and cross platform, without the need to deal with ugly OS code to create windows, its just a question of some lines of code using glut.

share|improve this answer
    
Is it possible that using glut could harm portability also? –  Jonathan Connell Jul 20 '11 at 13:20
1  
@3nixios Glut claims it "works across all PC and workstation OS platforms". If those are your target platforms, you're safe portability wise –  Maik Semder Jul 20 '11 at 13:37
    
I was indeed thinking about any platform not supported by GLUT. I was wondering what kind of an impact a late in the day change of target could have. –  Jonathan Connell Jul 20 '11 at 13:44
1  
@3nixios a late change from PC/workstations to mobiles is practically impossible without rewriting a lot of code AND assets. GLUT will be your smallest problem, if you try anyway :) –  Maik Semder Jul 20 '11 at 14:03
    
Oh nevermind... –  Jonathan Connell Jul 20 '11 at 14:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.