opengl initialization flow

Started by
5 comments, last by reenigne 10 years, 4 months ago

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

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.

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?

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

I also ran into SFML (http://www.sfml-dev.org/documentation/2.1/) it seems to be doing the same function as SDL. What do you guys think of SFML?

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.

My preference is SDL2.0

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.

This topic is closed to new replies.

Advertisement