• Advertisement
Sign in to follow this  

opengl initialization flow

This topic is 1494 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am building my first opengl app. I have been following the tutorials here http://www.rastertek.com/gl40tut03.html

I would like some explanation as to how the author know what calls to make next. Like what is the flow of initializing opengl?

 

looking at the InitializeExtensions method, he sets the devicecontext, then sets a pixel format and then creates a rendering context. So what decides what should be initialized before or after? is there a diagram where I can visualize as to what should be init first?

 

Thanks

Share this post


Link to post
Share on other sites
Advertisement

Where he got the information from was as he stated the documentation provided by the Khronos Group. You should be able to find it on opengl.org
As to what reason there is to an order. Some things rely on others to be built before hand. In other cases some of them can certainly be moved around and done at different times.
If you look at the function calls various items need to be passed to them. Example: you can't get the devicecontext with out the hwnd(handle to window) you can't get the renderContext without the device context. So the requirements for each of those in effect sets the order they are created.

In truth there are easier ways to create an opengl 4 program using SDL2.0 with opengl and glew is easier by far in my opinion having done both ways.

Using a simpler method would allow you more time to work on learning the API rather than dealing with the setup. Also using SDL2.0 will make it easier to go cross platforms if that is ever an interest.
 

Share this post


Link to post
Share on other sites

interesting, glew should be very useful! at first site, i was totally disgusted by putting all those typedefs and proc addresses in my project. I wished there was a simpler way so glew seems to be the way to go. What other benefits does one get from SDL2.0. It says it provides lowlevel access to the video buffer, audio output, mouse and keyboard. Isn't all that available in opengl? 

Share this post


Link to post
Share on other sites

everything to do with rendering is available in opengl - the benefit to SDL is that it also gives you input, sound, some file io, texture loading help, and other stuff.. opengl basically gives you access to functions that can manipulate the graphics card - you have to do everything else (or use other libraries to help - like loading images from file in to textures for example - I would definitely use some library to help with that)

 

if your going to be doing direct opengl calls then you should definitely be using GLEW or some such thing.. dont forget to initialize it before making any opengl calls

Edited by EarthBanana

Share this post


Link to post
Share on other sites

If you like low-level libraries, use SDL (it's C). If you like higher level libraries and object oriented stuff, use SFML (C++).

 

 

The only issue I can see that would override your preference above is smart phone/tablet support. SFML still shows iOS and Android support as "soon", so SDL is probably more mature and a safer bet if you're going to target smart phones and tablets.

Edited by richardurich

Share this post


Link to post
Share on other sites

My preference is SDL2.0 https://www.youtube.com/watch?v=UwpZOwT9nVc If you are using code::blocks this will tell you what you need to set it up with opengl3+ ->4+ and how to compile GLEW for it. Its easy enough my 12 year old son can do it.

If you are using Visual studio it is already compiled for it to start with. There majority of sites seem to cover visual studio. I chose code blocks because I can switch from Windows to Linux and my environment doesn't change. I've had no trouble compiling the programs from one OS to the other.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement