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. OpenGL a QPainter

OpenGL a QPainter

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 613 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.
  • PavelMP Offline
    PavelMP Offline
    PavelM
    wrote on last edited by
    #1

    Hello.
    This code draw 2 rects and one dotted circle.
    Problem is when circle is out off screen then second rectangle has color of the circle.
    If circle is non dotted then drawing is ok.

    It works only when GL_DEPTH_TEST is enabled but I want work with depht test disabled.

      m_fbo->bind();        
    
      CSkPainter p;
    
      QOpenGLPaintDevice device(m_size);          
    
      p.begin(&device);
      p.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);      
    
      p.beginNativePainting();
    
      m_gl->glViewport(0, 0, m_size.width(), m_size.height());
      m_gl->glEnable(GL_MULTISAMPLE);
    
      m_gl->glClearDepthf(1);
      m_gl->glClearColor(0.1f, 0.1f, 0.2f, 1);
      m_gl->glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  
    
      m_gl->glDisable(GL_DEPTH_TEST);
      //m_gl->glEnable(GL_DEPTH_TEST);
    
      //bk.render(m_transform, m_gl);
    
      p.endNativePainting();        
    
      p.setPen(QPen(Qt::red, 2));
      p.setBrush(Qt::NoBrush);
      p.drawRect(150, 150, 50, 50);
    
    
      p.setPen(QPen(QColor(0, 255, 0, 255), 4, Qt::DotLine));
      p.setBrush(Qt::NoBrush);
      p.drawEllipse(300, 600, 70, 70);
    
      p.setPen(QPen(Qt::red, 2));
      p.setBrush(Qt::NoBrush);
      p.drawRect(180, 180, 50, 50);
    
      p.end();
      m_fbo->release();
      return;
    
    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