OpenGL a QPainter
Unsolved
General and Desktop
-
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;