View within View Slide Set 7 06 View

  • Slides: 8
Download presentation
View within View Slide Set 7. 06

View within View Slide Set 7. 06

View within View • We can manipulate the target of a rendering operation in

View within View • We can manipulate the target of a rendering operation in order to send the result to a texture rather than directly to the screen • Then we can paint that texture on other objects in a successive rendering • We can apply multiple renderings to the same image 2

Calling display • • Three calls to display per rendering cycle Render scene to

Calling display • • Three calls to display per rendering cycle Render scene to a texture with the camera reversed Render scene as usual to the display Render the ‘rear view window’ to the display • Uses the texture generated in the first step 3

Buffers for Vertex Data • Setup two sets of buffers • Main objects of

Buffers for Vertex Data • Setup two sets of buffers • Main objects of the scene • Rear view mirror is just a rectangle • Each creates its own scene • The view/camera for the view-in-view is fixed 4

Shader Programs • Two sets of shaders • For objects, the usual • The

Shader Programs • Two sets of shaders • For objects, the usual • The fragment shader for the view-in-view scales and translates the texture coordinates to match part of the texture from the framebuffer 5

Setup framebuffer • • Create texture object Create framebuffer Attach the texture object to

Setup framebuffer • • Create texture object Create framebuffer Attach the texture object to the framebuffer to receive colors Create a depth buffer and attach to the framebuffer 6

View in View Setup • Texture coordinate transform 7

View in View Setup • Texture coordinate transform 7

Walk Through Driver • Set up frame buffer • In event loop • Reverse

Walk Through Driver • Set up frame buffer • In event loop • Reverse camera, render to texture • Render objects to window • Render view-in-view to window 8