[newbie alert] 3D rendering on top of canvas

Before I asked how to render 2D on top of a canvas, but now I’d like to know the same for 3D.

What I would like to know is how to render another scene (or same scene from different angle) on top of the canvas.

Possible effects I’m trying to implement are things like rear-view mirrors in racing games or rocket-cams in FPS (not Fps).

I tried to find if I could just setup another rendering pass and make it render within a specific rectangular area of the canvas, but without any luck.

I also read the thread about rendering to a pbuffer and using it as a texture, but I was wondering if that was the only way to do it. Couldn’t you “just” copy the pbuffer to the canvas for example?

A common technique for that is to use a stencil and render the second piece as a second pass of the same frame.

But I imagine that you would have to at least change view frustrum setting and things like that?

Any examples anywhere that people know of?

There are quite a few demos out there on using the stencil buffer to do things like create reflections or shadow volumes. Some good resources are flipcode.com, gamedev.net, and gamasutra.com. Here’s a link from google that describes using stenciling to create a reflection…

http://www.opengl.org/developers/code/mjktips/Reflect.html

The concept should be the same for creating a rear-view mirror: instead of using the floor as the reflection-area, you would define a polygon that represents the area of the screen that you want to draw into; and you wouldn’t just draw a reflection of the current scene, but rather the scene from the rear of the car.

Sean

Thanks, it actually seems simple :smiley: