PDA

View Full Version : QPainter and Shader



shetan
4th April 2011, 18:03
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




void drawBackground( QPainter *pPainter, const QRectF &pRect )
{
glClearColor( mBackGroundColor.redF(), mBackGroundColor.greenF(), mBackGroundColor.blueF(), 1.0f );

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glClearDepth(1.0f);

glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();

lViewAngle = lViewAngle * 360.0 / M_PI;
gluPerspective( lViewAngle, width() / height(), 0.1, 200 );

glMatrixMode( GL_MODELVIEW );

//OPENGL STUFF

glPopMatrix();
glMatrixMode( GL_PROJECTION );
pPainter->endNativePainting();

//shader doesn't work
shader.bind();
pPainter->fillRect(0, 0, 128, 128, Qt::black);
shader.release();

//shader work
shader.bind();
pPainter->fillRect(100, 100, 128, 128, Qt::black);
shader.release();
}




Thanks for your help

high_flyer
5th April 2011, 09:33
what happens if you switch the order - first use the 100,100 one, then the 0,0?