Hello

I'm using OpenGL in a QGraphicScene with drawBackground(

I create a simple shader that just change the pixel's color of a Qpainter rect
The shader works only the second time I use it


Qt Code:
  1. void drawBackground( QPainter *pPainter, const QRectF &pRect )
  2. {
  3. glClearColor( mBackGroundColor.redF(), mBackGroundColor.greenF(), mBackGroundColor.blueF(), 1.0f );
  4.  
  5. glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
  6. glClearDepth(1.0f);
  7.  
  8. glMatrixMode( GL_PROJECTION );
  9. glPushMatrix();
  10. glLoadIdentity();
  11.  
  12. lViewAngle = lViewAngle * 360.0 / M_PI;
  13. gluPerspective( lViewAngle, width() / height(), 0.1, 200 );
  14.  
  15. glMatrixMode( GL_MODELVIEW );
  16.  
  17. //OPENGL STUFF
  18.  
  19. glPopMatrix();
  20. glMatrixMode( GL_PROJECTION );
  21. pPainter->endNativePainting();
  22.  
  23. //shader doesn't work
  24. shader.bind();
  25. pPainter->fillRect(0, 0, 128, 128, Qt::black);
  26. shader.release();
  27.  
  28. //shader work
  29. shader.bind();
  30. pPainter->fillRect(100, 100, 128, 128, Qt::black);
  31. shader.release();
  32. }
To copy to clipboard, switch view to plain text mode 

Thanks for your help