Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. OpenGL newbie - why won't these lines display properly?

OpenGL newbie - why won't these lines display properly?

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 670 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.
  • C Offline
    C Offline
    cscooper
    wrote on last edited by
    #1

    I need to make it so part of my Qml view is "taken over" by some non-Qt OpenGL rendering, and I was having issues getting a texture to display properly so I thought I would just draw a line and get that to work before moving on to more complicated code.

    I took the Squircle sample code ( http://qt-project.org/doc/qt-5/qtquick-scenegraph-openglunderqml-example.html ) and modified it slightly so it would draw in a specified portion of the screen (instead of the entire screen) and that is working perfectly. Then, I modified just the renderer::paint() function to initially draw three green lines, and after 2 seconds to instead draw one blue line:

    @void CtRenderer::paint()
    {
    static int n = 0;

    if (n == 0)
    {
        glViewport(m_rect.x() + 10, m_rect.y() + 10, m_rect.width() - 20, m_rect.height() - 20);
    
        glEnable(GL_SCISSOR_TEST);
        glScissor(m_rect.x() + 10, m_rect.y() + 10, m_rect.width() - 20, m_rect.height() - 20);
    
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHTING);
    
        // glClearColor(1, 0, 0, 1);
        // glClear(GL_COLOR_BUFFER_BIT);
    
        glLineWidth(10);
        glColor4f(0.0, 1.0, 0.0, 1);
        glBegin(GL_LINES);
        glVertex3f(0.0, 0.0, 1);        glVertex3f(1, 0.5, 1);
        glVertex3f(0.0, 0.0, 1);        glVertex3f(0.5, 0.5, 1);
        glVertex3f(0.0, 0.0, 1);        glVertex3f(0.5, 1, 1);
        glEnd();
    }
    else if (n == 120)
    {
        glViewport(m_rect.x() + 10, m_rect.y() + 10, m_rect.width() - 20, m_rect.height() - 20);
    
        glEnable(GL_SCISSOR_TEST);
        glScissor(m_rect.x() + 10, m_rect.y() + 10, m_rect.width() - 20, m_rect.height() - 20);
    
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHTING);
    
        // glClearColor(1, 0, 0, 1);
        // glClear(GL_COLOR_BUFFER_BIT);
    
        glLineWidth(10);
        glColor4f(0.0, 0.0, 1.0, 1);
        glBegin(GL_LINES);
        glVertex3f(0.0, 0.0, 1);        glVertex3f(0.4, 0.8, 1);
        glEnd();
    
    }
    n++;
    
    return;
    

    }@

    What I get instead are three gray lines that flicker continuously and never change to being a single line. I'm relatively new to OpenGL, so I'm probably doing something stupid. Can someone point me in the right direction with this code?

    Thanks!
    Chris

    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