PDA

View Full Version : GL Logic op blending inside QGLWidget



ToddAtWSU
1st December 2006, 15:51
I am having problems getting a blending equation to work inside a QGLWidget. This works fine for me on a system where I use 8-bit color indexing mode but now I am on a system that can use 24-bit colors. I am trying to draw a box based on the user's mouse clicking and dragging. Here is what my code looks like:



if( mDrawBoxZoom == true )
{
setAutoBufferSwap( false );
qglColor( mPlotBoxZoomColor );
glDrawBuffer( GL_FRONT );
glLogicOp( GL_XOR );
glEnable( GL_COLOR_LOGIC_OP );
glEnable( GL_BLEND );
glBlendEquationEXT( GL_COLOR_LOGIC_OP );
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
glLineWidth( 2.0 );
// Draw back over the previously drawn box
glBegin( GL_LINE_LOOP );
glVertex3d( mBeginDrawBox[0], mBeginDrawBox[1], 0.0 );
glVertex3d( mBeginDrawBox[0], mOldEndDrawBox[1], 0.0 );
glVertex3d( mOldEndDrawBox[0], mOldEndDrawBox[1], 0.0 );
glVertex3d( mOldEndDrawBox[0], mBeginDrawBox[1], 0.0 );
glEnd( );
// Draw the new box with the current mouse position
glBegin( GL_LINE_LOOP );
glVertex3d( mBeginDrawBox[0], mBeginDrawBox[1], 0.0 );
glVertex3d( mBeginDrawBox[0], mEndDrawBox[1], 0.0 );
glVertex3d( mEndDrawBox[0], mEndDrawBox[1], 0.0 );
glVertex3d( mEndDrawBox[0], mBeginDrawBox[1], 0.0 );
glEnd( );
glFlush( );
glLineWidth( 1.0 );
glDisable( GL_COLOR_LOGIC_OP );
glDisable( GL_BLEND );
glDrawBuffer( GL_BACK );
setAutoBufferSwapping( true );
}


mDrawBoxZoom is set to true when the mouse button is clicked and set to false when the mouse button is released. I do other painting code when the box is not being drawn but this is the part that is not working. Like I said earlier it works fine when I am in 8-bit color indexing mode but not when I am in 24-bit color. The qglColor( ) call is similar to making a glColor*( ) call. My problem is I am capturing all my mouse coordinates correctly which I store in my 3 2-member arrays mBeginDrawBox, mOldEndDrawBox, and mEndDrawBox. These values are correct but I cannot see any box being drawn. I can see some flicker when I move my mouse so I know it's drawing to the front buffer but for some reason I cannot see the box being drawn. Thanks for your help in helping me to try and figure out why I cannot see my mouse.

ToddAtWSU
20th December 2006, 20:55
I have discovered that this is a Solaris hardware issue because I was able to port the code to a Linux box and it worked fine. So I have to try and figure out how to get my Solaris box to show stuff. Any ideas? Thanks!