Advertisement Jump to content


This topic is now archived and is closed to further replies.


Reduce viewport to a non-rectangular shape

This topic is 5397 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

First of all sorry about my poor english :/ I''m trying to code my own 2D GUI system and at this moment I only use it in 2D enviroments (for the game HUD) but I''m interested on extends the system to allow programmer to put widgets on the map walls (or any 3D enviroment). Everythings goes perfectly but I have found a problem about scrollable widgets like a text area. This kind of widget at this moment reduce the viewport to make only visible the area inside, then when inner widgets got rendered they where cuted acordly with the shape. Problem comes on 3D widgets because the area of the scrollable widget could be any quadrilateral shape (depending to the camera angle relative to the widget), not only rectangular shapes. I have got some ideas to solve the problem. Main idea is to cut one by one every poligon when got rendered inside the scrollable area, but It is imposible because I''m using a OO paradigme and a widget don''t know what kind of widget will be rendered inside of its (I use a composite design pattern). The second idea is to render the scrollable area out of the color buffer (maybe in stencil buffer) and when everything is rendered make a ''copy to texture'' and render a quad with that texture on the colorbuffer. But I''m afraid it will be slow (and maybe incompatible with poor cards). I hope there is another way to do that, maybe using the clipping planes defined in the Projection matrix (I dont know how) or maybe with any ofuscated opengl function I dont know. Can anybody bring me lights on that problem? Another stupid spanish coder

Share this post

Link to post
Share on other sites
Original post by tamat
This kind of widget at this moment reduce the viewport to make only visible the area inside,

You have to make this clearer...

Do you mean you cut the viewport down to the size of the widget, render ALL the text (letting the stuff outside the viewport just not get rendered) and then restore the viewport.

well that won''t work for 3d.

Render the text onto a texture, and then bind the right tecture coordinates to the surface. No messing with the viewport involved.

Share this post

Link to post
Share on other sites
Yes, sorry.

In my application every widget have widgets inside (composite pattern). Then when the application try to render the GUI it calls the Render method on the main widget, this widget renders what it wants (the mouse) and when function finishes the system call the render function on widgets inside (just explore the tree).

This is the reason why I say scrollable widget may cut the viewport down to surround its shape, then next widgets will be propper cuted. But I know viewport always have rectangular shape, this is why I ask that on the forum, to find another way to define the viewport shape (maybe using stencil or projection matrix).

About render out of color buffer and copy to a texture the result... I think it would be really slow, think about render a full screen scroll area, I may copy a 1024x768 texture...

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!