Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have been using the OpenGL ES on the iPhone for a while now and basically I feel pretty lost outside to the small set of commands I've seen in examples and adopted as my own. I would love to use OpenGL on other platforms and have a good understanding of it.

Every time I search for a book I find this HUGE bibles that seem uninteresting and very hard for a beginner. If I had a couple of weekends to spend on learning OpenGL what would be the best way to spend my time (and money)?

share|improve this question

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

closed as not constructive by Sean Middleditch, Trevor Powell, bummzack, Byte56, Josh Petrie Mar 28 '13 at 15:41

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

10  
I hate saying it, but the OpenGL Superbible or the OpenGL redbook are the best way to learn OpenGL. It's a complex subject, so the book needs to be large. –  Rachel Blum Jul 22 '10 at 18:23
4  
Is it accesible even for a newby? –  DFectuoso Jul 22 '10 at 19:49

15 Answers 15

up vote 30 down vote accepted

Be careful when you look at OpenGL tutorials, because many of them (NeHe) included just teach you things that you shouldn't do anymore. Todays OpenGL is a different beast that it was 10 years ago.

Some nice examples avoiding the deprecated stuff can be found here: http://www.g-truc.net/post-tech-content-sample.html

The OpenGL Samples Pack 4.0.1.0 is an update that brings the number of samples to a total of 58 samples; including 13 OpenGL 4 samples, 33 OpenGL 3.3 samples and 12 OpenGL 2 samples for Visual Studio 2008 and 2010 in 32 and 64 bits.

share|improve this answer
    
It's linking to a mountain! –  user14170 Jun 28 '13 at 14:59

http://www.opengl-tutorial.org/

Has tutorials for 'modern' OpenGL (3.0/4.0 core, e.g. no obsolete stuff (like glBegin/glEnd) is teached). Although the tutorials use shaders, the basics are explained in great detail, building a solid mathematical foundation along the way. The text is rounded out nicely with code* samples and helpfull visualisations.

Intermediate tutorials cover stuff like e.g. use of Quaternions or Lightmaps.

.* glm is used as a math library

share|improve this answer

There are many things you could learn from. Here's my thinking on each, from the perspective of someone new to OpenGL.

OpenGL Examples

There is plenty of example code out there that you can read. G-truc's examples are pretty extensive and cover a lot of advanced features.

However, if you are a beginner, learning from examples is a terrible way to learn. Reading code that you don't really understand will not teach you why it works. Indeed, the text on the above linked page specifically and rightly states that the examples are not for beginners.

Learning from bare source code, unless it is heavily commented (at which point it's a tutorial) is not an easy thing. Attempting to do so encourages cargo cult-style programming and copy-and-paste coding. It is very easy to convince yourself that you understand how something works when all you're really doing is just copying code from one place to another. You may be able to mix and match things, but true understanding is difficult to achieve without proper instructional material.

OpenGL Books

There are a fair number of actual purchasable books for OpenGL development. I'll cover my thoughts on the two biggest here.

OpenGL Redbook

This one is somewhat problematic from a purely practical standpoint. See, the 7th edition covers GL 3.0 and 3.1. Which is rather old. There have been a lot of useful features added to OpenGL since then, features which change how you would write things. And not all of them are hardware features.

The 8th edition is coming "soon", and will cover 4.1. There's no word on whether it covers old fixed-function stuff.

I'd say this book is OK. The biggest problem with it is the organization of information. It's more like a comprehensive reference manual than a book made for learning. Here's what I mean.

One of the most important things that one should do when teaching is to not overload the student with unimportant information. But the Redbook does exactly that. When introducing material, it introduces a lot of material. Much of it superfluous to the task at hand.

What you talk about and when you talk about it are crucial to making your book a good learning resource. The Redbook never holds back information until a more appropriate time. When it talks about how to draw triangles and primitives, it talks about everything about drawing them, all at once. It covers every option, every function, every parameter, etc.

That's just not a good organization of information.

OpenGL Superbible

The fifth edition of this book covers only core GL 3.x, so no fixed-function.

However, the general organization of the book is more or less identical to the organization of the fourth edition version. This seems impossible since the 4th edition used fixed-function and didn't introduce shaders until much later.

The way this was accomplished is my #1 complaint about the book. Essentially, the author built a library that implements a form of fixed-function OpenGL. It wraps VAOs, buffer objects, shaders, and various other things, so that he can get to drawing objects, matrix math, and textures without having to talk about things like how the GL pipeline works in detail.

By hiding all of these details, it makes the material easier to digest. But you will often see people walking away from the Superbible without knowing how to actually function without the library. They don't really understand how shaders connect to buffer objects, how data flows up the pipeline, etc.

It is a serviceable book, moreso than the Redbook. If all else fails, it will do the job. But I think it could be better.

Also, according to some reviewers, it seems to miss out on certain useful information, like packing attribute data using normalized values and such.

OpenGL Online Materials

There are many online materials that one could learn from.

NeHe's Tutorials

NeHe's tutorials, as others have stated, are extremely out of date. They focus on fixed-function OpenGL. It is often stated that it is easy to learn fixed-function GL, which is true. But that doesn't make it a good idea.

Understanding how the fixed-function pipeline truly works is hard. I would go so far as to say that it's harder than learning shaders. Once you get it, shaders are simple. Understanding the intricacies of texture environment stuff, combiners and whatnot, is very tricky and requires frequent visits to reference docs to make sure everything is set up right. Even if you understand everything correctly, it's easy to make a small mistake that causes everything to break.

The difference is that you can make fixed-function work without understanding it. This encourages cargo cult programming. It makes it possible to get something on the screen without really knowing what one is doing. Over on the OpenGL.org forums, we see questions constantly about minutiae surrounding fixed-function, from people not knowing how gluLookAt works, to difficulties with lighting, to people trying to get some particular effect to work with the texture environment.

So no, I do not think NeHe is a good way to learn OpenGL.

The above commentary can be used for any non-shader based tutorial, like Swiftless, Lighthouse, and so forth.

Wikibook's OpenGL Programming

The Wikibook OpenGL Programming is probably the modern equivalent to NeHe. It covers GL version 2.1, because they want to keep it relevant to mobile platforms. If that's important to you, then by all means look here.

The other issue with NeHe, and thus this Wikibook, is the large focus on source code. The text to code ratio is very small; there is a lot of code, but the text doesn't really explain how it all works.

As an example, look at the bottom of Tutorial 2. It introduces blending. It doesn't say how blending works. It doesn't say what glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) actually means or does. It just says, "Here's some code that makes things transparent."

That's not the best learning environment.

Incomplete Tutorials

Swiftless has a set of OpenGL 4.x tutorials. Durian Software also has some shader-based OpenGL tutorials. And there's the "OpenGLBook.com" tutorials.

The thing these all have in common are... that they're incomplete and abandoned. They all got about 4-5 tutorials in, and then were dropped. None of them reached texturing, lighting, or anything like that. Well, Durian did hit texturing but not lighting.

Much can be gleemed from them, but there is much that is missing as well.

Shameless Self-Promotion

Reviewing my own Modern 3D Graphics tutorials would be a horrible conflict of interest. So instead, I'll hold forth at length about the organization behind them and why I think they're good.

Oh and yes, I am working on Tutorial 17. The project's not dead.

The first three chapters are really about learning how the OpenGL pipeline works. The Superbible failed because it tried to hide details. Instead, I attempt to explain those details really, really well. Repeatedly. The introduction explains the pipeline in plain text. The first tutorial explains it with code accompaniment. And the second tutorial visits it even more.

From there, I naturally move on to positioning objects. This introduces uniforms, but I didn't want to jam uniforms and perspective projection in at the same time. So I separated the two concepts. After projection, depth buffering seemed a reasonable next step, followed by how transforms and matrices work. After that, cameras. Rotation with quaternions was a late addition, but I feel that it was an important thing to talk about for the budding graphics programmer.

The lighting tutorials again build one on the other. Diffuse, then per-fragment lighting, then specular. Dynamic range was an interesting choice. Most introductory material tries to stay away from that, but I embrace it. You're not a graphics programmer these days if you think light intensity always is on the range [0, 1]. And you're not a graphics programmer these days if you don't know how to maintain a linear color pipeline.

The final one in lighting, on imposters, was a weird one. I try to design tutorials that solve problems rather than just show some OpenGL functions, particularly as the book goes on. So much of my tutorial design comes from finding ways to talk about certain topics while still making them real issues and not obvious, "we're learning X now." Geometry shaders are a hard one, because they don't really solve very many problems.

Imposters represented a problem that GS's were actually useful for solving. Also, it allowed me to talk about other less used things like discard and changing a fragment's depth. And it really shows the power of shaders: you can make a flat square become a sphere.

