Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. [Qt+OpenGL]
Forum Updated to NodeBB v4.3 + New Features

[Qt+OpenGL]

Scheduled Pinned Locked Moved Solved Qt 6
5 Posts 2 Posters 606 Views
  • 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.
  • A Offline
    A Offline
    appdev
    wrote on 25 Mar 2022, 15:08 last edited by appdev
    #1

    Hey,

    I tried to modify the cube example in Qt by adding a coordinate system and changing the texture.
    These are the line codes to draw the frame:
    void MainWidget::draw_frame()
    { glLineWidth(8.0f);

         glBegin(GL_LINES);
          //X_axis
         glColor3f( (1.0, 0.0, 0.0);
         glVertex3f(0.0, 0.0, 0.0);
         glVertex3f(4.0, 0.0, 0.0);
         // arrow
         glVertex3f(4.0, 0.0f, 0.0f);
         glVertex3f(3.75, 0.25f, 0.0f);
    
         glVertex3f(4.0, 0.0f, 0.0f);
         glVertex3f(3.75, -0.25f, 0.0f);
         //Y_axis
         glColor3f (0.0, 1.0, 0.0);
         glVertex3f(0.0, 0.0, 0.0);
         glVertex3f(0.0, 4.0, 0.0);
         // arrow
         glVertex3f(0.0, 4.0f, 0.0f);
         glVertex3f(0.25, 3.75f, 0.0f);
    
         glVertex3f(0.0, 4.0f, 0.0f);
         glVertex3f(-0.25, 3.75f, 0.0f);
    
         //Z_axis
         glColor3f (0.0, 0.0, 1.0);
         glVertex3f(0.0, 0.0, 0.0);
         glVertex3f(0.0, 0.0, 4.0);
         // arrow
    
    
         glVertex3f(0.0, 0.0f ,4.0f );
         glVertex3f(0.0, 0.25f ,3.75f );
    
         glVertex3f(0.0, 0.0f ,4.0f );
         glVertex3f(0.0, -0.25f ,3.75f );
         glEnd();
    

    }

    Each axis is supposed to have a specific color ( for example x: red, y: green, z:blue).
    However the axes have the same color as the cube texture.
    axes.PNG

    Any idea on how to fix the problem ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      appdev
      wrote on 28 Mar 2022, 13:15 last edited by
      #2

      Update: I used texture->release() function to unbind it from the currently active texture unit. Now the frame is all black

      1 Reply Last reply
      0
      • A Offline
        A Offline
        appdev
        wrote on 1 Apr 2022, 10:52 last edited by
        #3

        Update: Problem solved.
        If you ever face this problem, Please tell me, I can help :D

        P 1 Reply Last reply 1 Apr 2022, 14:35
        0
        • A appdev
          1 Apr 2022, 10:52

          Update: Problem solved.
          If you ever face this problem, Please tell me, I can help :D

          P Offline
          P Offline
          Petross404_Petros S
          wrote on 1 Apr 2022, 14:35 last edited by
          #4

          @appdev Eerr, care to share with us now?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            appdev
            wrote on 6 Apr 2022, 11:03 last edited by
            #5

            Sure with great pleasure,

            After disabling texture and shader program, you should specify the matrix mode in glMatrixMode:

            glMatrixMode(GL_PROJECTION) then load the projection matrix you used (call glLoadMatrixf)
            glMatrixMode(GL_MODELVIEW) then load the modelview matrix. Transform it to identity.
            Finally you can draw the coordinate system or any other object. In this case, the texture of the first object won't have any effect on any other object rendered after. ^^

            1 Reply Last reply
            2

            1/5

            25 Mar 2022, 15:08

            • Login

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