QOpenGLWidget - "WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero"
-
Hi, Firstly, thanks very much for fixing the QOpenGLWidget in the WASM build environment. I'm very excited to find out what's possible.
I'm getting the following error when running my app once compiled for WASM and run in Firefox OR Chromium.
WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
Which when the glDrawArrays code is called gives:
VM1510:7586 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
This codebase compiles and runs on Linux / Windows desktops. The key section that generates the error is:
int mvpLocation = -1; int alphaLocation = -1; int lightLocation = -1; int vertexLocation = -1; int colourLocation = -1; int normLocation = -1; // Set modelview-projection matrix qDebug("Getting mvp matrix location"); mvpLocation = program->uniformLocation("mvp_matrix"); program->setUniformValue(mvpLocation, myTransMatrix); // Set alpha (transparency) value qDebug("Getting alpha array location"); alphaLocation = program->attributeLocation("alpha"); program->setAttributeValue(alphaLocation, myAlpha); lightLocation = program->attributeLocation("myLight"); program->setAttributeValue(lightLocation, myLight); // Tell OpenGL programmable pipeline how to locate vertex position data qDebug("Getting vertex array location"); vertexLocation = program->attributeLocation("a_position"); qDebug(" Set attribute array"); // Tell OpenGL programmable pipeline how to locate vertex texture coordinate data qDebug("Getting colour array location"); colourLocation = program->attributeLocation("ourcolor"); // Tell OpenGL programmable pipeline how to locate vertex texture coordinate data qDebug("Getting normal array location"); normLocation = program->attributeLocation("normal"); qDebug(" Enabling attribute arrays"); program->enableAttributeArray(vertexLocation); program->enableAttributeArray(colourLocation); program->enableAttributeArray(normLocation); qDebug(" Setting attribute arrays"); program->setAttributeArray(vertexLocation, myVert, 3); program->setAttributeArray(colourLocation, myColour, 3); program->setAttributeArray(normLocation, myNormals, 3); glDepthFunc(GL_LESS); glDepthMask(true); if ((myMode==GL_LINES)||(myMode==GL_LINE_LOOP)){ glLineWidth(myLineWidth); } qDebug(" Draw arrays"); glDrawArrays(myMode, 0, mySize); qDebug(" Disabling attribute arrays"); program->disableAttributeArray(vertexLocation); program->disableAttributeArray(colourLocation); program->disableAttributeArray(normLocation); qDebug("End setShaderProgramData()");
Thanks in advance for any help you many give
-
This seems to move things on a bit:
https://emscripten.org/docs/porting/multimedia_and_graphics/OpenGL-support.html#opengl-support-opengl-es2-0-emulationOn using
-sFULL_ES2
Now get multiple instances of:
QOpenGLWidget: Failed to make context current
and a black widget.
Edit: Turns out things are highly dependent on compile toolchain - later versions do not seem to help (yet) - see below.