Over the course of the last few months, I have received numerous emails and bug reports from people trying to compile the sample code as C++ code. So many, in fact, that I’m starting to think that the site may actually benefit from C++ code samples instead of C code samples.
To get a good idea of the consensus of C++ vs C in this case, I’ve opened up a little poll. Please take a second or so to select an option from the list and vote, I’d really like to hear your opinion on this. Also, if you have a comment on this, please post it as well.
If you’re getting the message Unable to create OpenGL 4.0 context (flags m, profile n) when creating your context (where m and n are numbers) your hardware does not support OpenGL 4.0.
Sadly, this is not something you can fix without upgrading your hardware. As mentioned in the Preface, the minimum graphics hardware you need for an OpenGL 4.0 context is:
If you own an NVIDIA GPU, it must at least be in the Fermi family of products, starting with the GeForce GTX 400 series.
If you own an AMD/ATI GPU, it must at least be in the Radeon HD 5000 series.
It is possible to run many of the samples using OpenGL 3.3 by using the code files found in the “OpenGL 3.3″ directories of each chapters’ source code listings. However, OpenGL 4.0+ core features will not work in OpenGL 3.3.
This post walks you through setting up OpenGL, GLEW, and FreeGLUT support in Visual C++ in order to compile the samples properly. My original thought was to put this in an appendix after all of the chapters were completed, but there’s need for it now, so here’s the extremely verbose step-by-step explanation:
After contacting OpenGL bug-basher extraordinaire Christophe Riccio (who runs a great site at G-Truc.net), he informed me that the only way to get this to work on AMD is to assign location 0, meaning that the following works:
layout(location=18) in vec4 in_Position;
layout(location=0) in vec4 in_Color;
So keep in mind when writing your programs to always occupy location 0 for something.
After a few requests for the Visual Studio Solution, I’ve moved the source code over from my self-hosted solution to a Google Project Hosting solution. In the process, I’ve also Open Sourced the source code (not the chapters or the site, just the code) under the MIT license, a very permissive Open Source license that allows you to use the code for any purpose you want.
The project itself is a Visual Studio 2010 solution containing individual projects for each of the chapters. If you have Subversion, you can check out the entire project, or if you’d like to view the files in your browser, you can do so here much better than I could implement on this site. Note that even though the project is a Visual Studio solution, the source can be compiled on many platforms.
It’s been a little while since the last update, but work on Chapter 4 is finally reaching a conclusion. In this chapter, we’ll make our first steps into the third dimension and introduce a bit of required mathematics.
If you haven’t read the previous chapters yet, I highly recommend you doing so before continuing with this chapter since you’ll need to understand all of the previous concepts.
Keep an eye out for this chapter in the near future!
In an effort to minimize the amount of bugs introduced, I am looking for someone to review the chapters and code before I release them into the wild.
This person needs to be an experienced OpenGL programmer who’s no stranger to modern OpenGL (3.0+) concepts and techniques.
Please note that since OpenGLBook.com is a free resource there is little to none in terms of monetary compensation, but I’m willing to negotiate any terms or suggestions you may have (credits etc.?). Let me know if you’re interested or if you have any questions by shooting me an email at: firstname.lastname@example.org