public:
protected:
void initializeGL()
{
this->setFixedSize(200,200);
p.fillRect(10,10,30,30,Qt::yellow);
QGLShaderProgram shader(this);
if(shader.addShaderFromSourceCode(QGLShader::Fragment,
"void main(void) {gl_FragColor = vec4(0, 0, 1, 1.0);}"))
qDebug("Shader prepared.");
shader.link();
shader.bind();
}
{
//painter.fillRect(0,0,200,100, Qt::gray); // line2
painter.fillRect(60,20,30,30, Qt::gray);
drawTexture
(QPoint(10,
10), fbo
->texture
());
}
private:
};
class GLWidget : public QGLWidget {
public:
GLWidget(QWidget *parent = 0): QGLWidget(parent) {}
protected:
void initializeGL()
{
this->setFixedSize(200,200);
fbo = new QGLFramebufferObject(200, 200);
QPainter p(fbo);
p.fillRect(10,10,30,30,Qt::yellow);
QGLShaderProgram shader(this);
if(shader.addShaderFromSourceCode(QGLShader::Fragment,
"void main(void) {gl_FragColor = vec4(0, 0, 1, 1.0);}"))
qDebug("Shader prepared.");
shader.link();
shader.bind();
}
void paintEvent(QPaintEvent *event)
{
QPainter painter(this);
//painter.fillRect(0,0,200,100, Qt::gray); // line2
painter.fillRect(60,20,30,30, Qt::gray);
drawTexture(QPoint(10, 10), fbo->texture());
}
private:
QGLFramebufferObject *fbo;
};
To copy to clipboard, switch view to plain text mode
Bookmarks