We have to draw a reference axis (XYZ) placed at the bottom left corner of the view port. I am using OpenGL 4.3 Core profile.
I found some methods implementing it using Orthographic projection in another view port and positioning it in window coordinates.
But I need some help in placing the reference axis aligned with the (bottom left corner)view port using perspective projection.
That is the 3D object (XYZ axis) even though it has world space position it has to align itself with the view port and orient accordingly with
respect to the camera
Align object in 3D space with respect to (View port) Window Coordinates,
Members - Reputation: 245
Posted 28 March 2014 - 02:50 AM
Members - Reputation: 375
Posted 28 March 2014 - 07:06 AM
I am not sure I get what you want.
Probably the easiest way would be to use a vertex shader that doesn't multiply the quad you are position by the modelview matrix. That way the coordinates you have to sent to OpenGL are coordinates relative to the camera, and it will always be shown at the same place on the screen regardless of how the camera move.
You can do this without a custom shaders, also, but then you have to apply the inverse of the view matrix to your quad every frame to neutralize the view transformation.
Note that what I am telling you still uses the projection matrix, so what you show will be "distorted" by it. If you didn't want that, then simply use the technique you already know (ortho + new viewport).
“We should forget about small efficiencies, say about 97% of the time; premature optimization is the root of all evil” - Donald E. Knuth, Structured Programming with go to Statements
"First you learn the value of abstraction, then you learn the cost of abstraction, then you're ready to engineer" - Ken Beck, Twitter