Advertisement

Help me to clear up my confusion about OpenGL

Started by July 15, 2015 08:02 AM
11 comments, last by jpetrie 9 years, 5 months ago

Hi folks,

I tried to get into OpenGL a couple of times now. Everything was clear while I was working in immediate mode. Well I also did understand how vbo's and voa's work. The problem is I find most of the tutorials on the web incoherent. For example a lot of them use functionality which they describe as deprecated. Plus it seems that every tutorial is using different libraries. There are:

  • GLUT
  • FreeGlut
  • GLU
  • GLFW

So I am pretty confused. My goals are:

  1. Rendering in retained mode
  2. loading and using shaders
  3. loading + displaying meshes created with Blender (or something similar).

Maybe at some point I want to process some user input but this is not my main goal. So I generally have two questions:

  1. What are the libraries I need to achive goals 1 + 2? And can someone point me to a tutorial where loading and using shaders is explained well. Please no NeHe, I am getting confused by those tutorials.
  2. What about Vulkan? Is it worth learning OpenGL right now? When is Vulkan coming out? Will it differ much from OpenGL? I read that it will be even more low level than OpenGL? Or would it be smarter to wait for it instead of deep diving into OpenGL right now?

I would love to learn graphics programming but I do not want it to be DirectX, so I would be very thankful if you give me some advice.

Regards

P.S.: If I get it right OpenGL applications can be implemented in both C and C++, what should be my choice here? I have a feeling that most of the tutorials are in C++? What are the pros and cons here?

1: learnopengl.com


What about Vulkan? Is it worth learning OpenGL right now? When is Vulkan coming out? Will it differ much from OpenGL? I read that it will be even more low level than OpenGL? Or would it be smarter to wait for it instead of deep diving into OpenGL right now?

Vulkan is an enanchment of opengl, if you don't have a solid base about opengl, vulkan will be an hard try....

So, deep driverolleyes.gif

Advertisement

It's difficult to recommend you NeHe tutorials, because they don't use shaders, except one lesson smile.png So, don't worry about that smile.png GLUT is the library for studying OpenGL, and as far as I know, it is not recommeded to use in serious applications. FreeGLUT is probably also a little bit deprecated. GLU is the library with some functions that can be written with just standart GL. So, it's helpful when you study OpenGL, but not necessarily too. To create window and initialize OpenGL you probably should use GLFW or API methods of your OS, if you prefer low-level programming smile.png SDL is also a popular library

GLUT
FreeGlut
GLU
GLFW
  • GLUT: Creates a window and context, and invokes callbacks from an event loop. About 20 years old, unmaintained. Somewhat "funny" half-free-proprietary license (no fee for distribution).
  • FreeGLUT: Same as GLUT, but a complete rewrite that is actively maintained. Not 100% compatible/identical (very similar, but some things are different). X/MIT license.
  • GLU: Holds some utility functions as well as software NURBS/tesselation code. Useless to almost everybody nowadays.
  • GLFW: Framework like GLUT or FreeGLUT, but more modern. No compatibility to GLUT whatsoever. Also has extra stuff like joystick support (and I believe threading/sound).

You did not list GLEW (not to be confused with GLFW). Used to load functions beyond OpenGL 1.2, needed for practically everything.

What are the libraries I need to achive goals 1 + 2 (retained mode + loading and using shaders)

