Sign in to follow this  
Leo_E_49

OpenGL Sub viewports?

Recommended Posts

How do you go about doing sub viewports, i.e. the ones used in X2 the Threat? Whereby you present another view of the scene on an embedded part of the screen (or billboard quad, I'm not sure). Either DirectX and/or OpenGL answers are welcome.

Share this post


Link to post
Share on other sites
In OpenGL the solution is pretty simple, you just define the viewport that you want to render to with glVieport(blah, blah, blah) and then define an orthographic projection glOrtho(etc, etc, etc) then just perform your rendering. You probably want to do this at the very end of frame writing.

The cool thing is you can still use alpha blending etc, if you want to partially (or fully) show what is going on underneath with your game.

There is probably a similar solution for DirectX but I am not 100% sure.

Share this post


Link to post
Share on other sites
I don't know much about D3D but I imagine it supports scissor test which would let you do this, even if with a lot more difficulty than GL because you'd have to adjust your projection matrix depending on where on screen your viewport was.

moagstar: I would've thought you could only use alpha blending if you had zero overdraw otherwise you'd end up being able to see through things in the viewport. Unless of course you rendered to an offscreen texture and drew that, which is also a perfectly good solution.

Share this post


Link to post
Share on other sites
Quote:
Original post by ZQJ
moagstar: I would've thought you could only use alpha blending if you had zero overdraw otherwise you'd end up being able to see through things in the viewport. Unless of course you rendered to an offscreen texture and drew that, which is also a perfectly good solution.


I'm not 100% sure I know what you mean by this, but if I understand (correct me if i'm wrong) then the whole point of using alpha on the viewport would be so that you could see through it?

Share this post


Link to post
Share on other sites
Yeah - well that's why I mentioned the other way. If you render to a texture then alpha blend that texture onto the screen it'll be like a transparent photo. If on the other hand you render a scene to a little part of the screen with all polygons having an alpha factor of say 0.5, then where you have two overlapping you'll be able to see both of them and the background will only have 0.25 intensity.

Share this post


Link to post
Share on other sites
one of my better previous posts has code for an easy (and slower/older) method. You might want to change the variable apiTarget from GL_TEXTURE_RECTANGLE_ARB to GL_TEXTURE_2D.

Cheers
-Danu

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this