hi all,
I'm learning GLSL recently, and trying to use vertex array object. but I just can't get things right.
I use glew for OpenGL setup, and use vertex array to bind vertex attributes. while the compiler doesn't show any complaint, the output doesn't show anything neither. I try to use glsldevil to debug my shader program. it turns out that every time when the program comes to execute glGenVertexArrays(1, m_vao), the error message window pops up saying the program xxxx.exe has stopped working. Show I assume that I did something wrong with glGenvertexArrays.
below is the snippet of my code, how am i gonna fix this? Thanks in advance.
glGenBuffers(1, &m_vertBO);
glGenBuffers(1, &m_indexBO);
glGenVertexArrays(1, &m_vao);
//vertex array=============================
glBindVertexArray(m_vao);
//pass in vertex data
glBindBuffer(GL_ARRAY_BUFFER, m_vertBO);
glBufferData(GL_ARRAY_BUFFER, sizeofvertdata, tempVertData, GL_STATIC_DRAW);
//pass in index data
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeofindexdata, tempIndexData, GL_STATIC_DRAW);
//vertex data
glEnableVertexAttribArray(vertLoc);
glVertexAttribPointer(vertLoc, 3, GL_FLOAT, GL_FALSE, 0, 0);
//texture data
if (objmodel.hasTexCoord())
{
glEnableVertexAttribArray(texCoordLoc);
glVertexAttribPointer(texCoordLoc, 2, GL_FLOAT, GL_FALSE, 0, (void *)(objmodel.texCoordOffset()));
}
//normal data
if (objmodel.hasNormal())
{
glEnableVertexAttribArray(normLoc);
glVertexAttribPointer(normLoc, 3, GL_FLOAT, GL_FALSE, 0, (void *)(objmodel.normalOffset()));
}
//unbind vertex array object
glBindVertexArray(0);
//unbind vertex and index buffer object
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);