The texturing tutorials are also interesting. One of the reasons I put off talking about diffuse color textures until the third one was to hold off on talking about sRGB textures for a while. This way, I could talk about the basic issues around textures (loading data, putting them in shaders, filtering, clamping, etc) without having to deal with linear issues. So then I could spend a whole tutorial on just that topic. That allowed me to really, really emphasize how important maintaining a linear color pipeline is.

It's one of my pet-peeves.

share|improve this answer
    
I've just started reading your book / source code, and it's incredible.. thank you so much for releasing this for free! –  Alex Coplan Aug 6 '12 at 21:30
    
Though I am a telecom guy, was simply giving a try to your tutorials. And they are really nice for a newbie. The only thing is that, unofficial opengl sdk is not properly buildable with Ubuntu12.04 + Eclipse. Is there any way, by which we can directly install it ?(like we do for GL, GLEW, GLU, glut etc.) –  iammilind Sep 21 '12 at 6:12
    
@iammilind: "is not properly buildable" How does the build fail? Also, there's no "installing"; that's half the point. It's a copy/premake/and run mechanism without any system installations, dependencies, PPMs, or any number of other things that I don't understand or have any idea how to use in Linux. You put it where you want, not where your system thinks it should go. –  Nicol Bolas Sep 21 '12 at 6:59
    
In Ubuntu, unfortunately the build process fails at preamake stage itself :( ... It will be of great help, if in your spare time you can try to execute your code tutorials with Ubuntu + Eclipse. For now, the other way I am following is to use the reading material you provided and relating that to some other code tutorials. The reason is that I have seen "arcsynthesis" the best place to on web till now for newbie OpenGL learning. –  iammilind Sep 21 '12 at 8:12
    
@iammilind: I noticed that you didn't file a bug report. How do you expect these things to get fixed without one? –  Nicol Bolas Sep 21 '12 at 14:36

Just note the best way to learn OpenGL is task oriented. Try to do something (like add a feature to your game) then look up what is required to do that.

Manuals and tutorials are really boring without a greater context - ie something beyond the tutorial that you want to achieve on your own.

share|improve this answer

Here is another one. Its very good. Though it has only 4 chapters.

http://openglbook.com/

Another one is, http://www.arcsynthesis.org/gltut/. This one is huge, slow and high profile.

Don't forget to track the http://www.opengl.org/wiki/Getting_started

share|improve this answer

I wouldn't say this video tutorial series is the best way, but it is very well explained: www.71squared.com/2009/03/iphone-game-programming-tutorial-1

share|improve this answer

Well no one talked about the OpenGL Programming Guide, I don't have this particular edition but older ones was pretty good.

share|improve this answer
1  
Tell me more about it, please. I wonder how this is better/different from the super bible and if it is worth the time worth reading such big books(no offense but if it takes 20+ hours to read a book i want to be sure it is worth it =) ) –  DFectuoso Jul 23 '10 at 0:48

We do some OpenGL(ES) in our Orchard's Craps game for the iPhone but it was handled by a programmer with mad 3D skillz. So, because of this I've been learning OpenGL(ES) so that I know what I'm talking about and so that I can code along with the team.

One site I found helpful, with a series of tutorials, is Jeff LaMarche's blog: http://iphonedevelopment.blogspot.com and here is a link for his OpenGL posts: http://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-ground-up-table-of.html

And from OpenGL.org there are these two links that are useful: http://www.opengl.org/code/ and http://www.opengl.org/resources/features/

The best way, was stated above several time. Jump in and do something small, that's interesting, and work your way up. It's all about understand the scene, the camera and materials (shaders). Once you get your head around these concepts you can start to look at physics engines, collision detection, particle effects and the like. Woot! (^_^)

Good luck with all of your endeavors, Kevin

share|improve this answer

My only book on OpenGL is "OpenGL SuperBible, 4th edition" and 5th is about to be released in a few weeks. I think it's good for both beginners and advanced programmers.

Edit: I might add don't go for the latest technology trends if you're just learning to program. Chances are once you become an expert using one methology, 5 new interfaces / versions just released. We've seen shaders advance every 3 months, it seems. So pick what has the best documentation (generally primitives), make a few programs, and gradually advance because more than likely you'll bump into older code in the future. Hope it helps!

share|improve this answer
    
I'm going through the superbible now and it's really good for people who don't have a graphics background as it explains all the concepts as you go along. –  Spidey Jan 18 '11 at 11:16

I would recomend starting with this tutorial series, they are good and use more modern features than the nehe ones http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html

share|improve this answer

Start with NeHe to quickly get your first triangle on the screen. Do a few of the beginner tutorials there to understand the basic concepts of 3D programming. If, as you imply, mentioning OpenGL ES, you already know the basics of 3D programming (what are matrices, what they're used for, how different matrices are used to project vertices on the screen, what vertices are, etc.), then I suggest you don't waste time with NeHe at all, because it might slow you down (by teaching you things you have to "unlearn" later on).

Apart from that, I agree that the best way to learn it is by doing. A good first non-hello-world project might be a 2D game (or a 2D game engine). Using modern OpenGL for 2D applications can teach you a lot of the relevant concepts (buffer and shader use, for example), and it will be less daunting than a 3D project. Then, afterwards, you can apply what you've learned in doing a 3D application.

share|improve this answer
    
NeHe is outdated. Also, although art creation is easier and you're mostly dealing with textured quads, there are a lot of corner cases (e.g. vector cross product) which make writing a 2D game before writing a 3D game more difficult. Games with 3D graphics but 2D gameplay (e.g. Pong, Breakout, ...) might be easier than pure 2D/3D games though. –  sarahm Mar 23 '13 at 19:43

I learned opengl by writing a "simple" game: 3D Tetris!

Try creating your own simple game/app:

  • Asteroids
  • Pong
  • Simple side scroller (you could learn to load in models for the player/enemies. Don't have any? Use Quake models)
  • 3d terrain generator

Do something simple that interests you!

share|improve this answer

As usual the best way to learn is to do it. I would hold off on spending money unless you feel you really benefit from having a textbook to read from, most (if not all) information can be found online. On top of learning OpenGL you may want to brush up on your Linear Algebra as well, it never hurts.

The big issue I faced is a lot of stuff that's out there has been depricated in recent version of OpenGL.

The best resource I've been able to find has been at Joe's Blog. It does it's best to introduce the modern pipeline and get you through some examples in a more readable fashion than what I've been able to find elsewhere. It seems Nehe has been getting a couple updated recently and while their lessons are still old, some of the news may be of interest. Lazy Foo' was also a great resource, but like Nehe it's tutorials use depricated material.

I think after a weekend or 2, once you get comfortable go off and do a small project to apply everything. Breakout, or tetris - something where you can concentrate on the code itself. You learn so much more when you go off and try to do an actual project, regardless of how simple.

share|improve this answer

The best way to learn OpenGL is to use it. I would recommend writing your own engine. This may seem like a daunting task, and it is. Your first engine won't be very good, but you'll have learned a lot.

Basically: write an engine, use it for a game, figure out what you don't like about it and rewrite it. Keep doing that and you'll get better at OpenGL. :)

What you will need:

  • Some way to load models (.obj)
  • Some way to load textures
  • Lighting, either in the fixed function pipeline or in a shader
  • For any slightly more complex scenes than a teapot on the screen, a scene graph
  • Lots of tiny tools (3d vector class, quaternion class, camera class, scene manager, etc)

This is already a lot of work.

share|improve this answer
    
Could you point me to any documentation on the basic architecture or components that a "first engine" should have? This might actually seem like a good way to get my hands dirty with open gl... –  DFectuoso Jul 22 '10 at 7:50
    
gamedev.net/reference/list.asp?categoryid=45#200 Article "Enginuity". –  egon Jul 22 '10 at 9:10
4  
-1 Writing engines as a way to get into gamedev isn't much good. You don't know what to put into the engine, for example. scientificninja.com/blog/write-games-not-engines –  The Communist Duck Nov 2 '10 at 17:34
    
@TheCommunistDuck SADLY, scientificninja is no more. web.archive link –  bobobobo Mar 23 '13 at 20:29

Well I have been told over and over that nehe's tutorials are the best, I guess they'll fit for you too ! http://nehe.gamedev.net/ I bought the red book...

share|improve this answer
    
This seem like a fun set of small chunks from zero to a great place, thanks! –  DFectuoso Jul 22 '10 at 7:50
2  
I have to strongly disagree. Yes, NeHe tutorials have been there for a long time, but they have never had a very good style and they are quite outdated by now. –  Andreas Jul 22 '10 at 14:35
8  
-1 Nehe is much too out-of-date. –  Axel Gneiting Jul 22 '10 at 15:51
7  
-1. Learned all sorts of bad stuff from nehe! –  Gabriel Isenberg Jul 23 '10 at 0:35
    
-1. NeHe should label its tutorials as obsolete and outdated. –  iamcreasy Jan 15 '12 at 11:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.