vertex array object not bound .. opengl core 4.1

hi i 'm trying to load a model using assimp, ( mac, c++ , opengl core 4.1) … but i’m running into vertex array object not bound error… I have read the forums they all suggest adding vao before binding the vbo … i’m doing that but still not happening… here is the code…


glGenVertexArraysAPPLE(1, &vao);

elementCount = mesh->mNumFaces * 3;

if(mesh->HasPositions()) {
    float *vertices = new float[mesh->mNumVertices * 3];
    for(int i = 0; i < mesh->mNumVertices; ++i) {
        vertices[i * 3] = mesh->mVertices[i].x;
        vertices[i * 3 + 1] = mesh->mVertices[i].y;
        vertices[i * 3 + 2] = mesh->mVertices[i].z;
    glGenBuffers(1, &vbo[VERTEX_BUFFER]);
    glBindBuffer(GL_ARRAY_BUFFER, vbo[VERTEX_BUFFER]);
    glBufferData(GL_ARRAY_BUFFER, 3 * mesh->mNumVertices * sizeof(GLfloat), vertices, GL_STATIC_DRAW);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
    glEnableVertexAttribArray (0);
    delete vertices;

so on the other buffers get generated after this…

and this for setting context


if anyone has any solution for this , pls post…

glGenVertexArraysAPPLE(1, &vao);

I don’t see APPLE_vertex_array_object on the list of supported extensions for core OpenGL 4.1. The implementation shouldn’t have advertised the extension, and if it didn’t, you shouldn’t be using functions from extensions that aren’t listed as supported.

The actual vertex array object functionality is core and has been since 3.0. So use that.

vertex array object not bound error.

I’m curious as to exactly what is giving you this error. OpenGL errors don’t tend to be as lucid as this. Are you using some form of EXT/ARB/KHR_debug? If so, does it say what line caused this error?

thanks Alfonse for pointing out that glGenVertexArraysAPPLE. Rectified that and then used opengl profiler .
It gave the error with glew as its uses glgetstring instead of glGetStringi rectified that even and the model is loading but its transparent .[ATTACH=CONFIG]995[/ATTACH]
But the vao error still persists .The program (shader program) validation status is coming out to GL_FALSE.

All the below things were working with opengl 2

here are the shaders :


#version 410
out vec3 Normal0;
out vec4 outcolor;

void main()
outcolor = vec4(.2f,.2f,.2f,1.0f);//* ( dot ( - vec3(3,3,3) , Normal0 ) );


#version 410
uniform mat4 transform;
in vec3 position;
in vec3 normal;

out vec3 Normal0;
void main()
gl_Position = transform * vec4(position, 1.0);
Normal0 = (transform * vec4(normal, 0.0)).xyz;

shader code:

m_program = glCreateProgram();

m_shaders[0] = createShader(shader::LoadShader(filename + ".vs"), GL_VERTEX_SHADER);
m_shaders[1] = createShader(shader::LoadShader(filename + ".fs"), GL_FRAGMENT_SHADER);

for( int i = 0 ; i < NUM_SHADER; i++)
    glAttachShader(m_program, m_shaders[i]);

glBindAttribLocation(m_program, 0, "position");
glBindAttribLocation(m_program, 1, "normal");

CheckShaderError(m_program, GL_LINK_STATUS, true, "link  error 


CheckShaderError(m_program, GL_VALIDATE_STATUS, true, "validate error 

"); // the error gets displayed here.

glValidateProgram() is meant to be called directly before a draw call with that shader bound and all the bindings (VAO, textures) set. Its purpose is to ensure that the shader can execute given the current GL state. So, you should not be calling it as part of your shader initialization.

glGenVertexArrays (core profile, 2008) is not the same function as glGenVertexArraysAPPLE (legacy profile, 2002).

If you call any function unsupported for the profile, you’ll get INVALID_OPERATION.

thanks alfonse and arekkusu for pointing out glGenVertexArraysApple and malexander for letting me know the design glitch…

redesigned the entire thing now it works well…