Jump to content

  • Log In with Google      Sign In   
  • Create Account


Graphics card vendor OpenGL drivers: How do you create an OpenGL context?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 tom_mai78101   Members   -  Reputation: 568

Like
0Likes
Like

Posted 23 January 2014 - 06:34 AM

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.

Sponsor:

#2 RobTheBloke   Crossbones+   -  Reputation: 2325

Like
2Likes
Like

Posted 23 January 2014 - 06:41 AM

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?


Edited by RobTheBloke, 23 January 2014 - 06:42 AM.


#3 slicer4ever   Crossbones+   -  Reputation: 3416

Like
0Likes
Like

Posted 23 January 2014 - 07:11 AM

if you want a light-weight extension library, i'd recommend grabbing http://www.opengl.org/sdk/libs/GLee/ it's sole purpose is automatically finding all the appropriate GL function pointers, and does all the work without having to do anything but include it. note: that link claims all upto 3.0, but if you do a bit of googling, you can find a version that has everything upto 4.x. i forget where i found that, so i can't toss you a link.

Edited by slicer4ever, 23 January 2014 - 07:16 AM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#4 arka80   Members   -  Reputation: 742

Like
0Likes
Like

Posted 23 January 2014 - 07:50 AM

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).



#5 richardurich   Members   -  Reputation: 1187

Like
2Likes
Like

Posted 23 January 2014 - 08:31 AM

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.



#6 powly k   Members   -  Reputation: 645

Like
0Likes
Like

Posted 23 January 2014 - 02:38 PM

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.



#7 tom_mai78101   Members   -  Reputation: 568

Like
0Likes
Like

Posted 28 January 2014 - 05:32 AM


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.



#8 BitMaster   Crossbones+   -  Reputation: 3812

Like
2Likes
Like

Posted 28 January 2014 - 06:27 AM

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.

#9 tom_mai78101   Members   -  Reputation: 568

Like
0Likes
Like

Posted 29 January 2014 - 05:52 AM

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.

  1. Do I really have to create (or rather, copy) the list of typedefs in the tutorial?
  2. Can't I just link to some Nvidia LIB file located somewhere in the drivers folder?
  3. 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.



#10 BitMaster   Crossbones+   -  Reputation: 3812

Like
0Likes
Like

Posted 29 January 2014 - 06:08 AM

Do I really have to create (or rather, copy) the list of typedefs in the tutorial?

Yes.

Can't I just link to some Nvidia LIB file located somewhere in the drivers folder?

Nvidia has nothing to do with it. If such a lib existed, it would have to come from opengl.org to be any use.

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?

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.

I never thought that creating a simple OpenGL context need to have relied upon copy/pasting so many typedef in the header file.

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.
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.

#11 tom_mai78101   Members   -  Reputation: 568

Like
0Likes
Like

Posted 29 January 2014 - 06:54 AM

Awww that totally sucks...

 

GLEW it is then.


Edited by tom_mai78101, 29 January 2014 - 06:59 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS