Hybrid View

Rubberband selection rectangle and local coordinates

( quick why)
I have a GDI+ rubberband or sweep rectangle that I have been using with OPengl and a MFC application. BUT as some have you already know, if you are using OPengl and GDI+ (which I was/is) .. Win7 aero or Win8 aero Desktop Window Manager (DWM) gets VERY mad at you where the sweept rectangle flickers like crazy if Aero is on.

So to remove GDI+ I created a opengl rubber band rectangle XOR and front buffer, but that is having 2 issue's:

Issues:
1. I cannot get the sweep rectangle to track my mouse curser of the box select , keep in mind I have created a 3d environment. What it wants to do is draw it in client cooridinates inside of OpenGL instead of the client rect of the opengl view. I want it to behave like standard CAD zooming/selection where I can have the 3d environment rotated but it draws to the screen like a standard zoom/selection rectangle

first gluOrtho2D and glOrtho( are mutually exclusive since the both initialize the same matrix. gluOrtho2D is for drawing in 2D in screen coordinates. If your redraw is really slow you can capture the screen to a buffer and just blit that buffer instead of redrawing the whole screen but then you have a problem with pan and zoom (the same problem exists with the XOR method). If you use double buffering you won't have a flicker problem.

It does draw the rectangle it is some set value off of the cursor??? very odd... It seems to stay in the X+, Y+ zone
It does redraw itself and erase itself but that doesn't track the cursor and if I rotate the screen off as well...

There are three transformations involved: model-view, projection, viewport.
If you want to draw in "pixel coordinates", the usual approach is to set the model-view matrix to the identity matrix, and the projection matrix to either gluOrtho2D(0, w, 0, h) or gluOrtho2D(0, w, h, 0) depending upon whether you want the origin at the bottom-left or top-left. That basically sets the projection transformation to the inverse of the viewport transformation, so that the combination of the three is an identity transformation.

Originally Posted by EricMar

Wouldn't doing redrawing the entire view, work but if you have ton of stuff on the screen wouldn't that take to much time and cause flicker...?

It won't cause flicker provided that you have double-buffering enabled. Whether it takes too much time depends upon the complexity of the scene, the performance of the video hardware, and the efficiency of the code. If it's too slow, you can cache the rendered scene in a framebuffer object (provided that you're using OpenGL 3 or later, or have either the GL_EXT_framebuffer_object or GL_ARB_framebuffer_object extension; with older versions, you needed to use a platform-specific mechanism to get an off-screen rendering surface).