I have some fundamental points/questions about OpenGL, not all involving code but concepts as well. I would be grateful if you could answer, affirm or expand on any of them. I warn you, some might be naive, so please bear with me.
-
I understand that OpenGL is just a standard, as opposed to a piece of software. For example, ‘getting’ OpenGL actually involves getting a third-party implementation which doesn’t necessarily have to be endorsed by Khronos.
-
OpenGL usually refers to the combination of the GL utilities (GLU) and the GL utilities toolkit (GLUT). They have methods beginning with
gluandglut, resp. and the ‘basic’ OpenGL methods, that begin with simplygl, are implemented by those that make graphics drivers, i.e. NVIDIA? -
I assume that
glutmethods are OS-specific helpers, for exampleglutKeyboardFunc()has to be, to interpret the keyboard. So if I wanted a more powerful alternative way to interpret keyboard input, I would just use the OS API. OpenGL itself is purely about graphics, butgluthas this sort of thing since graphics is not much without real-time human control. -
It seems to me that
glumethods may be identical to calling a series of lower-levelglmethods. One example I would like to quote isglOrtho()andgluPerspective(). They seem to me to have similar ways of working, but calculating perspective may be more complex, sogluPerspective()is for convenience, but might just resolve to someglmethods. -
I have studied basic OpenGL using freeglut at university, and I keep having this vision of a ‘hardcore’ way of using OpenGL, using only low-level methods. I don’t know if this is a totally naive thought, but is there a ‘professional’ way of writing OpenGL, to get out its maximum functionality? Like, presumably, game developers wouldn’t use
glutPostRedisplay()for example, right? It seems too easy and convenient, like it hides a lot of what is going on. I suspect this is also true for C++ since GLUT callbacks aren’t friendly with methods in namespaces (as I’ve seen in other questions).
Indeed.
No. OpenGL is just the functions beginning with
gl…. Everything else (GLU, GLUT) are third party libraries, not covered by OpenGL.Correct. GLUT is a very minimal framework, so using something else is strongly recommended.
I think you refer to
gluOrtho2Dbut yes, you’re correct.glOrthois a true OpenGL-1 function. In some way,gluOrtho2Dis one of the most useless functions ever:Right again, but it’s actually quite simple:
Starting with OpenGL-3 core, the whole matrix manipulation stuff has been removed. In any serious application it’s of little use, since you’ll manage the matrices yourself anyway.
Yes this is possible and most game engines indeed do all the grunt work themself.
There is libSDL, which also covers OpenGL. Personally I prefer GLFW or doing the stuff myself, indeed. However this does not change the way one uses OpenGL itself. But this is just infrastructure, and it’s mostly just writing boilerplate code. As a beginner you gain only very little by not using an established framework. If your program makes heavy use of GUI widgets, then using Qt or GTK, with its embedded OpenGL widget is a reasonable choice.
However some projects are very hardcore, and implement the whole GUI with OpenGL, too. Blender is the most extreme example, and I love it.
GLUT callbacks are okay with namespaces (a namespace is just a C++ compilation time thing). But what’s not possible is passing class instance methods as GLUT/C callbacks.