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