how do you make a mirror?

Started by
2 comments, last by paulbird 21 years ago
A. Is there a simple way to make a flat mirror in openGL - how about a spherical mirror. B. What about a lens? C. What if I wanted to draw a virtual world with a virtual computer in openGL and on the screen of that computer is the same virtual world?
Advertisement
quote:Original post by paulbird
A. Is there a simple way to make a flat mirror in openGL - how about a spherical mirror.

B. What about a lens?

C. What if I wanted to draw a virtual world with a virtual computer in openGL and on the screen of that computer is the same virtual world?


A:
Render everything 2 times.
First the reflection (the the original geometry mirrored, for example glScalef(1,-1,1)), then a transperent polygon as the mirror surface and finally the "real" geometry.

For spherical mirrors you need to use cube maps or environment mapping.

B:
Refractions are hard to do. Cube maps might work.

C:
Render the scene in to a texture and use that texture as the computer screen.
Have you got any example code of environment mapping such as sphere-mapping or cube-mapping? I''m not sure I understand exactly how that all works.
Nehe has a spheremapping tutorial on this site, you could try that

This topic is closed to new replies.

Advertisement