Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. QOpenGLWidget - "WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero"
Forum Updated to NodeBB v4.3 + New Features

QOpenGLWidget - "WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero"

Scheduled Pinned Locked Moved Solved Qt for WebAssembly
3 Posts 1 Posters 825 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yalnte
    wrote on 27 Dec 2022, 23:19 last edited by
    #1

    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

    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      yalnte
      wrote on 30 Dec 2022, 12:37 last edited by yalnte
      #2

      This seems to move things on a bit:
      https://emscripten.org/docs/porting/multimedia_and_graphics/OpenGL-support.html#opengl-support-opengl-es2-0-emulation

      On 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.

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yalnte
        wrote on 30 Dec 2022, 22:55 last edited by
        #3

        Success! Works with Qt6.4.1 and Emscripten 3.1.14 (was trying later versions of both which was giving above error)

        1 Reply Last reply
        0

        2/3

        30 Dec 2022, 12:37

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved