I'm trying to find a way to rubber band in OpenGL and Visual Studio C++. The problem I'm coming across is some Win 7 computers (i.e. My boss') won't allow me to read or draw to the front buffer thus killing drawing straight to it.
glDrawBuffer( GL_FRONT );
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp( GL_XOR );
glPolygonMode(GL_FRONT, GL_LINE);
glRecti(X0, Y0, X1, Y1);
X1 = X;
Y1 = Y;
glRecti(X0, Y0, X1, Y1);
*//Doesn't draw lines*
or copying the front buffer to the back buffer (redrawing to it would take to long) calling a swapbuffers drawing and then swaping agian
glReadBuffer( GL_FRONT );
glDrawBuffer( GL_BACK );
glCopyPixels(0, 0, Width, Height, GL_COLOR);
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp( GL_XOR );
glPolygonMode(GL_BACK, GL_LINE);
SwapBuffers(hdc);
glRecti(X0, Y0, X1, Y1);
X1 = X;
Y1 = Y;
glRecti(X0, Y0, X1, Y1);
SwapBuffers(hdc);
*//Doesn't display original drawing*
any ideas?
I'd do it like this:
After this, to draw the image on screen, you can just draw a single quad covering the whole render area, textured with created texture. This way there's no need to re-render the actual scene when drawing the image to screen.
Modern OpenGL implementations can also render to texture, with no need to move the image to main memory and back. Then again, if rendering the scene is already slow, the performance difference here won't be noticeable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With