Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]OpenGL as underlay with qml
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]OpenGL as underlay with qml

Scheduled Pinned Locked Moved General and Desktop
12 Posts 2 Posters 3.1k Views 2 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.
  • sajis997S Offline
    sajis997S Offline
    sajis997
    wrote on last edited by sajis997
    #1

    Hello forum,

    I am using the OpenGL Mathematics Library to do the affine transformation instead of the ones that come along with Qt. My intention is to use Qt only for the UI and the OpenGL context creation in platform independent manner. When i run the debugger I cannot access some of the information as follows:

    std::vector<glm::vec3> mVertices;
    
    

    The above is the declaration made inside the class header file and inside the source file, I am initializing the vector as follows:

    mVertices.resize(64);
    

    And the program crashes at the following command :

    glDrawArrays(GL_LINE_STRIP,0,mShowPoints);
    

    More details are pasted here:

    void Hilbert2DScene::render()
    {
        /*
         * Bind the vertex array object and vertex buffer object
         * */
        glBindVertexArray(mVaoID);
        /*
         * Now bind it to the context using the GL_ARRAY_BUFFER binding point
         * */
        glBindBuffer(GL_ARRAY_BUFFER,mVboVerticesID);
    
        mShader->Use();
    
        GL_CHECK_ERRORS;
    
        //allocate the buffer if the buffer is not allocated yet
        if(!mIsBufferAllocated)
        {
            //ALLOCATE THE BUFFER HERE
            unityCube(mIteration,mDim);
    
            //specify the amount of storage we want to use for the buffer
            glBufferData(GL_ARRAY_BUFFER,sizeof(glm::vec3) * mVertices.size(),&mVertices[0],GL_STATIC_DRAW);
    
            mIsBufferAllocated = true;
    
            mShowPoints = getNumberOfPointsForIteration(mIteration,mDim);
        }
    
        if(mClearBackground)
            glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
    
        static const GLfloat color[] = {0.0f,0.0f,0.0f,1.0f};
        static const GLfloat depth = 1.0f;
    
        glClearBufferfv(GL_COLOR,0,color);
        glClearBufferfv(GL_DEPTH,0,&depth);
    
    
        //draw stuff
    
        //transfer the scene along the z-axis
        glm::mat4 T = glm::translate(glm::mat4(1.0f),glm::vec3(0.0f,0.0f,mDist));
    
        //the rotation matrix along X concatenated with the translation matrix
        glm::mat4 Rx = glm::rotate(T, glm::radians(static_cast<float>(mRX)),glm::vec3(1.0f,0.0f,0.0f));
    
        //rotation matrix along Y is concatenated with the rotation matrix along X
        glm::mat4 MV = glm::rotate(Rx,glm::radians(static_cast<float>(mRY)),glm::vec3(0.0f,1.0f,0.0f));
    
        mModelViewMatrix = mProjectionMatrix * MV;
    
        glEnableVertexAttribArray((GLuint)0);
    
    
        glUniformMatrix4fv(mShader->getUniform("MVP"),1,GL_FALSE,glm::value_ptr(mModelViewMatrix));
    
        if(mShowPoints < getNumberOfPointsForIteration(mIteration,mDim))
            ++mShowPoints;
    
        glDrawArrays(GL_LINE_STRIP,0,mShowPoints);
    
    
        glDisableVertexAttribArray(0);
        glBindVertexArray(0);
    
        GL_CHECK_ERRORS;
    
        mShader->UnUse();
    }
    

    Looking forward to some hint to debug this issue.

    Thanks

    1 Reply Last reply
    0
    • sajis997S Offline
      sajis997S Offline
      sajis997
      wrote on last edited by
      #2

      Sorry folks, I believe that I have not explained enough. I cannot access the size of the vector while debugging. If I could access the size , I could have assumed the reason behind the crash.

      Thanks

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi, what you mean not access ?
        I can see a std::vector and even expand it to see all elements.

        However, I had to do the following
        Tools -> Options -> Debugger -> GDB tab
        Uncheck the option (Load system GDB pretty printers)

        For it to work.

        No idea if its related to what you ask but better to ask than to assume its not :)

        sajis997S 1 Reply Last reply
        0
        • mrjjM mrjj

          Hi, what you mean not access ?
          I can see a std::vector and even expand it to see all elements.

          However, I had to do the following
          Tools -> Options -> Debugger -> GDB tab
          Uncheck the option (Load system GDB pretty printers)

          For it to work.

          No idea if its related to what you ask but better to ask than to assume its not :)

          sajis997S Offline
          sajis997S Offline
          sajis997
          wrote on last edited by
          #4

          @mrjj

          Thanks for the hint , it did solve part of the issue, I do can see the value of the 3rd party library members (glm) and am still working on what may have causing the crash without any hint. I have tried with gdb backtrace command , but it shows only ?? and as mentioned before the application crashes at

          glDrawArrays(GL_LINE_STRIP,0,mShowPoints);
          

          Any further hint over this ?

          Thanks

          1 Reply Last reply
          0
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @sajis997 said:
            have you output value of mShowPoints ?
            Any chance it get bigger than the list ?

            also did you check that
            sizeof(glm::vec3) * mVertices.size()
            yields the expected size?

            1 Reply Last reply
            0
            • sajis997S Offline
              sajis997S Offline
              sajis997
              wrote on last edited by
              #6

              Hi

              I am sorry. I would like to ask, did you manage all the element values of std::vectorglm::vec3 mVertices ? I still cannot , even after I made the necessary changes as you suggested. It shows "not accessible".

              Thanks

              mrjjM 1 Reply Last reply
              0
              • sajis997S sajis997

                Hi

                I am sorry. I would like to ask, did you manage all the element values of std::vectorglm::vec3 mVertices ? I still cannot , even after I made the necessary changes as you suggested. It shows "not accessible".

                Thanks

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @sajis997
                Hi well I did not try with that type (glm::vec3) but
                for my own std::vector with all types I can see inside. even expand the inner struct/class.
                Are you on windows or linux/mac?

                sajis997S 1 Reply Last reply
                0
                • mrjjM mrjj

                  @sajis997
                  Hi well I did not try with that type (glm::vec3) but
                  for my own std::vector with all types I can see inside. even expand the inner struct/class.
                  Are you on windows or linux/mac?

                  sajis997S Offline
                  sajis997S Offline
                  sajis997
                  wrote on last edited by
                  #8

                  @mrjj

                  I am at Ubuntu Linux with Qt 5.4.1 on it.

                  mrjjM 1 Reply Last reply
                  0
                  • sajis997S sajis997

                    @mrjj

                    I am at Ubuntu Linux with Qt 5.4.1 on it.

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @sajis997
                    Strange it was exactly on ubuntu I had that
                    problem also and the after the option It did show.

                    if you make another list say with <int>, it is still not willing to show it ?

                    sajis997S 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @sajis997
                      Strange it was exactly on ubuntu I had that
                      problem also and the after the option It did show.

                      if you make another list say with <int>, it is still not willing to show it ?

                      sajis997S Offline
                      sajis997S Offline
                      sajis997
                      wrote on last edited by
                      #10

                      @mrjj

                      I checked with the vector :

                      std::vector<GLushort> mIndices;
                      

                      And I do see all the values inside the vector for type GLushort , but not for type glm::vec3 type. The latter shows "not accessible".
                      In that case I cannot be sure if the vector is getting populated with the value I am looking for which may have caused the crash at the point mentioned in my last post.

                      Thanks

                      1 Reply Last reply
                      0
                      • mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @sajis997 said:

                        glm::vec3

                        Ok. Maybe the namespace confuses it.
                        If you press F2 and see definition and then copy it to you program to say
                        vec3Test
                        and make a list with that, will it see it then ?
                        Also you could try to switch to clang code model and see if that helps. (in options)

                        1 Reply Last reply
                        0
                        • sajis997S Offline
                          sajis997S Offline
                          sajis997
                          wrote on last edited by
                          #12

                          I checked the value of size of the vector mVertices and the value of the variable mShowPoints and both of them are showing the same value in the debugger. The application still crashes at

                          glDrawArrays(GL_LINE_STRIP,0,mShowPoints);
                          

                          Any more hint to look into ?

                          1 Reply Last reply
                          0

                          • Login

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