I am trying to learn how to program in opengl and am using this tutorial. Tutorial 1 works fine, tutorial 2 crashes with return 1.
It fails on this:
GLu
After reading this thread it appears that calling
glewExperimental = GL_TRUE;
glewInit();
Would fix the problem. Reading up on glewExperiemental here, it says that
GLEW obtains information on the supported extensions from the graphics driver. Experimental or pre-release drivers, however, might not report every available extension through the standard mechanism, in which case GLEW will report it unsupported. To circumvent this situation, the glewExperimental global switch can be turned on by setting it to GL_TRUE before calling glewInit(), which ensures that all extensions with valid entry points will be exposed.
I'm not too sure how that helps with glGenVertexArrays, but it's worth the try
Using OpenGL 4.3 on an nvidia GPU and GLEW this trick still works.
i was able to use this fix to get the 'Our First Program: A Detailed Discussion' from the 8th edition 4.3 Chapter 1 to run.
commenting out
glewExperimental = GL_TRUE;
results in an unhandled exception, so i'm fairly certain this is the issue. add it back into the code and the program runs as expected.
Updating answer to clarify what is new from original answer:
[1] Notice the date on the original answer was over two years old so i validated this is still true in newer versions of OpenGL. A major issue with OpenGL sample code on the web is the aging of tutorial content that might still work but is not considered a best practice or most performant path. When I read the original answer my thoughts were:
'Well, but this is two years old...is GLEW still not updated and this answer is out of date?', so now the reader will know as of Sept 13, 2014 it is in fact true.
[2] I would expect many readers trying to make the very simple first example in the OpenGL Programmer's Guide to run and it will not without this fix. By including the name of the book I hope they turn up this answer in a web search.
[3] I specified the platform I am certain this works to clarify I did not test it on all platforms.
Update your glew to 2.0.0. This was caused by this bug.