Any idea how to specify a negative value for x/y part of viewport ?

Started by
4 comments, last by kamilzubair 13 years, 5 months ago
Hi, in my application I need to slide my viewport around arbitrary points in the screen. Say, if in a 1024*768 res application I need to slide the rendering viewport to the right until it only show half of it I can set :
D3DVIEWPORT9 v;
v.X = 512;
v.Y = 0;
v.Width = 1024;
v.Height = 768;
v.MinZ = 0;
v.MaxZ = 0;

But if I want to slide it to the left I can't set v.X = -512 because X is defined as unsigned long. Any idea how to achieve the effect I want ?
I know viewport in Direct3D 10 allow negative value for their x/y part but sadly I don't think I can port this application yet because it still need to run in XP.
Advertisement
I'm not familiar with dx10, so i won't comment on that, but is there a reason you are trying to render off the screen? Whatever you are doing, there is most likely a better way.
Well it's for the animation effect. Maybe an example, will make it clear:
Suppose I render a simple 2d rectangle and rotate 90 degrees in y axis, now all it looks is just single line in normal viewport. If I want to slide the result of the rendering I need to slide the whole viewport, I can't just add a translation in world matrix because it will only move the rectangle and will not be rendered as simple line anymore. Of course, this is just a simplified example, I plan to draw more interesting stuff in the actual application.

My initial solution is to render it in texture and slide the texture around but many of our material has transparency and we need to draw them on top of each other. If I render them in texture first and blend them later I'll get different color when I blend them directly in back buffer.
I think what you need to do is add a translation into your projection matrix (or possibly view matrix).
Try using SetScissorRect instead of SetViewport. SetScissorRect doesn't change the transformation.
I think I got it, I just create view matrix using D3DXMatrixPerspectiveOffCenterLH and slide it around.

Thanks everyone.

This topic is closed to new replies.

Advertisement