openglopenvdb

openvdb viewer & opengl


I am trying to use OpenVDB & viewer i just want to see openvdb file using viewer. Some of viewer's functions use opengl functions and return opengl error.

Below is execution of ovenvdb viewer and its error message.

C:\Users\user\Documents\Visual Studio 2013\Projects\openvdb_test\Debug>openvdb_test.exe armadillo.vd
b -i
ls_armadillo (1276 x 1519 x 1160 voxels)
Glew init (Windows)
INFO vertex sizes 2934312
INFO sizeof(GLfloat) 4
error genvertexbuffer 1281
openvdb_test.exe: Error: Unable to upload vertex buffer data

C:\Users\user\Documents\Visual Studio 2013\Projects\openvdb_test\Debug>

And this is the function in RenderModules of openvdb viewer that shows error message . I added some lines for debugging.

BufferObject::genVertexBuffer(const std::vector<GLfloat>& v)
{
    if (glIsBuffer(mVertexBuffer) == GL_TRUE) glDeleteBuffers(1, &mVertexBuffer);

    glGenBuffers(1, &mVertexBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
    if (glIsBuffer(mVertexBuffer) == GL_FALSE) throw "Error: Unable to create vertex buffer";
    printf("INFO vertex sizes %d \n", v.size());
    printf("INFO sizeof(GLfloat) %d \n", sizeof(GLfloat));
    int size = sizeof(GLfloat) * v.size();
    glBufferData(GL_ARRAY_BUFFER, size, &v[0], GL_STATIC_DRAW);
    GLenum err=glGetError();
    if (GL_NO_ERROR != err)
    {
        printf("error genvertexbuffer %d\n", err);
        throw "Error: Unable to upload vertex buffer data";
    }

    glBindBuffer(GL_ARRAY_BUFFER, 0);
}

II know that opengl error #1281 means invalid value of size. But, size of vertices is not negative value and also other args looks fine to me.

Did i miss something?


Solution

  • Just changed

    if (glIsBuffer(mVertexBuffer) == GL_FALSE) throw "Error: Unable to create vertex buffer";
    

    by

    do {
        glIsBuffer(mVertexBuffer);
    } while (glGetError() != GL_NO_ERROR);
    

    For me it failed for vertex and color, now it works.