Reputation: 368
How does one implement a HUD mirror? To simplify the problem let's consider that one has some objects in the scene and in a HUD rectangle the user will see all the objects behind (i.e. a rendering of the scene from the same eye point but with the look vector in the opposite direction)
Upvotes: 2
Views: 471
Reputation: 70106
Another way (in addition to the one proposed by fbafelipe) would be to set a viewport to the rectangular area where the "mirror" is, or stencil it out (or a combination of both, most real mirrors are not perfect rectangles). Then mirror the modelview-projection matrix (possibly with a scale, if it's something like a car mirror) and draw everything that is behind you.
The "render to FBO" solution has the advantage that you can cheat more easily, e.g. only draw the mirror every other frame. Most probably nobody will notice the difference. Also you can trivially apply any kind of image filter (blur, smudge) to the mirror.
Upvotes: 2
Reputation: 4952
You can render the mirror's content in a FBO. When rendering the HUD, use the FBO to draw the mirror.
Upvotes: 3