What should I do to make this simple shader work (everything should be blue I guess)?
Qt Code:
  1. class GLWidget : public QGLWidget {
  2. public:
  3. GLWidget(QWidget *parent = 0): QGLWidget(parent) {}
  4. protected:
  5. void initializeGL()
  6. {
  7. this->setFixedSize(200,200);
  8. fbo = new QGLFramebufferObject(200, 200);
  9. QPainter p(fbo);
  10. p.fillRect(10,10,30,30,Qt::yellow);
  11.  
  12. QGLShaderProgram shader(this);
  13. if(shader.addShaderFromSourceCode(QGLShader::Fragment,
  14. "void main(void) {gl_FragColor = vec4(0, 0, 1, 1.0);}"))
  15. qDebug("Shader prepared.");
  16. shader.link();
  17. shader.bind();
  18. }
  19. void paintEvent(QPaintEvent *event)
  20. {
  21. QPainter painter(this);
  22. //painter.fillRect(0,0,200,100, Qt::gray); // line2
  23. painter.fillRect(60,20,30,30, Qt::gray);
  24. drawTexture(QPoint(10, 10), fbo->texture());
  25.  
  26. }
  27. private:
  28. };
To copy to clipboard, switch view to plain text mode