0

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?

eclipse0922
  • 158
  • 2
  • 15
  • 2
    You may see the error value of an earlier OpenGL call. OpenGL errors "stack". You must call `glGetError` in a loop until it returns `GL_NO_ERROR` to retrieve all errors that may have accumulated (yes, people are going to nitpick, that his is because of the client/server architecture of earlier OpenGL versions, and what not; either way you have to call it in a loop). Also you must call glGetError also earlier; for what oyu know creation of a buffer name or binding it may have failed. – datenwolf Sep 06 '16 at 10:25

1 Answers1

2

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.

Claudia
  • 46
  • 3
  • At first, thanks for the answer. Unfortunately, this question was written in a long time ago, I stopped using openvdb. so I can't try your solution. But for some other people, I leave it without deleting. – eclipse0922 May 24 '17 at 08:58