PDA

View Full Version : rendering vertex buffer objects using a shared qglwidget on osx 10.10



inopportuno
07-17-2015, 02:35 AM
In attachment you can find a really small and stupid program representing a problem that i'm experiencing with osx 10.10 and all the qt libraries (> 5.0).

Let me explain what the program is intended to do. It should create a triangle in a SHARED (and hidden...) 3d opengl context, using a vertex buffer object for the triangle vertices coordinates and another vbo for the three vertex indices composing the triangle. Two others indepent opengl contexts should render the same triangle without replicating it in the GPU memory. I use QGLWidget class facilities to create the opengl context and to share the "server" context vbos data with the two opengl rendering clients.

The code works properly in windows 8.1 (qt version 5.1 64 bits), linux mint (qt 5.3), mac osx 10.9 (qt 5.4.2) and mac osx 10.10 (qt 4.8), BUT it doesn't render nothing in mac osx 10.10 with any qt libraries > 5.0.

Some additional info and constrains i have to respect in the code writing. in file glarea.cpp function Triangle::create you can find

glBindBuffer(GL_ARRAY_BUFFER, VertexVBOID);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat)*9, NULL, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER,0);

glBindBuffer(GL_ARRAY_BUFFER, VertexVBOID);
glBufferSubData(GL_ARRAY_BUFFER,0,sizeof(GLfloat)* 9, pvertex);
glBindBuffer(GL_ARRAY_BUFFER,0);
It is obvious that i could pass the vertex coordinates to opengl directly using the glBufferData function instead of just allocating the GPU memory space with this function call and effectly copying the vertex coordinates using the glBufferSubData function, but I must split the code in this way for reason depending from the whole system software architecture. I also noticed that invoking the glClear function in the GLArea::paintGL() rises an "invalid drawable buffer" opengl error. It is a well known problem caused by the mac version of qt libraries. I thank in advance everyone will waste time trying to help me.

PS1 in the application i use glew library. I couldn't include it in the zip file because of the file limitation size of the forum. I just added a mock empty folder just indicating the position where the code expects to find the required glew code files.

PS2 I want to reassure all the people that will download the file that it contains just few .cpp,.h and qt project files. No armful viruses at all :)