Archived

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

gajraaj

SetViewport

Recommended Posts

What happens if I set the viewport to a rectangle whose dimensions are smaller than the region specified within the render target surface? Obviously the scene will be rendered to the specified region only, but what if I dont set the viewport at all? By default, will the scene be rendered to the entire width and height of the default render target surface? Thanks in advance.

Share this post


Link to post
Share on other sites
There''s a default viewport set containing the complete render target.

If you set the viewport to a smaller region the rendering will be clipped. I''m using viewports for my gui to clip text and child controls inside their parent.

Share this post


Link to post
Share on other sites
In general, the viewport transforms geometry from homogeneous clip space into screen space. It takes the entire homogeneous clip space and maps it onto the area specified by the viewport.

Setting a viewport that is smaller than the render surface will cause the entire view to be scaled down a bit and placed in the area specified by the viewport. This is usefull for rendering user interfaces. For example, if you want the bottom of the screen to contain information like hitpoints, ammo, etc... of your character, you can set the viewport so that it only renders to the top part of the screen. The entire view is then mapped to the top part of the screen, leaving the bottom part of the screen available for you to display any info you need.

The viewport is essentially a scaling and translation matrix. If you're looking for something that will allow you to specify that you want to render into a specific 2D rectangle on the screen, then using a scissor rect would be a better choice. Look up SetScissorRect in the SDK docs.

neneboricua

[edited by - neneboricua19 on April 20, 2004 12:44:47 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by neneboricua19
If you''re looking for something that will allow you to specify that you want to render into a specific 2D rectangle on the screen, then using a scissor rect would be a better choice. Look up SetScissorRect in the SDK docs.

neneboricua

[edited by - neneboricua19 on April 20, 2004 12:44:47 PM]


Essentially, I am looking for an answer to this problem: after CreateDevice and seeting the backbuffer width and height if I dont call the SetViewport function, my limited understanding suggests that the scene would be rendered to the entire render target, can you please confirm if that is a correct assumption?

Thanks for the answer,helps me understand what a Viewport does


Share this post


Link to post
Share on other sites
quote:
Original post by gajraaj
Essentially, I am looking for an answer to this problem: after CreateDevice and seeting the backbuffer width and height if I dont call the SetViewport function, my limited understanding suggests that the scene would be rendered to the entire render target, can you please confirm if that is a correct assumption?


Yes, that''s correct. If you look up SetViewport in the SDK docs, it says that the default is to render to the entire render target.

neneboricua

Share this post


Link to post
Share on other sites