View Full Version : How to apply multiple viewports?
10-20-2000, 03:55 AM
Is there any solution to display multiple viewports on a GL window?
For an exampler, I'd like to make a racing game, which allows two player on just one PC. How can I render 2 different part of the same scene, which are specified by two different viewpoint?
10-20-2000, 07:11 AM
I think you have to store the render area for each player and maybe a camera object too.
Then when you want to render the view for a player, you define the viewport to the player's area and setup the current projection and model view matrix to the current player's.
I think that should work, but be carefull with the glClear function that clear the entire OpenGL context.
Otherwise, you could use two rendering contexts.
10-20-2000, 07:56 AM
glViewport can be used to select a portion of the context to work in.
Be careful to reset your projections when you switch which one you are rendering in, and judicious use of the matrix stacks could be in order.
10-20-2000, 04:28 PM
So, I must alternatively switch between viewports, right? Doesn't it sound a little bit slow? Is there any, say, simultaneous way to apply that situation?
10-20-2000, 06:00 PM
Nope, you clear the screen - then set your viewport A, decide what projection to use, switch back to the modelview matrix and render the scene.
Then, set your viewport B, decide what projection to use, switch back to the modelview matrix and render the scene again (maybe from a different angle or something).
The calculations for the extra transformations are tiny compared to the stuff for the actual filling of the viewports...
10-20-2000, 09:33 PM
Thanks guys, now I did it ^_^
Anyway, there's no way to create multiple viewpoints at the same time, right!
I thought I could draw the scene once, then select viewpoints for each viewport, and render all of them! But that's impossoble, isn't it?
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.