I've just started working through the OpenGL Programming Guide 8th Edition and it's really is a headache getting everything to work!

I've managed to get most things to work, except for, I believe, GLEW functions - such as; glGenVertexArrays, glBindVertexArray, glGenBuffers and a host of others.

GLUTCallbacks.h:

Code :

// Contains our "free methods" variables etc.
// Namespaces give our "free methods" some ownership
// We need to tell GLUTCallbacks about our HelloGL class, but HelloGL already #includes "GLUTCallsbacks.h", so if we used
// #include "HelloGL.h" it would create a circular dependency, which will cause the build to fail. The reason for this is because GLUTCallbacks is compiled first, so it will require HelloGL.h, but
// won't be able to find it because
#pragma once
class triangles; // Forward declare HelloGL
namespace GLUTCallbacks // all of the enclosed code is stored in the GLUTCallbacks namespace
{
void Init(triangles* gl); // We need to be able to access the HelloGL class, so we'll store the HelloGL reference in a pointer called gl and pass it to the Init function inside our namespace
void Display();
}

triangles.h (Tried that ifdef APPLE thing, found it on google, but didn't make it work):

// Contains out "free methods"
#include "GLUTCallbacks.h" // "" means the file is in the curent directory, <> means the file is in the system32 folder
#include "triangles.h" // This needs to be included so we know what the HelloGL class is
namespace GLUTCallbacks // All of the enclosed code is stored in the GLUTCallbacks namespace
{
namespace // This is an anonymous namespace, it means nothing can access any of the code inside the namespace, meaning nothing can access the HelloGL pointer, gl, except the code within the GLUTCallsbacks
// namespace.
{
triangles* triangleS = nullptr; // Initalises the pointer to null so it's not pointing at any memory.
}
void Init(triangles* tri)
{
triangleS = tri;
}
// This Display() method will simply call the display() method within the HelloGL class. We're doing this so we can have a nice structure (our HelloGL class), and just wrap the class methods up in free methods
// so that freeglut has access to them.
void Display()
{
if(triangleS != nullptr) // If the address of the helloGL pointer is not null, run the display function.
{
triangleS->Display();
}
}
}

main.cpp:

Code :

#include "triangles.h"
int main(int argc, char* argv[]) {
triangles * game = new triangles(argc, argv);
//Creates an instance of our game
return 0;
//Assumes a sucessful exit if our game exits and we make it to this
}

The GLUTCallbacks is from my uni course that I'm doing, but we never went through the redbook so it's a different way of setting things up that I'm normally used to. I think it's still required here though, but not 100% sure. Just doing what I know.

There are obviously a lot of other imminent errors but right now I just need GLEW to work. Thanks a lot to anyone that can help!