Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-18094

Problems on drawing text of big font size on QGLWidget and QGLFramebufferObject

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 4.7.2
    • GUI: OpenGL, GUI: Painting
    • None

    Description

      I wrote some code for test:

      #include <QtGui/QApplication>
      #include <QtOpenGL/QGLWidget>
      #include <QtOpenGL/QGLFramebufferObject>
      
      class GLWidget : public QGLWidget {
      public:
      	GLWidget() {
      		m_big = font();
      		m_big.setPixelSize(100);
      		makeCurrent();
      		m_fbo = new QGLFramebufferObject(500, 150);
      		m_fbo->bind();
      		glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      		QPainter painter(m_fbo);
      		painter.setFont(m_big);
      		painter.drawText(QRect(0, 0, 500, 150), "Test Text");
      		m_fbo->release();
      	}
      	~GLWidget() {
      		delete m_fbo;
      	}
      private:
      	void paintEvent(QPaintEvent *) {
      		QPainter painter(this);
      		painter.setFont(m_big);
      		painter.drawText(QRect(0, 0, 500, 150), "Test Text");
      		drawTexture(QPointF(0.0, 150.0), m_fbo->texture());
      	}
      	QFont m_big;
      	QGLFramebufferObject *m_fbo;
      };
      
      int main(int argc, char *argv[]) {
      	QApplication app(argc, argv);
      	GLWidget w;
      	w.show();
      	return app.exec();
      }
      

      To copy to clipboard, switch view to plain text mode

      The above codes do drawing two lines of "Test Text" on QGLWidget.
      Upper one is done by directly onto QGLWidget with QPainter,
      and the lower one is done by drawTexture whose texture is drawn in QGLFramebufferObject.

      The result is attached.
      Click image for larger version Name: result.png Views: 3 Size: 22.1 KB ID: 6070

      Both of them have problems.

      Upper one(drawn by QGLWidget with QPainter) is not anti-aliased.
      Lower one(drawn by QGLFramebufferObject) just shows black box.

      Also, when I tried with multi-sampled QGLWidget(with like QGLFormat::setSamples(4)),
      Upper one looks as same as lower one, that is, only black box.

      If you try with small font size, both of them display the texts normally.

      Is this a bug? or Did I mistake something?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            rodal Samuel Rødal
            xylosper Byoung-young Lee
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes