brijesh
21st March 2013, 11:00
---------
SITUATION
---------
In a QGraphicsView - QGraphicsScene framework ...
I have two VBOs declared as ...
QVarLengthArray<Vertex> mVertices1;
QGLBuffer mVBO1;
QVarLengthArray<Vertex> mVertices1;
QGLBuffer mVBO2;
They are instantiated in the scene constructor as ...
mVBO1.create();
mVBO1.bind();
mVBO1.setUsagePattern(QGLBuffer::StaticDraw);
mVBO1.allocate(mVertices1.data(), sizeof(Vertex)*nVertices1);
mVBO2.create();
mVBO2.bind();
mVBO2.setUsagePattern(QGLBuffer::StaticDraw);
mVBO2.allocate(mVertices2.data(),sizeof(Vertex)*nV ertices2);
In the draw background method of QGraphicsScene, I am ...
// Binding my shader program mShaderProgram.bind();
// Initialising my attribute variables mShaderProgram.attributeLocation("
// Enabling the attribute array mShaderProgram.enableAttributeArray( ..
// Setting the attribute Buffer mShaderProgram.setAttributeBuffer(...
Further, the draw calls are made as below ...
if (mVBO1.bind()) // mVBO1 draw block
{
glDrawArrays(GL_LINES,0,nVertices1);
// mVBO1.release();
}
if (mVBO2.bind()) // mVBO2 draw block
{
glDrawArrays(GL_LINE_STRIP,0,nVertices2);
//mVBO2.release();
}
Finally in the drawbackground method itself ..
// Disabling the attribute arrays mShaderProgram.disableAttributeArray(...
// Releasing the shader program mShaderProgram.release();
---------
PROBLEMS
---------
Independently, each of the "if" blocks shown above render the expected values.
However, when i wish to use both the VBOs together (mVBO1 and mVBO2), during the second or subsequent rendering loops
glDrawArrays within mVBO1 draw block will render nVertices1 values as GL_LINES from mVBO2 [mVertices2.data]
I tried releasing the VBOs (mVBO2.release()) but that results in a crash at glDrawArrays(GL_LINES,0,nVertices1);
Any help, ideas to fix this is greatly appreciated.
Note .. Binding the QGLBuffers (VBOs) return true, their buffer ids are also distinct when checked using the QGLBuffers::bufferid() api !!
SITUATION
---------
In a QGraphicsView - QGraphicsScene framework ...
I have two VBOs declared as ...
QVarLengthArray<Vertex> mVertices1;
QGLBuffer mVBO1;
QVarLengthArray<Vertex> mVertices1;
QGLBuffer mVBO2;
They are instantiated in the scene constructor as ...
mVBO1.create();
mVBO1.bind();
mVBO1.setUsagePattern(QGLBuffer::StaticDraw);
mVBO1.allocate(mVertices1.data(), sizeof(Vertex)*nVertices1);
mVBO2.create();
mVBO2.bind();
mVBO2.setUsagePattern(QGLBuffer::StaticDraw);
mVBO2.allocate(mVertices2.data(),sizeof(Vertex)*nV ertices2);
In the draw background method of QGraphicsScene, I am ...
// Binding my shader program mShaderProgram.bind();
// Initialising my attribute variables mShaderProgram.attributeLocation("
// Enabling the attribute array mShaderProgram.enableAttributeArray( ..
// Setting the attribute Buffer mShaderProgram.setAttributeBuffer(...
Further, the draw calls are made as below ...
if (mVBO1.bind()) // mVBO1 draw block
{
glDrawArrays(GL_LINES,0,nVertices1);
// mVBO1.release();
}
if (mVBO2.bind()) // mVBO2 draw block
{
glDrawArrays(GL_LINE_STRIP,0,nVertices2);
//mVBO2.release();
}
Finally in the drawbackground method itself ..
// Disabling the attribute arrays mShaderProgram.disableAttributeArray(...
// Releasing the shader program mShaderProgram.release();
---------
PROBLEMS
---------
Independently, each of the "if" blocks shown above render the expected values.
However, when i wish to use both the VBOs together (mVBO1 and mVBO2), during the second or subsequent rendering loops
glDrawArrays within mVBO1 draw block will render nVertices1 values as GL_LINES from mVBO2 [mVertices2.data]
I tried releasing the VBOs (mVBO2.release()) but that results in a crash at glDrawArrays(GL_LINES,0,nVertices1);
Any help, ideas to fix this is greatly appreciated.
Note .. Binding the QGLBuffers (VBOs) return true, their buffer ids are also distinct when checked using the QGLBuffers::bufferid() api !!