GLEW, unless you want to do the function loading by hand (no, you don't want to do that). That's what you need. GLFW or FreeGLUT or GLFW is something you might want to use for the sake of simplicity.

What about Vulkan? Is it worth learning OpenGL right now?

It is worth learning OpenGL now, unless you already know that you will delay your project for another 2 years.

When is Vulkan coming out? Will it differ much from OpenGL?

To date, these are questions nobody can answer. So far, a lot of nice presentations and a lot of marketing talk is publicly available, but no concrete specification, no release date for a specification, or a timeline for implementation by major IHVs.

It appears as if Vulkan will be based on Mantle, with some (minor?) modifications. The sales pitch is that everything is great and everything is much better and blah, but nothing specific is publicly known at this time, nor whether any details that have been published will change.

The specification is anticipated later this year (2nd week of august is likely), but you cannot know for sure until it has happened. The spec can be finalized tomorrow or in 3 years. Or never.


What are the libraries I need to achive goals 1 + 2? And can someone point me to a tutorial where loading and using shaders is explained well. Please no NeHe, I am getting confused by those tutorials.

You do not need any of those libraries. Nonetheless, they may make your life easier.

GLUT, FreeGLUT, and GLFW are libraries that abstract away the part where OpenGL touches the operation system. This part is not a component of OpenGL itself. If you deal with pixel formats, window handles, and input events directly in terms of your OS of choice, then you do not need them. Such libraries are neat in case that you want to go cross platform. IMO from those three you should go with GLFW (AFAIK GLUT is obsolete anyway).

Another library is GLEW that supports you in working with OpenGL extensions. This library is not necessary for the first steps (EDIT: Seems that for Windows this library is usefulin any case /EDIT). It is mostly meaningful in case that you want to write programs that should run on many platforms where some functionality may or may not be available from extensions instead of the core of OpenGL.

Another library is glm with provides vector and matrix math for OpenGL. It is obviously useful because with the go away of the matrix stack you need to do the math yourself.


What about Vulkan? Is it worth learning OpenGL right now? When is Vulkan coming out? Will it differ much from OpenGL? I read that it will be even more low level than OpenGL? Or would it be smarter to wait for it instead of deep diving into OpenGL right now?

There is an evolution from OpenGL 2.x over 3.x and 4.x up to Vulkan: Things got more and more compacted and closer to how the hardware works. People who know this evolution will probably understand Vulkan quickly. But I assume that jumping from immediate mode to Vulkan is a bit difficult. I would suggest that you start with OpenGL 4.x especially if you want to start just now.


If I get it right OpenGL applications can be implemented in both C and C++, what should be my choice here? I have a feeling that most of the tutorials are in C++? What are the pros and cons here?

OpenGL for C/C++ is a C API, so both are possible. You can also use Java or any of the various other language bindings that exist. However, the libraries you may want to use can perhaps demand for a language, like glm is a C++ library. So I suggest to use C++ from this variety.

Thank you for your awnsers, so my lessons learned here are:

  • in order to reach my main goals I will need to use GLEW and GLFW and GLM for math
  • C++ should be language of choice
  • Deep dive into OpenGL might make life easier when learning Vulkan
  • Vulkan is nothing to rely on yet

Also I liked the link posted by Revan1985 those tutorials are also using GLEW and GLFW. So thanks a lot guys!

Advertisement

Christophe Riccio's samples are a good source of good and modern OpenGL practices (Riccio's samples are often used by OpenGL driver teams to check their implementations, if your code resembles his', there's a high chance you will be free from bugs. Plus, if there's a driver bug and it can be easly repro'd in his samples, report it and the driver teams will often fix it in no-time).

The samples from OpenGL Superbible are also good.

apitest is an absolute must-see for bleeding edge, high performance OpenGL features & practices. The mindset of AZDO rendering with explicit synchronization will prepare your thinking-process you will apply in Vulkan.

Or just use Direct3D. And then you get better documentation and _far_ better debugging tools for the inevitable situations you'll run into when you try to draw something but get garbled or entirely missing output.

I always recommend that new graphics programmers start with D3D and then port that knowledge over to GL afterwards. You'll learn quicker and you'll end up being a stronger graphics developer.

p.s. there's no such thing as "retained mode." The so-called OpenGL "immediate API" confuses people on this topic. All drawing in GL and D3D is immediate mode drawing. Retained mode is when the API "retains" the commands, e.g. a scene graph API. Also, you don't want the old GL APIs anyway; the fact that those even still exist in GL is one of the many reasons I recommend people to start with D3D (there's no confusion about which of 10 different ways you should do something). If you want easy helper APIs, D3D has those in DirectXTK in the form of PrimitiveBatch.

Sean Middleditch – Game Systems Engineer – Join my team!


I would love to learn graphics programming but I do not want it to be DirectX

Why is this? I don't ask to open up a flame war, but out of interest in your reasoning. If your goal is as broad as learning rendering, shaders and meshes, it would be unwise to eliminate a well-documented technology with plenty of available tutorials and samples without serious consideration.

I started a thread about this not that long ago.

http://www.gamedev.net/topic/667482-modern-opengl-tutorials/

And don't get discouraged. OpenGL is one of those software things you hear about and think "Wow, this must be a really amazing library because everyone is using it." Then you find out that it is really difficult, you have to do everything yourself, fight with driver and platform bugs, inconsistencies, and undocumented behaviors.

But when you get the hang of it, it is wonderful.

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

This topic is closed to new replies.

Advertisement