mardi 23 janvier 2018

C++, Bus Error:10 due to adding another parameter to a function

I have the following code:

Object.cpp

bool Object::InitVBO(GLenum target, const float *data, GLsizeiptr DataSize, int layoutLocationa)
{
    GLuint * buffer;
    glGenBuffers(1, buffer);
    glBindBuffer(target, *buffer);
    if (!Game::OpenGLErrorCheck())
    {
        printf("Error while binding a VBO\n");
        return false;
    }
    glBufferData(target, DataSize, data, GL_STATIC_DRAW);

    switch(target)
    {
        case GL_ARRAY_BUFFER:
        {
            this->m_VBO_Vertex = *buffer;
            transforDataToShader(0, 0);
        }
    }

    glBindBuffer(target, 0);
    return true;
}

Object.h

[...]
bool InitVBO(GLenum target, const float *data, GLsizeiptr DataSize, int layoutLocation);
[...]

main.cpp

[...]
Object testObj = Object();
testObj.InitVBO(GL_ARRAY_BUFFER, vertexPositions, sizeof(vertexPositions), 0 )
[...]

If I delete the "layoutLocation" parameter from the function, the code works perfectly, but after I'm just adding that parameter (without even using it in anywhere in the function), the code gives

Bus error: 10

I'm trying to figure out what is the problem for last 2 days, but couldn't find anything, so I was hoping you guys can help.

Aucun commentaire:

Enregistrer un commentaire