VBO Crash on Vista

I’ve been messing around with VBOs and this code works on my Winxp 32-bit machine but crashes with an access violation (0xC0000005: Access violation reading location 0x00000000) on my Vista 64-bit machine. Its just a simple demo that draws a cube. It crashes somewhere in the driver when calling glDrawArrays.

Any help would be appreciated.


Scene::Scene(void) :
    m_name(0)
{
    InitVBOs();
}

void Scene::RenderGeometry()
{
    glBindBufferARB(GL_ARRAY_BUFFER, m_name);

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);

// **** CRASHES HERE **** //
    glDrawArrays(GL_QUADS, 0, m_vertexCount);

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);
    
    glBindBufferARB(GL_ARRAY_BUFFER, 0);

    assert(glGetError() == GL_NO_ERROR);
}

void Scene::InitVBOs()
{
    float vertices[] =
    {
        // Front
        -0.5,-0.5, 0.5,
        -0.5, 0.5, 0.5,
         0.5, 0.5, 0.5,
         0.5,-0.5, 0.5,
        // Back
        -0.5,-0.5,-0.5,
         0.5,-0.5,-0.5,
         0.5, 0.5,-0.5,
        -0.5, 0.5,-0.5,
        // Right
         0.5,-0.5,-0.5,
         0.5,-0.5, 0.5,
         0.5, 0.5, 0.5,
         0.5, 0.5,-0.5,
        // Left
        -0.5,-0.5,-0.5,
        -0.5, 0.5,-0.5,
        -0.5, 0.5, 0.5,
        -0.5,-0.5, 0.5,
        // Top
        -0.5, 0.5,-0.5,
         0.5, 0.5,-0.5,
         0.5, 0.5, 0.5,
        -0.5, 0.5, 0.5,
        // Bottom
        -0.5,-0.5,-0.5,
        -0.5,-0.5, 0.5,
         0.5,-0.5, 0.5,
         0.5,-0.5,-0.5
    };

    float normals[] =
    {
         0.0, 0.0, 1.0,
         0.0, 0.0, 1.0,
         0.0, 0.0, 1.0,
         0.0, 0.0, 1.0,

         0.0, 0.0,-1.0,
         0.0, 0.0,-1.0,
         0.0, 0.0,-1.0,
         0.0, 0.0,-1.0,

         1.0, 0.0, 0.0,
         1.0, 0.0, 0.0,
         1.0, 0.0, 0.0,
         1.0, 0.0, 0.0,

        -1.0, 0.0, 0.0,
        -1.0, 0.0, 0.0,
        -1.0, 0.0, 0.0,
        -1.0, 0.0, 0.0,

         0.0, 1.0, 0.0,
         0.0, 1.0, 0.0,
         0.0, 1.0, 0.0,
         0.0, 1.0, 0.0,

         0.0,-1.0, 0.0,
         0.0,-1.0, 0.0,
         0.0,-1.0, 0.0,
         0.0,-1.0, 0.0
    };

    float colors[] = 
    {
         0.0, 0.0, 1.0,
         0.0, 0.0, 1.0,
         0.0, 0.0, 1.0,
         0.0, 0.0, 1.0,

         0.0, 0.0, 1.0,
         0.0, 0.0, 1.0,
         0.0, 0.0, 1.0,
         0.0, 0.0, 1.0,

         1.0, 0.0, 0.0,
         1.0, 0.0, 0.0,
         1.0, 0.0, 0.0,
         1.0, 0.0, 0.0,

         1.0, 0.0, 0.0,
         1.0, 0.0, 0.0,
         1.0, 0.0, 0.0,
         1.0, 0.0, 0.0,

         0.0, 1.0, 0.0,
         0.0, 1.0, 0.0,
         0.0, 1.0, 0.0,
         0.0, 1.0, 0.0,

         0.0, 1.0, 0.0,
         0.0, 1.0, 0.0,
         0.0, 1.0, 0.0,
         0.0, 1.0, 0.0
    };

    m_vertexCount = 24;
    int count     = m_vertexCount * 3;
    int typeSize  = sizeof(float);
    int size      = count * typeSize;
    glGenBuffersARB(1, &m_name);
    glBindBufferARB(GL_ARRAY_BUFFER, m_name);
    glBufferDataARB(GL_ARRAY_BUFFER, size * 3, 0, GL_STATIC_DRAW);

    glBufferSubDataARB(GL_ARRAY_BUFFER, 0, size, vertices);
    glBufferSubDataARB(GL_ARRAY_BUFFER, size, size, normals);
    glBufferSubDataARB(GL_ARRAY_BUFFER, size * 2, size, colors);

    glVertexPointerEXT(3, GL_FLOAT, 3*typeSize, count, 0);
    glNormalPointerEXT(GL_FLOAT, 3*typeSize, count, BUFFERSIZE(size));
    glColorPointerEXT (3, GL_FLOAT, 3*typeSize, count, BUFFERSIZE(size * 2));

    glBindBufferARB(GL_ARRAY_BUFFER, 0);
}


Anyway, if anyone is curious, everything works as is now, I just changed


glVertexPointerEXT(3, GL_FLOAT, 3*typeSize, count, 0);
glNormalPointerEXT(GL_FLOAT, 3*typeSize, count, BUFFERSIZE(size));
glColorPointerEXT (3, GL_FLOAT, 3*typeSize, count, BUFFERSIZE(size * 2));

to


glVertexPointer(3, GL_FLOAT, 3*typeSize, 0);
glNormalPointer(GL_FLOAT, 3*typeSize, BUFFERSIZE(size));
glColorPointer(3, GL_FLOAT, 3*typeSize, BUFFERSIZE(size * 2));

For some reason the gl*PointerExt functions didn’t work on my Vista64 machine with a GeForce 8800, but my XP machine with a GeForce 6800 worked fine. Not sure whether it was the OS or Video Card issue that caused the problem.

A possible explanation is that newer nvidia drivers have removed the “ext” versions of these functions in favour of the core or arb ones. This is not a function of the OS, but rather a side-effect of using newer drivers.

Or possibly both, because it is possible that the “ext” version is only removed from the vista driver :smiley:

i also have a crash with FBO on Vista but slightly different.
im using

GLint active_fbo;
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT,&active_fbo);

and get an unhandled exception instead (0x695fb4e4 address violation).

any ideas?

NV GeForce 8800 GT - latest drivers

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.