-1

I am solving some drawing wrapper for my DLL which is calculating some array. In this code I need it to draw, but I dont understand, why when I bind it only once, it draws only 1 point. But when I am binding it(as I know, I should not do that because of memory) every paint event, it's drawing my grid as i expect it to.

Here is initial state of bindData.

bool mBindData = true;

and then in my draw function:

        GLuint vbo;
        if(mBindData){
            mBindData = false;
            glGenBuffers(1, &vbo);

            //getting size of my array of vertexes
            int size = this->mModel->GetVboSize() * sizeof(float);


            glBindBuffer(GL_ARRAY_BUFFER, vbo);
            glBufferData(GL_ARRAY_BUFFER, s2, this->mModel->GetVbo(), GL_STATIC_DRAW);
            glBindBuffer(GL_ARRAY_BUFFER, vbo);
            glEnableVertexAttribArray(0);
            glVertexAttribPointer(
                        0,                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
                        3,                  // size
                        GL_FLOAT,           // type
                        GL_FALSE,           // normalized?
                        0,                  // stride
                        (void*)0            // array buffer offset
                        );
        }
        glDrawArrays(GL_POINTS, 0,this->mModel->GetVboSize()); 

if there is no

if(mBindData){}

its working well. But as I said, I am sure its not the way.

I appreciate every advice you can give me.

Thank you very much.

EDIT1: My question is, why is it drawing only 1 point instead of NxN grid of points when i bind vbo only once. What am i missing?

1 Answers1

0

I am sorry for a question. I am just stupid and didn't read entire QT component. I had to call update() after paintGL(). It's working now.