Draw rubber-band selection box

Hi, I know this has been asked a number of times, but all the ones I found either referred to the old deprecated pipeline or did not answer the question of how to draw the rectangle.

In the old days it was fairly simple to draw a "rubber-band" selection box:
1) copy the current front buffer into the back buffer
2) set the orthographic projection
3) use glLogicOp(GL_XOR) and Begin(GL_LINES) to draw the box
4) Swapbuffers

These days I don't know how it is done. I have listed the code below which does not work on many levels, first glCopyPixels I don't think exists any more so I have no idea how to copy the front buffer into the back buffer.

actually in the good ol' days people simply did the rubber banding on the front buffer. No need for the copy to back buffer, and then another buffer swap. It was easy to undo as well as you just draw the same again and it'll disappear.

You can still do this today, but in Vista (onwards I assume) you need to call glflush or glfinish after you've finished drawing, otherwise the OS doesn't know to update the screen. Since everything is rendered through d3d.

actually in the good ol' days people simply did the rubber banding on the front buffer. No need for the copy to back buffer, and then another buffer swap. It was easy to undo as well as you just draw the same again and it'll disappear.

You can still do this today, but in Vista (onwards I assume) you need to call glflush or glfinish after you've finished drawing, otherwise the OS doesn't know to update the screen. Since everything is rendered through d3d.

I thought glflush and glfinish only complete the gl commands. In a double buffered system you still need to refresh the screen with a swap. The reason I copy the front to back is that
1) the back buffer is undefined after a swap
2) I don't want to redraw the scene, in my case there is no animation so the scene remains the same for duration of the mouse drag.

Anyways, I tried your suggestion and it still doesn't work. So, assuming you are right, then there must be something wrong with the drawing commands which I can't figure out.

I don't know how to refresh the screen in a double-buffered system without a swap, but that's another issue. I decided to just add this function to the end of my draw scene function (after removing the frame buffer commands) and there is definitely a problem with the drawing code that I cannot figure out. The shader I'm binding to does the following, the mvp matrix is just the orthographic projection matrix, there is no modelview transforms since I am drawing on top of the screen.

So it turns out the erasing effect was a bug outside of the opengl code. There is still a problem with this code, that I can't figure out. Whether I use dukey's suggestion to draw to the front buffer or just add it to the end of the draw scene function, still nothing happens. I don't know if it is in the vertex shader or the fragment shader but nothing is happening. Btw, the I edited the fragment shader to correct it.