This is a broader question, so I'll narrow it down. From online tutorials, I've pieced together that SDL has a library called SDL_opengl that helps with openGL loading. However, it doesn't seem to actually contain openGL itself. But I might be wrong.
What does SDL_opengl do? Why would I include it over GLEW or platform-specific GL implementations?
After working with it for a while, it seems like SDL_opengl is just a replacement for the older GL/gl.h libraries.
Related
Why do I need both the libopengl32.dll and the libglew32 libraries when compiling an OpenGL program? What's the difference between the libraries and why do I need both?
You do not (always) need both the libopengl32.dll and the libglew32 libraries when compiling an OpenGL program. You need both when compiling a GLEW program (which implies also being an OpenGL program since GLEW builds upon OpenGL). For some people, this difference is academic since they would never consider writing an OpenGL program without the convenience of GLEW (et al.). However, GLEW is not required by OpenGL.
Your OpenGL library is the base upon which your GLEW library depends. You can use OpenGL without GLEW, but you cannot use GLEW without OpenGL. If your program uses GLEW, then you need to link your GLEW library because you are using it, and you need to link your OpenGL library because GLEW (and probably your code as well) uses that. If you are using pure OpenGL with no elements of GLEW, you need just to link your OpenGL library.
Following this tutorial I was trying to manage my OpenGL buffers for an OpenGL context I created using SFML, under a visual studio environment. I installed SFML and Glew in their latest versions, did correct linking, and I am able to work with primitives like OpenGL glClear, glBegin and glVertext3d.
However there is plenty of other OpenGL functions that I can t seem to be able to call like glEnableVertexAttribArray or glBindBuffer and I would like to understand why. I noticed that the default OpenGL version set by SFML context is 4.6 but I can t find proper documentation for these functions on khronos website for this version. Moreover my visual studio doesn t even recognize theses functions as part of any library but I might have missed some includes given that I rely on SFML/OpenGL.hpp. Documentation on SFML side is very ligth on this subject...
Thanks !
I am able to work with primitives like OpenGL glClear, glBegin and glVertext3d. However there is plenty of other OpenGL functions that I can t seem to be able to call like glEnableVertexAttribArray or glBindBuffer and I would like to understand why.
The reason for this is that the opengl32 library on windows only provides OpenGL 1.1 functionality, everything else is brought in by your graphics card driver. To actually access these functions, windows provides a function to load them. However, writing all the declarations and loading all functions is a lot of work (See Load OpenGL Functions in the OpenGL Wiki) so libraries exist which do this for you, one such library is glew, "The OpenGL Extension Wrangler Library". After you created your OpenGL context (which SFML does), you must call glewInit() which then loads all the other functions. The declarations for those functions are also provided by glew, so make sure to include the glew header instead of your systems or SFMLs opengl header.
I am learning OpenGL with the help of tutorials found online. Many of them use GLUT library, even though it is generally recommended to use freeglut instead. How will replacing GLUT header file with freeglut header affect the compilation ? Is such a simple replacement possible ? Are there many differences in terms of syntax, function names and usage ?
As mentioned by Andon, replacing the header will do next to nothing. The FreeGLUT about page has a good description of the what and why (http://freeglut.sourceforge.net/index.php).
Why not to use GLUT, from the above link:
The original GLUT library seems to have been abandoned with the most
recent version (3.7) dating back to August 1998. Its license does not
allow anyone to distribute modified library code. This would be OK, if
not for the fact that GLUT is getting old and really needs
improvement. Also, GLUT's license is incompatible with some software
distributions (e.g., XFree86).
As for the syntax and function names, if your code currently compiles fine with GLUT, it should compile fine with FreeGLUT. You may need to tell the compiler to use/link against FreeGLUT instead of GLUT (and where to find it).
A quick Google search produced this result (using FreeGLUT), might be useful... http://peon-developments.blogspot.com.au/2011/04/creating-opengl-window-with-freeglut-in.html
I could only find gl/gl.h and gl/glu.h in my VC++. How to get GLFW and GLEW and GLUT?
And why do we include GLEW, GLFW and GLUT? Which library is must and why?
The difference between them is here:
Post in StackOverflow about the differences
And you have to download and install them as they tell in their official website and documentation. But first differenciate between them and choose the one that helps you out.
I can't seem to find where GL_UNSIGNED_INT_8_8_8_8_REV is defined. Googling around, I only seem to find places where it had been defined manually:
#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
It doesn't appear to be in gl/GL.h or gl/GLU.h or even anywhere in Windows.h.
Windows ships with an outdated version of <gl/GL.h> (the Windows version of this file was obsolete back in 1998, as of 2013 it still hasn't been updated). You will need to use something like GLEW to get access to modern OpenGL features on Windows. This will provide a complete OpenGL header, as well as a library to automatically detect OpenGL extensions.