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.

Thanks for any advice.

Code :
	wglMakeCurrent(m_hDC, m_hRC);
 
	RECT rc;
	::GetClientRect(m_hWnd, &rc);
 
	glReadBuffer(GL_FRONT);
	glDrawBuffer(GL_BACK);
	glCopyPixels(rc.left, rc.top, rc.right, rc.bottom, GL_COLOR);
 
	GLuint pBuffer;
	glGenBuffers(1, &pBuffer);
 
	Vector3f box[5] = {
		{ m_zoomTracker.Left(), m_zoomTracker.Bottom(), 0.f },
		{ m_zoomTracker.Right(), m_zoomTracker.Bottom(), 0.f },
		{ m_zoomTracker.Right(), m_zoomTracker.Top(), 0.f },
		{ m_zoomTracker.Left(), m_zoomTracker.Top(), 0.f },
		{ m_zoomTracker.Left(), m_zoomTracker.Bottom(), 0.f }
	};
 
	glBindBuffer(GL_ARRAY_BUFFER, pBuffer);
	glEnableVertexAttribArray(AGL_ATTRIBUTE_VERTEX);
	glBufferData(GL_ARRAY_BUFFER, sizeof(Vector3f)*5, box, GL_STATIC_DRAW);
	glVertexAttribPointer(AGL_ATTRIBUTE_VERTEX, 3, GL_FLOAT, GL_FALSE, 0, 0);
 
	m_frustum.SetOrthographic(rc.left, rc.right, rc.top, rc.bottom, -1.f, 1.f);
 
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_COLOR_LOGIC_OP);
	glLogicOp(GL_XOR);
	glColor3f(1.f, 1.f, 1.f);
	glLineWidth(2.f);
 
	glDrawArrays(GL_LINES, 0, 5);
	//glRectf(m_zoomTracker.Left(), m_zoomTracker.Top(), m_zoomTracker.Right(), m_zoomTracker.Bottom());
 
	glEnable(GL_DEPTH_TEST);
	glDisable(GL_COLOR_LOGIC_OP);
 
	glDeleteBuffers(1, &pBuffer);
 
	m_frustum.SetPerspective(FOV, m_aspectRatio, 1.0, m_sceneDiagonal * 4);
 
	SwapBuffers(m_hDC);