Graphics card vendor OpenGL drivers: How do you create an OpenGL context?
I am using Nvidia Geforce 640, but I am assuming that I may want to learn about creating OpenGL context on AMD and Intel. I do know that Geforce 6XX supports OpenGL 4.4, according to the Nvidia specs.
On the Nvidia site, I see that they provided the OpenGL 4.4 specs and driver, along with the latest include header files. But they don't provide any info on what default OpenGL context they meant for my programs to use GL 4.4, let alone anything above GL 1.1.
I do have a few questions:
1. Calling the default OpenGL context automatically tells the graphic card driver to instantiate an OpenGL context that supports from 1.2 and up?
2. If I were to use a library that supports OpenGL context creation, such as SDL, how would I create an OpenGL context from the library that supports OpenGL 1.2 all the way to OpenGL 4.4 (in this case, from SDL itself)?
3. How do I create an OpenGL context that supports 1.2 and up, without relying on extensions such as FreeGLUT and GLEW? This is for learning purposes and understanding the fundamental C++ and C implementations, not for game development.
4. As above per #3, where can I view an example code?
Thanks in advance.
1. yes.
2. Done for you.
3. See this, then manually extract each of the function pointers for GL4.4 by using wglGetProcAddress (which is what glew does for you)
4. Look at the source code for glew?
You have to use glew.
It's a simple to use library. Just include and link and use #include<gl/glew.h> instead of traditional #include <gl/gl.h>, and the lib will do the magic for you, so that you can simply write glGenBuffers (for example).
I am looking for a guide on implementing OpenGL with versions larger than what Visual Studios has provided. In Visual Studios, you get OpenGL 1.1.
I am using Nvidia Geforce 640, but I am assuming that I may want to learn about creating OpenGL context on AMD and Intel. I do know that Geforce 6XX supports OpenGL 4.4, according to the Nvidia specs.
On the Nvidia site, I see that they provided the OpenGL 4.4 specs and driver, along with the latest include header files. But they don't provide any info on what default OpenGL context they meant for my programs to use GL 4.4, let alone anything above GL 1.1.
I do have a few questions:
1. Calling the default OpenGL context automatically tells the graphic card driver to instantiate an OpenGL context that supports from 1.2 and up?
2. If I were to use a library that supports OpenGL context creation, such as SDL, how would I create an OpenGL context from the library that supports OpenGL 1.2 all the way to OpenGL 4.4 (in this case, from SDL itself)?
3. How do I create an OpenGL context that supports 1.2 and up, without relying on extensions such as FreeGLUT and GLEW? This is for learning purposes and understanding the fundamental C++ and C implementations, not for game development.
4. As above per #3, where can I view an example code?
Thanks in advance.
1. No clue what the default behavior is. You should explicitly state the version you want your code to use. The way to do this varies depending on what you're using. See (2) for SDL approach.
2. For SDL:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); //COMPATIBILITY instead of CORE if you really, really want to use old versions (you probably don't!)
You do that after SDL_Init() and before SDL_GL_CreateContext().
3. http://www.opengl.org/wiki/OpenGL_Loading_Library lists various options (including glew). You could also hand-code each call individually. I think the Rastertek tutorials take that approach. It's an incredible waste of time to do it that way though, especially if you ever have to track down a typo.
4. Rastertek tutorials show the manual approach (linked in 3). glew and equivalents have the headers to view.
For 1: the default context is a compatibility profile, it should let you mix up any and all OpenGL extensions and versions your graphics card supports. This often makes writing it less nice; I'd recommend to stick to either the core 3.3 or 4.3 profiles, depending on what hardware you have. That way you'll have way less driver dependent behaviour to debug.
You could also hand-code each call individually. I think the Rastertek tutorials take that approach. It's an incredible waste of time to do it that way though, especially if you ever have to track down a typo.
It's exactly relevant to my learning purposes. I would rather waste my time learning these during my retirement and not having to use the libraries and still not knowing how to do them before I die.
For 1: the default context is a compatibility profile, it should let you mix up any and all OpenGL extensions and versions your graphics card supports. This often makes writing it less nice; I'd recommend to stick to either the core 3.3 or 4.3 profiles, depending on what hardware you have. That way you'll have way less driver dependent behaviour to debug.
Duly noted.
You could also hand-code each call individually. I think the Rastertek tutorials take that approach. It's an incredible waste of time to do it that way though, especially if you ever have to track down a typo.
It's exactly relevant to my learning purposes. I would rather waste my time learning these during my retirement and not having to use the libraries and still not knowing how to do them before I die.
If you want to know 'how it works', you should do it by querying exactly one function by hand. Querying one or querying thousands makes no difference. The concept is always the same. It's just tedious, lengthy and error-prone without gaining even a teeny tiny bit more knowledge.
If you wanted something slightly more interesting, you could write a tool which parses an input glext.h header and produces the querying code automatically, as it is done in GLEW.
Personally, I would not do either because there are so many interesting problems with far more learning opportunities around.
Thanks for sharing your thoughts.
But I have encountered something anew. I have been following RasterTek's tutorial on OpenGL 4.0 up to Lesson 3, just after where I used #pragma to link to opengl32.lib. After that, I get confused as to how to get OpenGL 1.2 and above inside my header file.
- Do I really have to create (or rather, copy) the list of typedefs in the tutorial?
- Can't I just link to some Nvidia LIB file located somewhere in the drivers folder?
- Do I also have to include the latest include header file from Nvidia's Developers Site in order to unlock OpenGL 1.2 and up?
I never thought that creating a simple OpenGL context need to have relied upon copy/pasting so many typedef in the header file.
Yes.Do I really have to create (or rather, copy) the list of typedefs in the tutorial?
Nvidia has nothing to do with it. If such a lib existed, it would have to come from opengl.org to be any use.Can't I just link to some Nvidia LIB file located somewhere in the drivers folder?
Again, this has nothing to do with Nvidia. You would need a header file/extension description which contains the feature you are interested in. You do not need the latest whatever.Do I also have to include the latest include header file from Nvidia's Developers Site in order to unlock OpenGL 1.2 and up?
This is purely a Windows problem. Microsoft requires all OpenGL implementation to stick to OpenGL 1.1. Anything above that has to be queried by the extension mechanism.I never thought that creating a simple OpenGL context need to have relied upon copy/pasting so many typedef in the header file.
Exactly because that is a lot of boring work with a high potential for errors, libraries like GLEW exist. GLEW is a very simple library with a very permissive license.