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've just started digging into OpenGL and I've run into a problem trying to set a VOA.

It's giving me a run-time error of :

An unhandled exception of type 'System.AccessViolationException'

At

    // Create and bind a VAO
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);

I have searched the internet high and low for a solution and I haven't found one. The rest of my function looks like this:

int main(array<System::String ^> ^args)

{

// Initialise GLFW
if( !glfwInit() )
{
    fprintf( stderr, "Failed to initialize GLFW\n" );
    return -1;
}

glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 0); // 4x antialiasing
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // We want OpenGL 3.3
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL

// Open a window and create its OpenGL context
if( !glfwOpenWindow( 800, 600, 0,0,0,0, 32,0, GLFW_WINDOW ) )
{
    fprintf( stderr, "Failed to open GLFW window\n" );
    glfwTerminate();
    return -1;
}


// Initialize GLEW
if (glewInit() != GLEW_OK) {
    fprintf(stderr, "Failed to initialize GLEW\n");
    return -1;
}

glfwSetWindowTitle( "Game Engine" );


// Create and bind a VAO
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);

glfwEnable( GLFW_STICKY_KEYS );
share|improve this question
    
Are you intending to use C++/CLI or C++/CX? –  Josh Petrie Dec 18 '12 at 17:52
1  
I'm sorry: what's this int main(array<System::String ^> ^args)? –  Jefffrey Dec 18 '12 at 17:53
    
It is possible that the VAO creation is failing. You're not checking for GL errors. –  Josh Petrie Dec 18 '12 at 17:54
    
@Jeffery It looks like C++/CLI which is really only useful for interoperability and not writing real programs, which is why I asked if the OP intends to use it. –  Josh Petrie Dec 18 '12 at 17:56
    
I'm not sure what the difference is TBH. I've changed it from CLR to Win32 Console and now it's running through int main().. It's still running the same error where it is getting access violation on glGenVertexArrays(1, &vao); –  Paul Dec 18 '12 at 18:02
show 3 more comments

closed as off-topic by Josh Petrie Apr 7 at 15:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about debugging a problem in your project must present a concise selection of code and context so as to allow a reader to diagnose the issue without needing to read all of your code or to engage in extensive back-and-forth dialog. For more information, see this meta thread." – Josh Petrie
If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.